Skip to content
Tech Interview Prep
Technical interview guide

Quantum Algorithms II: Shor's Algorithm & Cryptographic Implications

How Shor's algorithm factors integers exponentially faster than any known classical method, and why that breaks RSA/ECC and drives the shift to post-quantum cryptography.

Minutes to read
3
Practice MCQs
25
Interview Q&A
25
Edition
v3
Editorial status
Reviewed

Scope: IBM Quantum current Shor/QPE documentation; Shor primary paper; NIST FIPS 203/204/205, IR 8547 draft, SP 800-57, and crypto-agility guidance reviewed 2026-09-04.

Interview Q&A

Treat each question like a live interview question: answer out loud first (structure, assumptions, tradeoffs), then open the model answer to spot gaps and rehearse a tighter follow-up.

Curated: · Written: · Reviewed:

25 questions

Q&A-1

How does Shor's algorithm reduce integer factorization to order finding, and what are the exact classical and quantum steps involved?

Answer

The 90-second version. Shor's algorithm never factors $N$ directly. It reduces factoring to order finding (given $a$ coprime to $N$, find the least $r > 0$ with $a^r \equiv 1 \pmod N$) and order finding is the only step that needs a quantum computer. The reduction: if $r$ is even and $a^{r/2} \not\equiv -1 \pmod N$, then $N$ divides $(a^{r/2}-1)(a^{r/2}+1)$ without dividing either factor, so $\gcd(a^{r/2}\pm 1, N)$ splits $N$. For random $a$ and $N$ with $k \ge 2$ distinct odd prime factors, the probability that $r$ is even and $a^{r/2} \not\equiv -1$ is at least $1 - 1/2^{k-1}$, so a couple of retries suffice. Everything except the order-finding subroutine is classical and cheap.

Classical steps.

  1. Reject even $N$, perfect powers $N = p^m$, and primes: Miller–Rabin plus integer $k$-th roots for $k \le \log_2 N$.
  2. Draw random $a \in [2, N-1]$; compute $\gcd(a, N)$. If $> 1$, you already have a factor; stop.
  3. After the quantum measurement returns $s$, run the continued-fraction expansion of $s/2^t$ and take convergents $p/q$ with $q < N$. Test $a^q \equiv 1 \pmod N$; the smallest such $q$ is $r$.
  4. If $r$ is odd or $a^{r/2} \equiv -1 \pmod N$, discard $a$ and go to 2.
  5. Otherwise output $\gcd(a^{r/2}-1, N)$ and $\gcd(a^{r/2}+1, N)$.

Quantum steps. Two registers: $t = 2n$ qubits ($n = \lceil \log_2 N \rceil$) in the first, $n$ qubits in the second, initialized $|0\ldots0\rangle|1\rangle$.

  • Hadamard the first register: $\frac{1}{\sqrt{2^t}} \sum_{x=0}^{2^t-1} |x\rangle|1\rangle$.
  • Controlled modular exponentiation: $|x\rangle|y\rangle \to |x\rangle|y \cdot a^x \bmod N\rangle$. This is the expensive part: $O(n)$ controlled modular multiplications, each $O(n^2)$ gates with schoolbook arithmetic, $O(n^2 \log n \log\log n)$ with fast multiplication.
  • Inverse QFT on the first register, then measure it. The outcome $s$ concentrates near $2^t k/r$ for integers $k$ coprime to $r$, with $|s/2^t - k/r| \le 1/2^{t+1} < 1/(2r^2)$: exactly Legendre's condition for $k/r$ to be a convergent of $s/2^t$.

Worked trace, $N = 15$, $a = 7$. $n = 4$, $t = 8$, $2^t = 256$. Order of 7 mod 15: $7, 4, 13, 1$, so $r = 4$. Phase estimation peaks at $s \approx 256k/4$ for $k \in {1,3}$, i.e. $s = 64$ or $192$. Continued fractions on $64/256 = 1/4$ gives $q = 4$; check $7^4 = 2401 \equiv 1 \pmod{15}$. $r$ is even and $7^2 = 49 \equiv 4 \not\equiv -1$. $\gcd(4-1, 15) = 3$, $\gcd(4+1, 15) = 5$. Factors 3 and 5.

Where you vary the design.

  • Semi-classical QFT (Griffiths–Niu, PRL 76, 3228, 1996). Replace the $t$-qubit inverse QFT with one ancilla qubit, measured and recycled, with the controlled-phase rotations applied classically. RSA-2048 drops from ~6145 logical qubits ($t = 2n+1 = 4097$ plus $n = 2048$) to ~2049. The cost is depth: modular exponentiation is repeated once per bit of the first register, and you need real-time mid-circuit measurement and classical feed-forward, which not every device supports.
  • Full QFT. Keeps the exponentiation parallel and needs no feed-forward, at the price of the extra $t-1$ qubits.
  • Regev's 2023 factoring algorithm (arXiv:2308.06572) is a different reduction with a different gate/qubit trade-off; it is not a drop-in replacement for the circuit above.
  • When classical wins. If $N$ has a small factor, Pollard rho or ECM finds it in negligible time; Shor's deep, $2n+1$-qubit circuit only pays off for balanced semiprimes. And Shor is one instance of the abelian hidden-subgroup framework: the same phase-estimation circuit solves discrete log, so the real design question is "is my problem order finding in a group where I can implement controlled multiplication?"

Failure modes and detection. All three: $r$ odd, $a^{r/2} \equiv -1$, or a measured $s$ whose convergents never satisfy $a^q \equiv 1$: are detected classically in $O(n^2)$ bit operations and cost one retry with a fresh $a$. Expected retries $\le 2$.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-3

How do Quantum Phase Estimation and the Quantum Fourier Transform work together to find the order r in Shor's algorithm?

Answer

Core answer (first 90 seconds). Assume $N$ odd composite, $\gcd(a,N)=1$, $L=\lceil\log_2 N\rceil$. QPE never computes $r$; it measures the eigenphase of the modular multiplication operator $U_a|y\rangle = |ay \bmod N\rangle$. The eigenvalues of $U_a$ are $e^{2\pi i s/r}$ for $0 \le s < r$, so the phase is $s/r$: the order sits in the denominator. The inverse QFT is the readout: it converts the phase-encoded counting register into a computational-basis integer $y \approx 2^m s/r$, and continued fractions on $y/2^m$ recover $r$. The QFT is not finding the period; it is the change of basis that makes the period measurable.

Eigenstates and the $|1\rangle$ trick. With $r$ unknown you cannot prepare an eigenstate, but

$$|u_s\rangle = \frac{1}{\sqrt r}\sum_{k=0}^{r-1} e^{-2\pi i sk/r}|a^k \bmod N\rangle,\qquad U_a|u_s\rangle = e^{2\pi i s/r}|u_s\rangle,\qquad \frac{1}{\sqrt r}\sum_{s=0}^{r-1}|u_s\rangle = |1\rangle .$$

So initializing the target register to $|1\rangle$ prepares a uniform superposition over all eigenphases at once. One run samples a random $s$, not a fixed one: that is why you repeat.

Circuit. $m$-qubit counting register at $|0\rangle^{\otimes m}$, target at $|1\rangle$:

  1. Hadamards give $\frac{1}{\sqrt{2^m}}\sum_{x=0}^{2^m-1}|x\rangle$.
  2. Controlled-$U_a^{2^j}$ on counting qubit $j$ kicks back phase: $|x\rangle|u_s\rangle \mapsto e^{2\pi i x s/r}|x\rangle|u_s\rangle$. Each block is one modular multiplication by the classically precomputed $a^{2^j} \bmod N$.
  3. $\mathrm{QFT}^\dagger|x\rangle = \frac{1}{\sqrt{2^m}}\sum_{y=0}^{2^m-1} e^{-2\pi i xy/2^m}|y\rangle$ makes the amplitudes interfere constructively at $y \approx 2^m s/r$.
Register / blockRoleSizeFailure mode
Targetuniform superposition of eigenstates ($= \lvert 1\rangle$)$L$ qubitsinitialized to $\lvert 0\rangle$: fixed point of $U_a$, every run returns $y=0$
Countingholds phase $s/r$$m = 2L+1$$m$ too small: convergent is a divisor of $r$ or wrong
Controlled-$U_a^{2^j}$modular exponentiation$m$ blocks, $O(L^3)$ gatesdephasing here flattens the output distribution
$\mathrm{QFT}^\dagger$phase → basis$O(m^2)$ gatescoherent rotation errors misalign the readout basis

Trade-offs. Three ways to get the same phase; the deciding criterion is which resource you are short of.

  • Coherent QPE (above): $m$ ancillas, one $m$-qubit inverse QFT, all controlled-$U_a^{2^j}$ applied before any measurement. Pick it when ancillas are cheap and you want the phase in one shot.
  • Semi-classical / iterative QPE (Griffiths–Niu 1996; Kitaev): one ancilla, measured after each controlled-$U_a^{2^j}$, with the classical result fed forward as a rotation on the next qubit. Same number of controlled-$U_a^{2^j}$ applications, but the $O(m^2)$ QFT collapses to $O(m)$ single-qubit rotations. Cost: feed-forward latency, and each feedback rotation must be accurate to better than $2^{-(j+1)}$ or that bit flips.
  • Classical order finding: for $N$ up to a few tens of digits, Pollard rho or ECM on one core beats any quantum run.

The deciding fact is that the QFT is not the bottleneck: modular exponentiation dominates. Beauregard's QFT-adder construction fits it in $2L+3$ qubits with $O(L^3)$ gates, against $O(m^2)$ for the QFT, so semi-classical QPE buys ancillas, not depth. Gidney–Ekerå (2019/2021) put 2048-bit RSA at ~20 million physical qubits and 8 hours, which is the honest scale of "worth it".

Note also that the period-finding circuit: prepare $\sum_x|x\rangle|a^x \bmod N\rangle$, measure the target, QFT the first register: is the same unitary as QPE with $|1\rangle$ input; measuring the target first just projects onto a coset. The QPE framing is what supplies the eigenphase error bound.

Classical extraction. Measure → $y$. Continued fractions on $y/2^m$ → convergent $s'/r'$. With $m = 2L+1$, $|y/2^m - s/r| \le 2^{-(m+1)} \le 1/(2r^2)$, so Legendre's criterion makes $s/r$ a convergent, and $r < N \le 2^L$ makes it unique. If $\gcd(s,r)=g>1$ you get $r' = r/g$; repeat and take the lcm.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-8

Design and validate a Shor or post-quantum migration workflow for inverse QFT.

Answer

Two workflows are hiding in that question and they share no step. The inverse QFT is a component of Shor's algorithm; post-quantum migration is a classical-crypto program. I'll design and validate the IQFT workflow, then say where the PQC one lives.

Assumptions: an n-qubit phase register with n ≈ 2L for an L-bit modulus (n = 4096 for RSA-2048), a compiler that reports logical gates, and an error budget of 2^-10 on the phase estimate.

1. Pin the bit ordering before anything else. The QFT maps |j⟩ → (1/√N) Σ_k e^{2πijk/N}|k⟩. The textbook circuit (H on qubit 0, controlled-R₂ from qubit 1, …, H on the last qubit, then swaps) computes that map. Drop the swaps and the output qubits come out reversed; in Shor that is free, because you read the measured bits in reverse order. Validate it as a matrix identity, not by inspection:

Python
import numpy as np

def qft_matrix(n):
    N = 1 << n
    j, k = np.meshgrid(np.arange(N), np.arange(N), indexing='ij')
    return np.exp(2j*np.pi*j*k/N) / np.sqrt(N)

def bitrev(x, n):
    return int(format(x, f'0{n}b')[::-1], 2)

def swap_free_qft(n):
    """Textbook QFT circuit with the final swaps omitted, as a matrix."""
    N, H = 1 << n, np.array([[1, 1], [1, -1]]) / np.sqrt(2)
    def run(col):
        s = col.astype(complex).copy()
        for q in range(n):
            s = s.reshape([2]*n)
            s = np.moveaxis(np.tensordot(H, s, axes=([1], [q])), 0, q).reshape(-1)
            for k in range(2, n - q + 1):          # controlled-R_k, control q
                t = q + k - 1
                s = s.reshape([2]*n)
                idx = [slice(None)]*n; idx[q] = 1; idx[t] = 1
                s[tuple(idx)] *= np.exp(2j*np.pi/2**k)
                s = s.reshape(-1)
        return s
    return np.column_stack([run(np.eye(N, dtype=complex)[:, j]) for j in range(N)])

n = 3
F, C = qft_matrix(n), swap_free_qft(n)
P = np.zeros((1 << n, 1 << n))
for x in range(1 << n):
    P[bitrev(x, n), x] = 1
