Legend:
Library
Module
Module type
Parameter
Class
Class type
Library
Module
Module type
Parameter
Class
Class type
To increase performance, Box uses the precomputation interface, in which rather than passing the public and secret keys separately each time, it first computes a combined key thus avoiding to repeat this step for every call.
unsafe_to_bytes k
is the internal Bytes.t
where the key is stored. DO NOT MODIFY.
keypair
generates both a secret key and its corresponding public key.
dh pk sk
computes the combined key from the sender's sk
and the recipient's pk
.
box k nonce msg cmsg
authenticates and encrypts msg
and writes both the message authentication tag and the ciphertext in cmsg
. For this reason, csmg
needs to be tagbytes
longer than msg
.
box_open key nonce cmsg msg
attempts to verify and decrypt cmsg
and if successful writes the plaintext in msg
. As above, msg
is expected to be tagbytes
shorter than cmsg
. Returns true if operation has succeeded, false otherwise.
box_noalloc k nonce tag buf
authenticates and encrypts in-place the contents of buf
using k
and nonce
and writes the message authentication tag in tag
.