package hacl-star
Install
Dune Dependency
Authors
Maintainers
Sources
md5=1ab1ada1189c4e61ddda06275cc3093f
sha512=710645d22a22f5d276a26019bda8f137861e3f0dc1f9e170eb9d25c88dc84293af01fd40923181a28a063a9b8d281cb51e28c7016144f7c8bb1d63b18797fbe1
doc/hacl-star/Hacl_star/Hacl/P256/index.html
Module Hacl.P256
Source
ECDSA and ECDH functions using P-256
Buffers have the following size constraints:
pk
: 64 bytes, corresponding to the "raw" representation of an elliptic curve point (see Point representation and conversions)sk
,k
: 32 bytessignature
: 64 bytesmsg
: depends on which hash function is being used (see ECDSA)
Point representation and conversions
Elliptic curve points have 2 32-byte coordinates (x, y) and can be represented in 3 ways:
- "raw" form (64 bytes): the concatenation of the 2 coordinates
- "compressed" form (33 bytes): the first byte is equal to
0x2 + (y % 2)
, followed by x - "uncompressed" form (65 bytes): the first byte is always
\04
, followed by the "raw" form
These functions convert points between these representations:
raw_to_compressed p
converts a "raw" point p
(64 bytes) to a "compressed" point (33 bytes)
raw_to_uncompressed p
converts a "raw" point p
(64 bytes) to an "uncompressed" point (65 bytes)
compressed_to_raw p
attempts to convert a "compressed" point p
(33 bytes) to a "raw" point (64 bytes) and returns it if successful.
uncompressed_to_raw p
attempts to convert an "uncompressed" point p
(65 bytes) to a "raw" point (64 bytes) and returns it if successful.
Point validation
valid_sk sk
checks if the contents of sk
can be used as a secret key or as a signing secret. This is the case if 0 < sk
< the order of the curve.
valid_pk pk
checks if the contents of pk
is a valid public key, as specified in NIST SP 800-56A.
ECDH
ECDH key agreement protocol
dh_initiator sk
takes a 32-byte secret key sk
and returns the corresponding 64-byte public key.
dh_responder sk pk
takes a 32-byte secret key sk
and another party's 64-byte public key and returns the 64-byte ECDH shared key.
ECDSA
ECDSA signing and signature verification functions
For the sign
and verify
functions included in this module msg
is the digest of the message to be signed, requiring users to use a cryptographic hash function of their choosing before calling them. In this case, msg
needs to be at least 32 bytes long.
sign sk msg k
attempts to sign the message msg
with secret key sk
and signing secret k
and returns the signature if successful.
verify pk msg signature
checks the signature
of msg
using public key pk
and returns true if it is valid.
The functions in the other submodules take the unhashed message msg
and first hash it using their corresponding version of the SHA-2 hash function. In this case, there is no minimum size requirement for msg
.
Buffers have the following size constraints:
Buffers have the following size constraints:
Buffers have the following size constraints: