Lion Cipher Lab

Implement ECDH from scratch — then break it with an invalid-curve attack and recover the private key

Why it matters

Almost every fresh TLS handshake, every Signal message, every SSH login and every modern VPN agrees on its key with elliptic-curve Diffie-Hellman, not the finite-field kind — ECDH gives the same security as a 3072-bit finite-field group in a 32-byte public key, which is why it won. But the move to curves brought a failure mode that is subtler and nastier than anything in finite-field DH: the elliptic-curve group law does not use the curve's b coefficient at all, so if you multiply your secret key by a point without first checking that point is actually on your curve, you are silently doing…

What you'll learn

Steps in this lab

  1. The idea, and the five words you need
  2. Set up, and write the group law by hand — every edge case
  3. Pick a curve that actually works — the singular-curve trap
  4. Run the exchange — and remember a point is not a key
  5. BREAK IT — the invalid-curve attack, in principle
  6. BREAK IT — recover the private key by CRT, then close the hole
  7. The better answer — why the world moved to Curve25519 / X25519
  8. The judgment: what to actually take away

Open the full interactive lab →