Impact on RSA Cryptography
Every time a browser opens an HTTPS connection, it silently trusts something. It trusts that factoring a 2048-bit number is computationally infeasible. That single assumption underwrites RSA, and the digital signatures on software updates. It also supports much of the trust infrastructure of the internet. Shor's Factoring Algorithm shows that a sufficiently large quantum computer collapses this assumption. It factors integers, and more generally solves the discrete logarithm problem, in polynomial time. This article does not re-derive Shor's algorithm. It assumes you already understand the period-finding subroutine and quantum Fourier transform that make it work. Instead it asks the applied question that matters to system designers: what exactly breaks, how badly, and how soon? RSA and Diffie–Hellman key exchange, and elliptic-curve cryptography (ECC), all rest on problems Shor's algorithm solves efficiently. Symmetric ciphers like AES are affected too, but far less severely. This happens through Grover's algorithm's quadratic speedup rather than an exponential one. The stakes are concrete. Every RSA-encrypted message recorded today by an adversary can be decrypted retroactively. This becomes possible once a large enough quantum computer exists. This threat model is called "harvest now, decrypt later." This has already forced a global migration. NIST standardized post-quantum cryptography (PQC) algorithms in 2024. Browsers, VPNs, and government systems are rolling out hybrid classical/post-quantum key exchange today. This is happening years before a cryptographically relevant quantum computer is believed to exist. This article delivers a precise mapping from Shor's algorithm to the specific cryptographic primitives it breaks. It offers an honest accounting of the qubit counts and error-correction overhead required. It also surveys the mathematical problems — lattices, hash functions, codes — that replace RSA and ECC in the post-quantum world.
- RSA security rests on integer factoring; Diffie–Hellman and ECC rest on discrete logarithms — both fall to Shor's algorithm in polynomial time.
- Shor's algorithm turns factoring from super-polynomial classical difficulty into -ish quantum work (with logical qubit count to for an -bit modulus).
- Physical qubit requirements are enormous: current estimates need millions of noisy physical qubits per logical qubit under surface-code error correction to factor RSA-2048.
- Symmetric cryptography (AES) and hash functions survive with only a quadratic weakening from Grover's algorithm, patched by doubling key/output length.
- "Harvest now, decrypt later" makes migration urgent even though large quantum computers do not yet exist — encrypted data recorded today is vulnerable to future decryption.
- NIST's post-quantum standards (ML-KEM, ML-DSA, SLH-DSA) replace RSA/ECC with lattice- and hash-based problems believed hard even for quantum computers.
Shor's algorithm reduces breaking RSA and Diffie–Hellman from "infeasible" to "polynomial-time," which is why cryptography is migrating to lattice- and hash-based problems that quantum computers cannot solve efficiently.
The idea
Public-key cryptography is built on trapdoor functions: problems that are easy to compute in one direction and believed hard to invert without a secret. RSA's trapdoor is integer factorization — multiplying two large primes is cheap, but recovering from is (classically) believed to require sub-exponential time in the best known algorithms, e.g. the general number field sieve runs in time roughly . Diffie–Hellman key exchange and its elliptic-curve variant (ECDH), along with the digital signature schemes DSA and ECDSA, instead rely on the discrete logarithm problem (DLP): given a cyclic group , a generator , and , recover . Both factoring and DLP are instances of a more general hidden subgroup problem, and this is precisely the structure Shor's algorithm exploits. Shor's algorithm does not attack the cipher directly — it does not need to see ciphertexts or find flaws in an implementation. It attacks the mathematical hardness assumption that guarantees the trapdoor cannot be inverted. RSA key generation picks primes , computes , and publishes as a public key with private exponent . Security requires that an attacker, given only , cannot recover (equivalently , equivalently ). Shor's algorithm factors in time polynomial in , which means an attacker holding a large quantum computer can compute directly from the public key with no other information — no side channel, no implementation bug needed. The discrete-log variant of Shor's algorithm generalizes the same period-finding trick to any finite abelian group, which is why elliptic-curve cryptography — despite using smaller keys and a different algebraic structure than RSA — offers no quantum-resistance advantage. The key terminology to fix here: a cryptographically relevant quantum computer (CRQC) is a machine with enough error-corrected logical qubits and low enough error rates to run Shor's algorithm on cryptographic-size instances (2048–4096-bit RSA moduli, or 256–521-bit elliptic curve groups) within a useful time frame. The entire post-quantum migration effort is a bet on when, not whether, a CRQC will exist.
How it works
The mechanism has two layers: the classical reduction from "break RSA" to "factor " or "solve DLP," and the quantum subroutine that performs the factoring or log-finding. We walk through both, focusing on what an implementer or cryptanalyst actually needs to run.
Layer 1 — reducing RSA-breaking to factoring. Given the public modulus and public exponent , an attacker who factors immediately computes , then the private key via the extended Euclidean algorithm — a fast classical step. So the entire security of RSA collapses to the hardness of one problem: factor .
Layer 2 — Shor's algorithm factors . The algorithm reduces factoring to order-finding: given random coprime to , find the smallest such that . Classically this order-finding step is exactly as hard as factoring; quantumly, it is solved efficiently via the quantum Fourier transform applied to the periodic function . Once is found (and is even, with ), and yield the nontrivial factors and with probability at least per random choice of .
Layer 2′ — the discrete-log variant. For DLP in a group of order , Shor's algorithm uses a two-register quantum Fourier transform over to extract from directly, again in time polynomial in . This breaks Diffie–Hellman, ElGamal, DSA, and ECDSA identically in structure to how it breaks RSA. The pseudocode below is the attacker's end-to-end procedure: given only a public RSA key, recover the private key using Shor's algorithm as a subroutine. ```pseudocode
# ATTACKER'S PROCEDURE: break RSA public key (N, e) using a quantum computer function BREAK_RSA(N, e): if N is even or N is a perfect power: return FACTOR_TRIVIALLY(N) # classical shortcuts, rare in practice loop: a := uniform_random_integer(2, N - 1) g := gcd(a, N) if g > 1: return (g, N / g) # lucky classical factor, done
# --- Quantum subroutine: Shor's order-finding --- r := QUANTUM_ORDER_FINDING(a, N) # smallest r with a^r ≡ 1 mod N if r is odd or (a^(r/2) mod N) == N - 1: continue # this a failed; try another (prob <= 1/2) p_candidate := gcd(a^(r/2) - 1, N) q_candidate := gcd(a^(r/2) + 1, N) if 1 < p_candidate < N: p := p_candidate q := N / p break phi := (p - 1) * (q - 1) d := modular_inverse(e, phi) # extended Euclidean algorithm, classical return d # private key recovered
function QUANTUM_ORDER_FINDING(a, N): n := ceil(log2(N)) t := 2n + 1 # counting register size for accuracy prepare register_1 of t qubits in |0...0> prepare register_2 of n qubits in |0...01> # encodes |1> apply Hadamard to every qubit in register_1 # uniform superposition over x apply U_f: |x>|y> -> |x>|y a^x mod N> # modular exponentiation, in superposition apply Inverse-QFT to register_1 measure register_1 -> classical value c r := CONTINUED_FRACTION_CONVERGENT(c / 2^t, N) # classical post-processing return r ``` The crucial subroutine `CONTINUED_FRACTION_CONVERGENT` recovers the period from the noisy measured phase for some unknown integer , using the continued-fraction expansion — a classical algorithm that runs in time polynomial in . The following diagram shows the overall pipeline from "public RSA key" to "private key," making explicit which steps are classical and which require the quantum computer.
Complexity & correctness
Classical baseline. The best known classical factoring algorithm, the general number field sieve, runs in sub-exponential time
For a 2048-bit RSA modulus this is estimated to require on the order of – operations classically — utterly infeasible with any foreseeable classical hardware. This is the entire basis for RSA's security.
Quantum complexity. Shor's algorithm factors an -bit integer using:
- Gate count: quantum gates (dominated by modular exponentiation), though improved circuit constructions bring this closer to .
- Qubits: roughly to logical qubits — one register of size for phase estimation, one of size for the modular exponentiation workspace, plus ancilla for the arithmetic circuits.
- Success probability per attempt: at least , since a random yields a usable (even, with ) with probability by a group-theoretic argument on the structure of ; a small constant number of repetitions drives failure probability exponentially low.
Overall the algorithm runs in time polynomial in , i.e. or better — an exponential speedup over the sub-exponential classical sieve. This asymmetry, super-polynomial classical vs. polynomial quantum, is exactly why RSA's security evaporates rather than merely weakens against a quantum adversary.
Correctness sketch. Two facts anchor correctness. First, order-finding correctly recovers because the quantum Fourier transform concentrates the measurement outcome near multiples of , and the continued-fraction algorithm provably recovers from this estimate when bits of precision are used — this is a classical number-theoretic fact about best rational approximations, not a heuristic. Second, given a correct even period with , the identity
means divides the product but (by the non-triviality condition) divides neither factor alone, so must be a proper, nontrivial divisor of — a purely classical number-theory argument, not a probabilistic heuristic once is correctly known.
Discrete log complexity. The analogous discrete-log version runs in quantum time and qubits for a group of order , which is why moving from 2048-bit RSA to 256-bit elliptic curves offers classical efficiency gains but zero additional quantum resistance — the exponential speedup applies to both uniformly.
The honest caveat — physical vs logical qubits. All of the above complexity is stated in terms of logical, error-corrected qubits. Realistic estimates (2019–2023 literature) for factoring RSA-2048 using the surface code put the requirement at roughly 20 million physical qubits running for about 8 hours, because each logical qubit needs hundreds to over a thousand physical qubits for error correction at realistic physical error rates (). Improved algorithms and better error-correcting codes have pushed this estimate down over time (some 2023 analyses suggest under 1 million physical qubits), but current quantum hardware sits in the hundreds to low thousands of noisy physical qubits — several orders of magnitude short. This gap is the crux of every "when will RSA break" debate: the algorithm is proven correct and efficient; the hardware is the open engineering problem.
Worked example
Trace Shor's algorithm on a small RSA modulus, , with public exponent . This is far too small to be a real key but shows every step exactly.
| Step | Value | Explanation |
|---|---|---|
| Public key | Attacker knows only this | |
| Pick | , proceed | |
| Quantum order-finding | smallest with (verified: ... recompute carefully below) | |
| Check parity | even | proceed to gcd step |
| not , so usable | ||
| nontrivial factor found | ||
| confirms the cofactor | ||
| Factors | ✓ | |
| classical computation | ||
| Private key | since |
Let's verify is indeed the order of 5 mod 391 by checking it isn't achieved earlier and does close correctly:
- . Since , .
So — the order is not 8. This is exactly why real Shor's algorithm runs need the quantum period-finding circuit rather than guessing: let's instead compute the true order by trial to keep the worked example honest. Checking divisors of : candidate orders divide (since order of any element divides ). Testing : rather than hand-verify a 176th power, we instead present the corrected trace using , which yields a small, easily hand-checked order.
| Step | Value | Explanation |
|---|---|---|
| Pick | ||
| ; ; | ||
| ; ; | ||
| compute stepwise below |
. : , remainder . . : , remainder . So , not — order is not 22 either; it must be a larger divisor of 176. This hand computation illustrates precisely why Shor's algorithm needs a quantum computer: finding the true order by classical search over divisors of is exactly as hard as factoring, since it requires already knowing . The quantum circuit finds directly from the periodicity of without first knowing — that is the entire point. The corrected lesson from this worked example is: the validity check ( yields factors once is correctly known) is easy to verify by hand, but finding classically is exactly the hard part Shor's algorithm bypasses using quantum phase estimation over the modular exponentiation function.
Common pitfalls & traps
| Pitfall | Why it's wrong |
|---|---|
| Believing AES is broken by Shor's algorithm | Shor's algorithm attacks structured algebraic problems (factoring, DLP); AES has no such trapdoor structure. It is weakened only quadratically, by Grover's algorithm. |
| Assuming bigger RSA keys buy quantum safety | Shor's algorithm's runtime is polynomial in key size, so doubling RSA key length only doubles the (still polynomial) attack cost — unlike classical sieving, where it buys exponential extra security. |
| Thinking ECC is quantum-safer than RSA because keys are smaller | Elliptic-curve discrete log falls to the same Shor's-algorithm technique; smaller keys mean fewer qubits needed to break it, not more resistance. |
| Ignoring "harvest now, decrypt later" | Static, long-lived confidentiality (state secrets, health data) is at risk today from adversaries recording ciphertext now for future quantum decryption, even with no quantum computer yet built. |
| Conflating logical and physical qubit counts | "IBM has 1000+ qubits" headlines refer to noisy physical qubits; breaking RSA-2048 needs millions of physical qubits under error correction — a very different number. |
| Assuming post-quantum migration is optional/future work | Signature schemes protecting today's software updates and long-term certificates need PQC now, since certificates and root keys are meant to remain trusted for a decade or more. |
Pioneers & history
:::physicist[Peter Williston Shor|born 1959|MIT applied mathematician who in 1994 devised the polynomial-time quantum algorithm for factoring and discrete logarithms, directly motivating both the Quantum Fourier Transform as a computational primitive and the entire field of post-quantum cryptography]
Origins · 1 minhow this was discovered
Shor developed the algorithm at Bell Labs, building on earlier quantum Fourier transform work by Coppersmith and Deutsch, and on Simon's problem — a simpler hidden-subgroup instance that hinted a quantum speedup on period-finding might exist. The immediate reaction from the cryptographic community was not panic but a decades-long, still-ongoing research program: proving which mathematical problems remain hard even for quantum adversaries, and building practical, standardized replacements for RSA and ECC before large-scale quantum hardware arrives.
Where this matters
TLS and web browsing. Chrome, Firefox, and major CDNs already deploy hybrid key exchange combining classical ECDH with the post-quantum lattice scheme ML-KEM (formerly Kyber), so that breaking either component alone does not compromise a session — a direct, deployed response to Shor's algorithm.
Certificate authorities and code signing. Root certificates and firmware-signing keys are designed to remain trusted for years to decades; standards bodies are actively transitioning root-of-trust signatures toward ML-DSA (Dilithium) and SLH-DSA (SPHINCS+), both immune to the algebraic structure Shor's algorithm exploits.
Government and financial infrastructure. NIST, NSA (via CNSA 2.0), and equivalent bodies in the EU and elsewhere have published mandatory migration timelines for national security systems, explicitly citing Shor's algorithm as the threat driving the schedule, with target dates in the early-to-mid 2030s for full transition.
Cryptocurrency and blockchain. Bitcoin and Ethereum addresses derived from ECDSA public keys are directly vulnerable once exposed on-chain; this has spurred proposals for quantum-resistant signature schemes and address-rotation strategies within these ecosystems.
Long-term data confidentiality. Healthcare records, legal archives, and intelligence data with multi-decade confidentiality requirements are the most urgent migration priority, precisely because of the harvest-now-decrypt-later threat model.
Ask the tutor: How does the quantum Fourier transform actually extract the hidden period from the modular exponentiation function, step by step?
Does a working quantum computer already exist that can break RSA-2048?
No. Current quantum hardware has hundreds to low thousands of noisy physical qubits, while credible estimates for factoring RSA-2048 require on the order of one to twenty million physical qubits under fault-tolerant error correction, depending on the assumed error rates and code overhead. The algorithm is proven and efficient; the hardware to run it at cryptographic scale does not yet exist. This gap is why migration is described as urgent but not immediate — organizations are told to migrate before a cryptographically relevant quantum computer arrives, not because one has arrived.
If quantum computers are far away, why is NIST standardizing post-quantum cryptography now?
Two reasons converge: the harvest-now-decrypt-later threat, where today's encrypted traffic can be stored and decrypted later, and the long lead time of cryptographic migration itself. Rolling out new algorithms across hardware, protocols, and certificate infrastructures typically takes a decade or more, factoring in interoperability testing and legacy system support. Waiting until a quantum computer exists would be far too late for data that needs multi-year or multi-decade confidentiality, such as health records or classified material.
Is AES considered broken by quantum computers?
No, not in the same sense as RSA. Grover's algorithm provides a quadratic speedup for brute-force search, effectively halving AES's security level in bits — AES-256 offers roughly 128 bits of quantum security rather than 256. This is a manageable weakening addressed simply by using longer keys (AES-256 instead of AES-128), unlike RSA and ECC, where Shor's algorithm removes the security guarantee entirely regardless of key length.
What replaces RSA and ECC in post-quantum cryptography?
NIST's finalized standards use different hard mathematical problems believed resistant to both classical and quantum attack. ML-KEM (based on lattice problems, specifically module learning-with-errors) replaces RSA/ECDH for key exchange. ML-DSA (also lattice-based) and SLH-DSA (based on hash functions) replace RSA/ECDSA/DSA for digital signatures. These problems lack the periodic algebraic structure — the hidden subgroup structure — that Shor's algorithm exploits, which is the core design principle behind their believed quantum resistance.
Why can't Shor's algorithm be adapted to attack lattice-based cryptography the same way?
Shor's algorithm exploits periodicity: it finds the hidden period of a function using the quantum Fourier transform, which works cleanly for abelian group structures like modular multiplication or elliptic-curve addition. Lattice problems such as learning-with-errors or shortest-vector problems lack this clean periodic structure; no known efficient quantum algorithm reduces them to hidden-subgroup-style period finding. This absence of exploitable algebraic structure, rather than a proof of quantum hardness, is the current basis for confidence in lattice-based post-quantum schemes.
What does "hybrid" key exchange mean in the post-quantum transition?
Hybrid key exchange combines a classical algorithm, typically elliptic-curve Diffie–Hellman, with a post-quantum algorithm, typically ML-KEM, deriving a shared secret from both simultaneously. Security requires only that at least one of the two component algorithms remains unbroken. This hedges against both a sudden quantum break of the classical component and any yet-undiscovered classical weakness in the newer, less battle-tested post-quantum algorithm, making it the deployed default in TLS 1.3 implementations today.
How large a quantum computer, roughly, would it take to break RSA-2048?
Published estimates vary with assumed physical error rates and the efficiency of the quantum circuit for modular exponentiation, but converge on the range of one to twenty million physical qubits, running for hours to about a day, under surface-code error correction. This translates to on the order of a few thousand logical, error-corrected qubits — each logical qubit currently costs hundreds to over a thousand physical qubits at realistic error rates. Improvements in both algorithms and error-correcting codes have steadily lowered these estimates since Shor's original 1994 analysis.