Chapter I
The Key Distribution Problem
Every cipher in history had the same weakness. Sender and receiver needed the same secret key, and they had to share it somehow beforehand, by courier, diplomatic bag or codebook. In a world of millions of strangers exchanging data, that was impossible.
In 1976 Whitfield Diffie and Martin Hellman showed it was unnecessary. Take a large prime and a base . Alice picks a secret and sends ; Bob picks and sends . Each raises what they received to their own secret, and both arrive at . An eavesdropper sees only and , and recovering from , a discrete logarithm, has no known fast method. The arithmetic is from elementary number theory. The idea was new.
Chapter II
RSA
A year later, three MIT researchers, Ron Rivest, Adi Shamir and Leonard Adleman, found a full public-key cipher. Publish , the product of two large secret primes, and an exponent . Anyone can encrypt a message as . Undoing it needs an exponent that can be computed only by someone who knows and , and it works because of Euler's generalisation of Fermat's little theorem: a 1640 curiosity turned into the lock on the world's data.
The story had a secret prologue. At Britain's signals intelligence agency GCHQ, James Ellis had conceived of "non-secret encryption" in 1970. Clifford Cocks found essentially RSA in 1973, and Malcolm Williamson found Diffie–Hellman in 1974. All of it stayed classified until 1997.
Chapter III
Curves and Primes
In 1985 Neal Koblitz and Victor Miller independently proposed moving the discrete logarithm into the group of points on an elliptic curve, the central object of arithmetic geometry. No known shortcut works there, so a 256-bit elliptic-curve key matches a roughly 3,000-bit RSA key. Elliptic curves, studied for their own beauty since Mordell, now carry most secure web traffic.
Cryptography also needs a plentiful supply of large primes, and a fast way to recognise them. In 2002 Manindra Agrawal and his students Neeraj Kayal and Nitin Saxena proved that primality can be decided in guaranteed polynomial time, using a generalisation of Fermat's little theorem. Gauss had called telling primes from composites one of the most important problems in arithmetic, in the Disquisitiones.
Chapter IV
A Closer Look: RSA and Diffie–Hellman with Small Numbers
Real keys use numbers hundreds of digits long, but the mechanics fit on a napkin.
RSA. Choose two primes, and , and publish . Compute and choose a public exponent sharing no factor with 40, say . The private exponent is the with : , since . The public key is , and the private key is .
To send the message , anyone computes
The key holder recovers it: . It works because of Euler's version of Fermat's little theorem, and finding requires knowing , which requires factoring . Factoring 55 is trivial. Factoring a product of two 300-digit primes is, as far as anyone knows, infeasible.
Diffie–Hellman. Alice and Bob agree in public on a prime and a base . Alice secretly picks and sends . Bob secretly picks and sends . Each raises what they received to their own secret:
Both now hold the shared secret 2, which never crossed the wire. An eavesdropper who saw 23, 5, 8 and 19 must recover 6 from , a discrete logarithm. With a 2048-bit prime, or on an elliptic curve, no efficient classical method is known. Shor's quantum algorithm would find it quickly, which is why both systems are being replaced.
Chapter V
The Quantum Threat
In 1994 Peter Shor showed that a quantum computer could factor numbers and compute discrete logarithms efficiently. RSA, Diffie–Hellman and elliptic curves would all fall. No machine is yet large enough, but data intercepted now could be read later, so the replacement has already begun. In 2024 the US standards body published its first post-quantum standards, most of them built on hard problems in lattices over rings of algebraic integers.
Beneath it all lies an unproved assumption. Every public-key system presumes that some problems are genuinely hard, that one-way functions exist, and no one has proved it. That question belongs to computational complexity, where it sits beside P versus NP. The security of the digital world rests, in the end, on a conjecture.