print(np.allclose(C, F @ P), np.allclose(C, F))   # True False

True False: the swap-free circuit equals the QFT followed by the bit-reversal permutation, and is not equal to the QFT itself. That is the check that catches a reversed convention.

Worked trace, n = 2, input |10⟩ (j = 2). H on q0 → (|00⟩ − |10⟩)/√2. CR₂ (control q0, target q1) leaves it alone: there is no |11⟩ amplitude to phase. H on q1 → (|00⟩ + |01⟩ − |10⟩ − |11⟩)/2. The exact QFT of |j=2⟩ is (1/2)(|00⟩ − |01⟩ + |10⟩ − |11⟩); the two differ exactly by swapping the two qubits, which is the readout reversal.

2. Choose the approximation cutoff m. Coppersmith's AQFT drops rotations below angle 2π/2^m; the error is bounded by roughly n/2^m. For n = 4096 and a 2^-10 budget, m = log₂n + 10 = 22. That is the number to defend, not "approximate rotations".

3. Count gates both ways.

nexact CR gatesmAQFT CR gatesratio
8288 (no cutoff)281.0×
16120141171.03×
642,016168402.4×
1,024523,7762019,26627×
4,0968,386,5602285,78598×

Exact QFT is n(n−1)/2 controlled rotations plus n Hadamards and n/2 swaps. AQFT at m = log₂n + 10 is about n·m rotations. Depth stays O(n) in the standard layout because the Hadamard chain serializes; AQFT buys gates, not depth.

4. Report logical depth and arithmetic cost separately. The QFT is O(n²) gates; modular exponentiation is O(n³) with schoolbook arithmetic. For RSA-2048 the QFT is a rounding error next to the ~10⁹–10¹⁰ Toffoli gates of the modular exponentiation (Gidney & Ekerå, Quantum 5, 433, 2021, put the whole thing at 20M physical qubits in 8 hours). If your resource estimate is dominated by the QFT, you have mis-scoped the arithmetic.

5. Validate against a known eigenphase. Prepare an eigenstate of the modular-multiply unitary, run QPE, and check the recovered phase against the classically computed one. This is the only test that catches a correct-looking QFT wired to the wrong register.

Trade-offs. Full-precision IQFT is worth it only when n is small (n ≲ 20, where m ≈ n anyway) or when the phase must be exact for a verification step. Above that, AQFT with m = log₂n + c is strictly better; the error is a controlled, budgeted quantity.

Failure modes and detection.

  • Swaps omitted but readout not reversed → phase estimates come out bit-reversed; detect with the matrix identity above.
  • Cutoff too aggressive (m < log₂n) → error bound exceeds budget; detect by comparing AQFT against exact on a random state for small n.
  • QFT advertised as full Shor → the estimate omits modular exponentiation; detect by checking the gate count against O(n³).
  • Arithmetic treated as free → detect by requiring the Toffoli count to appear in the same table as the QFT count.

Where PQC fits. The migration workflow is classical: inventory, hybrid key exchange (X25519MLKEM768 in TLS), and the NIST standards FIPS 203/204/205, finalized August 2024. The IQFT estimate is what sets the deadline, not a step in it.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-7

Design and validate a Shor or post-quantum migration workflow for phase estimation.

Answer

Assumptions first. Phase estimation (QPE) is the subroutine; the workflow is the pipeline that turns a unitary into a recovered phase, plus the classical post-processing and the validation gates around it. Post-quantum migration, moving off RSA/ECC to ML-KEM/ML-DSA, is a separate track that contains no phase estimation, so I cover it in one paragraph at the end because the question names it.

The workflow, in the order a candidate should say it.

  1. Fix the target: n bits of phase accuracy, total failure probability ≤ ε.
  2. Size the register. For order finding on N with L = ⌈log2 N⌉, use t = 2L + 1 + ⌈log2(2 + 1/(2ε))⌉ ancillas.
  3. Build the circuit: H on all t, controlled-U^(2^j) for j = 0…t−1, inverse QFT including the final swaps, measure y.
  4. Post-process exactly: continued fractions on Fraction(y, 2**t), take the convergent p/q with q < N and q² ≤ 2^t, then check a^q ≡ 1 mod N.
  5. Validate and retry: known-eigenphase unit tests, end-to-end factorisation, and a retry budget rather than an alarm.

Why it works. QPE on an eigenstate |u⟩ with U|u⟩ = e^(2πiφ)|u⟩ returns the nearest y with |φ − y/2^t| ≤ 1/2^t with probability ≥ 4/π² ≈ 0.405; the extra ⌈log2(2 + 1/(2ε))⌉ qubits push that to ≥ 1−ε. Continued fractions recovers s/r from y/2^t because any p/q with |x − p/q| < 1/(2q²) is a convergent of x (Legendre). Since |s/r − y/2^t| ≤ 1/2^(t+1) and r < 2^L, t = 2L+1 makes 1/2^(t+1) ≤ 1/(2r²).

Worked trace. N = 15, a = 7, L = 4, t = 9. The order is r = 4: 7, 49 ≡ 4, 343 ≡ 13, 2401 ≡ 1 mod 15. The input |1⟩ = (|u₀⟩+|u₁⟩+|u₂⟩+|u₃⟩)/2, so the measured s is uniform in {0,1,2,3}. Take s = 1: φ = 1/4, y = 0.25 × 512 = 128. Fraction(128, 512) = 1/4, convergent 1/4, q = 4, and 7⁴ ≡ 1 mod 15 ✓. Then gcd(7² − 1, 15) = gcd(48, 15) = 3 and gcd(7² + 1, 15) = gcd(50, 15) = 5. Factors 3 and 5.

Failure modes and how each is caught.

failurewhat it looks likedetection
missing final swaps (bit reversal)y read reversed: 128 → 2, so r = 256 and gcd(7¹²⁸ − 1, 15) = 15, a trivial factorknown-eigenphase test: φ = 1/4, t = 9 must give y = 128
controlled-U instead of controlled-U^(2^j)phase off by a power of twosame unit test
float post-processingt = 54, y = 2⁵⁴ − 1 rounds to 1.0 in float64 (round-half-to-even), continued fraction 1/1, r = 1assert the Fraction path; reject float for t > 53
one failed sample treated as failurer odd, or a^(r/2) ≡ −1, or gcd(s, r) ≠ 1retry budget; log retry count, expect O(log log N)
eigenstate assumptiongeneric QPE on a superposition returns a random eigenphasein Shor,

Trade-offs. t ancillas vs. iterative (Kitaev) QPE: one ancilla, t repetitions, needs mid-circuit measurement and feed-forward. Fewer qubits, longer wall clock. Continued fractions vs. brute-force r search: O(L) vs. O(N). More t buys success probability and a larger recoverable r at the cost of depth: controlled-U^(2^j) up to 2^(t−1) modular multiplications, O(L³) gates naively, O(L² log L) with fast multiplication.

Post-quantum migration. If the real ask is migrating off RSA/ECC, phase estimation is not in the workflow. The deliverable is a crypto inventory, hybrid key exchange (X25519MLKEM768 in TLS 1.3), and ML-KEM/ML-DSA (FIPS 203/204) deployment; NIST IR 8547 (draft) proposes deprecating RSA/ECC by 2030 and disallowing by 2035. Shor's role there is the threat model, not a subroutine you run.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-5

How do continued fractions extract the candidate period r from the phase estimation measurement, and under what conditions does this classical post-processing step fail?

Answer

Quantum phase estimation outputs an integer measurement $y \in {0, \dots, 2^m - 1}$ from an $m$-bit register, estimating an eigenphase $\theta \approx s/r$ for an unknown integer $0 \le s < r$, where $r$ is the multiplicative order of $a \pmod N$. To guarantee that $s/r$ is uniquely identifiable, the phase register uses $m = 2n + 1$ qubits (where $n = \lceil \log_2 N \rceil$, ensuring $2^m \ge 2N^2$).

The Continued Fraction Mechanism

By Dirichlet's approximation theorem, if a rational $p/q$ satisfies: $$\left| \frac{y}{2^m} - \frac{p}{q} \right| \le \frac{1}{2 q^2}$$ with $q < N < 2^{m/2}$, then $p/q$ is guaranteed to be one of the principal convergents $p_k / q_k$ of the continued fraction expansion of $y / 2^m$.

The algorithm computes the continued fraction expansion $[a_0; a_1, a_2, \dots]$ of $y / 2^m$ by standard Euclidean recurrence: $$p_{-1} = 1, \quad p_0 = a_0, \quad p_k = a_k p_{k-1} + p_{k-2}$$ $$q_{-1} = 0, \quad q_0 = 1, \quad q_k = a_k q_{k-1} + q_{k-2}$$ We terminate at the largest convergent index $k$ such that denominator $q_k < N$. The candidate order is tested against $a^{q_k} \equiv 1 \pmod N$.

Worked Trace: Factoring $N = 15, a = 7$

Here $n = 4$, so $m = 2(4) + 1 = 9$ bits ($2^9 = 512$). Suppose phase estimation samples $y = 384$, corresponding to phase $\tilde{\theta} = 384 / 512 = 3/4 = 0.75$.

  1. $384 / 512 = 0 + 1 / (512 / 384) = 0 + 1 / (1 + 128 / 384) = [0; 1, 3]$
  2. Convergents:
    • $k=0: a_0 = 0 \implies p_0/q_0 = 0/1$
    • $k=1: a_1 = 1 \implies p_1/q_1 = 1/1$
    • $k=2: a_2 = 3 \implies p_2/q_2 = 3/4$
  3. Check bound: $q_2 = 4 < 15$. Verify modular exponentiation: $7^4 = 2401 \equiv 1 \pmod{15}$. Order $r = 4$ is extracted directly.

Failure Modes & Recovery

Failure ModeMathematical CauseObservable SymptomMitigation / Recovery
Common Factor $\gcd(s, r) > 1$Measurement yields $s/r$ in non-reduced form; convergent produces $r' = r / \gcd(s, r) < r$.$a^{q_k} \not\equiv 1 \pmod N$, but $q_k \mid r$.Run QPE a second time to find coprime fraction $s'/r$; compute $r = \text{lcm}(q_k^{(1)}, q_k^{(2)})$, or test small integer multiples $j \cdot q_k$.
Phase Estimation Peak OffsetMeasurement lands on an adjacent bin outside the $\pm 1 / (2N^2)$ basin.$y/2^m - s/r
Trivial Phase $s = 0$Eigenvector superposition collapses to $s = 0$.$y = 0 \implies p/q = 0/1 \implies q=1$; $a^1 \not\equiv 1 \pmod N$.Discard run and re-sample QPE circuit.
Exponent Test OverheadCandidate denominator tested with naive power.Runtime stall or memory blowup.Use square-and-multiply modular exponentiation: $O(n^3)$ bit operations, constant memory.

Curated: · Written: · Reviewed:

Difficulty: Medium
Q&A-9

Design and validate a Shor or post-quantum migration workflow for continued fractions.

Answer

Assumption. The question bundles two things: the classical post-processing step of Shor's order-finding (continued fractions) and a post-quantum migration. I read it as: design the continued-fraction recovery workflow, validate it against its known failure modes, and use it as the harness that proves a PQC migration left no Shor-breakable primitive behind. If you meant only one half, the CF workflow is the load-bearing part.

Core answer (first 90 seconds). Shor's quantum register outputs an integer m; the phase is φ = m / 2^n with n = 2⌈log2 N⌉ qubits. φ approximates s/r, where r is the multiplicative order of a mod N. The classical workflow is: expand φ as a continued fraction, take each convergent p/q, and test q and small multiples of q as candidate orders by checking a^q ≡ 1 (mod N). The precision bound is what makes this work: with n = 2L qubits (L = ⌈log2 N⌉) the phase error is |φ − s/r| ≤ 1/2^{2L+1} ≤ 1/(2r²), so Legendre's theorem guarantees s/r is a convergent. Verification is not optional: a convergent denominator is a candidate, not an answer.

Why convergents recover r. Legendre: if |x − p/q| < 1/(2q²) then p/q is a convergent of x. Since r < N ≤ 2^L, we get 1/(2r²) ≥ 1/2^{2L+1}, which the QPE error satisfies. So 2L qubits is exactly the budget: one bit less and the theorem no longer applies.

Worked trace. N = 15, a = 7, L = 4, n = 8, den = 256. Order of 7 mod 15: 7¹=7, 7²=4, 7³=13, 7⁴=1, so r = 4. Suppose the register measures m = 128 → φ = 1/2. Here s = 2, gcd(s, r) = 2 ≠ 1, so s/r is not in lowest terms and the convergent denominator is 2, a divisor of r.

