
MerkleBNB is a vault on BNB Chain whose withdrawals are authorized by XMSS hash-based signatures — not by ECDSA. The signature scheme is verified inside the contract, its state is enforced by the contract, and its implementation is byte-for-byte compatible with the reference implementation of the standard.
A scaled model of the vault's key (h = 7: 128 signatures instead of 1,024), signing live in this browser. Each tick spends one index — the leaf lights, its authentication path folds to the root, recomputed with the same thashH the contract runs. When the key is exhausted it rotates to a fresh tree, exactly as the vault requires near index 1,000.
Both panels below run live in your browser. On the left, the attack that ends ECDSA: Shor's algorithm is polynomial, so under a cryptographically relevant quantum computer it always finishes. On the right, the only generic quantum attack on SHA-256 — Grover's — measured on your own hardware, against the full 2¹²⁸ preimage space it would have to search.
Projected scenario: a cryptographically relevant quantum computer runs Shor's algorithm against an exposed public key. The work is polynomial, so the race is not close — the key is recovered, in full, every time. "Harvest now, decrypt later" means the recording of today's keys has already started.
At your device's measured rate, finding one preimage takes ≈ — years
The universe is ≈ 1.38 × 10¹⁰ years old. Grover's algorithm only halves the exponent — a 2²⁵⁶ search becomes 2¹²⁸ — it does not make the search finishable, on this hardware or any projected quantum hardware.
The counter above is real: this device is hashing right now, and the bar is honest — it does not move. That immobility is the entire security argument of this vault, demonstrated instead of asserted.
MerkleBNB's vault authorization depends on SHA-256 preimage resistance only. There is no discrete logarithm to recover — on this scheme, the left race has no track to run on.
Every BNB Chain account is authorized by an ECDSA signature over the secp256k1 curve. Its security is the elliptic-curve discrete logarithm problem — a problem that a sufficiently capable quantum computer running Shor's algorithm solves in polynomial time. Once a public key is exposed on-chain (and on an account-model chain, public keys are exposed by use), the corresponding private key is, in principle, recoverable.
The attack does not need to happen in real time. Adversaries can record encrypted traffic and exposed keys today and exploit them when the hardware matures — "harvest now, decrypt later". Long-lived vault assets are exactly the exposure window this attack is built for. The question is not whether the industry migrates; it is whether your assets sit behind a signature scheme that survives the migration deadline.
Breaks factoring and discrete logarithms — RSA, ECDSA, Ed25519. It does not apply to hash functions. There is no Shor attack on SHA-256.
The best generic quantum attack on a hash: a quadratic speedup. A 256-bit hash keeps 128 bits of security — the design target of the XMSS-SHA2_*_256 parameter sets.
XMSS security reduces to the preimage resistance of SHA-256 — the same primitive that secures Bitcoin addresses and proof-of-work, with decades of cryptanalysis behind it. No lattices, no codes, no isogenies: no structured assumption to collapse.
The stateless alternative (SLH-DSA, FIPS 205) needs 7,856+ byte signatures and tens of thousands of hashes per verification — impractical in the EVM today. XMSS is compact, and its one weakness — state — is precisely what a smart contract can enforce. See §03.
One XMSS key is a binary Merkle tree of height 10 over 1,024 WOTS+ one-time keys. Each WOTS+ public key is compressed by an L-tree into one leaf; the tree's single 32-byte root — together with a public seed — is the public key. A signature reveals one one-time signature plus the 10 sibling hashes that reconnect its leaf to the root. Verification recomputes the root and compares. Nothing else is trusted.
| Parameter | Symbol | Value | Note |
|---|---|---|---|
| Hash output length | n | 32 bytes | SHA-256 (FIPS 180-4), via EVM precompile 0x02 |
| Winternitz parameter | w | 16 | Each chain has positions 0..15 |
| Message digits | len1 | 64 | ceil(8n / log2 w) |
| Checksum digits | len2 | 3 | floor(log2(len1·(w−1)) / log2 w) + 1 |
| WOTS+ chains | len | 67 | len1 + len2 |
| Merkle tree height | h | 10 | 2^10 = 1,024 one-time keys |
| WOTS+ signature | len·n | 2,144 bytes | 67 chain values |
| Authentication path | h·n | 320 bytes | One sibling hash per level |
| Full signature | — | 2,500 bytes | idx(4) ‖ R(32) ‖ WOTS+ sig(2,144) ‖ auth(320) |
| Public key | — | 64 bytes | root(32) ‖ PUB_SEED(32) |
A scaled model of the production tree (h = 4, 16 leaves instead of 1,024). Node hashes are computed live in your browser with the genuine RFC 8391 tree-hash (thashH with hashtree addresses). Click any leaf: the page derives its authentication path — the sibling hash at every level — and folds it back to the root.
—
Leaf values in this model are stand-in hashes of their labels; in production a leaf is the L-tree root of a WOTS+ public key (§02 table). Node hashing, addressing and the path fold are the real algorithm. At h = 10 the path is 10 siblings = 320 bytes.
On-chain, the contract takes index and auth path as separate arguments and wotsSig = R ‖ WOTS+ sig (2,176 B); the byte content is identical to the canonical encoding.
Schematic — heights are illustrative, not computed from a real digest. Each column is one WOTS+ chain; a signature reveals one position per chain, set by a base-16 digit of the message digest (64 message digits + 3 checksum digits). Verification completes every chain to position 15, then folds the 67 tops through the L-tree.
A stateful scheme is only as safe as its counter. WOTS+ key reuse is catastrophic — sign two messages at one index and an attacker can forge — and counters are exactly what client software gets wrong (backups, restores, parallel devices). PQVaultV2 therefore makes the contract the state authority: it stores nextIndex, accepts a withdrawal only at index == nextIndex, and increments the counter in the same transaction, before any transfer. Reuse and index-skipping are not discouraged; they are impossible on-chain.
The same discipline covers every path that can move funds or change keys. An early draft let the wallet's ECDSA key rotate the XMSS key on its own — a backdoor that would have voided the entire post-quantum claim, found in review and closed. Today, rotation itself requires an XMSS signature under the current key. The withdrawal digest binds chain ID, vault, user, token, recipient, amount and index, so a signature cannot be replayed across chains, contracts, tokens or amounts.
| Action | Authorized by | Effect / rule |
|---|---|---|
| withdraw | XMSS signature (consumes nextIndex) | The only path that moves funds. Index must equal nextIndex. |
| rotateVault | XMSS signature under the current key | Installs a fresh key, resets the counter, clears any pending recovery. A previously used root can never be re-activated. |
| cancelRecovery | XMSS signature under the current key | Vetoes a pending recovery at any time inside the 30-day window. |
| initiateRecovery | ECDSA | No immediate effect. Registers a pending root and starts a public 30-day timelock — the seed-loss path. |
| finalizeRecovery | ECDSA + timelock expired | Installs only a root that sat publicly pending for the full 30 days, unvetoed. |
| registerVault | ECDSA | Initial binding, before any funds depend on the root. Binds a root to the caller's own address only. |
| deposit | ECDSA | Can only add funds to the caller's own balance. Cannot endanger existing funds. |
Any call with index ≠ nextIndex, an invalid XMSS signature, or a previously used root reverts. A key holds 1,024 indices; operational guidance is to rotate near index 1,000. Withdrawal recipients are bound by the signature and may be addresses that have never appeared on-chain — the authorization step exposes no ECDSA public key.
| Operation | Gas | @ 0.05 gwei |
|---|---|---|
| XmssSha256.verify() | 2,124,458 | ≈ 0.000106 BNB |
| PQVaultV2.withdraw() | 2,576,477 | ≈ 0.000129 BNB |
| PQVaultV2.rotateVault() | 2,388,207 | ≈ 0.000119 BNB |
| PQVaultV2.cancelRecovery() | 2,427,046 | ≈ 0.000121 BNB |
| PQVaultV2.initiateRecovery() | 97,599 | ≈ 0.0000049 BNB |
| PQVaultV2.finalizeRecovery() | 62,491 | ≈ 0.0000031 BNB |
Gas usage is rate-independent; 0.05 gwei is the observed BSC rate as of Dec 2026, not a guarantee. Verification cost ≈ 500 chain steps + 66 L-tree hashes + 10 path hashes, ≈ 1,800 SHA-256 precompile calls.
A signature scheme you implement yourself is a claim, not evidence. The strongest public evidence available is interoperability with the authors' own code: our test vectors are the full bytes exported by the unmodified XMSS reference implementation, fingerprinted against its stock test program's output. Our signer reproduces its public key and its signatures at indices 0, 1 and 512 byte-for-byte, and the reference implementation's signatures verify inside our Solidity contract. Below, the same check runs in your browser.
This panel carries a verification-only port of the same algorithm (WOTS_pkFromSig → L-tree → root reconstruction, RFC 8391 Algorithms 6, 8, 13). Press the button: your browser recomputes the root implied by the reference signature and compares it against the reference root. No server is involved; view source and check the math yourself.
| Cross-check | Method | Result |
|---|---|---|
| JS keygen vs reference public key | scripts/check-vectors.js | Byte-for-byte identical |
| JS signatures @ idx 0 / 1 / 512 vs reference | scripts/check-vectors.js | Byte-for-byte identical (3/3) |
| Solidity verify accepts reference signatures | test/xmss-vectors.test.js | 3/3 |
| Python (hashlib) third implementation: chains, digits, leaf | scripts/python-crosscheck-xmss.js | Three-way agreement (JS · Solidity · Python) |
| Tamper rejection (message / index / auth / signature element / truncation) | test suite | All rejected |
| Vault state machine + authorization model | test/pqvault2.test.js | 16/16 |
| Full test suite | npx hardhat test | 29/29 |
Note: NIST SP 800-208 publishes no official known-answer tests. These vectors are the reference implementation's own test system — which is precisely why matching them is meaningful: it is the same code the standard's authors ship.
| Property | ECDSA · secp256k1 | ML-DSA-44 · FIPS 204 | XMSS-SHA2_10_256 · RFC 8391 |
|---|---|---|---|
| Hardness assumption | Elliptic-curve discrete log | Module-LWE / Module-SIS (structured lattices) | SHA-256 preimage resistance only |
| Signature size | 65 B | 2,420 B | 2,500 B |
| Public key size | 33 B | 1,312 B | 64 B |
| Stateful | No | No | Yes — enforced by the vault contract |
| Shor's algorithm | Breaks it | Resistant (by design) | Not applicable |
| Grover's algorithm | Not applicable | Resistant (by design) | 128-bit security remains |
| Status on BNB Chain | Current default — the thing being replaced | BEP-736 precompile proposed; testnet targeted in 4–8 weeks | This project: application-layer verification, working today, no protocol change required |
BNB Chain's BEP-713 roadmap (3 Dec 2026) migrates the protocol itself in four phases; its BEP-736 draft proposes native precompiles for ML-DSA-44 and the stateless hash-based SLH-DSA-SHA2-128s. MerkleBNB operates one layer up: the vault's authorization is post-quantum now, independent of the protocol timeline — and a future precompile would only make the same verification cheaper.
Ralph Merkle's dissertation introduces one-time signatures, the Merkle tree, and the construction this project is named after — 47 years of cryptanalysis and counting.
The IETF publishes XMSS as an RFC; the SHA2 parameter sets are marked mandatory for deployment.
NIST approves XMSS and LMS for use in US federal systems, with state management as the central operational requirement.
ML-KEM, ML-DSA and SLH-DSA become federal standards. Hash-based signatures are standardized in both stateful (SP 800-208) and stateless (FIPS 205) forms.
US agencies urge operators of national-security systems to speed the move to post-quantum cryptography.
BEP-713 sets out a four-phase migration of BSC accounts and consensus; BEP-736 proposes signature-verification precompiles, testnet targeted within 4–8 weeks.
A working, vector-verified XMSS implementation and a state-enforcing vault, in development on the application layer — the layer users can actually choose today.
The full technical brief: scheme identification, parameter set, security analysis (including the rotation threat model and the hole it closed), the SHA-256 vs Keccak decision record, test-vector provenance and cross-check results, gas benchmarks, the contract state machine, limitations, and reproduction commands. Every number on this page traces to it.