package tezos-hacl-glue
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.
val unsafe_to_bytes : _ key -> Stdlib.Bytes.t
unsafe_to_bytes k
is the internal Bytes.t
where the key is stored. DO NOT MODIFY.
val blit_to_bytes : _ key -> ?pos:int -> Stdlib.Bytes.t -> unit
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
.
val box :
k:combined key ->
nonce:Stdlib.Bytes.t ->
msg:Stdlib.Bytes.t ->
cmsg:Stdlib.Bytes.t ->
unit
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
.
val box_open :
k:combined key ->
nonce:Stdlib.Bytes.t ->
cmsg:Stdlib.Bytes.t ->
msg:Stdlib.Bytes.t ->
bool
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.