Python
def convergents(a, b):
    """Convergents p/q of a/b, exact integer arithmetic."""
    p2, p1 = 0, 1
    q2, q1 = 1, 0
    while b:
        k = a // b
        a, b = b, a - k * b
        p2, p1 = p1, k * p1 + p2
        q2, q1 = q1, k * q1 + q2
        yield p1, q1

def recover_order(N, a, m, n_bits, max_mult=8):
    den = 1 << n_bits
    for p, q in convergents(m, den):
        if q <= 1 or q >= N:      # skip trivial q=1; r < N always
            continue
        for mult in range(1, max_mult + 1):
            r = q * mult
            if r >= N:
                break
            if pow(a, r, N) == 1:
                return r
    return None

Trace: convergents(128, 256) yields (0,1) then (1,2). q=1 is skipped. q=2: pow(7,2,15) = 4 ≠ 1; mult=2 → r=4, pow(7,4,15) = 1 → returns 4. Factor: r even, x = 7^{r/2} = 4 mod 15; gcd(4−1,15)=3, gcd(4+1,15)=5 → 15 = 3·5.

Failure modes and detection.

failurewhat it looks likedetectioncost
first denominator acceptedq=1 from the integer part of φverify a^q ≡ 1; q=1 passes only if a ≡ 11 modexp
float precision lossφ stored as a double (53-bit); CF diverges for N > 2^26use integer m/2^n, or diff CF of the double against the exact rationalsilent wrong r, caught by verification, rerun
q ≥ N acceptedr ≤ φ(N) < N, so any q ≥ N is invalidreject q ≥ N before testing0
reduced fraction hides divisors/r not lowest terms → convergent q = r/ktest k·q for k=2..; a^{kq} ≡ 1 at k = r/qup to r/q modexps
no verificationaccepting q without a^q ≡ 1always verify; also check a^{r/2} ≢ ±1 before factoring1 modexp

Trade-offs. CF costs O(log N) convergents × O(log N) modexps: polynomial in log N. Brute-force search over r ∈ [1,N) is O(N) modexps, infeasible past N ≈ 2^80. Lattice reduction (LLL) on the phase is more noise-tolerant but heavier and rarely needed. The tempting shortcut, take the convergent with the largest denominator below N, fails exactly on the reduced-fraction row above.

PQC migration validation. NIST's post-quantum standards (FIPS 203 ML-KEM, FIPS 204 ML-DSA, FIPS 205 SLH-DSA, finalized August 2024) rest on lattice and hash hardness, not factoring or discrete log, so Shor's order-finding plus this CF pipeline does not apply to them. The migration workflow: inventory every classical asymmetric primitive in the trust path (RSA, ECDSA, ECDH, DH), run this CF harness against the largest modulus still present, and confirm each new parameter set matches its FIPS document. If the harness recovers an order, the migration is incomplete: the harness is the cheap regression test that catches a leftover Shor-breakable component.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-6

Design and validate a Shor or post-quantum migration workflow for controlled powers.

Answer

Assumptions. I read "controlled powers" as the controlled modular exponentiation unitary U_a: |x⟩|y⟩ → |x⟩|y·a^x mod N⟩, the dominant cost in Shor's order-finding and in ECDLP. "Post-quantum migration" is the classical-side response: moving the crypto Shor breaks onto NIST PQC. The question asks for both, so I answer both.

Core answer (first 90 seconds). Build U_a from t controlled multipliers, one per exponent bit, with t = ⌈log₂ N⌉. Bit i carries the constant a^(2^i) mod N, computed classically by repeated squaring: t modular multiplications, microseconds. On the quantum side each controlled multiplier is a reversible modular adder plus a conditional subtract. Validate by simulating every controlled power on every basis state |y⟩ and comparing to y·a^(2^i) mod N computed classically, then asserting the control=0 branch is the identity. On the migration side: inventory the crypto, rank by Mosca's inequality, ship hybrids first.

Why repeated squaring gives the powers. Write x = Σ xᵢ2ⁱ. Then a^x = Π (a^(2^i))^xᵢ. One controlled multiplier per bit, applied only when xᵢ = 1, computes the whole exponentiation: no distinct circuit per exponent value. The constants are public: a^(2^i) mod N reveals nothing about the order r beyond what a and N already do. What leaks is caching r, or the recovered factor, in a shared job store: validate that the store drops it.

Validation harness.

Python
import numpy as np
from math import gcd
from qiskit.quantum_info import Statevector

N, a, t, n = 15, 7, 4, 4          # 2^t = 16 >= N, n = ceil(log2 N)
assert gcd(a, N) == 1, "U_a is not a permutation unless gcd(a, N) = 1"

consts = [pow(a, 2**i, N) for i in range(t)]   # [7, 4, 1, 1]

def check(circ, i):
    k = consts[i]
    for y in range(N):
        # control = 1: |y> must map to |y*k mod N>
        psi = Statevector.from_int((1 << n) | y, 1 << (n + 1)).evolve(circ)
        assert int(np.argmax(np.abs(psi.data))) == (1 << n) | ((y * k) % N)
        # control = 0: identity
        psi0 = Statevector.from_int(y, 1 << (n + 1)).evolve(circ)
        assert int(np.argmax(np.abs(psi0.data))) == y

In production circ is the synthesized controlled multiplier; the harness is unchanged. Add the exponent edges: x = 0 must return |1⟩, x = 2^t − 1 must return a^(2^t−1) mod N.

Adder choice.

constructionToffoliCNOTancillaother
CDKM ripple-carry2n2n1—
Draper QFT0002n H, n(n−1)/2 controlled rotations

Resource arithmetic. RSA-2048: n = 2048, so the exponentiation register is 2n + 2 = 4098 logical qubits and the Toffoli count is O(n³), ~10⁹–10¹⁰. Gidney and Ekerå (Quantum 5, 433, 2021) put the full factoring run at 20 million physical qubits and 8 hours at 0.1% gate error. ECDLP on P-256 is cheaper: Roetteler et al. (2017) estimate 2330 logical qubits and 1.26×10¹¹ Toffoli. That gap is why harvest-now-decrypt-later targets ECDH first.

Failure modes, with detection. Exponent off-by-one: bit i must carry a^(2^i), not a^(2^(i+1)); caught by the x = 0 and x = 1 edges. Control polarity: control=0 must be identity; caught by the second assertion. Overflow: the work register must hold N − 1, so n = ⌊log₂ N⌋ wraps the top residue; test y = N − 1 with k = N − 1. Non-coprime a: gcd(a, N) > 1 makes U_a non-unitary; caught by the build-time assert. Order leakage: caching r or the factor; assert the job record has no field for r.

Migration workflow. NIST published FIPS 203 (ML-KEM), 204 (ML-DSA) and 205 (SLH-DSA) on 13 Aug 2024. Inventory TLS, code signing, firmware and long-lived secrets; rank by Mosca's inequality X + Y > Z. Deploy X25519MLKEM768 hybrid in TLS 1.3 first: it keeps classical security if ML-KEM falls. Validate against NIST ACVP vectors and test downgrade resistance.

Trade-offs. Precompute vs on-the-fly: precomputing t constants is free classically and shrinks the circuit; on-the-fly synthesis costs t extra modular multiplications on the quantum side and buys nothing unless N is secret. Draper vs CDKM: Draper has no ancilla and no Toffoli but n(n−1)/2 rotations, which dominate under magic-state costing; CDKM uses 2n Toffoli and one ancilla. Pick CDKM when Toffoli count is the budget, Draper when ancilla width is.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-10

Design and validate a Shor or post-quantum migration workflow for even order.

Answer

Assumption. The question joins two mechanisms that don't share one. "Even order" is a condition inside Shor's order-finding subroutine; a post-quantum migration (RSA/ECC → ML-KEM/ML-DSA) has no order-finding step, so even order doesn't apply to it. I'll design and validate the Shor even-order workflow, where pass/fail is decidable, and flag the migration track at the end.

Core answer. Shor factors N by finding r = ord_N(a), the smallest r > 0 with a^r ≡ 1 (mod N), for a random a coprime to N. If r is even, the difference of squares gives gcd(a^(r/2) − 1, N) and gcd(a^(r/2) + 1, N), which split N. If r is odd, that step is undefined, a^(r/2) is not an integer exponent, so the only correct move is a new a and a rerun. The workflow is a bounded retry loop whose gate is "r even and a^(r/2) ≢ −1 (mod N)".

Mechanism. For a semiprime N = pq, a random a coprime to N yields a usable r with probability at least 1/2 (Shor 1994; Nielsen & Chuang §5.3 give the general bound 1 − 2^(1−k) for k distinct prime factors). The two failure cases are r odd, and r even but a^(r/2) ≡ −1 (mod N), which makes both gcds trivial (1 and N).

Python
from math import gcd
import random

def post(a, r, N):
    if r % 2:                 # odd order: difference of squares undefined
        return None
    x = pow(a, r // 2, N)
    if x == N - 1:            # a^(r/2) == -1 mod N: both gcds trivial
        return None
    return gcd(x - 1, N), gcd(x + 1, N)

def factor(N, trials=10, seed=0):
    rng = random.Random(seed)          # seed recorded for reproducibility
    for _ in range(trials):
        a = rng.randrange(2, N - 1)
        g = gcd(a, N)
        if g > 1:                      # lucky classical hit
            return g, N // g
        res = post(a, order(a, N), N)  # order() is the quantum subroutine
        if res:
            return res
    return None                        # exhausted: alert, don't silently pass

Trace (N = 15). a = 7: 7^2 = 49 ≡ 4, 7^4 ≡ 4^2 = 16 ≡ 1, so r = 4. x = 7^2 mod 15 = 4 ≠ 14. gcd(3, 15) = 3, gcd(5, 15) = 5 → factors 3 and 5. a = 14: 14 ≡ −1, so r = 2, x = 14 = N − 1 → retry. a = 4: r = 2, x = 4, gcd(3, 15) = 3, gcd(5, 15) = 5. Odd-order case, N = 21, a = 4: 4^3 = 64 ≡ 1, r = 3 → retry.

Retry arithmetic. With per-trial success p ≥ 1/2, failure after t trials is ≤ 2^(−t): 10 trials → ≤ 9.8e-4, expected trials ≤ 2. Cap at 10 and log every (a, r, outcome).

StagePassFail → action
order rr evenr odd → new a
difference of squaresa^(r/2) ≢ −1 (mod N)≡ −1 → new a
gcd1 < gcd < Ngcd = 1 or N → new a

Trade-offs. Retrying with a fresh a is cheap and correct; rounding r up or forcing the gcd on an odd r is not an option: it produces a wrong factor. A classical pre-check (N even, or a perfect power) removes cases the quantum loop can't help with.

Failure modes and detection. Retry not bounded → cap trials and alert on exhaustion. Selected successes only → log all trials and compare the observed rate to the 1/2 bound. Random seed missing → record the seed or the run isn't reproducible. Failed work excluded from cost → count every order-finding call, not just successes.

Migration track. ML-KEM (FIPS 203) and ML-DSA (FIPS 204) have no order-finding step, so even order is irrelevant there; that workflow is inventory, hybrid key exchange, and cutover, a separate design.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-12

Design and validate a Shor or post-quantum migration workflow for factor extraction.

Answer

Assumption. "Factor extraction" = the Shor pipeline: classical pre- and post-processing around a quantum period-finding core. Target RSA-2048 (N = p·q, p, q ≈ 1024-bit). No quantum computer factors RSA-2048 today, so validation runs on small N and a classical simulator of the core. The validated pipeline is the threat-model evidence a post-quantum migration program consumes.

Pipeline: four phases, one gate each.

Phase 0, pre-filter. Even N → 2. Perfect-power test N = m^k → m. Miller–Rabin → prime, stop. Trial division below 10^6. Gate: only composite, non-prime-power N reaches the core.

Phase 1, base. Draw a ∈ [2, N−2] uniformly. g = gcd(a, N); if g > 1, return g. Gate: log(a, g).

Phase 2, period. Quantum: phase estimation on U_a|y⟩ = |ay mod N⟩ with t = 2n+2 qubits (n = bit length of N); continued fractions on the measured m/2^t recovers r. Simulator: r = multiplicative order of a mod N by repeated squaring. Gate: a^r ≡ 1 (mod N) and no proper divisor of r satisfies it.

Phase 3, post-processing. r odd → retry. a^(r/2) ≡ −1 (mod N) → retry. Else g₁ = gcd(a^(r/2) − 1, N), g₂ = gcd(a^(r/2) + 1, N). Gate: 1 < g₁ < N and g₁·g₂ ≡ 0 (mod N).

Phase 4, recurse on composite gᵢ through Phase 0. Gate: product of leaves = N.

Why it works. a^r ≡ 1 means N | (a^(r/2) − 1)(a^(r/2) + 1). If a^(r/2) ≢ ±1 (mod N), N's prime factors split across the two terms, so each gcd is nontrivial. For odd N with ≥ 2 distinct prime factors, a random a gives even r with a^(r/2) ≢ −1 with probability ≥ 1/2, so expected ≤ 2 attempts.

Worked trace, N = 15, a = 7. gcd(7,15) = 1. 7² = 49 ≡ 4, 7³ ≡ 13, 7⁴ ≡ 1 → r = 4. r even; 7² ≡ 4, and 4 ≢ 1, 4 ≢ 14. gcd(4−1, 15) = 3, gcd(4+1, 15) = 5. 3·5 = 15. ✓

The quantum half: n = 4, t = 10, so the register holds m ∈ [0, 1024). Phase estimation returns m ≈ 1024·s/r for the s it samples; each run lands within 1/2^(t+1) of some s/r with probability ≥ 4/π² ≈ 0.41. Take m = 256: 256/1024 = 1/4 = [0;4], convergents 0/1 and 1/4; the last with denominator < N = 15 is 1/4 → r = 4, and 7⁴ mod 15 = 1 ✓. Take m = 512: 512/1024 = 1/2 → r = 2, rejected because 7² mod 15 = 4 ≠ 1. Continued fractions return a divisor of r, never a multiple, which is why the a^r ≡ 1 gate exists.

Failure modes.

failuredetectioncost
r oddr % 2 == 0 before exponentiationone extra period round
a^(r/2) ≡ −1compare to N−1retry, ~half of draws
gcd ∈ {1, N}assert 1 < g < Nretry
CF returns a divisor of rpow(a, r, N) == 1discard run, re-measure
N prime or prime powerPhase 0 Miller–Rabin + perfect-powerpre-filter, no quantum
overflow in a^(r/2)pow(a, r//2, N)O(log r) multiplications

Validation. Three layers. Unit: for every N ≤ 2^20 and every a coprime to N, assert the simulator's order matches sympy.n_order and the leaves multiply to N. Interface: replay recorded phase samples through the continued-fraction step and assert the gate accepts exactly when a^r ≡ 1. Known-answer: the N = 15 traces above, including a = 14 (14² ≡ 1, r = 2, 14 ≡ −1 → retry), pinned as regression tests. The quantum core is not validated: only its classical contract.

Scale and migration. RSA-2048 needs t = 4098 logical qubits in the core; Gidney and Ekerå (Quantum 5, 433, 2021) estimate ~20 million physical qubits and ~8 hours with surface-code error correction. So validation today is classical simulation at N ≤ ~40 bits. GNFS is L_n[1/3, 1.923] (sub-exponential, infeasible at 2048 bits) which is why Shor, not GNFS, drives migration. Migration options: hybrid X25519MLKEM768 in TLS 1.3, ML-KEM (FIPS 203), ML-DSA (FIPS 204), SLH-DSA (FIPS 205). Deciding criterion: harvest-now-decrypt-later exposure window versus re-encryption cost. Don't run the Shor workflow when N is small, ECM or GNFS is cheaper, and don't use it to test migration tooling; a classical simulator is enough.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-13

Design and validate a Shor or post-quantum migration workflow for classical verification.

Answer

Assumption first. The question names two workflows. I'll answer both, because they share one gate: classical verification that recomputes the claim instead of trusting the producer. If you want only one, say which and I'll go deeper.

Core answer (first 90 seconds). In both cases the producer, a quantum sampler or a new PQC library, emits a candidate. The verifier recomputes the claim with independent classical arithmetic and asserts the invariants that make the candidate meaningful. For Shor that means verifying the order r, not just the factors. For a PQC migration it means NIST ACVP vectors, a second implementation, and negative tests that must fail. This is cheap enough to run on every candidate: a 2048-bit modexp is roughly 1–3 ms in GMP.

Shor: why the output can be wrong. Order-finding measures the phase register; the outcome's continued-fraction convergent yields a candidate denominator r. Two things break. The measured phase can be a convergent of s/r with gcd(s, r) > 1, so you recover a divisor of r, not r. And even with correct r, if r is odd or a^(r/2) ≡ −1 (mod N), then gcd(a^(r/2) ± 1, N) returns 1 and N. Both are caught classically, never on the quantum side.

Trace, N = 15, a = 7: 7^1≡7, 7^2≡4, 7^3≡13, 7^4≡1 (mod 15), so r = 4. Even, and 7^2 ≡ 4 ≢ 14. gcd(4−1, 15) = 3, gcd(4+1, 15) = 5. Check: 3·5 = 15, both prime.

Python
# Python 3.12; sympy 1.13 for isprime (Miller-Rabin + BPSW)
from sympy import isprime

def verify(N, factors):
    prod = 1
    for f in factors:
        prod *= f                      # arbitrary precision, no overflow
    assert prod == N, f"product {prod} != {N}"
    for f in factors:
        assert 1 < f < N, f"trivial factor {f}"
        assert isprime(f), f"composite factor {f}"
    return True

verify(15, [3, 5]) → product 15, 1<3<15, isprime(3), 1<5<15, isprime(5) → True. verify(15, [1, 15]) → product passes, then 1<1 fails: "trivial factor 1". verify(15, [3]) → product 3 ≠ 15: partial factorization caught.

PQC migration. Inventory → agility → hybrid → cutover, each with a classical gate. NIST finalized FIPS 203 (ML-KEM), 204 (ML-DSA) and 205 (SLH-DSA) in August 2024; HQC was selected in March 2025 as a backup KEM. Gates: (1) ACVP KATs pass; (2) cross-implementation agreement. Liboqs, OpenSSL 3.5 and BoringSSL produce identical encapsulations from the same seed; (3) negative tests. A tampered ML-KEM ciphertext must fail decapsulation with implicit rejection, not return a key; (4) downgrade test. A server that strips the hybrid group is rejected.

Trade-offs: hybrid X25519MLKEM768 (TLS codepoint 0x11EC) costs 1216 bytes of client key share (32 X25519 + 1184 ML-KEM-768 encapsulation key) against 32 bytes for X25519 alone. Fine for TLS, painful on constrained firmware. ML-DSA-44 signatures are 2420 bytes; SLH-DSA-SHA2-128s is 7856 bytes but rests only on hash security. Take ML-DSA unless you must avoid lattice assumptions or have a weak RNG.

failuredetectioncost
shared arithmetic bugdifferential test vs a third implementation + ACVP KATsone CI job
factor 1 or N acceptedassert 1 < f < Nfree
product overflowarbitrary-precision product; assert bit_length(prod) == bit_length(N)free
partial factorization called completerecurse until every factor is prime; product must equal None isprime per factor
sample mapping lostlog raw measurement, convergent, derived a and r; replaystorage
PQC downgradeassert negotiated group ∈ allowlist; alert on classical-only handshakeone config check

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-4

What are the primary circuit and computational bottlenecks when implementing reversible modular exponentiation in Shor's algorithm on fault-tolerant hardware?

Answer

Start with the assumptions, because they decide the answer. I'm assuming an n-bit modulus N, a fault-tolerant surface-code machine where Clifford gates are cheap and every non-Clifford gate costs a magic state from a distillation factory, and a code cycle around 1 µs.

The bottleneck is not phase estimation or the inverse QFT: those are O(n²) gates. It's the modular exponentiation feeding them. The exponentiation is 2n controlled modular multiplications, one per exponent bit, each by a classical constant a^(2^j) mod N. Each of those multiplications is n controlled modular additions. Each addition is O(n) Toffoli gates. Multiply it out and you get O(n³) non-Clifford gates, and in a surface code the non-Clifford gates are the entire bill.

Concretely, for n = 2048: 2n² ≈ 8.4 million modular additions, each roughly n Toffolis, so about 1.7×10^10 Toffoli gates. A Toffoli costs 4 T gates given a clean ancilla, so ~7×10^10 T gates. At one non-Clifford layer per 1 µs cycle that's ~19 hours of pure gate time, before routing or distillation throughput is considered.

Three things actually bind.

T-count and distillation throughput. Every T gate needs a magic state, and a distillation factory consumes a large block of physical qubits to produce states at a fixed rate. If the circuit issues T gates faster than the factories supply them, the algorithm stalls: the factory rate, not the gate count, sets wall-clock time. This is why T-depth matters as much as T-count: two circuits with the same T-count can differ by an order of magnitude in runtime depending on how many T layers can run in parallel.

Space versus depth in the adder choice. A Cuccaro/CDKM ripple-carry adder uses 2n + O(1) qubits and about 2n Toffolis, but its depth is O(n) per addition, so O(n³) overall. Carry-lookahead cuts depth to O(log n) per addition at the cost of O(n) extra ancillas per block, pushing the total to roughly 3n–4n logical qubits. Draper's QFT adder needs no ancillas for the addition itself, but it uses n(n+1)/2 controlled rotations with angles down to π/2^n; those small angles have to be synthesized to a target precision, and approximate synthesis trades T-count against the error budget of the whole run.

Uncomputation. Reversible arithmetic leaves garbage: carry, borrow and comparison bits. Bennett's trick uncomputes them, roughly doubling the circuit, but skipping it leaves scratch qubits entangled with the computational register and destroys the interference phase estimation depends on. So the ancilla budget and the T-count are coupled: fewer qubits usually means more uncomputation and more gates.

AdderLogical qubitsDepth per additionNon-Clifford cost
Cuccaro ripple-carry2n + O(1)O(n)~2n Toffoli
Carry-lookahead~3n–4nO(log n)O(n) Toffoli
Draper QFT~2nO(n²) rotationshigh T-count from rotation synthesis

If qubits are plentiful relative to gate time, windowed arithmetic (Gidney, 2017) is the alternative worth naming: it looks up a window of exponent bits from a quantum table and cuts the Toffoli count by roughly the window size, at the cost of extra qubits and table-lookup circuitry. Gidney and Ekerå's 2021 construction factors 2048-bit RSA in 8 hours using 20 million physical qubits and a few billion Toffoli gates: about an order of magnitude below the naive 2n³ bound, which tells you how much of the cost is construction choice rather than physics.

The failure modes to watch: distillation starvation when T gates are issued faster than factories produce; routing congestion in 2D lattice surgery when data patches and factories compete for channels; magic-state injection errors that dominate the logical error rate; and decoherence if uncomputation is skipped or ancillas are reused in the wrong order.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-23

Design and validate a Shor or post-quantum migration workflow for resource realism.

Answer

Clarify first. This prompt bundles two migrations that share only a validation discipline. Shor resource estimation sizes a future quantum computer; PQC migration moves live systems off RSA and ECC. I'll answer both, and define "resource realism" the same way for each: every headline number is a function of stated parameters, carries a range, and names the first thing that breaks in production.

Shor side. The chain is algorithm → arithmetic circuit → logical qubits → code distance → physical qubits → runtime. For RSA-2048, modular exponentiation needs about 2n+2 ≈ 4096 logical qubits. A surface code at physical error p = 1e-3, with threshold p_th ≈ 1e-2, needs distance d ≈ 27, because logical error per cycle ≈ (p/p_th)^((d+1)/2) = 0.1^14 ≈ 1e-14. Each logical qubit costs roughly 2d² ≈ 1458 physical qubits, so data alone is about 6M. Runtime, though, is set by T-state factories, not data: RSA-2048 is on the order of 10^9–10^10 T gates, and 15-to-1 distillation factories emit T states at a rate fixed by their footprint and cycle time. That is why published estimates diverge. Gidney–Ekerå (2021) get 20M qubits in 8 hours at p = 1e-3; Gidney's 2025 preprint gets under 1M qubits in about a week. Same physics, different architecture: a 20x swing on factory and routing choices alone. Validate by reproducing the estimate from its stated parameters, then sweeping each one; if the answer moves most when you change p, you have a physics claim, not an engineering one.

PQC side. Inventory where RSA and ECC live, then prioritize by harvest-now-decrypt-later: key exchange first, because recorded ciphertext is already a liability, and signatures later, because forgery needs a live quantum computer. The standards are FIPS 203 (ML-KEM), 204 (ML-DSA) and 205 (SLH-DSA), finalized August 2024, with HQC added March 2025; NIST IR 8547 targets deprecation by 2030 and disallowance by 2035. Here "resources" are bytes and cycles, not qubits. ML-KEM-768's public key is 1184 B and its ciphertext 1088 B, against X25519's 32 B; ML-DSA-65 signatures are 3309 B against ECDSA P-256's ~64 B. A hybrid X25519MLKEM768 handshake plus a PQC certificate chain blows past the 1500-byte MTU, adding round trips and middlebox drops: Chrome 131+ and Cloudflare ship that hybrid, so the failure is observable in the field. Validate by measuring handshake bytes and p99 latency before and after, on the real middleboxes, and by checking HSM and firmware support.

Trade-offs. On the Shor side, pick the 20M-qubit/8-hour point if you are time-constrained and the sub-1M/week point if you are qubit-constrained. On the PQC side: ML-KEM versus HQC, the code-based backup if lattice assumptions fall; ML-DSA versus SLH-DSA, which has 32-byte keys but 7856-byte signatures and slow signing. Fine for firmware you sign rarely, wrong for TLS; hybrid versus pure PQC, where hybrid survives a PQC break but costs bytes. Do not put short-lived signature certificates on the same clock as key exchange.

Failure modes, with detection. Quoting 4096 as the machine size: check the estimate names a code distance and a physical error rate. T-count without factory footprint: check the runtime derives from factory throughput. Assuming the exponentiation circuit is free: check the T-count is stated as O(n³). A cherry-picked p = 1e-4 with d = 15: run the sensitivity sweep. A single number with no range: ask for the interval. On the PQC side: ignoring signature size, measure bytes on the wire; assuming your HSM supports ML-DSA, get the vendor firmware matrix.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-11

Walk me through the full Shor pipeline that would break RSA-2048 (period finding, phase estimation, continued fractions) then tell me why moving to RSA-8192 or P-521 doesn't fix it, while AES-256 is a different story.

Answer

Assumption. I'll take RSA-2048 as the target and AES as the contrast case, since the question asks for both. This is about the algorithm and its consequence, not a migration plan.

Core answer (first 90 seconds). Shor factors N in four steps. (1) Pick a random a coprime to N; the problem becomes finding r = ord_N(a), the smallest r > 0 with a^r ≡ 1 (mod N). (2) Build the unitary U|y⟩ = |ay mod N⟩ and run quantum phase estimation on it. Its eigenphases are s/r for s ∈ {0..r−1}, so the phase register measures an estimate of s/r. (3) Read the measured integer m and recover r from φ = m/2^t by continued fractions: the convergents p/q of φ are candidates for s/r, and each candidate is verified by checking a^q ≡ 1 (mod N). (4) If r is even and a^(r/2) ≢ −1 (mod N), then gcd(a^(r/2) − 1, N) and gcd(a^(r/2) + 1, N) split N. If r is odd, or a^(r/2) ≡ −1, retry with a new a; a random a is usable with probability ≥ 1/2 for a semiprime.

Worked trace, N = 15, a = 7. L = ⌈log2 15⌉ = 4, so t = 2L = 8 phase qubits: the precision Legendre's theorem needs to guarantee s/r is a convergent. ord_15(7) = 4 (7, 4, 13, 1 mod 15). The phase is s/r = 1/4, so m = 64 and φ = 64/256 = 1/4 exactly. Continued fraction of 1/4 gives convergent 1/4, q = 4; verify 7^4 mod 15 = 1 ✓. r = 4 is even, a^(r/2) = 7^2 = 49 ≡ 4 (mod 15), and 4 ≢ 14. gcd(4−1, 15) = 3, gcd(4+1, 15) = 5. 15 = 3 × 5. The entire classical tail is microseconds of Python; the quantum step is the only expensive part.

Cryptographic implication. Shor solves factoring and discrete log in polynomial time, so it breaks every deployed primitive resting on either.

PrimitiveHard problemAttackDoes a bigger key help?
RSA-2048integer factoringShor, polynomialNo: key size scales the constant, not the complexity
Finite-field DH (2048/3072-bit MODP)discrete log in F_p*Shor, polynomialNo
ECDH / ECDSA / EdDSA (P-256, secp256k1, Ed25519)ECDLPShor, polynomialNo, and ECC is cheaper to break per bit than RSA
AES-128 / AES-256key searchGrover, quadraticYes: AES-256 restores the margin
SHA-256 preimagepreimageGrover, quadraticYes: SHA-384/512

The asymmetry is the whole point. Shor is exponential-to-polynomial, so no key length is safe: RSA-8192 doubles the logical qubit count and multiplies the gate count, and the attacker just waits. Grover is a square-root speedup, so doubling the key length restores the original security level, which is why AES-256 and SHA-384 are the standard answers, and why NIST's August 2024 PQC standards (FIPS 203 ML-KEM, FIPS 204 ML-DSA, FIPS 205 SLH-DSA) replace key establishment and signatures while leaving AES and SHA in place.

Arithmetic for why AES-256 holds: Grover on AES-256 needs ~2^128 sequential iterations. At 1 ns each that is 3.4×10^38 × 10^-9 s ≈ 3.4×10^29 s ≈ 10^22 years. Grover also parallelizes badly, k machines give only a √k speedup, so you cannot buy the gap back with hardware.

Resource realism. "Polynomial time" hides the constant. RSA-2048 needs ~4,096 logical qubits (2L) and billions of Toffoli gates for the modular exponentiation. Gidney & Ekerå (2021) put the full fault-tolerant run at ~20 million noisy physical qubits for ~8 hours: roughly 5,000 physical qubits per logical qubit, almost all of it surface-code overhead. A 2025 preprint (Gidney, arXiv:2505.15917) claims under 10^6 noisy qubits at about a week of runtime. Either way the gap to today's few-thousand-qubit noisy devices is three to four orders of magnitude, and the bottleneck is error correction, not raw qubit count.

Failure modes to name. Conflating logical and physical qubits: a 4,096-qubit claim is not a 4,096-qubit machine. Assuming Shor breaks AES. Assuming RSA-8192 buys time. Forgetting the retry loop in the classical tail. And treating "not yet" as "not urgent": harvest-now-decrypt-later means traffic recorded today is exposed the day the machine exists, which is why the draft NIST IR 8547 puts RSA-2048 and 256-bit ECC on a deprecate-by-2030, disallow-by-2035 track.

Curated: · Written: · Reviewed:

Difficulty: Medium
Q&A-14

Design and validate a Shor or post-quantum migration workflow for RSA impact.

Answer

Assumptions. "RSA impact" splits into two threats on different clocks. Confidentiality is already broken by harvest-now-decrypt-later: an adversary records RSA-encrypted or RSA-key-exchanged traffic today and decrypts it once a cryptographically relevant quantum computer (CRQC) exists. Authenticity (RSA signatures on certs, JWTs, firmware) only breaks when the CRQC exists, because you cannot forge a signature retroactively. I assume a hybrid deployment target (classical plus PQC), TLS 1.3, and the NIST FIPS 203/204/205 algorithm set.

The workflow, in five steps.

  1. Inventory. Build a cryptographic bill of materials. You cannot migrate what you cannot see, and RSA hides outside TLS: SSH host keys, code-signing certs, JWT RS256, S/MIME, firmware images, database column encryption, and archived ciphertext.

  2. Classify by data lifetime, not by algorithm. The deciding question is "how long must this stay secret?" A session token that expires in an hour is low priority; a 30-year medical record encrypted under RSA is already compromised.

  3. Prioritize. Long-retention confidentiality first, then signatures, then short-lived ephemeral traffic.

  4. Migrate. Hybrid key exchange (X25519MLKEM768) for TLS; ML-DSA (FIPS 204) for signatures; ML-KEM (FIPS 203) for KEM use.

  5. Validate. Interop tests, performance benchmarks, and a rollback path.

Artefact 1: classification table.

AssetThreatClockTarget
Archived ciphertext (RSA-OAEP)HNDL decryptAlready runningRe-encrypt with ML-KEM
TLS session keys (RSA kex)HNDL decryptAlready runningHybrid X25519MLKEM768
Code-signing cert (RSA)ForgeryOn CRQC arrivalML-DSA
JWT RS256ForgeryOn CRQC arrivalML-DSA

Artefact 2: inventory commands.

# Signature algorithm and key size on a live endpoint
openssl s_client -connect example.com:443 -showcerts </dev/null 2>/dev/null \
  | openssl x509 -noout -text | grep -E "Signature Algorithm|Public-Key"
#   Signature Algorithm: sha256WithRSAEncryption
#   Public-Key: (2048 bit)

# SSH host key type
ssh-keyscan -t rsa host 2>/dev/null

Artefact 3: the arithmetic that sets the deadline. Gidney and Ekerå (2021) estimate factoring a 2048-bit RSA modulus needs roughly 20 million noisy physical qubits running about 8 hours. That hardware does not exist, but the number keeps falling, and it is irrelevant to HNDL: the recording starts now. So the migration deadline is set by your longest data-retention period, not by the qubit count.

Trade-offs. Hybrid versus pure PQC: hybrid keeps classical security if the PQC algorithm is later broken, at the cost of roughly 1.2 KB of extra handshake data and more CPU. Pure PQC is smaller but bets everything on one lattice assumption. For signatures, ML-DSA signatures are about 2.4–3.3 KB against 256 bytes for RSA-2048, which matters for constrained firmware. SLH-DSA (FIPS 205) is a hash-based fallback if lattice assumptions fall, but its signatures run to about 8 KB and signing is slow.

Failure modes and detection.

  • RSA missed in a non-TLS path (SSH, JWT, firmware). Detect with a CBOM scan in CI that fails the build on any RSA or ECC primitive not on an allowlist.
  • Retired keys assumed irrelevant. Detect by checking whether archived ciphertext is still decryptable with a retired key, if it is, it is still exposed.
  • Hardware uncertainty used to delay everything. Detect by tracking the retention clock, not the qubit clock.
  • Hybrid negotiation silently downgraded. Detect by asserting the negotiated group in a canary request.

Curated: · Written: · Reviewed:

Difficulty: Medium
Q&A-16

Design and validate a Shor or post-quantum migration workflow for symmetric distinction.

Answer

The distinction that decides the whole migration: Shor's algorithm breaks public-key cryptography (RSA, ECDH, ECDSA, finite-field and elliptic-curve Diffie-Hellman) because it solves factoring and discrete log in polynomial time. It does nothing to AES. Symmetric ciphers and hashes are touched only by Grover's algorithm, a quadratic speedup on unstructured search. So the two halves of a crypto inventory migrate on different clocks, for different reasons, and a workflow that treats "post-quantum" as one problem will either over-migrate symmetric keys or under-migrate signatures.

Assumptions I'd state up front: we're protecting data with a multi-decade confidentiality requirement, we take NIST's post-quantum guidance as the bar, and we are not assuming a cryptographically relevant quantum computer exists today.

Why symmetric security halves. Grover searches an unstructured space of N items in about sqrt(N) steps, so brute-forcing 2^k keys becomes ~2^(k/2) quantum evaluations. AES-128 falls from 128-bit to 64-bit security; AES-256 falls from 256 to 128. That is the entire symmetric story, and it is why AES-256 is the answer and AES-128 is not.

The parallel-cost caveat is the part people get wrong. Running k independent Grover instances gives at most a linear speedup in wall-clock time, not k times the quadratic: total work stays ~2^(k/2). You cannot buy back the quadratic advantage with more machines, so 2^128 quantum operations stays infeasible. Grover also needs a long coherent circuit, and with error correction the constant factors are enormous. That is why NIST treats AES-256 as providing 128-bit post-quantum security.

The workflow.

  1. Inventory every primitive and tag it Shor-vulnerable (public key) or Grover-affected (symmetric, hash).
  2. Symmetric: anything below 128-bit post-quantum security moves. AES-128 → AES-256. AES-192 gives 96-bit quantum security, below the bar, so it also moves to AES-256.
  3. Hash: split preimage from collision. SHA-256 preimage is 128-bit quantum (fine); collision resistance falls to roughly 2^85 via Brassard–Høyer–Tapp, so long-lived collision-sensitive uses move to SHA-384.
  4. Public key: migrate to ML-KEM (FIPS 203) and ML-DSA (FIPS 204), hybrid with X25519/ECDSA during the transition.

Trade-offs. AES-256 versus AES-128: with AES-NI the throughput difference is a few percent; in pure software it is roughly 1.4x slower. For most workloads that is the right trade. Where it is not (high-volume, short-lived sessions) AES-128 is defensible if the data's confidentiality lifetime is shorter than the migration horizon. NIST IR 8547 sets 2030 to deprecate and 2035 to disallow below-128-bit security, so the deadline is a policy choice, not a physics one.

Failure modes and how to detect them.

  • Calling AES broken by Shor. Detect: a symmetric primitive flagged Shor-vulnerable in the inventory review.
  • Inventing a key-length response. Doubling AES-128 to AES-256 because Grover halves it is right; claiming AES-128 must become AES-512 is wrong: no such standard cipher exists. Detect: check the target key size exists in the standard.
  • Ignoring Grover parallel costs. Treating 2^64 as trivially reachable. Detect: a cost model that assumes linear parallel speedup.
  • Conflating hash properties. Applying preimage numbers to collision. Detect: separate preimage and collision columns in the inventory.
primitiveclassicalquantumaction
AES-1282^1282^64 (Grover)→ AES-256
AES-2562^2562^128 (Grover)keep
SHA-256 preimage2^2562^128 (Grover)keep
SHA-256 collision2^128~2^85 (BHT)→ SHA-384
RSA-2048~2^112 (GNFS)broken (Shor)→ ML-KEM / ML-DSA

Validation. Run NIST CAVP test vectors against the migrated primitives, verify hybrid handshake interop with a classical-only peer, and prove crypto-agility with a test that swaps the primitive without a code change. If the swap needs a code change, the workflow is not done.

Curated: · Written: · Reviewed:

Difficulty: Medium
Q&A-2

How is Shor's algorithm adapted to solve the discrete logarithm problem over elliptic curve groups (ECDLP), and why does it break standard curves like Ed25519 or secp256k1 using fewer logical qubits than RSA-2048?

Answer

Core Mechanism: Two-Dimensional Period Finding

Shor's algorithm solves the Discrete Logarithm Problem (DLP) over an elliptic curve group $E(\mathbb{F}_q)$ by framing it as finding the period (or hidden kernel) of a two-dimensional group homomorphism.

Given base point $P$ of prime order $r$ and public key $Q = dP$, we seek scalar $d \in [0, r-1]$. The algorithm initializes three quantum registers:

  1. Register 1 ($m$ qubits) initialized to uniform superposition over integers modulo $r$: $\frac{1}{\sqrt{r}} \sum_{x=0}^{r-1} |x\rangle$
  2. Register 2 ($m$ qubits) initialized to uniform superposition over integers modulo $r$: $\frac{1}{\sqrt{r}} \sum_{y=0}^{r-1} |y\rangle$
  3. Register 3 ($n$ qubits) holding identity $\mathcal{O}$, large enough to represent affine or projective point coordinates $(X, Y) \in \mathbb{F}_q$.

A controlled group operation computes point addition: $$f(x, y) = xP + yQ = (x + yd)P$$

Evaluating this into Register 3 yields: $$\frac{1}{r} \sum_{x=0}^{r-1} \sum_{y=0}^{r-1} |x\rangle |y\rangle |xP + yQ\rangle$$

Measuring Register 3 collapses Registers 1 and 2 to states $(x, y)$ yielding constant point $C$. Because $x + yd \equiv k \pmod r$, these points lie on the line $x + yd \equiv k \pmod r$. Applying an inverse 2D Quantum Fourier Transform (QFT mod $r$) to Registers 1 and 2 produces peaks at frequencies $(u, v)$ satisfying: $$u \cdot d \equiv -v \pmod r$$

Measuring $(u, v)$ yields $d \equiv -v \cdot u^{-1} \pmod r$ via classical modular inversion whenever $\gcd(u, r) = 1$.


Why ECC Requires Fewer Logical Qubits Than RSA-2048

Quantum resource scaling depends on the underlying operand width rather than classical security bits. To achieve NIST Security Category 1 (~128-bit classical security), RSA uses a 2048-bit modulus ($N$), while ECC uses a 256-bit prime field ($q$).

RSA-2048 Modular Exp:     Modulus N ~ 2048 bits  --> Registers hold 2048-bit integers
ECC-256 (Ed25519/secp256k1): Field q ~ 256 bits   --> Registers hold 256-bit coordinates
  1. Register Representation: Shor's RSA factoring circuit requires storing $N$ and computing controlled modular exponentiation $a^x \pmod N$. Standard implementations (e.g., Beauregard or Gidney-Ekerå constructions) require $2n + 2$ to $4n$ logical qubits, translating to roughly 4,096 to 6,000+ logical qubits for RSA-2048.
  2. Curve Point Arithmetic: For a 256-bit curve (e.g., secp256k1, Ed25519, or NIST P-256), the group order $r \approx 2^{256}$. Point addition over $\mathbb{F}_q$ operates on 256-bit coordinates. Efficient reversible elliptic curve point-addition circuits (such as Roetteler et al.) require approximately $9n$ logical qubits (around 2,300 to 2,800 logical qubits for $n = 256$).
AlgorithmClassical Security LevelWorking Modulus / Coordinate Width ($n$)Logical Qubits (Approx.)Circuit Depth / Toffoli CostPrimary Classical Replacement
RSA-2048~112 bits2048 bits~4,096 – 6,000+$\mathcal{O}(n^3)$ gatesFIPS 203 (ML-KEM-768/1024)
secp256k1 / Ed25519~128 bits256 bits~2,300 – 2,800Lower gate counts than RSA-2048FIPS 204 (ML-DSA) / FIPS 205 (SLH-DSA)
RSA-4096~128 bits4096 bits~8,192 – 12,000+$\mathcal{O}(n^3)$ gatesFIPS 203 / CNSA 2.0

Because ECC derives its classical hardness from exponential Pollard's rho ($2^{n/2}$) rather than sub-exponential Number Field Sieve ($L_N[1/3, c]$), its keys are an order of magnitude smaller for equivalent classical security. Shor's algorithm converts both to polynomial quantum time $\mathcal{O}(n^3)$, making the smaller base field of ECC far more vulnerable to earlier, lower-capacity Cryptanalytically Relevant Quantum Computers (CRQCs).

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-15

Design and validate a Shor or post-quantum migration workflow for ECC impact.

Answer

What I'd say first

Shor's algorithm breaks ECC the same way it breaks RSA: it solves the elliptic-curve discrete logarithm in polynomial time. Roetteler et al. (2017) put P-256 at roughly 2,330 logical qubits and 1.26×10^11 Toffoli gates: the same order of magnitude as RSA-2048. ECC is not "safer than RSA" against a quantum adversary; it's just cheaper to break. So the migration is a workflow with a validation gate, not a cutover.

Assumption I'd state up front: you have TLS, SSH, code signing and some embedded roots, and you cannot change them all at once.

The workflow

PhaseWhat it producesDeciding criterion
1. InventoryCurve and algorithm per surfaceTelemetry and scans must agree
2. ClassifyExposure tier per surfaceHarvest-now-decrypt-later vs. forgery-on-use
3. MigrateHybrid key agreement, PQC signaturesInterop with oldest supported client
4. ValidateEvidence the surface is cleanRe-discovery + downgrade test

Phase 1: Inventory. Don't trust a spreadsheet. Pull three sources: TLS handshake telemetry (negotiated group and signature algorithm per connection, from load-balancer logs or a JA4 fingerprint); config and code scans for the literal tokens secp256r1, prime256v1, X25519, ES256, ed25519, ecdsa-sha2-nistp256; and artifact scanning for embedded certs and keys in firmware, containers and HSMs (PKCS#11 object enumeration). The scan finds what's declared; the telemetry finds what's actually negotiated. They disagree more often than you'd like.

Phase 2: Classify by exposure, not by algorithm. Key agreement is exposed to harvest-now-decrypt-later: traffic recorded today is decrypted when a CRQC arrives. Signatures are not: a forged signature only matters at the moment of use. So ECDHE/X25519 migration is urgent; ECDSA certificate migration can trail it.

Phase 3: Migrate with hybrids. X25519MLKEM768 for key agreement: if either half holds, the session holds. ML-DSA-44/65 (FIPS 204) for signatures, or composite ECDSA+ML-DSA certs during the transition.

Phase 4: Validate. Four gates: re-run discovery and prove zero ECC on the migrated surface; a downgrade test that forces classical-only and confirms policy rejects it; an interop matrix against your oldest supported client; and measurement.

Arithmetic that decides the design

X25519MLKEM768 client key share = 32 (X25519) + 1,184 (ML-KEM-768 encapsulation key) = 1,216 bytes; server share = 32 + 1,088 = 1,120 bytes. That pushes the TLS 1.3 ClientHello past one MTU on some paths, which is where handshake failures show up. ML-DSA-44 signatures are 2,420 bytes against ECDSA P-256's ~72, so a certificate chain grows by several KB: check OCSP stapling and chain-size limits before rollout.

Failure modes and how you catch them

  • Factoring-only inventory: you scanned for RSA and declared victory. Detect by asserting the scan output contains at least one ECC token per surface; a surface reporting zero is a scan gap, not a clean bill.
  • ECDSA verification ignored: you migrated signing but not verification, so old clients still accept ECDSA. Detect with the downgrade test.
  • Embedded roots missed: firmware and HSMs don't appear in config scans. Detect by artifact scanning and PKCS#11 enumeration.
  • Proprietary curves: absent from any standard list. Detect by parsing actual named-group IDs from telemetry rather than matching a known list.
  • Incomplete certificate chain: the intermediate is still ECDSA. Detect by walking the full chain, not just the leaf.

When not to do this

If your data's secrecy lifetime is shorter than your estimate of CRQC arrival, hybrid key agreement is cheap insurance but not urgent. On a constrained embedded link with a tight MTU budget, ML-KEM's key share may not fit: that's where you consider a smaller parameter set or a different transport.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-17

Design and validate a Shor or post-quantum migration workflow for harvest now.

Answer

Clarify first. "Harvest now, decrypt later" means an adversary records ciphertext today and decrypts it once a cryptographically relevant quantum computer exists. So the question isn't when we get quantum computers: it's which of our ciphertext is still sensitive when Q-day arrives. I'll assume a mid-size SaaS: TLS on every egress, a Postgres fleet, S3 archives with 7-year retention, and code-signing keys. Shor's algorithm is the threat to RSA/ECDH/ECDSA; the migration is to post-quantum algorithms.

Core answer: the workflow has five stages, each with a validation gate.

  1. Inventory and classify. For every data flow record three things: secrecy lifetime (how long the plaintext must stay secret), the key exchange protecting it, and whether the ciphertext is re-encryptable. That last one is the pivot, if you can re-encrypt, you can migrate late; if you can't, you must migrate before capture.

  2. Score urgency with Mosca's inequality: if (secrecy lifetime X) + (migration time Y) > (time to Q-day Z), you are already exposed. Hypothetical: a 10-year health record, 3-year migration, 12-year Q-day estimate gives 13 > 12. Start now. A 24-hour session token gives 0.1 + 3 < 12: schedule it.

  3. Sequence by re-encryption feasibility, not data volume. Non-re-encryptable, long-lived data goes first.

  4. Migrate key exchange to hybrid: X25519MLKEM768 in TLS 1.3, which Chrome and Firefox ship by default and OpenSSL 3.5 enables. Hybrid keeps you safe if ML-KEM falls and safe against Shor if X25519 falls.

  5. Migrate signatures separately, later: ML-DSA (FIPS 204) or SLH-DSA (FIPS 205) for code signing and firmware, where the risk is future forgery, not retroactive decryption.

Validation. You validate by re-running the inventory against live traffic, not by trusting the design doc: capture a pcap on each egress and assert the ClientHello offers a hybrid group; run a key-rotation drill on the archive and prove you can decrypt with the new key and shred the old one; re-run the Mosca arithmetic quarterly as Z estimates move.

stageartefactvalidation gate
inventorydata-flow map with secrecy lifetimeevery egress has a named key exchange
urgencyMosca score per data classno class with X+Y>Z left unowned
key exchangehybrid TLS configpcap shows X25519MLKEM768 offered
archivere-encryption runbookdrill decrypts and shreds the old key
signaturesML-DSA code signingold signatures still verify

Trade-offs. Hybrid vs pure PQC: hybrid adds roughly 1.2 KB to the ClientHello and a second key share, but it's the only option safe against both a classical break of ML-KEM and a quantum break of X25519. Pure ML-KEM is leaner but bets everything on one lattice assumption. Crypto-agility vs phased re-encryption: agility (algorithm negotiation, key versioning) is a one-time cost that makes every future swap cheap; phased re-encryption is per-dataset labour. With a handful of non-re-encryptable stores, do the phased work; with hundreds, build agility first.

Failure modes, with detection.

  • Machine forecast alone: teams migrate when Q-day is "soon" and ignore 10-year archives. Detect: Mosca score per data class; any class with X+Y>Z and no owner is a finding.
  • Long-lived backups ignored: the live path is hybrid but the S3 archive still holds RSA-wrapped keys. Detect: scan backup manifests for classical-only key wrapping.
  • Metadata omitted: ciphertext is protected but the index, filenames, or logs leak the content. Detect: sample the metadata store for plaintext PII.
  • Already-exposed traffic assumed recoverable: you can't un-capture what's on the wire. Detect: any class whose X+Y>Z at first capture is a write-off. Re-key it, don't re-encrypt it.
  • Integrity mixed with confidentiality: signatures aren't retroactively forgeable, so treating code signing as urgent as archives wastes budget. Detect: keep the two risk registers separate.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-20

Design and validate a Shor or post-quantum migration workflow for crypto inventory.

Answer

Treat the crypto inventory as a pipeline with a coverage number, not a spreadsheet. Five stages, each with an exit gate, and validation that runs continuously, because a scanner whose recall has never been measured is a guess with a dashboard.

Two assumptions up front: you have runtime flow visibility (VPC flow logs, eBPF, or a service mesh) and a CI system. Without runtime visibility, stage 1 is manual and the timeline roughly doubles.

1. Discover: union sources, record provenance. No single source sees everything:

sourceseesblind spot
code + SCAlibraries, hard-coded keysruntime-only TLS, config
config / IaCcipher suites, TLS versionswhat is actually deployed
certificates (CT logs, internal CA)public endpointsinternal CAs, mTLS
network telemetryreal handshakesdormant paths
HSM / KMSkey algorithms, rotationapp-side usage
firmware + vendor attestationembedded cryptounpatched devices

Record which source found each asset. Found by one source, it is a lead; found by two, it is inventory.

2. Classify. Per asset: algorithm, key size, protocol, data lifetime, owner. Then apply Mosca's inequality: start when migration time plus data lifetime exceeds time to a cryptographically relevant quantum computer.

Python
# Python 3.12 — Mosca prioritisation
CRQC_YEARS = 10          # planning assumption, revisit yearly

assets = [
    # name,                  migration_years, data_lifetime_years
    ("TLS edge (ECDHE)",     2,  1),
    ("Archive (RSA-2048)",   3, 25),
    ("Firmware signing",     4, 10),
]

for name, mig, life in assets:
    total = mig + life
    verdict = "START NOW" if total > CRQC_YEARS else "monitor"
    print(f"{verdict:9} {name}: {mig}+{life}={total} vs {CRQC_YEARS}")

Output:

monitor   TLS edge (ECDHE): 2+1=3 vs 10
START NOW Archive (RSA-2048): 3+25=28 vs 10
START NOW Firmware signing: 4+10=14 vs 10

The archive wins on data lifetime, not algorithm strength: that is the harvest-now-decrypt-later case. The model is only as good as its two inputs: set CRQC_YEARS to 20 and only the archive moves.

3. Prioritise. Long-lived confidentiality first, then signing roots (a forged firmware signature outlives the device), then ephemeral session keys.

4. Migrate: hybrid first. X25519MLKEM768 in TLS 1.3 has shipped by default in Chrome and Cloudflare since 2024; it stays safe if ML-KEM is broken. OpenSSL 3.5 (April 2025) carries ML-KEM, ML-DSA and SLH-DSA; FIPS 203/204/205 were finalised August 2024. NIST IR 8547 (initial public draft, Nov 2024) proposes deprecating RSA and ECC by 2030.

5. Validate: three gates, not one scan.

  • Reconciliation: every TLS connection in flow logs must map to a known certificate. Coverage = matched / total; below ~95% you are prioritising blind.
  • Known-answer canary: deploy an endpoint with a deliberately weak cipher and a hard-coded key. If the scanner misses it, recall is broken and every "clean" result is void.
  • CI gate: diff the CycloneDX CBOM (1.6, 2024) against the previous build and fail on a newly introduced RSA or ECDSA dependency.

Failure modes and how you catch them. Scanner-only blind spots: canary recall test. Dormant paths: an asset with zero observed connections for 90 days is either dead or invisible. Confirm before deleting. Hard-coded keys: secret scanning plus strings on release binaries. Hybrid handshake fragmentation: ML-KEM-768 adds a 1184-byte encapsulation key to the ClientHello, pushing it past 1500 bytes; watch TLS handshake failure rate by client. Signature blowup: ML-DSA-65 signs at 3309 bytes against Ed25519's 64, so a two-cert chain grows from ~144 bytes to ~6.6 KB of signatures. Enough to break JWT headers and constrained devices.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-18

Design and validate a Shor or post-quantum migration workflow for finalized standards.

Answer

Core answer

The threat model sets the order. Shor's algorithm breaks RSA and ECDH/ECDSA once a cryptographically relevant quantum computer exists; the migration target is the finalized NIST PQC standards: FIPS 203 (ML-KEM, key encapsulation), FIPS 204 (ML-DSA, signatures), FIPS 205 (SLH-DSA, stateless hash-based signatures), all published August 2024. Assume a TLS-terminating fleet, a code-signing pipeline, and long-lived firmware.

Four stages: inventory every RSA/ECDSA/ECDH use and record the data's confidentiality lifetime; prioritize key exchange before signatures; deploy hybrid rather than pure PQC during transition; validate against the standard's own test vectors, not against "the handshake succeeded."

Why key exchange first: arithmetic

A TLS session's ECDHE key can be recorded today and decrypted later. If a document must stay confidential for 10 years and a CRQC is plausible within 10–15, the exposure window is already open. Signatures differ: a signature only needs to be unforgeable at verification time, so migrating them later carries no retroactive exposure. That asymmetry is the deciding criterion.

Parameter sets and sizes (FIPS 203/204/205)

AlgorithmSetPublic keyCiphertext / signature
ML-KEM7681184 B1088 B
ML-KEM10241568 B1568 B
ML-DSA651952 B3309 B
ML-DSA872592 B4627 B
SLH-DSA-SHA2-128s—32 B7856 B

ML-KEM-768 is the common default (NIST category 3); ML-DSA-65 matches it. SLH-DSA is the fallback if you distrust lattice assumptions: it costs ~8 KB signatures and slow signing.

Hybrid deployment

X25519MLKEM768 (IANA group 0x11EC) combines classical X25519 with ML-KEM-768, so the session is safe if either is broken. OpenSSL 3.5.0 (April 2025) ships ML-KEM, ML-DSA and SLH-DSA. Hybrid costs bytes: the ClientHello grows by roughly 1.2 KB, which can exceed a 1500-byte MTU and force a second round trip when the certificate chain is large. Measure it on your own path.

Validation

Run the ACVP vectors for the exact parameter set, and check the negative cases. Trace of an ML-KEM-768 validation run:

  1. Load the FIPS 203 ACVP keyGen vector with its seed d, z.
  2. Derive (ek, dk); compare ek to the vector's expected 1184-byte value.
  3. Encapsulate with the vector's m; compare the 1088-byte ciphertext and 32-byte shared secret.
  4. Decapsulate; assert the shared secret matches.
  5. Tamper one ciphertext byte; assert decapsulation returns an implicit-rejection value, not an error.

Step 5 is the one teams skip. ML-KEM uses implicit rejection, so a corrupted ciphertext yields a pseudorandom shared secret rather than a failure. A test that expects an exception passes wrongly.

Failure modes and detection

  • Draft name retained: code imports "Kyber768" or "Dilithium3" from a pre-standard library. Detect by scanning the dependency tree for draft OIDs and names; the finalized names are ML-KEM and ML-DSA.
  • Parameter mismatch: one side negotiates ML-KEM-512, the other 768. Detect by logging the negotiated group ID and alerting on anything below the policy floor.
  • KEM used as signature: ML-KEM has no signing operation, so a wrapper that "signs" with it is broken. Detect by API review: encapsulation and signing must be separate interfaces.
  • Validation status assumed: "it's FIPS 203" without a certificate. Detect by requiring a CMVP certificate number for the module, not the algorithm name.

Trade-offs

Pure PQC now versus hybrid: pure is smaller and simpler but has no classical fallback if a lattice break lands. Hybrid is the safe default until the standards have a decade of cryptanalysis behind them. SLH-DSA versus ML-DSA: SLH-DSA trades ~8 KB signatures and slow signing for hash-only assumptions.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-19

Design and validate a Shor or post-quantum migration workflow for signature choices.

Answer

Assumptions first: I'm signing three classes of things. TLS and network certificates, firmware and code-signing artifacts, and long-lived documents that must verify for ten years or more. If your mix is different, the profile changes but the workflow doesn't. Shor's algorithm breaks RSA and ECDSA, so any signature that must remain unforgeable past the point a cryptographically relevant quantum computer exists needs to move.

Core recommendation: For general-purpose signatures, use ML-DSA (FIPS 204, from Dilithium). For a conservative, hash-based-only trust anchor, use SLH-DSA (FIPS 205, SPHINCS+). For firmware where you control the signer and can manage state, use LMS or XMSS (SP 800-208). During transition, run hybrid: ECDSA plus ML-DSA in the same certificate or signature blob, so a break in either doesn't break you.

Workflow:

  1. Inventory every signature by lifetime and exposure. A 10-year root CA is different from a 90-day TLS cert.
  2. Map to a profile. CNSA 2.0 mandates ML-DSA-87 for national security systems, LMS/XMSS for firmware, SLH-DSA for backup. NIST IR 8547 says deprecate RSA/ECDSA by 2030, disallow by 2035.
  3. Pilot hybrid. Sign with both, verify with both.
  4. Validate with test vectors and negative tests.
  5. Monitor and rotate.

Trade-offs table:

AlgorithmSecurity basisStateful?Public keySignatureWhen not to use
ML-DSA-44Module latticeNo1312 B2420 BIf you need hash-only trust
ML-DSA-65Module latticeNo1952 B3309 BIf size is tight
ML-DSA-87Module latticeNo2592 B4627 BIf device can't fit 4.6 KB
SLH-DSA-128sHash (SHA-256)No32 B7856 BIf signature size matters
SLH-DSA-128fHash (SHA-256)No32 B17088 BIf bandwidth is tight
LMSHash (SHA-256)Yes~32 B~1-2 KBIf you can't persist state
XMSSHash (SHA-256)Yes~64 B~2.5 KBIf you can't persist state

Security levels map to NIST categories: ML-DSA-44 is category 2, ML-DSA-65 category 3, ML-DSA-87 category 5; SLH-DSA-128 is category 1.

Failure modes:

  • State reuse in XMSS/LMS: signing twice with the same one-time key reveals the private key. Detect with a monotonic state counter and a hardware-backed counter; cost is total key compromise.
  • KEM/signature confusion: using ML-KEM as a signature or ML-DSA as a KEM. Detect with type tagging in the API and cross-checking OIDs; cost is accepting invalid signatures or leaking keys.
  • Size overflow: ML-DSA-87 signature is 4627 B; a certificate chain with three of them exceeds 16 KB, breaking some TLS handshakes. Detect with handshake fragmentation metrics; cost is connection failures.
  • RNG failure: lattice key generation needs uniform randomness; a biased RNG leaks the private key. Detect with entropy health tests (NIST SP 800-90B); cost is key recovery.
  • Side channels: lattice rejection sampling has data-dependent branches; timing leaks can recover the key. Detect with timing variance tests; cost is key extraction.
  • Mandate without sector check: CNSA 2.0 requires ML-DSA-87, but a 32-bit microcontroller may not have 4.6 KB of RAM for the signature. Detect with device memory profiling; cost is bricked firmware.

Validation method:

  • Run NIST ACVP test vectors for ML-DSA, SLH-DSA, LMS, XMSS.
  • Cross-implementation: sign with one library, verify with a second (e.g., liboqs).
  • Negative tests: wrong key, tampered signature, wrong message.
  • State reuse test: for LMS/XMSS, attempt to sign twice with the same state and confirm the implementation refuses.
  • RNG failure injection: feed a biased RNG and confirm key generation fails or warns.
  • Size and performance benchmarks: measure handshake size and signing time on target hardware.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-21

Design and validate a Shor or post-quantum migration workflow for crypto agility.

Answer

Opening (60–120s)

I'd assume TLS 1.3 termination on OpenSSL 3.5 or BoringSSL, and data whose confidentiality must outlive the expected arrival of a cryptographically relevant quantum computer. That splits the work into two tracks with different clocks. Key exchange goes first: harvest-now-decrypt-later means ciphertext recorded today is already exposed, so the confidentiality of a 2025 session depends on the key exchange used in 2025. Signatures go second: a forged signature only matters at the moment it's verified, so there's no retroactive exposure.

The design is a five-phase workflow, and the validation is a downgrade test plus an interop matrix, not a code review.

Design: five phases

phasedeliverableexit criterion
1. Inventoryevery endpoint, library, protocol version and negotiated group, from telemetry not from a wikiyou can name the group each service negotiated last week
2. Abstractiona crypto-provider interface so the algorithm is a config value, not a call siteswapping the group is a config change, no rebuild
3. Policyan allowlist of acceptable groups per service class, enforced at the clienta group outside the allowlist aborts the handshake
4. Negotiationhybrid groups offered alongside classicalhybrid selected on the canary fleet
5. Rolloutcanary → 1% → 10% → 100%, with telemetry on negotiated grouphybrid share ≥ target, error rate flat

Mechanism: what a hybrid handshake actually does

Take X25519MLKEM768 (IANA group 0x11EC), the standardized hybrid now enabled by default in OpenSSL 3.5 and shipped by Chrome.

  1. Client sends ClientHello with supported_groups = [0x11EC, 0x001D (X25519)].
  2. Server picks 0x11EC and sends a key_share of X25519 public key (32 bytes) concatenated with the ML-KEM-768 encapsulation key (1184 bytes, FIPS 203).
  3. Client runs X25519 ECDH → 32-byte secret, and ML-KEM-768 encapsulation → 1088-byte ciphertext plus a 32-byte secret.
  4. Both sides concatenate: shared_secret = X25519_ss || MLKEM_ss (64 bytes), fed into the TLS 1.3 HKDF-Extract key schedule.

The security property is that the session is safe if either primitive holds. A future break of X25519 leaves ML-KEM-768 standing, and vice versa.

Why downgrade resistance is a transcript property, not a policy flag

TLS 1.3 hashes the full ClientHello and ServerHello into the transcript, and the Finished MAC covers that transcript. So if a MITM strips 0x11EC from the ClientHello, the server negotiates X25519 and computes its transcript over the modified ClientHello, but the client computes over the ClientHello it actually sent, which still lists 0x11EC. The two transcripts diverge, the server's Finished fails verification, and the handshake aborts. That's the test: run a MITM proxy that strips the hybrid group and assert the connection fails rather than silently falling back.

Validation criteria

  • Downgrade test: strip 0x11EC, expect handshake failure.
  • Interop matrix: each client version × each server version, recording the negotiated group.
  • Cost: X25519MLKEM768 adds roughly 1.2 KB to the handshake (1184-byte key + 1088-byte ciphertext). Measure handshake bytes and CPU on the canary before widening.
  • Telemetry: alert if the hybrid share drops below target. That's the signal a client or LB was rolled back.

Trade-offs and failure modes

  • Hybrid costs handshake size and CPU; if a middlebox chokes on the larger ClientHello, you see it as a connection reset, not a clean error. Detect with canary error rates.
  • "Fallback forever": if the allowlist permits X25519 indefinitely, you never actually migrate. Set a date and remove the classical-only path.
  • Rollback: reverting the group is a config change, but if you've already rotated keys under the new scheme, check that old sessions still decrypt. Keep the previous provider loaded during the window.
  • Signatures: ML-DSA (FIPS 204) certificates are much larger than ECDSA; validate chain size against your TLS record limits before enabling.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-22

Design and validate a Shor or post-quantum migration workflow for hybrid migration.

Answer

Assumptions. TLS 1.3 terminates at a load balancer or CDN; clients are a mix of browsers and service-to-service; some recorded traffic must stay confidential for years. If nothing is recorded and both ends are under your control, hybrid buys less and you can sequence differently.

Core answer. Four phases, each with a validation gate that must pass before the next.

Phase 1: Inventory and rank by exposure. Enumerate every RSA/ECDSA use: TLS endpoints, mTLS, code signing, firmware, data at rest, key wrapping. Rank by how long the secret must survive. Recorded TLS traffic and long-retention archives go first, because a harvest-now-decrypt-later attacker only needs to store ciphertext. Authentication goes later: a forged signature needs a live attacker, not a recording.

Phase 2: Hybrid key exchange at the TLS layer. Deploy X25519MLKEM768 (draft-ietf-tls-ecdhe-mlkem, codepoint 0x11EC). The combiner is plain concatenation: the 32-byte X25519 shared secret followed by the 32-byte ML-KEM-768 shared secret, and that 64-byte string is the (EC)DHE input to the TLS 1.3 key schedule, where HKDF-Extract is the KDF. You do not hash the two yourself: the key schedule already does. Security is the stronger of the two: an attacker must break both.

Phase 3: Hybrid/composite signatures for authentication (draft-ietf-lamps-pq-composite-sigs), once your CA and clients support them. Phase 4: pure PQC where the ecosystem allows.

Validation gates.

PhaseTestPass criterionFirst production miss
1Crypto discovery scan + owner sign-offEvery endpoint mapped to an owner and a retention classUnmapped internal mTLS service
2Downgrade test: MITM strips 0x11EC from ClientHelloServer refuses classical-only when policy requires hybrid; alert firesSilent fallback to X25519-only
2Interop matrix across client/server versionsAll supported pairs complete the handshakeOld middlebox drops the large ClientHello
2ACVP known-answer tests for ML-KEM-768Encaps/decaps vectors matchCustom combiner diverges from the draft
3Chain-size test on constrained clientsHandshake completes within record limitsComposite cert exceeds the client buffer

Size arithmetic. X25519MLKEM768 key_share = 32 (X25519) + 1184 (ML-KEM-768 encapsulation key) = 1216 bytes; with ClientHello framing, roughly 1400 bytes. That no longer fits in one QUIC Initial packet (minimum 1200 bytes), so the ClientHello spans multiple CRYPTO frames: a path some stacks handle poorly. Test it explicitly rather than assuming TCP segmentation saves you.

Failure modes and detection.

  • Downgrade. TLS 1.3's downgrade sentinel covers version, not group. Log the negotiated group per connection and alert when a hybrid-capable client negotiates X25519-only.
  • Failure-open. If the PQC half errors and the stack falls back to classical-only, you get no security and no signal. Assert the negotiated group in the handshake and fail closed.
  • Combiner misuse. Wrong order, truncation, or using only one secret collapses security to the weaker half. Catch it with ACVP KATs and code review against the draft.
  • Size. Large ClientHellos and composite cert chains cause handshake failures on constrained or middleboxed paths. Watch handshake failure rate by client version and TCP retransmit metrics.

Trade-off. Hybrid costs about 1.2 KB per handshake and roughly doubles the key-exchange work. It is worth it while ML-KEM is young and while you cannot rule out an imminent classical break. Skip it only when there is no recording threat and you control both ends.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-24

Design and validate a Shor or post-quantum migration workflow for demo boundary.

Answer

Clarify first. The prompt bundles two things that share only a boundary: a Shor's-algorithm demo that claims to threaten RSA, and a post-quantum migration. I'll answer both, because the deciding question in each is the same, where does a demonstration stop being evidence of a real capability?

Shor demo: the mechanism. Shor factors N by reducing it to order finding: find r with a^r ≡ 1 (mod N), then gcd(a^(r/2) ± 1, N) yields the factors. Only the order finding is quantum (phase estimation on a modular-exponentiation unitary); factor extraction is classical continued fractions.

Worked trace, N=15, a=2:

  • 2^1=2, 2^2=4, 2^3=8, 2^4=16 ≡ 1 (mod 15) → r=4.
  • r is even, a^(r/2)=4, and 4 ≢ −1 (mod 15).
  • gcd(4−1,15)=3, gcd(4+1,15)=5 → 15 = 3×5.

That trace is the entire algorithm for N=15, and it runs on paper. That is the demo boundary: the order is 4, the modular-exponentiation unitary is small enough to compile with the answer baked in, and the quantum step can be replaced by a phase oracle that already knows r.

N=15 demogeneric order findingRSA-2048 break
circuitcompiled, answer hardcodedparameterized by Nparameterized by N
qubitssingle-digit logicalgrows with N~20M physical, 8 h (Gidney & Ekerå 2021)
who factorsclassical post-processingclassical post-processingclassical post-processing

Failure modes, with detection:

  • Post-selection on noise. Keep only shots that return r and the success rate is fiction. Detect by reporting the raw accepted-shot fraction before any filtering; if it is absent, the result is not evidence.
  • Base chosen for a trivial order. a=2 mod 15 gives r=4. Detect by re-running with random a and reporting the distribution of r, not one lucky value.
  • Linear extrapolation. Qubit counts do not scale linearly: error-correction overhead dominates. Detect by comparing against a published resource estimate instead of a fitted line.
  • Demo marketed as a break. Detect by asking what N the circuit accepts as a parameter; a hardcoded 15 is a lesson, not a capability.

PQC migration workflow. Design: discover → inventory → prioritize → hybrid pilot → enforce → retire.

  • Discover/inventory: build a cryptographic bill of materials. Every TLS endpoint, certificate, key and library.
  • Prioritize by harvest-now-decrypt-later: long-lived secrets (health, government, anything needing >5–10 years of confidentiality) move first.
  • Pilot hybrid: X25519MLKEM768 in TLS 1.3 (deployed by Chrome and Cloudflare in 2023). ML-KEM-768 (FIPS 203, Aug 2024) has a 1184-byte encapsulation key and 1088-byte ciphertext, against X25519's 32 bytes.
  • Enforce, then retire the classical-only path.

Validation: an interop matrix across clients; measure handshake bytes and watch for TLS record fragmentation, since the larger key share can split the ClientHello across records; confirm signatures with ML-DSA (FIPS 204) or SLH-DSA (FIPS 205).

Trade-offs: hybrid costs bytes and CPU but survives a break of either primitive; pure PQC is smaller but drops classical assurance mid-transition. Decide by data lifetime against migration cost.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-25

Design and validate a Shor or post-quantum migration workflow for migration evidence.

Answer

Assumptions first. "Migration evidence" here means a per-asset record proving each cryptographic dependency moved off a quantum-vulnerable algorithm, plus the test that proves it. I assume a mixed estate: TLS endpoints, code-signing keys, at-rest encryption, and long-lived archives. The workflow has four stages, and each stage emits an artefact a reviewer can check.

1. Discover: build a CBOM. Scan for algorithm use, not library versions. Output is a CycloneDX CBOM with one entry per key or certificate: algorithm, key size, protocol, owner, data lifetime. This is the only stage that automates cheaply; everything downstream depends on it being complete.

2. Classify by lifetime, not by a Q-day date. There is no single Q-day. The deciding number is the confidentiality lifetime of the data against the migration horizon. A 10-year secret plus a 5-year migration means the ciphertext is already exposed to harvest-now-decrypt-later. That arithmetic sets priority:

data lifetimemigration horizonverdict
1 year5 yearsdefer
10 years5 yearsmigrate now
25 years (archive)5 yearsmigrate now, re-encrypt

3. Migrate: hybrid first, then pure. For TLS, deploy X25519MLKEM768 (ML-KEM-768, FIPS 203) alongside X25519 so a break in either is survivable and old peers still connect. For signatures, ML-DSA-65 (FIPS 204) is the default; SLH-DSA (FIPS 205) only where you need stateless hash-based assurance and can pay the 7,856-byte signature. Keep an algorithm-agility layer so the next swap is config, not a rewrite.

4. Validate: negative tests plus independent attestation. A migration is not done because the config says ML-KEM. It is done when a test proves the old algorithm is gone and a second party confirms it. A CI gate over the CBOM, checked against jq 1.7:

Shell
# fail the build if any certificate entry is RSA/ECC or has no owner
jq -e '[.components[]
  | select(.cryptoProperties.assetType == "certificate")
  | select(.cryptoProperties.algorithmProperties.primitive == "rsa"
        or .cryptoProperties.algorithmProperties.primitive == "ecc")
  | select(.supplier.name == null)] | length == 0' cbom.json

Failure modes and how each is detected:

  • Invented deadline. Detected by: no single date in the plan; priority is per-asset lifetime. A plan with one Q-day fails review.
  • Standards drift. Pin to FIPS 203/204/205 and CNSA 2.0; a quarterly diff against NIST IR 8547 flags deprecation changes.
  • Missing owner. CBOM entries without an owner fail the gate above.
  • Long-lived data ignored. Lifetime is a required field; blank fails the scan.
  • No implementation assurance. Require ACVP/CAVP test vectors for the library, not just the algorithm name.
  • Self-attested completion. Require a negative test (handshake fails against an RSA-only peer) and a second reviewer.

Trade-offs: hybrid costs roughly 1.2 KB per ClientHello and some middlebox breakage; pure PQC is smaller on the wire but loses fallback. ML-DSA-65 signatures are ~3.3 KB, which breaks some certificate chains: that is why SLH-DSA exists, but it is rarely the right default.

Curated: · Written: · Reviewed:

Difficulty: Hard