Sub topic 5
Seed Phrases and Key Derivation
Assume you understand that public-key cryptography uses a private key to authorize spending and that a wallet manages keys rather than storing coins. This chapter focuses on how many wallets create and recover those keys.
What a seed phrase represents
A seed phrase is a human-readable backup for randomly generated wallet data. In the common BIP-39 standard, a 12-word phrase represents 128 random bits plus a 4-bit checksum. Longer phrases use more random bits.
The words are not the keys themselves. They encode the random data that a wallet uses to recreate a master seed. From that seed, a hierarchical deterministic wallet derives many private keys, public keys, and addresses.
import hashlib
import secrets
# BIP-39: 128 bits of entropy -> 12 words.
entropy = secrets.token_bytes(16)
checksum_len = 4 # entropy bits / 32
digest = hashlib.sha256(entropy).digest()
entropy_bits = bin(int.from_bytes(entropy, "big"))[2:].zfill(128)
checksum_bits = bin(digest[0])[2:].zfill(8)[:checksum_len]
all_bits = entropy_bits + checksum_bits # 132 bits
# Each 11-bit group is an index (0-2047) into the 2048-word BIP-39 wordlist.
indices = [int(all_bits[i:i + 11], 2) for i in range(0, len(all_bits), 11)]
print(len(indices)) # 12
print(all(0 <= i < 2048 for i in indices)) # TrueEach 11-bit group selects one word from the fixed 2,048-word BIP-39 list. The checksum helps detect an invalid phrase, but it does not prove that the phrase belongs to you. Anyone who obtains a valid phrase can usually recreate the wallet.
flowchart TD
A[Random entropy] --> B[Add checksum]
B --> C[Split into 11-bit indexes]
C --> D[BIP-39 words]
D --> E[Mnemonic-to-seed function]
E --> F[Master key]
F --> G[Derived private keys]
G --> H[Public keys and addresses]caption: From random data to wallet addresses alt: A flowchart showing entropy becoming a seed phrase, then a master key, derived private keys, and addresses.
From words to derived keys
A wallet converts the mnemonic sentence into a 512-bit seed with PBKDF2-HMAC-SHA512. The standard uses 2,048 rounds. The salt is the text mnemonic followed by an optional passphrase.
That optional passphrase is sometimes called a “25th word,” although it is not limited to one word. It creates a completely different wallet. A passphrase is not a recovery password. If you forget it, the original words recover a different wallet with different addresses.
Wallets then apply a key-derivation scheme such as BIP-32 and a derivation path. A path such as m/84'/0'/0'/0/0 selects a particular account, asset type, account number, address chain, and address index. Different wallet software can use different paths, so entering the correct phrase may still appear to show an empty wallet until the correct account or path is selected.
Backup and recovery rules
| Practice | Why it matters |
|---|---|
| Write the phrase offline | Screenshots and cloud notes can be copied |
| Check every word and its order | One changed word usually produces another wallet |
| Keep backups in separate secure locations | One fire, theft, or flood should not destroy every copy |
| Test recovery with a small amount | It confirms that the backup and derivation path work |
| Never type the phrase into a website | Fake support pages commonly steal phrases |
A metal backup can resist fire and water better than paper, but it does not solve theft or unauthorized access. Consider who can find the backup, whether trusted people can recover funds after your death, and whether the wallet uses a passphrase that must be documented separately.
Exercise
A wallet accepts your 12 words but shows no balance. Name two explanations that do not require assuming the blockchain lost your funds.
Show answer
The wallet may be using a different derivation path or account, or the optional passphrase may be missing or different. The addresses should be compared before moving funds.