How would a quantum computer break RSA, and why hasn't one yet?
In 1994 Peter Shor showed that a quantum computer could factor huge numbers in polynomial time. Three decades on, lab demonstrations have only managed tiny numbers, and none has met the algorithm's full requirements.
▶ Start the storyA quantum computer would break RSA by turning the hard problem of factoring into a different one it is good at: finding a repeating pattern. In 1994 the American mathematician Peter Shor devised a quantum algorithm for finding the prime factors of an integer. It runs in polynomial time, while the best classical method, the general number field sieve, takes sub-exponential time. That gap is what puts RSA at risk, and the same algorithm also threatens the Diffie-Hellman key exchange, in both its ordinary and elliptic-curve forms.
The algorithm has two parts. A classical part reduces factoring to order-finding: for a chosen number a, find the smallest positive k such that a to the power k, divided by N, leaves remainder 1. For example, the order of 4 modulo 7 is 3. The quantum part finds that order, using wave interference that amplifies the probability of the right answer, and a few extra steps with Euclid's algorithm turn the order into a factor. Shor said he found the discrete logarithm version first, and that later that week he solved factoring too.
Step 1: Pick a number a
Classical: choose a to test against N
Step 2: Find its order
Quantum: interference and the Fourier transform reveal the period
Step 3: Use Euclid's algorithm
Classical: greatest common divisors turn the order into a factor
Step 4: Repeat if unlucky
A few runs are likely to succeed
So why is RSA still safe? Because the machines are not there yet. As of 2026, laboratory demonstrations obtain correct results in only a fraction of attempts and have only succeeded with small semiprimes, and the small demonstrations so far compile the circuit using prior knowledge of the solution. Beating classical computers may require millions of qubits because of error correction. In 2019 an estimate said 20 million noisy qubits could factor a 2048-bit RSA number in eight hours; in 2025 Craig Gidney estimated less than a million, in less than a week. The danger is real enough that Shor's algorithm has driven the search for post-quantum cryptography.
Noisy qubits needed to factor a 2048-bit RSA number
millions of noisy qubits
| Millions of noisy qubits | |
|---|---|
| 2019 estimate | 20 millions of noisy qubits |
| 2025 estimate (upper bound) | 1 millions of noisy qubits |
Quiz me
0/3
Recap
Shor's algorithm turns factoring into order-finding, lets the quantum computer find that period by interference, and finishes with ordinary arithmetic; the obstacle is building machines with enough reliable qubits.
💡 A trick to remember it · Quantum finds the beat, classical finds the factors: Shor hears the period, Euclid does the rest.
Surprising fact · Small lab demonstrations of Shor's algorithm compiled the circuit using prior knowledge of the answer, and some were equivalent to coin flipping.
Connects to
- 🛡️ What kind of lock could a quantum computer not pick?
- 💻 What can a quantum computer actually do that an ordinary one can't?
- 〰️ How did a theory about heat end up taking music apart?
- 🔐 Why is it so hard to split a big number into its primes?
- 🔢 How does RSA turn two prime numbers into a lock anyone can close but only you can open?
Sources (7)
No source, no claim. Every fact in this lesson (25 claims) cites at least one of these.