Module Mirage_crypto_ec.Ed25519

Curve 25519 DSA, also known as Ed25519.

type priv

The type for private keys.

type pub

The type for public keys.

Serialisation

val priv_of_octets : string -> (priv, error) Stdlib.result

priv_of_octets buf decodes a private key from the buffer buf. If the provided data is invalid, an error is returned.

val priv_to_octets : priv -> string

priv_to_octets p encode the private key p to a buffer.

val pub_of_octets : string -> (pub, error) Stdlib.result

pub_of_octets buf decodes a public key from the buffer buf. If the provided data is invalid, an error is returned.

val pub_to_octets : pub -> string

pub_to_octets p encodes the public key p into a buffer.

Deriving the public key

val pub_of_priv : priv -> pub

pub_of_priv p extracts the public key from the private key p.

Key generation

val generate : ?g:Mirage_crypto_rng.g -> unit -> priv * pub

generate ~g () generates a key pair.

Cryptographic operations

val sign : key:priv -> string -> string

sign ~key msg signs the message msg using the private key. The result is the concatenation of r and s, as specified in RFC 8032.

val verify : key:pub -> string -> msg:string -> bool

verify ~key signature msg verifies the signature on the message msg with the public key. The return value is true if verification was successful, false otherwise.