Why do we care about Quantum Computing?
Public-key cryptography lets computers establish shared secrets over untrusted networks and verify digital signatures. We use it when a browser authenticates a website, an SSH client authenticates a server, or an operating system checks a software update's signature.
A sufficiently capable quantum computer could recover the private keys behind much of the public-key cryptography we use. It could read communications protected by vulnerable key exchanges and forge signatures that we rely on to authenticate people, computers, and software updates.
The machine needed to do this is called a cryptographically relevant quantum computer, or CRQC. It must be able to complete a cryptographic attack at a useful key size and within a useful amount of time.
One target is RSA, a public-key cryptosystem for encryption and digital signatures, named for Rivest, Shamir, and Adleman. For encryption, a sender uses the recipient's public key, and the recipient decrypts with the private key. For signatures, the owner signs with the private key, and others verify the signature with the public key.
RSA constructs its key pair using two large, distinct primes, and . Their product, called the modulus, is part of the public key:
Multiplying the primes is easy. Recovering them from a properly chosen, sufficiently large is beyond the reach of the best known classical factoring methods. Someone who factors can reconstruct the private key from the public key. That compromises both RSA encryption and RSA signatures.
Diffie–Hellman key exchange lets two parties establish a shared secret over a public network. They can use that secret to derive keys for encrypting their traffic. It relies on a different mathematical problem from factoring. In the modular-arithmetic version, they agree on a suitable prime and a public base . Alice publishes and Bob publishes . Their exponents remain secret. Each can calculate using the other person's public value and their own exponent. An eavesdropper sees the public values, but recovering an exponent requires solving a discrete logarithm problem. Recovering either exponent lets an eavesdropper calculate the shared secret.
Elliptic-curve cryptography (ECC) is a family of public-key schemes for key exchange and digital signatures. Its arithmetic adds points on an elliptic curve. A public key is a point , obtained by adding a publicly known point to itself times. The secret is . Classical attacks on well-chosen curves are expensive, which allows much shorter keys than RSA at comparable classical security levels. But quantum discrete-logarithm algorithms apply to elliptic curves too, making their key exchanges and digital signatures vulnerable.
A mathematical group is a set with an associative combining operation, an identity element, and an inverse for each element. In an abelian group, combining two elements in either order gives the same result. These quantum attacks exploit periods and discrete logarithms in such groups when their operations can be computed efficiently. Factoring and discrete logarithms are the problems on which these cryptosystems depend. Merely using a group does not mean a cryptosystem's security depends on either problem.
Peter Shor's result makes factoring and discrete logarithms possible in polynomial time on a suitable quantum computer. Polynomial time means that the number of operations grows as a polynomial in the number of bits used to describe the problem. Increasing an RSA key's length makes the quantum attack more expensive, but it does not restore the mathematical obstacle that protects it against known classical attacks.
A physical qubit is a physical system in which we use two distinguishable quantum states to represent and . They might be two internal states of an atom or ion, or two energy levels of a superconducting circuit. We must be able to prepare the system, manipulate it, couple it to other qubits, and measure it.
A logical qubit is encoded across multiple physical qubits using a quantum error-correcting code: a mathematical scheme that adds redundancy so errors can be detected and corrected. A CRQC needs enough logical qubits, reliable gates, and an enormous amount of classical computation to keep the quantum computation working.
The notation and , pronounced “ket zero” and “ket one,” denotes two basis vectors, just as and do in linear algebra. A superposition is a normalized linear combination of them:
The coefficients and are called amplitudes. The pair is the state vector in this basis. Measuring in this basis gives zero with probability and one with probability , with .
A complex amplitude has magnitude and phase , its angle in the complex plane. Euler's formula gives , where . The relative phase is the difference between the two amplitudes' angles.
When an operation combines contributions to the same measurement outcome, their amplitudes add before we take the squared magnitude. Contributions with matching phases reinforce one another; opposing contributions can cancel. This is interference.
A quantum gate acts on the state vector. For the computation between measurements, it is a unitary transformation: a reversible linear map that preserves the sum of the squared magnitudes of the amplitudes, keeping total probability equal to one.
A pure state is one described by a single state vector. The usual geometric representation is the Bloch sphere. Ignoring a common phase multiplying the entire vector, which does not change measurement probabilities, we can write a pure single-qubit state as

