← Back to section · Quantum Computing

Shor's Algorithm: How Quantum Computing Threatens RSA and Elliptic-Curve Cryptography

Starting from why factoring and discrete logarithms are hard, an explanation of Shor's core idea, how large a quantum computer breaking RSA-2048 would have to be, and why 'harvest now, decrypt later' makes migration a present-day task.

Published 20 November 2026 · 5 min read · PQ Frontier

Shor's Algorithm: How Quantum Computing Threatens RSA and Elliptic-Curve Cryptography
AI-generated artwork created for PQ Frontier
Video explainer · Quantum Algorithms

The two pillars of current public-key cryptography

RSA’s security rests on integer factorization: given the product N=p×qN = p \times q of two large primes, recovering the factors with the best known classical algorithms would take far longer than the age of the universe. Elliptic-curve cryptography (ECC) rests on the discrete logarithm problem: given Q=dGQ = dG on a curve, recovering the private key dd is equally infeasible.

These two pillars carry nearly all of today’s key exchange, digital signatures and certificate systems. The problem: neither survives a quantum computer.

What Shor’s algorithm does

In 1994, Peter Shor showed that a quantum computer can solve integer factorization and discrete logarithms in polynomial time. The core idea is to reduce factoring to period finding: for a randomly chosen aa, the function f(x)=ax mod Nf(x) = a^x \bmod N is periodic, and once the quantum Fourier transform extracts the period rr efficiently, a non-trivial factor of NN follows with high probability.

Shor’s algorithm runs in roughly O((log⁡N)3)O((\log N)^3) time, against the sub-exponential general number field sieve — the best classical method. This is not “somewhat faster”; it is the difference between impossible and possible. The barrier that protects RSA-2048 classically simply does not exist for a sufficiently large fault-tolerant quantum computer. A variant of Shor’s algorithm covers elliptic-curve discrete logarithms with the same conclusion — and at equal security levels, ECC needs even fewer quantum resources than RSA.

Turning a period into factors: the classical last step

The quantum part hands over only a period rr; converting it into factors is classical number theory — easy, but worth spelling out, because it sets the algorithm’s success probability. If rr is even and ar/2≢−1(modN)a^{r/2} \not\equiv -1 \pmod N, then ar≡1(modN)a^r \equiv 1 \pmod N implies that (ar/2−1)(ar/2+1)(a^{r/2}-1)(a^{r/2}+1) is a multiple of NN while neither factor is, so gcd⁡(ar/2±1,N)\gcd(a^{r/2} \pm 1, N) must yield a non-trivial factor of NN — computed instantly on a classical machine with Euclid’s algorithm. If luck is bad (rr odd, or the unlucky −1-1 case), pick a fresh random aa and retry; number theory guarantees a success probability of at least about one half per attempt, so failures decay exponentially with repetition. The quantum kernel needs only a constant expected number of runs, and the bottleneck is never this classical cleanup — it is the scale of the quantum part, which is why every resource estimate stares at the phase-estimation circuit alone.

How large a quantum computer does it take?

The operative words are “sufficiently large”. Running Shor’s algorithm against RSA-2048 requires a fault-tolerant machine: the well-known 2019 estimate by Gidney and Ekerå puts it at about 20 million noisy physical qubits running for roughly 8 hours, under specific surface-code and error-rate assumptions.

Today’s quantum computers sit at roughly a thousand physical qubits with no large-scale fault tolerance — orders of magnitude away from that threshold. Nobody can credibly promise the year it will be crossed, and that is precisely the point: a migration decision cannot rest on a timeline nobody can guarantee.

The real urgency: harvest now, decrypt later

Even if the machines are a decade away, the clock has already started. An attacker can record encrypted traffic today — harvest now — and decrypt it once a quantum computer is available — decrypt later. If your data must stay secret longer than the time until such a machine exists, it is already unsafe today.

Mosca’s inequality makes this concrete: let data need XX years of secrecy, migration take YY years, and a large quantum computer arrive in ZZ years — if X+Y>ZX + Y > Z, you are already late. Medical records, state secrets and long-term contracts routinely carry an XX measured in decades, and large systems carry a YY measured in years. The conclusion is direct: the urgency of migration depends not on when quantum computers arrive, but on how long your data must remain secret.

The estimates keep tightening

It is worth noting that the “price” of breaking RSA-2048 is not fixed — it keeps falling as algorithms and error correction improve. Estimates around 2012 still ran to billions of physical qubits. In 2019, Gidney and Ekerå used improved arithmetic circuits and windowed lookups to bring the figure down to about 20 million physical qubits. In 2025, Gidney went further, publishing a construction using fewer than one million noisy qubits — at the cost of a runtime stretched to roughly a week, and of leaner magic-state preparation and approximate arithmetic. None of these reductions came from a hardware miracle; each was clever accounting at the compilation and error-correction layers. The trend matters more than any single number: the threshold is walking monotonically towards us, and planning should assume estimates will tighten further rather than defend against today’s headline figure.

Not in the same boat: symmetric cryptography and hashes

Shor’s algorithm attacks the mathematical structure of public-key cryptography; symmetric cryptography is not in the same boat. Against AES-class algorithms the quantum side has only Grover’s search, a quadratic speedup: AES-128’s effective strength drops to roughly the 64-bit level (and Grover parallelises poorly, so the real cost is far above the nominal one), while AES-256 retains about 128 bits — doubling key length is essentially a complete countermeasure, which is why national guidance is comparatively relaxed about symmetric primitives. Hash functions are similar: the preimage resistance of SHA-256 and SHA-384 remains acceptable after the Grover discount. The urgency concentrates on the two public-key functions, key exchange and signatures. But signatures carry an easily missed time dimension: long-lived root certificates, firmware signatures and notarised records, if forgeable in the quantum era, would have their historical authenticity questioned retroactively — so signature migration, too, cannot wait until the machines exist.

Summary

  • Shor’s algorithm ends the security of RSA and ECC in theory — that is a mathematical result, not speculation;
  • what is missing is only a large enough fault-tolerant quantum computer, on a schedule nobody can guarantee;
  • harvest-now-decrypt-later puts long-lived data at risk today;
  • post-quantum migration — starting with ML-KEM — is therefore engineering work to schedule now, not a topic for the future.

References

  1. Shor, P. W., Polynomial-Time Algorithms for Prime Factorization and Discrete Logarithms on a Quantum Computer, SIAM Journal on Computing, 1997. https://arxiv.org/abs/quant-ph/9508027
  2. Gidney, C., Ekerå, M., How to factor 2048 bit RSA integers in 8 hours using 20 million noisy qubits, Quantum 5, 433 (2021). https://arxiv.org/abs/1905.09749
  3. Mosca, M., Cybersecurity in an era with quantum computers: will we be ready?, IEEE Security & Privacy, 2018.

Tags: Shor's AlgorithmRSAQuantum ThreatHarvest Now Decrypt Later