GithubHelp home page GithubHelp logo

datkt / crypto Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 21 KB

Various cryptographic function for datkt

License: MIT License

Vim Script 2.28% Kotlin 97.72%
crypto dat kotlin keypair sign verify blake2b node npm

crypto's Introduction

crypto

Various cryptographic function for datk.

Installation

The datkt.crypto package an be installed with NPM.

$ npm install @datkt/crypto

Prerequisites

Usage

## Compile a program in 'main.kt' and link crypto.klib found in `node_modules/`
$ konanc -r node_modules/@datkt -l crypto/crypto main.kt

where main.kt might be

import datkt.crypto.*

fun main(args: Array<String>) {
  val kp = keyPair()
  // @TODO
}

API

data class KeyPair(val publicKey: ByteArray, val secretKey: ByteArray)

A simple data class container for a public and secret key pair

keyPair(seed: ByteArray? = null): KeyPair

Generates a ed25519 key pair suitable for creating signatures.

val kp = keyPair("some random seed value".toUtf8())

or

val kp = keyPair()

sign(message: ByteArray, secretKey: ByteArray): ByteArray

Generates a signature for a given message and secret key.

val ( publicKey, secretKey ) = keyPair()
val message = "hello".toUtf8() // convert to ByteArray
val signature = sign(message, secretKey)

Tests

To run the tests, make sure the crypto.klib Kotlin library is built by running the following command.

$ npm run build

When the library is built, run the following command to run the tests.

$ npm test

See Also

License

MIT

crypto's People

Contributors

jwerle avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.