The polar angle sets the measurement probabilities: for zero and for one. The angle is the relative phase between the two amplitudes. Every point on the equator gives equal zero/one probabilities, although those states behave differently in subsequent operations.
A pure state corresponds to a point on the sphere's surface. Preparing or with equal classical probabilities gives a statistical mixture at the center; preparing gives a pure state on the equator. A reversible single-qubit gate moves the point by rotating the sphere's radius vector. This is what “rotation” means here: a controlled change of the quantum state. A relative phase shift moves the point around the vertical axis while preserving its zero/one measurement probabilities.
A classical circuit can be built entirely from NAND gates, or entirely from NOR gates. Each is universal for Boolean logic: it can express every Boolean function, given enough gates and wires. For NAND, tying the two inputs together produces NOT. Negating a NAND output produces AND. Applying NAND to two inverted inputs produces OR, by De Morgan's law.

The small circle at a gate's output means inversion. NAND alone can build NOT, AND, and OR; NOR has the same universality property. Practical circuit designs use a broader gate library to improve area, power, and delay.
For qubits, the state vector has amplitudes, one for each possible -bit string. Two qubits have four amplitudes; three have eight. The notation labels the basis state for the bit string : its amplitude is one and all other entries are zero.
To implement Boolean logic with quantum gates, the computation must be reversible. An AND gate maps three different inputs to zero, so its output cannot tell us which input was supplied. We can implement that Boolean function reversibly by preserving its inputs and writing the result into an additional qubit.
That is one job for a Toffoli gate, also called controlled-controlled-NOT. It has two control qubits, and , and a target qubit, . For inputs with definite bit values, it leaves and unchanged and flips exactly when both controls are one:
is exclusive-or and is AND. Start the target at zero and it receives . Apply the gate twice and the original state is restored. Together with simpler reversible gates, Toffoli gates build adders, multipliers, and other Boolean computations. In a quantum circuit, the operation acts on superpositions without measuring the controls. A reversible arithmetic circuit acts on a superposition of inputs while preserving their phase relationships.
Reversible Boolean gates alone permute the possible bit strings. Quantum universality also requires control over superpositions and phases. The Hadamard gate, , replaces a qubit's zero and one amplitudes with . The T gate advances the phase of the one component relative to the zero component by . CNOT, or controlled-NOT, flips a target qubit when a single control qubit is one, leaving the control unchanged.
The Hadamard rule shows why phase matters. The amplitude pairs and both give equal zero/one probabilities when measured. After a Hadamard, the first gives zero with certainty and the second gives one with certainty.

