Skip to content
QuantDash

Quantum cryptography simulator

QBreak

Factor a small number two ways: by classical trial division, and with a simulation of Shor's period-finding algorithm. Everything runs in your browser, and every log line comes from the code as it executes.

Demonstration modulus

N = 221

8 bits. Generated as the product of two random primes, which the algorithms must rediscover.

Generate

Algorithm
Execution log0 events, elapsed ms

No run yet. Every line that appears here is emitted by the simulation code as it executes.

Execution progress

  1. Trial division
  2. Choose base a
  3. Modular exponentiation
  4. Measure work register
  5. Fourier transform
  6. Measure counting register
  7. Continued fractions
  8. Compute factors

Order-finding circuit

countingt = 16 qubitsworkn = 8 qubits|0⟩|1⟩Haˣ mod NQFTysuperposeevaluated directly65,536 amplitudessampled

The Hadamard layer, both measurements and the Fourier transform act on a simulated state vector. The modular exponentiation block is computed as ordinary arithmetic.

Why a period reveals the factors

Pick a number a that shares no factor with N. The sequence a⁰, a¹, a², … taken modulo N repeats with some period r, so aʳ ≡ 1 (mod N).

If r is even, aʳ − 1 = (a^(r/2) − 1)(a^(r/2) + 1) is a multiple of N. Unless a^(r/2) ≡ −1, each bracket shares a non-trivial factor with N, and a greatest common divisor extracts it. Finding r is the hard part classically, and it is the part a quantum computer does efficiently.

What this page simulates, and what it does not

QBreak holds the full state vector of the counting register in memory, 2^(2n) complex amplitudes for an n-bit N. It simulates the measurement of the work register, applies a real Fourier transform to those amplitudes, and samples a measurement outcome from the resulting probabilities. Continued fractions and the final gcd steps are the same classical post-processing a real run would use.

The modular exponentiation is computed directly as a^x mod N instead of as a circuit of quantum gates. No noise, gate errors or error correction are modelled.

Simulation versus quantum hardware

A simulator stores every amplitude explicitly, so its memory doubles with each added qubit. That is why this page stops at 10-bit numbers. A quantum computer would hold the same state in 2n counting qubits plus a work register, without writing the amplitudes down.

Real hardware faces the opposite problem: qubits are noisy, and long computations need error correction that spends many physical qubits on each reliable logical qubit. Published estimates for factoring a 2048-bit RSA number have fallen from about 20 million noisy qubits (Gidney and Ekerå, 2019) to under one million (Gidney, 2025). Machines of that size and quality have not been built.

How this relates to cryptocurrency

Bitcoin, Ethereum and Solana do not use RSA. Their signatures rely on the elliptic-curve discrete logarithm problem, which a variant of Shor's algorithm also solves by period finding. Factoring is shown here because it is the clearest way to see the method.

QBreak works only on small teaching values generated on this page. It does not target wallets, and nothing here can recover a real private key.