Shor's algorithm

How a quantum computer would break RSA, Diffie-Hellman and elliptic curves, and what machine it would need

Shor's algorithm is an algorithm for quantum computers that factors integers and computes discrete logarithms in polynomial time. Peter Shor published it in 1994, when he was at AT&T. These are exactly the two problems that RSA, Diffie-Hellman and elliptic curves rely on. With real-size keys, a quantum computer would not try keys faster: it would compute the private key from the public one.

That machine does not exist yet.

What Shor's algorithm does

Factoring an RSA modulus means finding the two primes that, multiplied together, give it. At 2048 bits (617 digits), no current computer can do it with the known classical algorithms.

Shor relies on a result from number theory: if you pick at random a number a with no factors in common with N and compute its powers modulo N (the remainders of dividing a, a², a³… by N), the remainders repeat with a fixed rhythm, a period. Once the period is known, at least half the time the factors of N come out of a quick calculation, the greatest common divisor. If they do not, you try another a.

The hard part is finding that period, which for a 2048-bit N can have hundreds of digits. An ordinary computer cannot find it without work comparable to factoring. The quantum computer does it like this:

  1. It prepares a register with all the exponents at once (a superposition).
  2. It computes the remainders of a raised to each of them in a single pass. This is the expensive part: billions of operations for a real key.
  3. It applies the quantum Fourier transform, which does something to the period similar to what a prism does to light: the values that fit the rhythm reinforce each other and the rest cancel out.
  4. When it measures, it gets with good probability a number from which the period can be deduced. If not, it repeats.

Shor's algorithm example: factoring 15

With N = 15 and a = 7, the powers of 7 leave remainders of 7, 4, 13, 1, and then 7, 4, 13, 1 again. The period is 4. With half the period, 7² = 49, which leaves a remainder of 4. The greatest common divisor of 15 and 4 − 1 is 3, and of 15 and 4 + 1 is 5: the two factors.

Does Shor break elliptic curves and Diffie-Hellman?

Diffie-Hellman relies on the discrete logarithm: given g raised to x modulo a prime, find x. Elliptic curves use the same idea on the points of a curve. Shor solved it in the same paper, also by looking for a hidden period, and the method works for curves. So RSA, Diffie-Hellman, ECDH, X25519, ECDSA and Ed25519 all fall: almost all of today's public-key cryptography.

Curves are an even easier target. Back in 2017, Roetteler and others calculated that a 256-bit curve needs fewer qubits than RSA with comparable classical security. With current estimates, the difference lies mainly in the operations: fewer than 90 million Toffoli gates for a 256-bit curve, compared with about 6.5 billion for RSA-2048.

Making keys longer does not fix it: the cost of Shor grows polynomially. A key twice as long needs roughly twice as many qubits and about eight times as many operations, an increase similar to the extra work for whoever uses the key.

In AES there is no known hidden period to exploit: the best known quantum attack against it is Grover's algorithm, which only speeds up brute force.

How many qubits does it take to break RSA?

Estimates are given in physical qubits, the ones that are actually built and that often fail. With error correction, each logical qubit, the one that does the computation, is built from hundreds or thousands of physical ones. The estimates in the table assume superconducting qubits in a grid that fail once every thousand operations (0.1%).

YearEstimateTargetPhysical qubitsTime
2019Gidney and EkeråRSA-204820 millionabout 8 hours
2025GidneyRSA-2048under 1 millionunder a week
2026Google (Babbush et al.)secp256k1 curveunder 500,000minutes

The 2025 reduction comes from approximate arithmetic, which needs fewer logical qubits (about 1,500 compared with more than 6,000 in 2019), from a cheaper way of preparing the special states that Toffoli gates require and from another way of storing the qubits that are waiting. In exchange, the computation takes longer.

With other types of qubit, which do not exist at that scale either, the figures drop further. In March 2026, Cain et al. estimated about 26,000 neutral-atom qubits for a 256-bit curve in a few days. In October, Alice & Bob estimated about 23,000 “cat” qubits for RSA-2048 in just over three days, assuming those qubits do not suffer one of their two types of error.

