package octez-libs
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=c6df840ebbf115e454db949028c595bec558a59a66cade73b52a6d099d6fa4d4
sha512=d8aee903b9fe130d73176bc8ec38b78c9ff65317da3cb4f3415f09af0c625b4384e7498201fdb61aa39086a7d5d409d0ab3423f9bc3ab989a680cf444a79bc13
doc/octez-libs.crypto/Tezos_crypto/Crypto_box/index.html
Module Tezos_crypto.Crypto_box
Source
Tezos - X25519/XSalsa20-Poly1305 cryptography
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.
Size of the message authentication tag.
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 pk
.
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 msg
.
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 cmsg
.
fast_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
.
fast_box_open_noalloc k nonce tag buf
attempts to verify and decrypt the contents of buf
in-place using k
, nonce
, and 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 pk
.
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 pow_target
.
The parameter 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.
The parameter 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.
neuterize sk
generates the corresponding public key of sk
equal a b
tests keys for equality