Simon’s algorithm is a quantum algorithm that finds a hidden bit string s for a function promised to satisfy f(x) = f(y) exactly when y equals x or x XOR s. Among quantum algorithms, it was the first to show an exponential speedup over randomized classical computation in the oracle model: it needs about n queries to the function, while any classical method needs on the order of 2^(n/2) queries.
Proposed by Daniel Simon in 1994, the algorithm is mostly of theoretical importance, yet its structure of Hadamard transforms, an oracle call and classical post-processing directly inspired Shor’s algorithm. It remains a standard teaching case in quantum computing and a working tool in quantum cryptanalysis of symmetric-key constructions.
The problem Simon’s algorithm solves
Simon’s problem is a promise problem about a black-box function that maps n-bit strings to n-bit strings. The function is either one-to-one or exactly two-to-one with a fixed pattern: every pair of inputs that share an output differs by the same secret string s under bitwise XOR. The task is to determine s, or to establish that s is the all-zero string.
Classically, the only useful information comes from finding a collision, two inputs with the same output. By the birthday bound, a randomized search needs roughly 2^(n/2) evaluations before a collision becomes likely, and a matching lower bound proves no classical strategy does fundamentally better. The quantum approach avoids collisions entirely and extracts linear equations about s instead.
The table below compares the query cost of the main approaches for the same problem.
| Approach | Queries needed | Growth |
|---|---|---|
| Deterministic classical | About 2^(n−1) + 1 in the worst case | Exponential |
| Randomized classical | On the order of 2^(n/2) | Exponential |
| Simon’s algorithm | About n plus a small constant | Linear |
How the quantum circuit works
The circuit uses two registers of n qubits each and repeats one short subroutine. Every run yields a random string y that is orthogonal to s, meaning the bitwise dot product y·s equals 0 modulo 2.
- Apply a Hadamard gate to each qubit of the first register to create an equal superposition of all 2^n inputs.
- Call the quantum oracle once, writing f(x) into the second register by XOR.
- Measure the second register, or simply ignore it; the first register collapses to an equal superposition of x and x XOR s.
- Apply Hadamard gates to the first register again; interference cancels every y with y·s = 1.
- Measure the first register to obtain one linear equation over GF(2).
After roughly n − 1 linearly independent equations are collected, Gaussian elimination over the binary field recovers s in O(n^3) classical operations. Because some measured strings repeat or depend on earlier ones, the expected number of runs is slightly above n, and the probability of failure drops exponentially with every extra repetition.
The following table maps each stage to its resource cost.
| Stage | Quantum cost | Classical cost |
|---|---|---|
| State preparation | n Hadamard gates | None |
| Oracle query | One call per run | None |
| Interference step | n Hadamard gates | None |
| Post-processing | None | Gaussian elimination, O(n^3) |
Relation to other quantum algorithms
Simon’s algorithm belongs to the family of hidden subgroup problem algorithms. Its hidden subgroup is {0, s} inside the group of n-bit strings under XOR, and the Hadamard transform plays the role of the Fourier transform over that group. Shor’s algorithm follows the same template over the integers modulo N using the quantum Fourier transform.
The table below places Simon’s algorithm among the early oracle algorithms that preceded large-scale quantum hardware.
| Algorithm | Hidden structure | Speedup type |
|---|---|---|
| Deutsch–Jozsa algorithm | Constant or balanced function | Exponential over deterministic only |
| Bernstein–Vazirani algorithm | Linear function f(x) = a·x | Polynomial, n to 1 queries |
| Simon’s algorithm | XOR period s | Exponential over randomized |
| Shor’s algorithm | Period modulo N | Superpolynomial, no oracle needed |
The key distinction is that Deutsch–Jozsa loses its advantage once classical randomness with small error is allowed, whereas Simon’s separation survives bounded-error classical algorithms. That robustness made it the first convincing evidence that BQP might be larger than BPP relative to an oracle.
Use in quantum cryptanalysis
Simon’s algorithm has a concrete application in breaking symmetric cryptographic constructions when an attacker may query a keyed function in superposition. Many designs hide an XOR-periodic function, and the algorithm exposes the period, which often reveals the secret key or a forgery.
- Three-round Feistel networks can be distinguished from random permutations with a polynomial number of superposition queries.
- The Even–Mansour cipher leaks its whitening key, because a suitable combined function has the key as its period.
- Several message authentication modes, including CBC-MAC variants, allow forgeries under the same model.
- Combined with Grover’s algorithm, the technique accelerates slide and key-recovery attacks on some block ciphers.
These attacks assume the superposition query model, in which the attacker sends quantum states to the victim’s encryption device. Whether that model is realistic is debated, but it has pushed designers to analyze modes against quantum adversaries.
Limitations and common misconceptions
The exponential advantage of Simon’s algorithm is a query-complexity result, not a general claim about solving practical problems faster. Several limitations keep it from being a direct industrial tool.
- The oracle must be built as a reversible circuit, and its cost can dominate the total runtime.
- The promise must hold: if f is not exactly two-to-one with one XOR period, the output may be meaningless.
- Noise breaks orthogonality: a single wrong equation corrupts Gaussian elimination, so results need verification by evaluating f.
- No natural real-world function with this structure is known outside cryptanalytic settings.
In simple terms
Imagine a machine that hides a secret pattern: any two inputs that differ by that pattern give the same output. A classical detective must keep testing inputs until two outputs match, and with long inputs that takes an enormous number of tries.
A quantum computer can test all inputs at once in superposition and then let the results interfere. Each run does not reveal the secret directly, but it gives one clue about the pattern. After about as many runs as the input has bits, the clues together pin down the secret exactly.
A practical example
A university course on quantum computing asks students to run Simon’s algorithm for n = 3 with the secret s = 110 on a cloud superconducting processor. The circuit needs six qubits, six Hadamard gates and an oracle built from a few CNOT gates that copy bits and fold them together.
Each run of 1,000 shots produces mostly the strings 000, 001, 110 and 111, which all satisfy y·s = 0 modulo 2. Noise adds a few percent of forbidden strings, so the students keep only the outcomes whose frequencies stand clearly above the noise floor.
Solving the equations from 001 and 110 with Gaussian elimination gives s = 110, and evaluating the oracle classically on 000 and 110 confirms the collision. The exercise shows both the algorithm’s core idea and why noise filtering and verification are necessary on current hardware.