Time runs from left to right. A filled dot is a control; a circled plus is a NOT target. The basis-state mappings shown for CNOT and Toffoli extend linearly to superpositions.
For two independent qubits in pure states, the amplitude of each bit pair is the product of one amplitude from each qubit. Now start with both qubits at zero, apply a Hadamard to the first, and use that qubit as the control of a CNOT targeting the second. The resulting amplitudes are for 00 and 11, and zero for 01 and 10. No two single-qubit amplitude lists can produce this: nonzero products for 00 and 11 would require nonzero products for 01 and 10 as well. This is entanglement. The pure state of the pair cannot be written as separate state vectors for its two parts.
Sequences of H and T gates can approximate any single-qubit unitary operation, up to an unobservable overall phase. CNOT supplies the interaction between qubits. Any unitary operation on several qubits can be decomposed into single-qubit operations and CNOT gates. This makes universal for quantum computation: circuits built from them can approximate any unitary operation to any desired accuracy. More precision generally requires more gates.
A digital circuit represents zero and one by ranges of voltages. Small disturbances within those ranges can be removed as gates regenerate the signal. A qubit must preserve the amplitudes and relative phase needed by the computation. An unwanted phase change can spoil the answer even when the probabilities of immediately measuring zero or one have not changed.
Physical qubits interact with their surroundings. An excited (higher-energy) state can lose energy to the environment and decay. Fluctuating electric or magnetic fields can change the relative phase. Uncontrolled interaction with the environment can carry away information about the qubit and destroy coherence, the phase relationships needed for interference. These processes are called relaxation and dephasing.
Control introduces further opportunities for error. A microwave or laser pulse can change the amplitudes or relative phase by the wrong amount. A signal intended for one qubit can disturb its neighbor. The engineering problem is to suppress unwanted interactions while retaining the deliberate interactions needed to compute. Cooling, shielding, vacuum systems, and precisely controlled fields address different parts of that problem, depending on the hardware.
The encoding of a logical qubit distributes its information so that certain errors can be detected and corrected without learning the encoded amplitudes. It is not a collection of identical backups: the no-cloning theorem rules out copying an arbitrary unknown quantum state.
Error-correction circuits repeatedly measure relationships among the physical qubits, according to the chosen encoding scheme. The checks give the same expected results for all valid logical states, but physical errors can change those results. That lets us detect errors without learning the encoded logical amplitudes. The resulting patterns of check results are called error syndromes. A classical decoder is an algorithm that interprets those patterns to infer likely errors and determine corrections. More physical qubits can provide stronger protection when the physical operations are reliable enough for the chosen encoding and decoder. There is no fixed conversion rate from physical qubits to logical qubits.
Given RSA's public modulus , Shor's factoring algorithm divides the work between quantum and classical processors. The quantum circuit produces a sample carrying information about a period. The classical processor recovers a candidate period, checks it, and calculates the factors. The quantum gates determine the probabilities of the possible samples; they do not test candidate factors.
To turn a period into factors, choose relatively prime to , and consider
The smallest positive for which is the order of modulo , and it is the period of .
The residues relatively prime to form a finite group under multiplication modulo . Their number, , is Euler's totient. The powers of form a subgroup, a subset that is itself a group under the same operation. This subgroup has elements. Lagrange's theorem says that the size of a subgroup divides the size of the group, so divides . Since for , we know . We will use that bound when interpreting the quantum measurement; we do not need to calculate first.
If is even, set . Then
Each prime factor of must divide or , because divides their product. If both primes divided the same term, would be or modulo . When neither is true, the factors are split between the two terms. Euclid's algorithm finds them by calculating the greatest common divisors and . Finding the period is the expensive step on a classical computer.
For a worked example, take .
1. Set up the registers. The classical processor chooses and checks . A register is a group of qubits whose possible values we label with binary integers. We use nine logical qubits for the input register, representing values through , and five for the result register, which must hold residues through . The arithmetic also needs temporary qubits. We chose an input range of size because gives the later frequency measurement enough precision.
For a systems programmer, a useful mathematical model is a table indexed by the pair (input, result), with a complex amplitude in each entry. This describes the joint state of the qubits; it is not a table stored in classical RAM. Measuring both registers returns one pair, with probability equal to the squared magnitude of its amplitude. We can calculate with the full table in a small simulation, but measurement does not let us read it out.
Initially the input register holds and the result register holds . The entry (0, 1) has amplitude one; every other entry has amplitude zero.
2. Give every input the same amplitude. Apply a Hadamard gate to each input qubit. In the joint amplitude table, it acts on pairs of entries whose input values differ only in that bit, using the sum-and-difference rule above. Starting with one nonzero entry, the first gate produces two equal nonzero amplitudes, the second produces four, and so on. After nine gates, all 512 entries (x, 1) have amplitude . Their squared magnitudes sum to one.
3. Compute the modular powers. Write , where are its binary digits. The classical processor precomputes : start with , then repeatedly square the previous value and take the remainder modulo . The nine constants are . Multiplying the constants for the nonzero bits of , reducing modulo , gives .
For each input bit , a controlled multiplication circuit multiplies the result by modulo when that bit is one, and leaves it alone otherwise. For input , the active multipliers are and : the result changes from to to . Each multiplication block contains many reversible gates. The input qubits control those gates without being measured, and the arithmetic reverses its temporary calculations to restore the workspace. Workspace records that distinguish inputs producing the same result would prevent their contributions from interfering later. IBM's account of order finding describes this construction.
Modular multiplication is reversible because each is relatively prime to : it permutes the residues through without merging any two of them. Multiplication by , for example, is undone by multiplication by , since . The unused result values through can be left unchanged.
The circuit moves the amplitude from each entry (x, 1) to (x, 2^x mod 21). It applies this rule to the whole superposition by linearity. The first few occupied entries are:
| Input | Result | Amplitude |
|---|---|---|
| 0 | 1 | |
| 1 | 2 | |
| 2 | 4 | |
| 3 | 8 | |
| 4 | 16 | |
| 5 | 11 | |
| 6 | 1 | |
| 7 | 2 | |
The input and result registers are now entangled. If they were independent, each would have its own amplitude list. The amplitude for any pair (x, y) would equal the input amplitude for x multiplied by the result amplitude for y.
Our table shows why. The pairs (0, 1) and (1, 2) have nonzero amplitudes, but (0, 2) and (1, 1) have zero amplitudes. Independent lists that allow inputs 0 and 1 and results 1 and 2 would also allow those cross-pairs. They cannot reproduce this table. We must describe the quantum state of the registers jointly.
A classical mixture of the same pairs could have the same measurement probabilities at this stage, but it would not preserve the phase relationships needed for the later interference. The circuit has created the entangled state using only , , and the input bit positions; it was never given the period or the factors.
4. Select a regularly spaced set of inputs. Measure the result register. Suppose it returns . The entries consistent with that result have inputs . There are 86 of them, each with probability , so this result occurs with probability . We add probabilities because the input values still distinguish the entries. Their amplitudes have not interfered.
After observing that result, all other entries disappear from the conditional state. Each remaining amplitude becomes so that the remaining probabilities sum to one. Another measured result would select a different starting point with the same spacing.
We can see the spacing in our mathematical description. Measuring the input register now would give us only one of those values. We need to change the amplitudes so that a measurement carries useful information about the spacing.
5. Define and apply the Fourier transform. A discrete Fourier transform turns a list of values into sums that reveal its repeating patterns. The quantum Fourier transform (QFT) applies that transformation to a register's complex amplitudes. For a register with possible values, call an input value and an output value , both between and . If is the amplitude of input , the QFT produces
Each occupied input contributes to every possible output. For a fixed output , the factor advances the phase by as increases by one. Different values of give different rates of phase advance, the frequencies of the transform. Contributions to the same output add before we square their magnitude to obtain its probability. In our factoring example, , so is a nine-bit integer.
The transform can be built from elementary gates. The circuit below implements the same Fourier formula for three qubits, so . A controlled phase gate multiplies an amplitude by when both its control and target bits are one; it leaves the other amplitudes unchanged.

