ECDH (including X25519 and X448)
Elliptic-curve Diffie-Hellman key agreement on NIST curves, Curve25519 and Curve448
Overview
Elliptic Curve Diffie-Hellman lets two parties derive a shared secret from each other's public keys over an insecure channel. It is the classical key agreement used in TLS, SSH, Signal and most modern protocols, and today is usually paired with ML-KEM in hybrid post-quantum key exchange.
Each party holds a secret scalar and publishes the corresponding curve point. Multiplying the peer's public point by one's own scalar yields the same point on both sides, because scalar multiplication commutes. An eavesdropper who sees only the public points would need to solve the elliptic curve Diffie-Hellman problem. The raw shared secret should always be passed through a KDF such as HKDF before use as a key.
Two styles are present. ecdh-p256, ecdh-p384 and ecdh-p521 operate on the NIST prime curves following SP 800-56A and SEC 1, and require validating that received points lie on the curve to avoid invalid-curve attacks. X25519 and X448, specified in RFC 7748, use Montgomery curves and the Montgomery ladder; they accept any 32- or 56-byte string as a public key and clamp private scalars, which removes most validation pitfalls.
X25519 targets about 128-bit classical security and X448 about 224-bit. X25519 is the most widely used key exchange in TLS 1.3 and is the classical half of the X25519MLKEM768 hybrid. P-256 and P-384 remain common where FIPS validation is required, and X448 is used where a higher classical security margin is wanted. The raw output is the x-coordinate (the u-coordinate for X25519 and X448), not a uniformly random key.
History
1985–2018ECDH published
Specified in RFC 7748
Specified in NIST SP 800-56A Rev. 3
How it works
- Each party generates a secret scalar a or b and publishes A = aG or B = bG.
- Each side validates the peer's public key (point-on-curve checks for NIST curves).
- Both compute the shared point aB = bA and extract its x-coordinate.
- The shared value is fed into a KDF together with protocol context to derive keys.
Security notes
Broken by a large quantum computer, so recorded traffic is exposed to harvest-now, decrypt-later attacks; combine with ML-KEM in a hybrid for long-term confidentiality. On NIST curves, skipping public-key validation enables invalid-curve attacks, and the all-zero X25519 output from low-order points should be rejected where contributory behaviour matters.
Typical uses
Variants in NextSSL
5| Algorithm | Tier | Sizes (bytes) | Standards | API |
|---|---|---|---|---|
| ECDH-P-256 ecdh-p256 |
standard FIPS | pk 65 · sk 32 · ss 32 · seed 32–32 | SEC 1, NIST SP 800-56A Rev. 3 | safe |
| ECDH-P-384 ecdh-p384 |
standard FIPS | pk 97 · sk 48 · ss 48 · seed 32–48 | SEC 1, NIST SP 800-56A Rev. 3 | safe |
| ECDH-P-521 ecdh-p521 |
standard FIPS | pk 133 · sk 66 · ss 66 · seed 32–66 | SEC 1, NIST SP 800-56A Rev. 3 | safe |
| X25519 x25519 |
standard | pk 32 · sk 32 · ss 32 · seed 32 | RFC 7748 | safe |
| X448 x448 |
standard | pk 56 · sk 56 · ss 56 · seed 32–56 | RFC 7748 | safe |
Frequently asked questions
Which ECDH (including X25519 and X448) variants does NextSSL include?
NextSSL registers 5 ECDH (including X25519 and X448) variants: ecdh-p256, ecdh-p384, ecdh-p521, x25519, x448.
Families with similar names
Other key exchange
All 7Related
HMAC-based extract-and-expand key derivation function (RFC 5869)
ML-KEMNIST's primary post-quantum key encapsulation mechanism, standardised in FIPS 203
HPKEHybrid Public Key Encryption: a KEM, a KDF and an AEAD combined per RFC 9180
ECDSAElliptic Curve Digital Signature Algorithm on NIST curves and secp256k1
EdDSADeterministic Edwards-curve signatures: Ed25519 and Ed448