In 1976, Whitfield Diffie and Martin Hellman published an idea that solved the key distribution problem. (British mathematicians at GCHQ had discovered the same ideas years earlier but kept them classified — a fun footnote in the history of secrecy.)
The idea is called public-key cryptography, or asymmetric cryptography. It works like this:
Imagine a padlock with a peculiar property. When you buy it, it comes open, and closing it requires no key at all — you just snap it shut. The only key in existence is the one that opens it, and you keep that key forever in your pocket. You make hundreds of copies of the padlock itself — in the open state — and hand them out to anyone who wants one. Put them on a public stall in the town square.
Now anyone in the world can send you a secret message: they take one of your open padlocks, snap it shut over their message, and send you the locked box. They never needed a key. You're the only person alive who can open it.
In digital terms:
- You generate a key pair: a public key (the open padlock — you publish it to the world) and a private key (the key that opens it — you never show anyone).
- Anyone can encrypt a message to you using your public key.
- Only your private key can decrypt it.
Notice what this destroys: the key distribution problem. There is no key to distribute. The public key is meant to be public. Intercepting it tells the spy nothing.
This is genuinely as clever as it sounds, and it is not an overstatement to say the modern economy was built on it. Every secure website visit, every bank login, every encrypted message begins with some form of public-key cryptography. The two most famous algorithms are RSA (invented 1977, from the initials of its three inventors) and, later, systems based on elliptic curves — a more compact mathematical cousin doing the same job with shorter keys.
So how does the math work? Here is the novice-level version.
RSA's security rests on a simple-sounding question: multiply two large prime numbers together, and you get a big number N. Given N alone, can you work out which two primes were multiplied?
Multiplying is easy — a pocket calculator can do it. Going backwards, from the product to the two primes, is called factoring, and for numbers with hundreds of digits it is so hard that all the computers on Earth, running for the age of the universe, would not finish the job. The big number N is your public key. The two hidden primes are your private key.
Every public-key system in use today rests on a mathematical problem in this style — a task that is easy in one direction and effectively impossible in the reverse direction. Elliptic-curve cryptography (used everywhere modern, including Bitcoin and Signal) rests on a different such problem, but the pattern is identical.
And here is the sentence this whole article exists to explain: in 1994, a mathematician named Peter Shor proved that a quantum computer could solve exactly those reverse problems — factoring, and the elliptic-curve equivalent — quickly. We will get there. First, one more piece of the puzzle.
Public-key cryptography solves the key-sharing problem with a two-part key: publish the padlock, keep the key. Its security rests on math problems that are easy one way and astronomically hard the other way — until someone can solve them.