The wires correspond to binary place values 4, 2, and 1. Read from left to right. A filled dot is a control; the connected crosses exchange the two outer qubits.
Follow input , whose bits are 101. For this input, each control still has a definite bit value when its phase gate acts, so we can track the qubits separately. Each amplitude pair below lists the amplitude for zero first, then for one. The first Hadamard gives the top qubit amplitudes . The middle control is zero, so the first phase gate does nothing. The bottom control is one, so the next gate multiplies the top qubit's amplitude for one by , producing . On the middle wire, its Hadamard and controlled phase produce . The bottom Hadamard produces .
After exchanging the outer qubits, the three amplitude pairs, from top to bottom, are , , and . For an output with bits , select the corresponding amplitude from each pair and multiply them. Writing , the result is
That is the Fourier amplitude for input and output . Other inputs supply different signs and activate different phase gates. Linearity gives the transform of a superposition by adding those contributions. Extending this pattern to nine qubits uses nine Hadamards, 36 controlled phase gates, and four swaps. Its gate settings are fixed by the register size. With H, T, and CNOT as the available logical gates, the controlled phase operations must themselves be built from sequences of those gates, approximating the small angles to the required accuracy.
Now apply that nine-qubit circuit to the input state from step 4. Its nonzero inputs are , for , so the calculation becomes
At , the terms alternate between and . There are 43 of each, so they cancel exactly and . At , the terms go almost once around the complex plane and nearly cancel, giving .
At , the angle between successive terms is , almost a full turn. Successive contributions point in similar directions and reinforce. Their sum has magnitude about , giving
is about 11,000 times as likely as . No gate has recognized a correct answer. Addition and cancellation of complex amplitudes have changed the odds.

Each blue arrow is one term in the sum. Red marks the net contribution from the start to the end, before normalization. Both panels use the same scale. Squaring the normalized length gives the measurement probability.
For an input state with spacing , the phase advances by between successive contributions to output . When is close to an integer , that advance is close to a whole number of turns, so successive contributions reinforce. Solving for gives peaks near . For our example, the peaks are near . A measurement samples one value from this distribution.

