← All projects

Two Dials That Disagree

Full report (PDF)Architecture diagram (PDF)Raw README (Markdown)
Starting Python in your browser …

Everything above runs locally in this tab, on the project's own experiment.py — no server, and nothing precomputed. The first visit downloads a Python runtime, so give it a moment.

Full write-up, result figures and method

Winternitz parameter selection for signature size and for the blast radius of state failure.

Hash-based signatures are one-time by construction: a W-OTS key signs once, and a state failure that reuses it leaks chain material. The Winternitz parameter w is chosen for signature size and speed. This asks what it does to the damage when state management fails, and the two criteria point opposite ways.

Architecture diagram

The question

Every treatment of stateful hash-based signatures says never reuse a one-time key. None says how bad one slip is. State failure is the real deployment risk: a restored backup, a cloned image, a counter reset after power loss. An operator who finds one duplicated index has to decide whether to rotate keys or scrap the device, and there is no number to decide with.

The attacker modelled here does no cryptanalysis at all. They hash forward from values the signer has already published, which is a public operation.

What it found

The blast-radius curve. Forgeable fraction against the number of times a key is reused:

reusesforgeable fraction
1–4below Monte-Carlo resolution
51 in 12,000
61 in 2,400
71 in 750
81 in 185

Exposure is non-monotonic in w, and the extremes are the worst choices. At four reuses, forgeability is 1.902e−06 at w = 2 and 5.942e−04 at w = 8, making w = 8 about 312× more exposed. That is the opposite of the size-driven recommendation for radio-bound devices, where a large w is attractive because it shortens the signature. The two dials disagree, and the disagreement is the result.

The small probabilities needed a model, and the model needed validating twice. Sampling cannot resolve a one-in-a-million event at any practical trial count, so the curve rests on a closed-form random-oracle digit model. It is checked against Monte Carlo wherever Monte Carlo resolves, and against an exact conditional computation that includes the checksum coupling the model ignores. The model is accurate to 1–3%.

An apparent 0.64 to 0.97 disagreement between model and simulation looked like a flaw in the model and was not. The Monte Carlo's trials=300 meant 30 scenarios, because the loop read range(trials // 10): the parameter name hid a factor of ten, and the resulting ±33% sampling error was mistaken for model error. The loop now takes an explicit scenarios argument.

Exposure against the Winternitz parameter

Scope

schemeW-OTS and a Merkle tree over it, not full XMSS or SPHINCS+
implementationLamport, W-OTS and Merkle written from scratch on hashlib alone
cost metrichash-function calls, not wall-clock, so ratios are meaningful and absolute times are not
modelrandom-oracle digit model, exact for w dividing 8
validationexact conditional computation, plus Monte Carlo where resolvable
showsstate-failure exposure is non-monotonic in w, and the selection rule that follows
does not showfull-scheme security proofs, or the behaviour of real stateful signers under real fault conditions

Running it

pip install -r requirements.txt
python experiment.py              # Lamport, W-OTS, Merkle, size and cost
python experiment_statereuse.py   # how fast key reuse becomes forgery
python experiment_analytic.py     # closed-form model and its validation
scriptruntimeoutputs
experiment.py~60 sresults.json, figure_pqc.png
experiment_statereuse.py~2 minresults_statereuse.json, figure_statereuse.png
experiment_analytic.py~3 minresults_analytic.json, figure_analytic.png

CPU only, no download. Pure hashlib, no cryptographic library.

Full write-up

The complete report, with the derivation of the model, the exact conditional computation and the size-versus-exposure selection rule, is in report.pdf. The architecture diagram is also available as architecture.pdf. The report’s closing section states the limitations of every result in full.

Result figures

Plots produced by the experiment scripts in this folder, referenced from the full report.

Analytic
Analytic
Pqc
Pqc
Statereuse
Statereuse