val zero_nonce : nonce
val random_nonce : unit -> nonce
generate_nonces ~incoming ~sent_msg ~recv_msg generates two nonces by hashing (Blake2B) the arguments. The nonces should be used to initialize the encryption on the communication channels. Because an attacker cannot control both messages, it cannot determine the nonces that will be used to encrypt the messages. The sent message should contains a random nonce, and we should never send the exact same message twice.
module Secretbox : sig ... end
val default_pow_target : pow_target
val make_pow_target : float -> pow_target
Generates both a secret key and its corresponding public key, along with a hash of the public key.
precompute pk sk computes a channel key from the sender's
sk and the recipient's
fast_box k nonce msg authenticates and encrypts
msg and returns both the message authentication tag and the ciphertext. For this reason, the returned buffer will be
tagbytes longer than
fast_box_open k nonce cmsg attempts to verify and decrypt
cmsg and if successful returns the plaintext. As above, the returned buffer will be
tagbytes shorter than
fast_box_noalloc k nonce tag buf authenticates and encrypts in-place the contents of
nonce and writes the message authentication tag in
fast_box_open_noalloc k nonce tag buf attempts to verify and decrypt the contents of
buf in-place using
tag and returns true if successful.
check_proof_of_work pk pow target returns true if
pow is proof of work following
target for the public key
val generate_proof_of_work : ?yield_every:int -> ?max:int -> public_key -> pow_target -> nonce Lwt.t
generate_proof_of_work pk pow_target generates a proof of work for the public key
pk following the
yield_every (defaults to
500) inserts a cooperation point (
Lwt.pause ()) every so many attempts. This allows other promises to make progress towards resolution. It also allows Unix signals to be processed so that, say, Ctrl+C can be effective.
max (not set by default) sets a maximum number of attempts to be made before giving up. When
max number of attempts have been made and no pow has been found, the exception
Not_found is raised.