package hacl_x25519
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=816754a8e8f9739d0e6d98ced6e50b026a28d59232445c5051a66e4332cc572d
sha512=9a0fb07af4af999a12cb65f3bc15487c5999ddf6fff0a923cf4b8087a15933632266be55ec01cff3b15d354c9e526d906a7e15aee84c743f58f8cdfe899b110d
doc/hacl_x25519/Hacl_x25519/index.html
Module Hacl_x25519Source
Diffie-Hellman key exchange over Curve25519 (also known as X25519).
This implementation uses C code from Project Everest, an effort to build and deploy a verified HTTPS stack.
Key material. In elliptic curve terms, a scalar.
To generate a key pair, use gen_key.
In the usual setting, the private key only be generated and used for key exchange. But it can be useful to create values of type secret with a known value, for example to check against test vectors. One can use the following pattern to do this:
let (secret, _) = gen_key ~rng:(fun _ -> known_data) Generate a key pair. rng should return a Cstruct.t with the specified key length (in bytes) and fill it with random bytes.
If the cstruct returned by rng does not have the correct length, raises Failure _.
encode_secret secret is the secret encoded into a buffer.
Kind of errors.
Pretty printer for errors
Perform Diffie-Hellman key exchange between a private part and a public part.
It checks length of the pub key and returns an error if it has an incorrect length.
In DH terms, the private part corresponds to a scalar, and the public part corresponds to a point, and this computes the scalar multiplication.
The resulting shared secret is not truncated.
As described in RFC 7748, section 6.1, this function might internally generate an all-zero value. If this is the case Error `Low_order will be returned instead. This check is necessary in the context of TLS 1.3, but might not in other protocols.