Skip to content

miguelsandro/curve25519-kotlin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Axlsign

Ed25519-like signatures with X25519 keys, Axolotl-style.

Functions

Functions accept and return IntArrays.

generateKeyPair(seed) -> keyPair

Generates a new key pair from the given 32-byte secret seed (which should be generated with a CSPRNG) and returns it as object:

keyPair = {
    privateKey: IntArray // 32-byte private key
    publicKey: IntArray  // 32-byte public key
}

The returned keys can be used for signing and key agreement.

sign(privateKey, message, [random]) -> signature

Signs the given message using the private key and returns signature.

Optional random data argument (which must have 64 random bytes) turns on hash separation and randomization to make signatures non-deterministic.

verify(publicKey, message, signature) -> 1 | 0

Verifies the given signature for the message using the given private key. Returns 1 if the signature is valid, 0 otherwise.

signMessage(privateKey, message, [random]) -> signedMessage

Signs the given message using the private key and returns a signed message (signature concatenated with the message copy).

Optional random data argument (which must have 64 random bytes) turns on hash separation and randomization to make signatures non-deterministic.

openMessage(publicKey, signedMessage) -> message | null

Verifies signed message with the public key and returns the original message without signature if it's correct or null if verification fails.

sharedKey(privateKey, publicKey) -> rawSharedKey

Returns a raw shared key between own private key and peer's public key (in other words, this is an ECC Diffie-Hellman function X25519, performing scalar multiplication).

Credits

Ported to Kotlin by Miguel Lucero miguel.sandro@gmail.com may 2017. You can use it under MIT or CC0 license.

Curve25519 signatures idea and math by Trevor Perrin https://moderncrypto.org/mail-archive/curves/2014/000205.html

Derived from axlsign.js written by Dmitry Chestnykh. https://github.com/wavesplatform/curve25519-js

About

Curve25519 signatures (and also key agreement) like in the early Axolotl, ported to Kotlin

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages