Topic

Classical cryptography and the quantum threat

How RSA, Diffie–Hellman and elliptic curves work, why Shor’s algorithm breaks them, what Grover does to symmetric ciphers, and why the threat is real today.

What cryptography must do

Cryptography gives confidentiality, integrity, authentication and non-repudiation. There are three practical families:

FamilyExamplesSecurity rests onQuantum impact
Symmetric ciphers and MACsAES, ChaCha20, HMACShared secret key; no shortcut better than searchGrover: quadratic speed-up; double key length (AES-256)
Hash functionsSHA-2, SHA-3Preimage and collision resistanceGrover on preimages; collisions need about $2^{n/3}$ quantum work
Public-key encryption and signaturesRSA, Diffie–Hellman, ECDH, ECDSAFactoring, discrete logarithm, elliptic-curve discrete logarithmShor: polynomial time. Broken.

Shannon’s one-time pad is the only classically proven information-theoretically secure cipher, but needs a random key as long as the message and used once. The key distribution problem (how to share that key) is what public-key cryptography solved computationally, and what QKD solves physically.

RSA with small numbers

RSA picks primes $p,q$, sets $n=pq$ and $\varphi(n)=(p-1)(q-1)$, picks $e$ with $\gcd(e,\varphi)=1$ and $d\equiv e^{-1}\pmod{\varphi}$. Public key $(e,n)$; private key $(d,n)$. Encrypt $c=m^e\bmod n$, decrypt $m=c^d\bmod n$.

Toy example (insecure on purpose)$p=3,\ q=11\Rightarrow n=33,\ \varphi=20$. Choose $e=3$; then $3d\equiv1\pmod{20}$ gives $d=7$. Encrypt $m=4$: $c=4^3\bmod33=64\bmod33=31$. Decrypt: $31^7\bmod33=4$. ✓

Real RSA uses 2048–4096-bit moduli. Security assumes recovering $p,q$ from $n$ is infeasible. Key generation needs large primes, found with probabilistic primality tests such as Miller–Rabin (below).

Discrete logarithms and Diffie–Hellman

In the multiplicative group $\mathbb Z_p^*$ with generator $g$, the forward map $x\mapsto g^x\bmod p$ is easy (square-and-multiply) but the inverse, the discrete logarithm, is believed hard classically. Toy example: modulo 17 with $g=3$, $3^4=81\equiv13$, so $\log_3 13=4$.

Diffie–Hellman: Alice sends $g^a$, Bob sends $g^b$, both compute $g^{ab}$. Elliptic-curve versions (ECDH, ECDSA) rely on the elliptic-curve discrete logarithm. Best classical attacks are sub-exponential for $\mathbb Z_p^*$ (number-field sieve) and fully exponential ($\sim\sqrt{\text{group size}}$) for generic or elliptic-curve groups. Both problems fall into the hidden subgroup problem family that Shor’s algorithm solves.

Primality testing and Miller–Rabin

Primality testing (is $n$ prime?) is far easier than factoring (find the factors). For odd $n$, write $n-1=2^s d$ with $d$ odd. For a base $a$, $n$ is a strong probable prime if

$$a^{d}\equiv1\pmod n\quad\text{or}\quad a^{2^rd}\equiv-1\pmod n\ \text{for some }0\le r<s$$

This works because modulo a prime the only square roots of 1 are $\pm1$. If $n$ is composite, at most $\tfrac14$ of the bases are “strong liars”, so $k$ random bases give error probability at most $4^{-k}$, and the error is one-sided (“composite” answers are always correct). Cost is $O(k\log^3n)$. Example: $n=341=11\cdot31$ passes the plain Fermat test to base 2, but with $340=4\cdot85$ we get $2^{85}\equiv32$ and $32^2\equiv1\pmod{341}$, a non-trivial square root of 1, so 341 is exposed as composite. The deterministic AKS test (2002) proves polynomial-time primality but is slower in practice.

Miller–Rabin vs ShorMiller–Rabin generates the primes used in RSA keys; it does not factor. Turning it into a quantum oracle gives no useful speed-up for attacking RSA because it is already fast classically. Shor’s algorithm is what finds $p$ and $q$.

Shor’s algorithm

Shor (1994) factors $N$ in polynomial time, roughly $O((\log N)^3)$ gate operations, by reducing factoring to order finding:

  1. Pick random $a$ coprime to $N$.
  2. Quantum phase estimation with the QFT finds the period $r$ of $f(x)=a^x\bmod N$.
  3. If $r$ is even and $a^{r/2}\not\equiv-1$, then $\gcd(a^{r/2}\pm1,N)$ yields non-trivial factors with good probability.

The same period-finding idea solves discrete logarithms in any finite abelian group, including elliptic-curve groups. Hence RSA, DH, ECDH, ECDSA and EdDSA all fall.

Resources. Early estimates needed ~20 million noisy qubits for RSA-2048; a 2025 analysis by Gidney reports under one million noisy qubits and about a week. Today’s machines are far from this scale, but estimates keep falling.

Grover and symmetric cryptography

Grover search finds a marked item among $N$ in $O(\sqrt N)$ queries (provably optimal). Against a $k$-bit key this costs about $2^{k/2}$ operations, but Grover parallelises poorly and has large overheads, so AES-256 is widely considered quantum-safe and AES-128 acceptable for now. Quantum computers do not break one-time pads or information-theoretic MACs.

Harvest now, decrypt later

An adversary can record encrypted traffic today and decrypt it once a quantum computer exists. Mosca’s inequality: if data must stay secret for $x$ years, migration takes $y$ years, and a cryptographically relevant quantum computer arrives in $z$ years, you are at risk when $x+y>z$. This is why key exchange is migrated first and why QKD and post-quantum cryptography are both being deployed before large quantum computers exist.

Ways forwardThree responses exist: (1) post-quantum cryptography: new math, runs on classical hardware; (2) QKD: physics-based key exchange, needs special hardware; (3) hybrids. See Post-quantum cryptography.

Search

Press / to open search. Esc to close.

◈ QuantumVerse Hub