Everything below runs in this tab, in js/wots.js — the same
functions as blackhole/src/wots.cairo, over the same field, in the
same field order, and diffed against the vectors snforge printed
out of the Cairo itself. Nothing is sent anywhere. Nothing is deployed anywhere.
01 Make a one-time key
—
One felt is all a wallet keeps. The seed, all 66 chain secrets and the public key come
out of it: sk[i] = Poseidon(DOMAIN_WOTS_SK, master, i), each
walked all fifteen steps, the tops folded into one hash.
master
—
seed
—
public key
—
hashes
—
02 Build the spend
note::spend_message
The six fields a signature commits to. The last one is the payee — which is the whole
point, so it is the one you will change in step 04.
shield
—
message
—
03 Sign it, and verify it
—
The message becomes 63 base-16 digits; the checksum adds 3 more. Chain i is its
secret walked d[i] steps. Verifying walks each one the rest of the way and folds
the tops back into a key — so the verifier never sees a secret, only a key coming out.
63 message chains3 checksum chainsheight = the digit, 0 to 15
—
checksum
—
steps walked
—
recovered
—
verdict
—
04 Take it
the attack this was built for
You are a watcher, or the sequencer. You have the whole transaction before it lands: the
seed, all 66 signature felts, the nonce, the leaf index, the twenty siblings. Change the
payee to your own address and send it first.
—
new message
—
key recovered
—
note rebuilt
—
the leaf in the tree
—
contract says
—
Why walking forwards is not enough
The checksum always leaves one chain short.
An adversary holding one signature can walk any chain forwards — that is just
hashing, and anybody can hash. So every message whose digits are all at least as large is
reachable. The checksum is sum(15 − digit): raise any digit by one
and it falls by exactly one, which means at least one of the three checksum chains has to be
walked backwards. Walking a hash chain backwards is a preimage.
In the Cairo
test_wots
raising_any_digit_lowers_the_checksum raises every raisable
digit of a real message, one at a time, and asserts the checksum drops by exactly one
each time. the_best_forgery_an_adversary_can_build_does_not_verify
then builds the forgery above in Cairo, counts the chains it could not reach, and
asserts both that the count is not zero and that the result recovers a different key.
And in this tab
—
The port is only worth what it is diffed against. Every number this page computes
answers to a line snforge printed out of the contract: the
parameters, all 66 digits of eight messages, chain steps at both ends of a chain, whole
keys, whole signatures, and the key each one recovers.
checking…
!
One key signs once — and here it cannot sign twice.
Two signatures under one Winternitz key leak enough chain values to forge a third
message. In this design a key opens exactly one leaf, and the first spend that lands
burns that leaf's nullifier, so the second signature has nothing left to authorise. The
bound on key reuse is the nullifier set, not the user's discipline. The one way to
misuse it that the contract cannot see is minting a replacement note under the
same master — which is why a_moved_note_must_be_minted_under_a_fresh_key
exists as a test rather than as advice.