ERC-8499 BIP-39 hash-based key derivation (Hash-Based Key Derivation from BIP-39)
Draft · Signatures & auth · created 2026-11-13
Defines a way for wallets to always derive hash-based quantum-resistant signing keys (such as SLH-DSA) from a BIP-39 recovery phrase in the same manner, so that any wallet can restore the same key from the same phrase.
Why it is needed
Hardware wallets and software wallets have already begun supporting hash-based quantum-resistant signatures (such as leanSPHINCS), but there is no common rule for how to extract these keys from a BIP-39 recovery phrase. Some wallets apply Keccak-256 to the BIP-39 entropy, others rerun BIP-39's PBKDF2 with their own salt, and still others attach their own label to the BIP-39 seed and apply HMAC-SHA512. As a result, entering the same recovery phrase into a different wallet produces an entirely different key, and a quantum-resistant account created in one wallet cannot be restored in another wallet or recovery tool. Moreover, if such a key is derived through a path that passes through an elliptic curve public key, as in BIP-32, then if a quantum computer recovers the private key from that public key, the hash-based key could be put at risk along with it.
In depth
Creating the root secret R
Using the mnemonic sentence M and the passphrase P (an empty string if none is given), PBKDF2-HMAC-SHA512 as used by BIP-39 is run 2048 times to obtain a 64-byte seed S. HKDF-Extract(salt, IKM=S) is then applied once more with the fixed salt "HBKD/v1" as the key, producing a 64-byte root secret R. This path never passes through BIP-32 or elliptic curve operations, so even if an ECDSA key created from the same phrase is broken by a quantum computer, R and the hash-based keys derived from it are not exposed. M must consist of the exact words from the mnemonic wordlist separated by a single space, and a wallet must reject any word outside the wordlist or a checksum failure.
The info layout and three purposes
Every value derived after R is the output of HKDF-Expand(R, info, L). info is a byte string formed by concatenating purpose (1 byte) || account (4 bytes, big-endian) || L (2 bytes) || name length (1 byte) || name || tail, in that order. purpose is 0x01 for stateless keys, 0x02 for stateful keys, and 0x03 for application secrets. The reason for including a length field is that, without specifying the length, a short output would end up identical to the prefix of a longer output; the reason each field has a fixed width or a length byte is to prevent different inputs from colliding into the same byte string. L must be between 32 and 16320 bytes.
Account and key type strings
account is an integer from 0 up to but not including 2^32, dividing independent key sets under a single root, similar to the account level in BIP-44. Wallets are recommended to use accounts sequentially starting from 0, without gaps. The key type is 1 to 255 printable ASCII characters excluding whitespace, and it designates the signature scheme and parameter set, hash function, whether it is stateful, the seed length L (minimum 32 bytes), and the entire procedure for producing a key pair from the seed. If the mapping from seed to public key changes in any way, the key type string must also change, and two different procedures must not share the same string. If there is a parameter whose value varies, such as tree height, a separate key type string must be used for each value.
Stateless keys and SLH-DSA key types
The seed for a stateless key is seed = HKDF-Expand(R, 0x01 || account || L || name length || key type, L), and restoring the root must always produce the same key pair. SLH-DSA key types use the parameter set names from FIPS 205 exactly (such as SLH-DSA-SHA2-128s), are all stateless keys, and L is three times the hash length n (48, 72, or 96 bytes). The seed is split in order into SK.seed (n bytes), SK.prf (n bytes), and PK.seed (n bytes), fed into slh_keygen_internal (FIPS 205 Algorithm 18), and the public key is PK.seed || PK.root (2n bytes). Key types whose secret key changes after a single use (such as one-time keys) must not be derived with this stateless method, because restoration would revive a key that has already been used for signing.
Fingerprint and account discovery during restoration
After restoring the phrase, a wallet must display the fingerprint, the first 4 bytes of the SHA-256 hash of account 0's SLH-DSA-SHA2-128s public key, as 8 hexadecimal characters. The fingerprint must not be computed directly from R or the BIP-39 seed, so that the user can notice when an incorrect passphrase produces a different, but still valid, root. Account discovery is recommended to proceed sequentially from 0 and stop at the first account with no key in use, and a replaced key must still be considered 'in use' so that discovery does not stop prematurely. Since the phrase does not record the number of signatures made, it is recommended that key types capable of reaching a usage limit be derived from the phrase only for the purpose of certifying other keys.
Optional derivation - stateful keys
Stateful keys (one-time, few-time, multi-use keys that use an index) must not be reproducible from the root alone; each instance has a 32-byte context chosen by the application and a 32-byte instance value generated from a cryptographically secure random number. The seed is derived by appending purpose 0x02 and context || instance to the end of info. The instance must not be generated deterministically, and state such as the index used must be stored together with the instance before a signature is issued; after restoration, a new instance must always be created, and an instance can only be revived from a backup if the state was backed up along with it and that state is current. Signers that cannot reliably store state, or whose memory can be duplicated, must not hold stateful keys.
Optional derivation - application secrets and random roots
An application secret is derived as secret = HKDF-Expand(R, ..., L) using purpose 0x03 and a 1-255 byte UTF-8 label chosen by the application; it cannot be used as a seed for a key type, and can only be used as key material for other purposes, such as the private key of an ECDSA account that pays gas. A device without a phrase, or an automated signer, can generate its own root as R = HKDF-Extract(salt, IKM) using at least 32 bytes of randomness as IKM, after which all subsequent derivations apply in exactly the same way as a root created from a phrase. A stateless key from the phrase can authenticate such a device's key and revoke it if needed.
A proposal that has not yet been finalized
ERC-8499 is currently in Draft status, still undergoing community discussion and review, and its detailed values or structure may change or the proposal may stall. Specific key type examples such as leanSPHINCS are reference test vectors only; the scope this ERC directly standardizes is limited to the SLH-DSA key type and the core derivation rules.
Things to watch out for
- The phrase and root expose every key: Anyone who knows the phrase and passphrase gains every stateless key and application secret for all accounts derived from it. R is as secret as the phrase itself, so a wallet that stores only R must protect it with the same level of security as storing the phrase.
- Duplicating a stateful key enables forgery: If a signer whose memory or storage can be duplicated at runtime holds a stateful instance, the two copies can sign different messages with the same index of the same one-time key, and once both signatures are public, forgery becomes possible. VM snapshots, replicas behind a load balancer, and restored backups all count as this kind of duplication.
- A passphrase typo causes irreversible loss: Entering the passphrase incorrectly produces a different, valid key that no one knows about, and funds sent to it are lost. Checking the fingerprint together with the phrase is one way to catch this, but a fingerprint stored alongside the phrase can also be used in a passphrase-guessing attack.
- A restoration cannot reveal the signature-count budget: Wallets must not assume that a restored key has never signed before; a key type that can reach its limit should be derived from the phrase only for the purpose of authenticating other keys, and each device is recommended to sign with its own key.
- Automated signers should not hold the phrase: Services or agents that sign without human involvement should not store the phrase or R, which would give them every account's keys; instead they should use their own random root and authenticate and revoke it with a key from the phrase.