I’d like feedback on a draft ERC that says how a wallet derives hash-based post-quantum keys (leanSPHINCS, SLH-DSA, WOTS, FORS, XMSS) from a BIP-39 phrase.
Why
Contracts already verify hash-based signatures through ERC-1271 and account abstraction, and EIP-8288 would aggregate leanSPHINCS. Users back their accounts up with BIP-39 phrases, but no standard says how a phrase becomes a hash-based key, and implementations have diverged:
- from the BIP-39 entropy, with Keccak-256 over application labels (the Winterlock signer I work on does this today);
- through a second PBKDF2 over the phrase with its own salt (WOTS-39);
- through HMAC-SHA512 over the BIP-39 seed under its own label (a hardware wallet in development).
So the same phrase gives different keys in different wallets, and restoring it elsewhere does not restore the keys.
A wallet that already has BIP-32 might derive these keys through it. That would bring a problem of its own. Every BIP-32 node has an elliptic-curve public key. Given an account-level xpub, which wallets export to watch-only software all the time, a quantum adversary computes that node’s private key and then every hardened child below it.
What
Every secret is derived with HMAC-SHA512: in BIP-39’s own PBKDF2, then in HKDF (RFC 5869). No BIP-32, no curve arithmetic.
S = BIP39-Seed(mnemonic, passphrase) 64 bytes, as BIP-39
R = HKDF-Extract(salt = "HBKD/v1", S)
seed = HKDF-Expand(R, info, L)
info = purpose || be32(account) || be16(L) || len8(name) || name || tail
purpose 0x01 stateless key name = key type
purpose 0x02 stateful key (optional) name = key type, tail = context || instance
purpose 0x03 application secret (optional) name = the application's label
The core is small. A wallet conforms if it derives the root, and a seed for each stateless key, named by an account and a key type. The draft defines the twelve SLH-DSA key types of FIPS 205 itself, for example SLH-DSA-SHA2-128s: the seed is cut into SK.seed, SK.prf and PK.seed. So two conforming wallets get the same SLH-DSA public key from the same phrase. When a fork fixes a new parameter set, the wallet derives a new key from the same phrase and the old key certifies it. No new backup.
Three parts are optional, because no two wallets need to agree on them:
- Stateful keys (WOTS, FORS, XMSS) are never restored. Each instance takes 32 fresh random bytes, stored with its state, so a restored wallet cannot sign twice with a one-time key.
- Application secrets, one per label.
- Random roots for devices and automated signers, which hold no phrase. The phrase’s stateless key certifies and revokes their keys.
The draft has test vectors and a short Python reference implementation. The vectors cover three phrases (two of them BIP-39’s own TREZOR vectors), a random root, accounts 0, 1 and 2^32 − 1, stateful instances, app secrets, inputs that must be rejected, and three SLH-DSA keys from phrase to public key, which two independent libraries reproduce. A second implementation, in no_std Rust for browsers and microcontrollers, reproduces every value.
Questions
- Seed or entropy? The draft derives from the BIP-39 seed, so passphrases and hidden wallets keep working and wallets that keep only the seed can implement it. The cost: a mistyped passphrase gives valid but wrong keys, so wallets should show a fingerprint after a restore. Should this ERC fix the fingerprint’s format, so that two wallets show the same one?
- The
infolayout. Every field has a fixed width or a length byte, and the output lengthLis part ofinfo, as in TLS 1.3. Is anything missing, or in the wrong place? - Key types. The draft defines SLH-DSA’s. Other schemes, such as leanSPHINCS once its parameters settle, would define theirs in their own specs. Is that the right split, or should this ERC keep a registry?
- Stateful keys. Is “a random instance, never restored” right, or is there a case for a deterministic counter, for example on devices without reliable storage?
- Hardware wallets. Is anything here hard on a device that stores only the BIP-39 seed?
- Agents and other automated signers. The draft says a signer that can be copied (a VM snapshot, replicas, an agent started several times from one image) must not hold one-time keys, because two copies would sign with the same key. It asks automated signers to hold their own random root, not the phrase, and to use key types whose signature limit they cannot reach. If you build agent wallets: does that match how your agents hold keys, and what is missing?