← Back to section · Education & Knowledge Base

Shor's Algorithm: Why It Forces Public-Key Cryptography to Migrate

Shor's algorithm factors large integers and solves discrete logarithms in polynomial time on a quantum computer, striking RSA and elliptic-curve cryptography directly. This entry lays out its idea, the boundary of its power, and what it takes to run.

Published 22 November 2026 · 5 min read · PQ Frontier

Shor's Algorithm: Why It Forces Public-Key Cryptography to Migrate
AI-generated site artwork
Video explainer · Quantum Computing Encyclopedia: entanglement and key exchange

In 1994 the mathematician Peter Shor proposed a quantum algorithm that factors large integers and solves discrete logarithms in polynomial time. Before that, the fastest classical factoring method (the number field sieve) had sub-exponential complexity, and RSA rests precisely on “factoring is too slow.” Shor’s algorithm demolishes that wall mathematically: the failure of today’s public-key cryptography is not an engineering problem but a settled conclusion at the level of algorithms; all that remains is when the hardware arrives. It is the most fundamental driver of the entire post-quantum migration.

The Idea: Turn Factoring into Finding a Period

The elegance of Shor’s algorithm lies in a reduction. To factor a composite number N, first pick a random number a coprime to N and consider the function f(x) = a raised to the x, modulo N. This function is periodic: there exists an r such that the function repeats every r steps. One can prove that, provided r is even and satisfies a mild condition, computing greatest common divisors of a^(r/2) ± 1 with N directly yields a nontrivial factor of N. “Factoring” has thus been converted into “finding a period.” A classical computer still needs exponential time to find this period, whereas a quantum computer can prepare the function’s values for all x in superposition at once and then apply the quantum Fourier transform — a transformation exquisitely sensitive to periodic structure — to concentrate the period information into measurement outcomes, recovering r with high probability from a few samples. The subsequent steps, such as the greatest-common-divisor computations, are entirely classical post-processing. Note also that the algorithm is probabilistic: a single run has some chance of returning a useless period or an r that fails the conditions, but failure is recognizable on the spot, and a few reruns push the success probability close to certainty — and for the purpose of attacking a key, this kind of “verifiable probabilistic algorithm” is entirely sufficient, since factoring a key ten failures and one success has the same ending as succeeding at once. Only one step in the whole procedure genuinely uses quantum mechanics — finding the period — but that step is exactly where classical methods get stuck.

Why Classical Computers Get Stuck on the Same Step

It is worth asking why a classical computer cannot find the period quickly. Because the period of f(x) can be nearly as large as N itself, classical methods essentially have to evaluate the function at enough values of x, one by one, and look for a repetition — a sample count that grows with the period and is astronomical for a 2048-bit N. The quantum computer’s advantage is not that it “computes faster” but that it can encode the function values for exponentially many x into a single superposition, then use the quantum Fourier transform to extract a global structure — the period — in one go, sidestepping the need to check values individually. The quantum Fourier transform must also be distinguished from the classical fast Fourier transform: the former acts on amplitudes and its results cannot be read out component by component, only exploited indirectly through measurement sampling; it is fast because it never outputs that exponentially long table of data. This is the design essence of Shor’s algorithm: ask the quantum computer only the question it can answer (the period), and leave everything else to classical post-processing.

Three Decades On: Its Place Since 1994

Published in 1994, Shor’s algorithm almost immediately launched two long arcs. First, cryptographers began seriously searching for public-key schemes that do not rest on factoring or discrete logarithms; NIST’s post-quantum standardization process (launched in 2016, first standards published in 2024) can be seen as one terminus of that arc. Second, it gave quantum computing research a concrete and enticing target, and every hardware advance since has been measured against it. Experimentally, records for integers factored with Shor’s algorithm long remained at small demonstration numbers (such as 15 and 21), and such demonstrations often exploit advance simplifications based on the known structure of the answer; their significance lies in validating the procedure, not in computing power. Hybrid records combining classical methods with modest quantum resources have also appeared, but they do not change the conclusion: factoring cryptographically sized integers requires a complete fault-tolerant machine. Read this entry alongside the “Quantum Error Correction” entry and it becomes clear why migration timelines are set by error-correction progress rather than by algorithm news.

Scope: What It Breaks and What It Does Not

The same period-finding framework, slightly adapted, solves the discrete logarithm problem, so the blast radius extends beyond RSA: Diffie–Hellman key exchange, DSA, and elliptic-curve cryptography (ECDH, ECDSA, EdDSA) rest on assumptions of the same family and are dissolved by Shor’s algorithm together. That means the three pillars of the Internet’s trust infrastructure — key exchange, digital signatures, and the certificate system — fail simultaneously in front of a sufficiently powerful quantum computer. Conversely, Shor’s algorithm poses no such exponential threat to symmetric encryption and hash functions (that is Grover’s territory, and only a quadratic speedup), nor to post-quantum algorithms built on different mathematical problems such as lattices, hashes, and codes. Its strike zone is precise and lethal: it covers exactly the mainstream public-key infrastructure humanity has deployed over the past four decades.

Running Conditions: Why It Has Not Happened Yet

An algorithm being valid does not mean it can run today. Shor’s algorithm demands extremely deep circuits executed over hundreds to thousands of logical qubits, where an error in any step pollutes the result, so complete quantum error-correction protection is a must. Published resource estimates (such as the 2021 work of Gidney and Ekerå) indicate that factoring RSA-2048 requires physical qubits in the millions, running continuously for hours; current devices fall short in both scale and error rate by orders of magnitude, and integers factored in public demonstrations remain at teaching scale. The threat posed by Shor’s algorithm is therefore a “scheduling problem,” not a “tonight event”: what is genuinely urgent is harvest-now-decrypt-later — an attacker records encrypted traffic today and decrypts it once the machine matures — which forces the migration of key exchange to be completed before the threat materializes. When judging progress, watch logical qubits and error-correction metrics rather than being led by individual headline numbers.

Tags: Shor's AlgorithmFactoringRSAQuantum Threat