Module ed25519

Braindead-easy sign/verify for arbitary binary data with ed25519.

Backed by: https://github.com/orlp/ed25519

Crypto code shipped directly inside package.

Types

Seed* = array[32, byte]
  Source
PublicKey* = array[32, byte]
  Source
PrivateKey* = array[64, byte]
  Source
Signature* = array[64, byte]
  Source
Scalar* = array[32, byte]
  Source
SharedSecret* = array[32, byte]
  Source
KeyPair* = tuple[publicKey: PublicKey, privateKey: PrivateKey]
  Source

Procs

proc seed*(): Seed
Creates a 32 byte random seed for key generation.   Source
proc createKeypair*(seed: Seed): KeyPair
Creates a new key pair from the given seed.   Source
proc sign*(message: string; keyPair: KeyPair): Signature
Creates a signature of the given message using keyPair.   Source
proc verify*(message: string; signature: Signature; publicKey: PublicKey): bool
Verifies the signature on the given message using publicKey.   Source
proc addScalar*(keyPair: KeyPair; scalar: Scalar): KeyPair
Adds scalar to the given key pair where scalar is a 32 byte buffer (possibly generated with ed25519_create_seed), generating a new key pair. You can calculate the public key sum without knowing the private key and vice versa by passing in NULL for the key you don't know. This is useful for enforcing randomness on a key pair by a third party while only knowing the public key, among other things. Warning: the last bit of the scalar is ignored - if comparing scalars make sure to clear it with scalar[31] &= 127.   Source
proc keyExchange*(publicKey: PublicKey; privateKey: PrivateKey): SharedSecret

Performs a key exchange on the given public key and private key, producing a shared secret. It is recommended to hash the shared secret before using it.

Hint: Put in the other's person public key: The magic here is that ed25519_keyExchange(publicKey, otherPersonPrivateKey) would result in the same shared_secret.

  Source