Tech●●●●●Difficulty 4 of 5

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 story

A 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.

Shor's algorithm in two halves
  1. Step 1: Pick a number a

    Classical: choose a to test against N

  2. Step 2: Find its order

    Quantum: interference and the Fourier transform reveal the period

  3. Step 3: Use Euclid's algorithm

    Classical: greatest common divisors turn the order into a factor

  4. 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

Bar chart: Noisy qubits needed to factor a 2048-bit RSA number. (millions of noisy qubits)
Millions of noisy qubits
2019 estimate20 millions of noisy qubits
2025 estimate (upper bound)1 millions of noisy qubits
Estimates fell, but the 2025 figure is still close to a million qubits, while lab demonstrations remain tiny.

Quiz me

0/3

  1. 1.What does the quantum part of Shor's algorithm actually compute?
  2. 2.Why can a quantum computer find such a pattern when a measurement returns only one value?
  3. 3.Why does Shor's algorithm also threaten elliptic-curve cryptography even though its keys are shorter?

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.

Sources (7)

No source, no claim. Every fact in this lesson (25 claims) cites at least one of these.

  1. [1]Shor's algorithm · Wikipedia
  2. [2]Multiplicative order · Wikipedia
  3. [3]Peter Shor · Wikipedia
  4. [4]How to factor 2048 bit RSA integers with less than a million noisy qubits · arXiv (Craig Gidney)
  5. [5]Quantum computing · Wikipedia
  6. [6]Quantum Fourier transform · Wikipedia
  7. [7]Integer factorization · Wikipedia
More lessons in 💻 Tech (3) See all tech lessons →

One more light on your map.

Get one lesson like this every day, about the things you love. Free, in two or five minutes.

Get the share card for this lesson ↗