package sodium

  1. Overview
  2. Docs
type 'a key
type secret_key = secret key
type public_key = public key
type channel_key = channel key
type keypair = secret key * public key
type nonce
val primitive : string

Primitive used by this implementation. Currently "curve25519xsalsa20poly1305".

val public_key_size : int

Size of public keys, in bytes.

val secret_key_size : int

Size of secret keys, in bytes.

val channel_key_size : int

Size of channel keys, in bytes.

val nonce_size : int

Size of nonces, in bytes.

val random_keypair : unit -> keypair

random_keypair () generates a random key pair.

val random_nonce : unit -> nonce

random_nonce () generates a random nonce.

val nonce_of_bytes : Bytes.t -> nonce

nonce_of_bytes b creates a nonce out of bytes b.

val increment_nonce : ?step:int -> nonce -> nonce

increment_nonce ?step n interprets nonce n as a big-endian number and returns the sum of n and step with wrap-around. The default step is 1.

val wipe_key : 'a key -> unit

wipe_key k overwrites k with zeroes.

val precompute : secret key -> public key -> channel key

precompute sk pk precomputes the channel key for the secret key sk and the public key pk, which can be used to speed up processing of any number of messages.

val equal_public_keys : public key -> public key -> bool

equal_public_keys a b checks a and b for equality in constant time.

val equal_secret_keys : secret key -> secret key -> bool

equal_secret_keys a b checks a and b for equality in constant time.

val equal_channel_keys : channel key -> channel key -> bool

equal_channel_keys a b checks a and b for equality in constant time.

val compare_public_keys : public key -> public key -> int

compare_public_keys a b compares a and b.

module type S = sig ... end
module Bytes : S with type storage = Bytes.t
module Bigbytes : S with type storage = bigbytes
OCaml

Innovation. Community. Security.