Physical qubits each estimate requiresLinear scale. None of these machines exists.

Superconducting, 0.1% error rate

  • Gidney and Ekerå 2019 · RSA-2048: 20 million
  • Gidney 2025 · RSA-2048: under 1 million
  • Google 2026 · secp256k1 curve: under 500,000

Other types of qubit

  • Neutral atoms (Cain et al. 2026) · 256-bit curve: about 26,000
  • “Cat” qubits (Alice & Bob 2026) · RSA-2048: about 23,000

Google's March 2026 estimate is for secp256k1, the curve used by Bitcoin and Ethereum, and needs fewer than 1,200 logical qubits. Google did not publish the circuits, but a zero-knowledge proof so that others could check the figures without seeing them. In June 2026, André Schrottenloher (Inria) openly published circuits with similar costs. Which coins would be exposed is explained in the article on the bitcoin crash and the quantum risk, and when the machine might exist in Q-Day.

What numbers has a quantum computer factored?

In 2001, an experiment published in Nature factored 15 = 3 × 5 with seven qubits, nuclei of a molecule controlled by nuclear magnetic resonance, a technique that does not scale and whose truly quantum nature is disputed. The circuit was already simplified for the chosen bases. In 2012, another experiment factored 21 = 3 × 7 with photons and a “compiled” circuit, simplified for that specific number.

Those shortcuts come with a catch, and every experiment has used them to some extent. In 2013, Smolin, Smith and Vargo showed that, by simplifying the circuit this way, you can “factor” huge numbers with just two qubits, because what measures the difficulty is the period, not the size of the number.

In 2025, Gidney calculated that the full circuit for 21 needs about 115 times more two-qubit operations than the one for 15, and concluded that no quantum computer has yet factored 21 without shortcuts that assume the answer.

Has China broken RSA with a quantum computer?

Every so often a story appears claiming that a quantum computer has broken RSA or a Bitcoin key. To date, none has broken a real-size key:

  • December 2022. A Chinese team (Yan et al.) claimed that RSA-2048 could be attacked with a 372-qubit circuit. Their method is not Shor's, but a classical algorithm by Schnorr, whose effectiveness was never shown, combined with a heuristic quantum technique (QAOA). They factored numbers of up to 48 bits with 10 qubits. Scott Aaronson called it one of the most misleading quantum computing papers he had seen in 25 years.
  • 2024. Researchers at Shanghai University factored a 22-bit RSA number with a D-Wave quantum annealer. It is not Shor, and RSA uses at least 2048 bits. Rob Joyce, former NSA cybersecurity director, described the claims as “totally overblown”.
  • April 2026. A researcher used a variant of Shor to obtain the private key of a 15-bit elliptic curve on a cloud quantum computer. This is Shor, but with 32,767 possible keys: a laptop tries them all instantly, and Bitcoin uses 256 bits.

When you see a headline like that, check whether it uses Shor, how many bits the number had and whether the quantum computer did anything a laptop cannot do instantly.

What to do about Shor: post-quantum cryptography

Shor cannot be fixed within RSA or curves: they have to be replaced by algorithms based on other mathematical problems, post-quantum cryptography. For key exchange, ML-KEM; for signing, ML-DSA and SLH-DSA. AES stays. Since what is transmitted today can be stored and decrypted later, key exchange is the more urgent part, and the major browsers and some messaging apps have already switched.

Sources: Shor (1994) · Kaplan, Leurent, Leverrier, Naya-Plasencia (2016) · Roetteler, Naehrig, Svore, Lauter (2017) · Gidney, Ekerå (2019) · Gidney (2025) · Babbush et al. (2026) · Google Research (2026) · Schrottenloher (2026) · Gidney: We should just publish openly (2026) · Cain et al. (2026) · Pappalardo et al., Alice & Bob (2026) · Vandersypen et al. (2001) · Martín-López et al. (2012) · Smolin, Smith, Vargo (2013) · Gidney: Why haven't quantum computers factored 21 yet? (2025) · Yan et al. (2022) · Aaronson: Cargo Cult Quantum Factoring (2023) · TechTarget (2024) · Project Eleven (2026).