Sub topic 2
How a Phrase Becomes Keys and Addresses
Prerequisites: you should understand the difference between a public address and a private key, and have basic experience with a self-custody software or hardware wallet.
A recovery phrase is a human-readable representation of wallet backup data. In the BIP-39 standard, the phrase is created from random entropy, which is a sequence of random bits. Common phrases contain 12, 15, 18, 21, or 24 words.
The phrase is not an address and does not directly contain your coins. Instead, a wallet uses it as input to a deterministic key-generation process. Deterministic means that the same input produces the same result every time.
From entropy to words
BIP-39 adds a checksum to the random entropy before dividing the result into groups of 11 bits. Each 11-bit group selects one word from a list of 2,048 words.
For example, 128 bits of entropy receives a 4-bit checksum. The resulting 132 bits divide into twelve 11-bit groups. This produces a 12-word phrase.
| Entropy | Checksum | Phrase length |
|---|---|---|
| 128 bits | 4 bits | 12 words |
| 256 bits | 8 bits | 24 words |
The checksum helps detect transcription errors. It does not prove that a phrase is yours, and it cannot detect every possible mistake. A changed word can sometimes still produce another valid phrase.
# Word count of a BIP-39 phrase from entropy size.
# Checksum length is entropy_bits / 32; each word encodes 11 bits.
for entropy_bits in (128, 160, 192, 224, 256):
checksum_bits = entropy_bits // 32
words = (entropy_bits + checksum_bits) // 11
print(f"{entropy_bits} bits entropy + {checksum_bits} checksum bits = {words} words")From words to wallet keys
When you restore a BIP-39 phrase, the wallet converts the words back into entropy and uses a key-stretching function to produce a 512-bit seed. Key stretching is a process that makes guessing attempts more expensive.
The wallet then applies a hierarchical deterministic, or HD, wallet algorithm. Hierarchical means that keys are organized in a tree. Deterministic means that every key can be regenerated from the same root seed.
The main stages are:
- The phrase becomes a seed.
- The seed produces a master private key and chain code.
- The master key derives child keys along a derivation path.
- A private key produces a public key.
- The public key is encoded into a blockchain address.
A derivation path is a sequence of numbers that selects a branch in the key tree. Wallets may use different paths for different networks, accounts, or address formats. Therefore, restoring the correct phrase with the wrong wallet settings can show an empty wallet even when the funds still exist.
The phrase can regenerate many private keys and addresses, not just the address currently displayed by the wallet. The blockchain records balances at addresses. The wallet uses the derived private keys to prove control and authorize transactions.
The optional passphrase
Some wallets support an additional BIP-39 passphrase. It is sometimes called a 25th word, although it is not limited to one word. The phrase and passphrase together produce a different wallet. A wrong passphrase usually creates a valid but empty wallet, so forgetting it can be equivalent to losing the funds.
Exercise
Why might restoring the correct recovery phrase show no balance?
Show answer
The wallet may be using a different network, account, address type, or derivation path. The funds remain at the original blockchain addresses.