The input size of an integer factorization problem is its number of bits . Trial division up to is exponential in ; advanced classical algorithms do substantially better, but no general polynomial-time classical factoring algorithm is known. The heuristic general-purpose general number field sieve has subexponential rather than polynomial scaling, roughly . This describes known algorithmic performance, not a proof that efficient classical factoring is impossible or that every large integer is difficult.
Choose with . A nontrivial greatest common divisor already supplies a factor; otherwise find the multiplicative order of modulo . If is even and , then
Minimality of the order also excludes , so factor extraction from an even modular order gives nontrivial factors through . Unhelpful choices of or odd orders require another trial. For , has successive residues and order four, giving
Computing the powers is easy by repeated squaring; discovering a large order is the step accelerated by Shor's algorithm.[ref]
Put and suppose . For each residue class , let
These are normalized uniform superpositions of the arguments with the same modular-exponentiation value. Their amplitudes repeat at separation within the finite register window. Exact cyclic periodicity requires . The correctly normalized entangled register state is
The equal prefactor in the displayed algorithm is exact when , for then every . It is not generally exact for an arbitrary unknown order. A physical implementation uses quantum modular exponentiation as a reversible map; its specified action on second-register input zero is extended to a unitary operator on the whole register space.
For the illustrative , and , the four first-register states are
Applying the positive-sign quantum Fourier transform to the general state gives
The bracket is a finite geometric Fourier amplitude. If , it vanishes unless for , when it equals . Hence
The second-register states are orthogonal, so their different phases do not change the marginal first-register probabilities. Measurement gives
In the example the possible outcomes are . A nonzero observed ratio estimates , not a prime factor directly. Reducing it gives denominator ; repeating avoids uninformative outcomes or recovers missing order factors. For example, or gives denominator four, whereas alone gives only two.
When , the Fourier probabilities have narrow peaks near instead of support only on an exact reciprocal grid. The general marginal distribution is
Choosing supplies the usual precision for continued-fraction recovery in quantum order finding: a nearest grid sample differs from the target rational by at most . Candidate denominators and extracted divisors are checked classically, and repetitions provide useful samples. The small example works exactly because its order divides the register size; it is not a general precision guarantee for factoring every four-bit integer.
Figure 1.
Exact reciprocal-period sampling for order four and broadened peaks when the order does not divide the register
. Details.
A sufficiently large reliable quantum computer would undermine RSA by efficient factorization. The related discrete-logarithm algorithm also threatens Diffie-Hellman key exchange and elliptic-curve public-key schemes. This does not imply that every communication scheme or symmetric cipher is broken by the same algorithm; post-quantum cryptography studies alternatives based on other problems. The mathematical speedup assumes a scalable quantum computation with enough precision and error control, not merely a small demonstration of factoring fifteen.
Put and , with nonnegative integer so the register exists. The geometric sum satisfies
Consequently the matrix with entries has . This proves unitarity and
For a binary output string , expansion of the printed tensor product gives coefficient
Thus the printed product is exactly . It is a correct product decomposition of a Fourier phase state, but the printed recovery identity has inconsistent signs:
by the square of the quantum Fourier transform. To recover instead, use , replacing every product phase by its complex conjugate. Equivalently one may reverse the sign in the definition of . The discrepancy is visible for by taking concentrated at : the printed expression returns the basis vector at . The recovery display also uses as the summation variable on its right while its summand uses ; that dummy variable should be .
For factorization first check . Successive residues are
The first return is . Its half power is , which is neither nor modulo . Therefore
In Shor's algorithm prepare a uniform exponent register of size , conveniently , and reversibly compute into a second register. Measuring that second register, or tracing it out, leaves periodic exponent correlations of period . Conditional on one measured residue, the first register is a superposition over an arithmetic progression of exponents separated by . The quantum Fourier transform converts this periodic structure into peaks near . Continued fractions recover ; when is coprime to , its denominator is . Verify by modular exponentiation and repeat when the reduced denominator is insufficient. For this example is suitable, and useful peaks include those near and . Either transform sign gives the same period information, so the source's inverse-sign error does not invalidate the order-finding mechanism.
Put and , with nonnegative integer so the register exists. The geometric sum satisfies
Consequently the matrix with entries has . This proves unitarity and
For a binary output string , expansion of the printed tensor product gives coefficient
Thus the printed product is exactly . It is a correct product decomposition of a Fourier phase state, but the printed recovery identity has inconsistent signs:
by the square of the quantum Fourier transform. To recover instead, use , replacing every product phase by its complex conjugate. Equivalently one may reverse the sign in the definition of . The discrepancy is visible for by taking concentrated at : the printed expression returns the basis vector at . The recovery display also uses as the summation variable on its right while its summand uses ; that dummy variable should be .
For factorization first check . Successive residues are
The first return is . Its half power is , which is neither nor modulo . Therefore
In Shor's algorithm prepare a uniform exponent register of size , conveniently , and reversibly compute into a second register. Measuring that second register, or tracing it out, leaves periodic exponent correlations of period . Conditional on one measured residue, the first register is a superposition over an arithmetic progression of exponents separated by . The quantum Fourier transform converts this periodic structure into peaks near . Continued fractions recover ; when is coprime to , its denominator is . Verify by modular exponentiation and repeat when the reduced denominator is insufficient. For this example is suitable, and useful peaks include those near and . Either transform sign gives the same period information, so the source's inverse-sign error does not invalidate the order-finding mechanism.
The Part C inverse-transform display also prints as its summation index while the summand uses ; that sum must be over , as in the corrected inverse above.
Post-quantum cryptography 2026-10-20
Cryptography intended to remain secure against adversaries with quantum computers. It includes classical algorithms based on problems other than the integer factorization and discrete logarithm problems efficiently treated by Shor's algorithm. A candidate's security still depends on its precise construction, parameters and known attacks; the label alone is not a proof. It is distinct from requiring quantum hardware for quantum key distribution.