package octez-libs
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=ddfb5076eeb0b32ac21c1eed44e8fc86a6743ef18ab23fff02d36e365bb73d61
sha512=d22a827df5146e0aa274df48bc2150b098177ff7e5eab52c6109e867eb0a1f0ec63e6bfbb0e3645a6c2112de3877c91a17df32ccbff301891ce4ba630c997a65
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