For , , and , the upper plot shows the input state after measuring result . The lower plot shows the probabilities after the Fourier transform.
6. Turn a sample into factors. Suppose measurement of the input register gives . The quantum part of this run is finished. The classical processor forms and uses continued fractions to find rational approximations with small denominators. The first division is , so
Continuing Euclid's divisions gives and . Substituting back gives . The integer part is ; truncating the nested fraction at successive levels gives , , and . By the bound from Lagrange's theorem, the order is less than , so only denominators and are candidates. One fails because ; six passes because .
Six is even, so calculate . Eight is neither nor , the residue representing modulo . The factors are
Finally, verify that both factors are greater than one and . The measured integer has led us to the factors and through classical arithmetic.
The choice supplies the precision needed for this reconstruction. For a measurement nearest to a peak at ,
because . At this accuracy, in lowest terms appears among the continued-fraction approximations. Its denominator is when and are relatively prime; otherwise it is a divisor of .
A different sample may require another run. For example, gives . Its denominator suggests , but , so that candidate fails the check. The outcome supplies no period information. Both are prominent peaks in the graph: a large measurement probability does not guarantee enough information to factor . A new sample requires reinitializing the qubits and rerunning the quantum circuit. Measuring the finished register again would give the same value. If a recovered order is odd or gives , we choose another base .
The speedup comes from obtaining period information without enumerating powers until they repeat. For , the Fourier circuit uses gates, and the reversible modular arithmetic also has polynomial cost in the bit length of . Implementing the phase gates accurately on error-corrected hardware adds work. At RSA sizes, the CRQC must carry out this computation with enough logical qubits and sufficiently reliable gates to preserve the interference throughout.
The discrete-logarithm version uses related interference in two dimensions. Let generate a cyclic group of known prime order , so its powers run through all elements. Suppose , and is secret. Take and modulo and consider
Changing by leaves the value unchanged. Prepare a uniform superposition of the pairs and compute into a third register. Use the Fourier sum with on each input register, with output frequencies and .
For any one result value, the input pairs that produce it differ by multiples of . Each pair contributes a Fourier phase to output . Moving by advances that phase by . Across the input pairs, the contributions cancel unless that advance is a whole number of turns. The measured frequencies satisfy
For a nonzero , calculate and check that . The inverse is the number that multiplies to give one modulo ; it exists because is prime. If , take another sample. For an elliptic curve, write and use the function . Changing by again leaves the result unchanged, so the same Fourier argument recovers .
The logical qubits must support reliable gates as well as reliable storage. For factoring, modular exponentiation accounts for much of the work. The Fourier transform is a comparatively small part of the circuit.
The Clifford gates are the operations that can be built from , CNOT, and the phase gate , which advances the relative phase by . Starting with qubits initialized to , Clifford gates and measurements in the zero/one basis alone give circuits that can be simulated efficiently on a classical computer. They do not provide universal quantum computation.
The T and Toffoli gates are non-Clifford operations: they lie outside that restricted family. A common error-correcting scheme, the surface code, uses local checks on a two-dimensional arrangement of qubits. Computation must be fault-tolerant, meaning that errors in individual components, including the correction machinery, are contained rather than allowed to spread into an uncorrectable logical error.
The T gate must act on the encoded logical amplitudes while preserving the protection of the code. Applying physical T gates independently to the qubits of a surface code does not implement a protected logical T.
In surface-code architectures, supplying non-Clifford operations requires additional machinery. One approach consumes specially prepared auxiliary states called magic states. For example, the state used to supply a T gate is
For a logical data qubit with amplitudes , apply a CNOT with the data qubit as control and the magic-state qubit as target, then measure the target. Outcome zero leaves the data with amplitudes , the desired T operation. Outcome one leaves . Applying S changes this to , the same T result up to an unobservable common phase. The auxiliary state has been measured and must be replaced for another T gate.
This construction is called gate injection: consuming an auxiliary state to implement a gate. Feed-forward means using a measurement result to choose a subsequent operation, such as the S correction above. Preparing the resource state supplies what the Clifford operations cannot do alone.
A magic-state factory dedicates physical qubits, gates, and time to producing those states reliably. Distillation protocols consume multiple imperfect resource states to obtain fewer, cleaner ones. Other approaches, including magic-state cultivation, change how the states are prepared and checked. A computation that needs these states must wait if the factory has not produced them.

