Expand description
ecdh key creation (SP 800-56A ECDH over the NIST prime-order curves).
Keys minted here drive AgreementSecretKey::agree, whose result
chains into the KDFs (see
hkdf_sha2::prepare_from), exactly as
X25519’s do. The shared secret is the x-coordinate of the agreed point,
so its natural length is the curve’s field size: 32 bytes for P-256, 48
bytes for P-384. Unlike X25519’s deliberately permissive raw import,
public imports are strict — a point not on the declared variant’s curve
fails at import as Error::InvalidKey.
Enums§
- Ecdh
Variant - The served curves. (Each algorithm interface names its closed set
of parameterizations
<algorithm>-variant; ECDH’s parameter is the curve alone.)
Functions§
- generate_
key - Generate a fresh random keypair on the declared variant’s curve, returning both halves.
- import_
public_ key_ jwk - Import a peer’s public key from an EC public JWK (as JSON text) whose
crvmatches the declared variant’s curve. - import_
public_ key_ raw - Import a peer’s public key as an uncompressed SEC1 point (
04 ‖ x ‖ y; 65 bytes for P-256, 97 bytes for P-384). - import_
public_ key_ spki - Import a peer’s public key from an X.509 SubjectPublicKeyInfo (DER) whose encoded curve matches the declared variant’s.
- import_
secret_ key_ jwk - Import a static secret key from an EC private JWK (as JSON text) whose
crvmatches the declared variant’s curve. - import_
secret_ key_ pkcs8 - Import a static secret key from a PKCS#8 PrivateKeyInfo (DER) whose encoded curve matches the declared variant’s.