curve25519¶
Bindings for x25519.
Hint
curve25519 has been designed so all points on the curve have the
desired security properties. This makes picking a point (i.e.
generating a private key) using secrets.token_bytes(32) (or
os.urandom(32)) easy, safe and recommended.
- pyhacl.diffie_hellman.curve25519.ecdh(private_key: bytes, public_key: bytes) bytes¶
Given our 32-bytes private key, and the 32-bytes public key of a peer, compute and return a third 32-bytes key. The peer is also capable of computing this same secret key given our public key and their private key.
- Parameters:
private_key – Our private key, as a 32 bytes point.
public_key – Their public key, as a 32 bytes point.
- Raises:
ValueError – When any key has an incorrect length.
Uses
Hacl_Curve25519_51_ecdh.
- pyhacl.diffie_hellman.curve25519.scalarmult(private_key: bytes, public_key: bytes) bytes¶
Compute the scalar multiple of a point. It returns the resulting point encoded in 32 bytes.
- Raises:
ValueError – When any key has an incorrect length.
Uses
Hacl_Curve25519_51_scalarmult.
- pyhacl.diffie_hellman.curve25519.secret_to_public(private_key: bytes) bytes¶
Calculate a public point from a private key.
- Raises:
ValueError – When the key has an incorrect length.
Uses
Hacl_Curve25519_51_secret_to_public.