tezos-crypto
-
tezos-crypto
-
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.
- raises Invalid_argument
if argument is not
skbytes
bytes long
- raises Invalid_argument
if argument is not
pkbytes
bytes long
- raises Invalid_argument
if argument is not
ckbytes
bytes long
- raises Invalid_argument
if
pos
is outside the buffer or the buffer is less thanskbytes
bytes long
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
.