A factory supplies auxiliary quantum states to the computation. Clifford operations, measurements, and classical feedback use them to enact non-Clifford gates. Encoded states throughout this system still require error correction.
In March 2026, Google's researchers reported two circuit designs for a 256-bit elliptic-curve discrete-logarithm problem:
| Logical qubits | Toffoli gates |
|---|---|
| Fewer than 1,200 | Fewer than 90 million |
| Fewer than 1,450 | Fewer than 70 million |
These are logical resource estimates. Each protected Toffoli operation can require many physical operations and additional auxiliary states. Turning a gate count into a runtime requires the circuit's dependencies, opportunities for parallelism, factory throughput, and classical response times.
Under its superconducting-hardware assumptions, Google's study estimated fewer than 500,000 physical qubits and a runtime of minutes for this elliptic-curve attack.
For RSA-2048, whose public modulus is 2,048 bits long, Craig Gidney's 2025 estimate put the physical requirement below a million noisy qubits, with a runtime below a week, under specified assumptions about gate errors, connectivity, error-correction cycles, and classical control. These numbers change as algorithms, codes, and hardware improve. There is no single qubit count that defines a CRQC independently of its target and operating conditions.
Error correction remains a substantial part of the machine. An uncorrected physical error probability that looks small for one gate is disastrous over a long computation. As a simple illustration, a billion vulnerable operations, each independently failing with probability , would produce about a thousand failures on average. We need a much smaller logical error rate across the whole computation.
An error-correction scheme has an error threshold: under its assumed noise model, this is the physical error level below which adding redundancy improves protection. Surface-code constructions show how to do this, including the additional machinery needed for a universal set of logical gates.
The syndrome measurements keep the classical decoder busy throughout the calculation. It must infer the likely errors and determine the corrections, often tracking them in a classical record rather than immediately applying a physical correction.
Both the bandwidth and the computation can be enormous. If 100,000 error checks each produce one syndrome bit every microsecond, the raw stream is bits per second: 12.5 gigabytes per second. An illustrative larger system with ten million such checks would produce 1.25 terabytes per second, before compression or communications overhead. The measurements continue throughout the calculation, potentially for hours or days.
The decoder must compare check results from neighboring qubits over successive rounds to infer likely error patterns. Under their surface-code and decoder assumptions, Camps and colleagues estimated petaflop-scale classical capacity for decoding in a 1,000-logical-qubit chemistry calculation: roughly floating-point operations per second. Their model converts CPU decoder timings into equivalent floating-point capacity.
Throughput and latency both matter. The classical system must keep pace with incoming measurements, and it must deliver the information needed by later quantum operations. A growing backlog slows the computation. Google's Willow real-time decoding experiment ran error-correction rounds every microseconds, while decoder latency averaged microseconds. Several rounds can be in flight at once; the sustained processing rate must keep up with new rounds.
Reducing the logical-qubit requirement does not eliminate the physical-qubit overhead, the gate count, or the classical decoding workload. A CRQC is an integrated quantum and classical computer.
Conflating artificial intelligence with quantum computing is nonsense. Today's mainstream AI systems are trained and run on classical computers. Shor's algorithm does not depend on a trained model. There are specific research connections, including neural networks for decoding quantum error syndromes. In that work, classical software interprets the quantum processor's error measurements. It does not make the two technologies interchangeable. A sales pitch that simply bundles “AI” and “quantum” together is asking for your money with two buzzwords.
Post-quantum cryptography (PQC) supplies replacements for vulnerable key exchanges and signature schemes, using different mathematical assumptions. It runs on classical computers. NIST's first three finalized standards cover key establishment and digital signatures. Their security relies on mathematical problems that Shor's algorithm does not solve.
For readers interested in the algorithms, I have implemented classical and post-quantum cryptography in pure Rust. The code is available in my cryptography repository.
How soon a system needs to adopt post-quantum cryptography depends partly on how long its information must remain secret. An adversary can retain a vulnerable key exchange and the encrypted traffic associated with it, then attack the exchange when a suitable machine becomes available. NIST calls this harvest now, decrypt later. Upgrading the systems later does not retrieve the copies already recorded.