10. Elliptic Curve Cryptography
The same security with far smaller keys
RSA and classic Diffie-Hellman work, but they need enormous keys: 2048-3072 bits for adequate security, with sizes growing as computers get faster. In the 1980s, Neal Koblitz and Victor Miller independently proposed using a different mathematical structure — elliptic curves — where the underlying hard problem is even harder to solve. The result: equivalent security with keys roughly 10x smaller.
What's an Elliptic Curve?
An elliptic curve is defined by an equation of the form:
The Weierstrass equation
y² = x³ + ax + b
For example, the curve y² = x³ - 3x + 5 looks like:
│ ·····
│ ·· ··
│·· ··
──────·───────────··──────
│·· ··
│ ·· ··
│ ·····
│
The curve is symmetric about the x-axis. In cryptography, we don't use real numbers — we use a finite field (integers mod a prime p), which turns the smooth curve into a scattered set of discrete points.
Point Addition — The Key Operation
The magic of elliptic curves is that you can define an addition operation on points. Given two points P and Q on the curve, their "sum" P+Q is a third point on the curve, computed geometrically:
-
Draw a line through P and Q
This line intersects the curve at exactly one more point (by the algebraic structure of cubic curves).
-
Reflect across the x-axis
The reflection of that intersection point is defined as P + Q.
-
Point doubling
When P = Q, use the tangent line at P instead. This gives 2P.
Geometric point addition
│ P·───────────·Q
│ · \ ·
│· \ ·
───────·───────\───·──────────
│· \· ← line hits curve here
│ · ·R'
│ · ·
│ ·P+Q ← reflect R' to get P+Q
│ · ·
│· ·
Over a finite field, there are no smooth curves — just discrete points. But the algebraic formulas for addition work exactly the same way, using modular arithmetic instead of real numbers.
Scalar Multiplication — The Trapdoor
If we can add two points, we can add a point to itself repeatedly:
2P = P + P
3P = P + P + P
...
nP = P + P + ... + P (n times)
This is called scalar multiplication: n × P = Q
The Elliptic Curve Discrete Logarithm Problem (ECDLP)
Given a base point G and a result point Q = nG, finding n is the elliptic curve discrete logarithm problem. Computing nG is fast (using double-and-add, analogous to repeated squaring). But recovering n from G and Q is believed to be infeasible — even harder than the classical discrete log problem used in Diffie-Hellman.
Easy (microseconds)
Given G and n=42:
Compute Q = 42 × G
Hard (infeasible)
Given G and Q:
Find n such that Q = n × G
ECDH — Elliptic Curve Diffie-Hellman
Diffie-Hellman works exactly the same way over elliptic curves, with point multiplication replacing modular exponentiation:
ECDH protocol
Public parameters: curve E, base point G, order n
Alice's secret: a (random integer)
Bob's secret: b (random integer)
Alice computes: A = a × G (a point on the curve)
Bob computes: B = b × G (a point on the curve)
Exchange: Alice sends A, Bob sends B
Alice computes: S = a × B = a × (b × G) = ab × G
Bob computes: S = b × A = b × (a × G) = ab × G
Shared secret: S (the x-coordinate of the shared point)
This is the ECDHE (Ephemeral Elliptic Curve Diffie-Hellman) key exchange used in TLS 1.3.
ECDSA — Elliptic Curve Digital Signatures
Just as RSA can sign and verify, elliptic curves support a signature scheme called ECDSA (Elliptic Curve Digital Signature Algorithm):
ECDSA in brief
Key pair:
Private key: d (random integer)
Public key: Q = d × G (a point)
Signing message m:
- Compute hash h = SHA-256(m)
- Pick random k, compute R = k × G
- r = R.x mod n
- s = k⁻¹ × (h + r·d) mod n
- Signature = (r, s)
Verifying:
- Compute h = SHA-256(m)
- Compute u₁ = h·s⁻¹ mod n, u₂ = r·s⁻¹ mod n
- Compute P = u₁×G + u₂×Q
- Signature valid if P.x ≡ r (mod n)
Standard Curves
| Curve | Key size | Security | Used in |
|---|---|---|---|
| P-256 (secp256r1) | 256 bits | ~128 bits | TLS, most web PKI |
| P-384 (secp384r1) | 384 bits | ~192 bits | Government / high security |
| Curve25519 | 256 bits | ~128 bits | Signal, WireGuard, SSH (Ed25519) |
| secp256k1 | 256 bits | ~128 bits | Bitcoin, Ethereum |
| Ed448 | 448 bits | ~224 bits | Specialized high-security |
Curve25519 and Ed25519
Designed by Daniel Bernstein, Curve25519 (for key exchange) and Ed25519 (for signatures) have become the modern standard. Their advantages over the NIST P-curves:
- Constant-time — designed to resist timing side-channel attacks by construction
- No special cases — the Montgomery/Edwards form eliminates edge cases that have caused implementation bugs in P-256
- Transparent parameters — nothing-up-my-sleeve numbers, unlike the NIST curves whose parameter origins were never fully explained
- Fast — optimized for software implementation
Why ECC Wins: Key Size Comparison
| Security level | Symmetric | RSA / DH | ECC |
|---|---|---|---|
| 80 bits | 80 | 1024 | 160 |
| 112 bits | 112 | 2048 | 224 |
| 128 bits | 128 | 3072 | 256 |
| 192 bits | 192 | 7680 | 384 |
| 256 bits | 256 | 15360 | 512 |
At 128-bit security, an RSA key is 3072 bits. An ECC key is 256 bits — 12x smaller. This matters for constrained environments (smart cards, IoT devices) and for bandwidth (smaller certificates, faster handshakes).
The Quantum Threat
Shor's Algorithm
A sufficiently powerful quantum computer running Shor's algorithm could solve both the integer factorization problem (breaking RSA) and the discrete logarithm problem (breaking DH and ECC) in polynomial time. This would break all public-key cryptography discussed in this series.
Current quantum computers are far too small (thousands of logical qubits needed vs. dozens available), but the threat is taken seriously. NIST has standardized post-quantum algorithms (ML-KEM/Kyber for key exchange, ML-DSA/Dilithium for signatures) based on lattice problems that resist quantum attacks. TLS and SSH are already beginning to deploy hybrid modes that combine classical ECC with post-quantum algorithms.
Real-World Usage
| System | How it uses ECC |
|---|---|
| TLS 1.3 | ECDHE (P-256 or X25519) for key exchange; ECDSA for certificates |
| Signal / WhatsApp | X25519 DH for key agreement; Ed25519 for identity keys |
| SSH (Ed25519) | Ed25519 keys replacing RSA as the default |
| WireGuard | Curve25519 exclusively — no cipher negotiation |
| Bitcoin / Ethereum | secp256k1 ECDSA for transaction signing |
| Apple / Google | ECDSA certificates for app signing and platform security |
Try It Yourself — Curve Visualizer
Adjust a and b to see how the shape of y² = x³ + ax + b changes. In cryptography we use finite fields, but the real-number curve shows the underlying geometry.
Points & Addition over a Finite Field
Over a finite field Fp, the smooth curve becomes a set of discrete points. Pick two points and see point addition computed step by step with modular arithmetic.
Scalar Multiplication & the ECDLP
Scalar multiplication computes nG by repeated doubling and adding. Watch the double-and-add algorithm in action, then consider the reverse: given G and Q = nG, how would you find n?
Key Takeaways
- Elliptic curves define a group structure where point addition is the core operation
- Scalar multiplication (n × G = Q) is the trapdoor: easy to compute, hard to reverse
- ECDH replaces classic DH with much smaller keys (256 vs. 3072 bits for 128-bit security)
- ECDSA provides digital signatures; Ed25519 is the modern preferred scheme
- Curve25519/Ed25519 are designed to resist implementation pitfalls and side-channel attacks
- Quantum computers threaten all public-key crypto — post-quantum algorithms are being deployed now
This series has traced the evolution of encryption from Caesar's letter-shifting to the elliptic curves powering every HTTPS connection today. The core ideas recur at every level: confusion and diffusion in symmetric ciphers, trapdoor functions in asymmetric ciphers, and the constant tension between security, performance, and key management. Understanding these fundamentals equips you to reason about any cryptographic system you encounter.