← Back to section · Post-Quantum Cryptography
Merkle Trees: One Tree, a Million One-Time Keys
How a Merkle tree folds a multitude of one-time public keys into a single root: one public key good for a million signatures, logarithmic authentication paths, and the engineering trade-offs of tree height and traversal.
Lamport signatures left a problem behind: one key, one signature. If every signature required a fresh key with its own separately distributed public key, key management would crush the system. Ralph Merkle’s 1979 hash tree is the elegant answer: organize a large number of one-time public keys into a binary tree, hash them together layer by layer, and publish a single root. One public key now stands behind thousands upon thousands of signatures, and the one-time constraint becomes something you can count and manage. This tree is the skeleton of every stateful hash-based signature scheme that followed.
From leaves to root: folding commitments
Construction starts at the leaves. Generate 2^h one-time key pairs (Lamport or Winternitz keys, say); hash each one-time public key into a leaf node; then pair adjacent leaves and hash them into the layer above, continuing upward until a single node remains — the root. The root is the system’s public key, just one hash value in size. On the private side, the signer keeps all the one-time private keys (or a seed from which they are deterministically derived) plus a counter recording which leaf has been reached.
In essence the tree is a batch commitment: the root cryptographically binds every leaf beneath it. Replacing any one-time public key would change the entire chain from that leaf to the root and fail to match the published root — unless the attacker finds a hash collision. So the statement “this one-time key belongs to this tree” can be proven with very little evidence.
Authentication paths: logarithmic proofs
To sign, the signer uses the one-time private key of leaf i, and attaches two things: that leaf’s one-time public key, and the authentication path from the leaf to the root — the sibling hash at each layer along the way. For a tree of height h, the path has exactly h hashes.
Verification takes two steps. First, verify the message signature against the one-time public key, as in Lamport or Winternitz verification. Second, hash the one-time public key into its leaf and fold it together with the authentication path, layer by layer, up to the top, and check that the result equals the published root. One detail in the folding cannot be skipped: at each layer it matters whether the current node is the left or the right child, and the concatenation order is fixed by the bits of the leaf index — get the order wrong and the recomputed “root” is simply a different value. The verifier needs to trust nothing the signer supplies beyond the published root and the hash function itself; every hash on the path is recomputed by the verifier’s own hand, which is exactly why this proof is both short and hard. If both pass, the signature came from a legitimate one-time key in the tree, used exactly once. Both the computation and the extra signature size grow only with the height h, while the total number of signatures is 2^h: a height-20 tree signs over a million messages, and each signature carries just 20 extra hashes. That is the power of logarithmic scaling.
Height and traversal: the engineering core of stateful schemes
Tree height is the most important parameter in these schemes, and it pulls several curves at once. A taller tree signs more messages and amortizes the master key better; but key generation must compute every leaf and internal node, a cost that grows exponentially in h (mitigated in practice by seed-based derivation and on-demand generation); and the authentication path must be refreshed after every signature — having signed with leaf i, the next signature needs the path for leaf i+1, and recomputing the whole tree each time is out of the question.
“Traversal” therefore became a research topic in its own right: how to emit the authentication path of each successive leaf while storing only a few nodes and doing only a few hashes per step. Classical traversal algorithms bring both storage and per-step work down to the order of the tree height, making tall trees practical even on embedded devices. Much of the implementation quality of XMSS and LMS comes down to exactly this: key generation and traversal engineering.
Storage on the private side is solved by deterministic derivation: instead of storing every one-time private key, the signer keeps a single master seed, and each leaf’s one-time key is computed on demand from the seed and the leaf index through a pseudorandom function, then discarded after use. Private-key storage drops from proportional to the number of leaves to a constant — and as a bonus, forward security becomes possible: spent leaf keys never linger on the device, so a later compromise cannot endanger the unforgability of earlier signatures. Seed derivation, on-demand generation and traversal algorithms together are what turned the Merkle tree from a mathematical construction into a system component that can run for decades on constrained devices.
One precondition cannot be engineered away: the counter. A leaf, once used, is spent, and the counter may only move forward — never back — or the same one-time key signs two messages and the collapse described in the Lamport article follows. The Merkle tree solved scale, but it handed deployers the duty of keeping that state reliably monotonic. Every operational rule around stateful hash-based signatures grows out of this lesson of the tree.
Closing
The Merkle tree turned one-time signatures from a mathematical curiosity into a countable signing resource: one short public key, millions of signatures, logarithmic per-signature cost. It did not remove the one-time constraint; it made the constraint manageable — at the price of state. All of the specification work in XMSS and LMS consists of fitting this tree with more compact one-time components (Winternitz chains), finer parameters and stricter state discipline; the stateless SPHINCS+ route, by contrast, decided to pay with very large signatures to be rid of the state obligation entirely. Understand the Merkle tree and you hold the key to the whole family.
Tags: Merkle treehash treeone-time signaturesauthentication path