〰 Interactive Simulation

Elliptic Curve Diffie-Hellman

The same key-exchange idea as DH, but on an elliptic curve — far smaller keys, same hard problem.

〰
Step 1 — Choose an Elliptic Curve
An elliptic curve is defined by y² = x³ + ax + b (mod p). Points on the curve form a group — the key structure ECDH exploits.
Elliptic curves over finite fields give us a group of points where "addition" of two points is geometrically defined. Multiplying a point by an integer k is fast; reversing it (finding k given kP) is the Elliptic Curve Discrete Log Problem — the hard problem underpinning ECDH.
a = —
b = —
p = —
|E| = — points
Curve points (mod p) Generator G Alice's public key A Bob's public key B Shared secret S
📍
Step 2 — The Generator Point G
G is a public base point on the curve. All public keys are multiples of G. The order of G (how many times you can add G before cycling back) determines the key space size.
Point multiplication: kG means "add G to itself k times". This is fast with the double-and-add algorithm. But given P = kG, finding k is the ECDLP — computationally infeasible for large curves.
🔐
Step 3 — Each Party Picks a Private Scalar
Alice picks secret integer a, Bob picks b. These are never transmitted. Each computes their public key by multiplying G by their scalar.
Public keys are points, not numbers. Alice's public key A = aG is a point on the curve. Bob's public key B = bG is another point. An attacker seeing A and G cannot find a — that's the ECDLP.
📡
Step 4 — Exchange Public Points
Alice sends A = aG to Bob; Bob sends B = bG to Alice. Both points are public. The curve itself and G are also public. Only a and b stay secret.
What an eavesdropper sees: the curve, G, A, and B — four public values. To find the shared secret they must solve: given aG and bG, compute abG. This is the Computational ECDH (ECDH) problem — no efficient algorithm known.
🙋 Alice
private a—
A = aG—
✉ sends A publicly
→
A over public channel
←
B over public channel
🧔 Bob
private b—
B = bG—
✉ sends B publicly
🤝
Step 5 — Derive the Shared Secret Point
Alice multiplies Bob's point by her scalar: S = aB. Bob multiplies Alice's point by his: S = bA. Both equal abG — the same point.
S = aB = a(bG) = ab·G = b(aG) = bA
Both parties arrive at the same curve point S. The shared secret is typically the x-coordinate of S, then hashed to derive a symmetric key.
🙋 Alice computes
S = aB = a·(bG)
= —
S =—
🟰
🧔 Bob computes
S = bA = b·(aG)
= —
S =—
🔒 Shared Secret Point (never transmitted)
—
In practice: shared_key = KDF(S.x) — the x-coordinate is hashed into a symmetric key
↑ Return to Step 1 to see all points plotted on the curve
⚖️
Step 6 — ECDH vs DH vs RSA
Why ECDH became the dominant key-exchange algorithm in modern protocols, and where it stands against post-quantum alternatives.
Smaller keys, same security. A 256-bit ECC key gives roughly the same classical security as a 3072-bit RSA key. This means faster handshakes, smaller certificates, and less bandwidth — crucial for TLS performance at scale.
SchemeKey sizeClassical securityQuantum securityUsed in
RSA-20482048 bit112-bitBrokenLegacy TLS, HTTPS
DH-20482048 bit112-bitBrokenLegacy VPN, TLS
ECDH P-256256 bit128-bitBrokenTLS 1.3, HTTPS, SSH
ECDH X25519255 bit128-bitBrokenSignal, WireGuard, TLS 1.3
Kyber-7681184 B pk180-bit161-bitChrome+Cloudflare hybrid TLS
X25519+Kyber768combined180-bit161-bitChrome 116+, TLS PQ hybrid

Why ECDH won over DH
✓ 10× smaller keys for same security
✓ Faster key generation & agreement
✓ Less bandwidth in TLS handshake
✓ Ephemeral ECDHE gives forward secrecy
✓ X25519 has no patent issues, faster still
Migration path
Now X25519 / P-256 ECDHE
Hybrid X25519 + Kyber768
Future Kyber-768 alone
Hybrid protects against both classical and quantum attackers during transition