0.5.0 • Published 6 years ago

@datkt/crypto v0.5.0

Weekly downloads
2
License
MIT
Repository
-
Last release
6 years ago

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

0.5.0

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.0

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago