Sub topic 4
Generating a phrase on a trusted device
This chapter assumes you know what a recovery phrase is, how BIP-39 turns it into keys, and the threat model of theft, loss, and damage. It covers where a phrase should be created, what makes the randomness good, and the mistakes people make at this step.
Why generation is the riskiest moment
Every later protection depends on the phrase being secret and unpredictable from the first second. If someone else saw the phrase as it was created, or if the random numbers behind it were guessable, no amount of steel plates or safe-deposit boxes can fix that.
Generation has two requirements:
- Unpredictable entropy. Entropy is the raw randomness the phrase is built from. A 12-word phrase encodes 128 bits of entropy, and a 24-word phrase encodes 256 bits. These sizes are only secure if the bits are truly random.
- A private environment. Nothing else, such as malware, a camera, or another person, should be able to see the words as they appear.
How the phrase is built from entropy
A wallet picks random bits, computes a short checksum from them, and splits the result into groups of 11 bits. Each group selects one word from a list of 2048 words. The following script shows why valid phrase lengths are 12, 15, 18, 21, or 24 words.
# 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")The output lists 12 words for 128 bits and 24 words for 256 bits. The checksum adds only 4 to 8 bits, so it helps catch typing mistakes. It adds no security.
What counts as a trusted device
A trusted device generates the entropy itself, keeps the words off the network, and shows them only to you.
Best choice: a hardware wallet
A reputable hardware wallet is purpose-built for this job. It has a dedicated random number generator, it never exposes the phrase to a connected computer, and it displays the words on its own screen. Buy it directly from the manufacturer or an authorized reseller. Inspect the packaging, and be suspicious of any device that arrives with a phrase already written on a card. A pre-filled phrase means someone else knows it, so do not use that device.
Acceptable: an offline, dedicated device
Some people generate a phrase on a clean computer booted from a live operating system with networking disabled. This approach needs more care and more technical skill. It is easy to leave traces, such as clipboard contents or swap files, if you are not careful.
Software wallets on a phone or laptop
A mobile or desktop wallet from a well-known project can be reasonable for smaller amounts. The risk is the device itself. A phone or laptop that runs many apps and stays online has far more ways to be compromised than a hardware wallet. Match the device to the value at stake.
Avoid
- Websites that offer to "generate a seed phrase for you". The site, or anything that tampers with it, can record what it shows.
- Browser extensions or apps from unknown publishers, or lookalike apps in a store.
- Phrases supplied by another person, a seller, or a support agent.
- Any tool that asks you to choose your own words or "make a memorable phrase". Human-chosen phrases are predictable.
Preparing the environment
Before you generate, spend a minute on the setting:
- Choose a private room. Close the door and confirm no one is looking over your shoulder.
- Check for cameras. This includes smart speakers with cameras, webcams, doorbell cameras facing a window, and your own phone's camera propped up nearby. Turn them off or point them away.
- Prepare your writing tools in advance: the backup card or plate, a pen that will not smear, and a second copy if you plan to make one.
- Keep the phone away from the table. Do not photograph the screen, the card, or your notes.
- Allow enough time. Hurrying at this step leads to transcription errors, which the next chapter covers.
Generating on a hardware wallet
The exact menus differ by brand, but the sequence is similar:
- Verify the device is genuine, using the manufacturer's instructions, and check the firmware.
- Set a PIN on the device. The PIN protects against casual physical access, but it does not replace the phrase.
- Choose "create a new wallet" and not "restore".
- Pick the phrase length. 12 words give 128 bits, which is out of reach of brute force. 24 words give 256 bits and extra margin. Either is acceptable. Choose the one you can record carefully.
- Read each word from the device screen as it is shown, and write it in order.
- Complete the device's confirmation step, where it asks you to re-enter selected words. This catches many mistakes immediately.
Notice what did not happen: the phrase never touched your computer, a cable, or the internet.
Where randomness goes wrong
Phrases are rarely cracked by brute force. They are broken when the randomness is weak. Known failure modes include:
- Weak or biased random number generators. If a program seeds its generator from something predictable, such as the current time, an attacker can enumerate the possible outputs. Real wallets have lost funds this way, and attackers have swept the affected addresses automatically.
- Human-chosen "random" words. People pick words that mean something to them. Attackers know this and test song lyrics, quotes, and common patterns.
- Dice and coin methods done badly. Rolling dice for entropy is a legitimate way to avoid trusting a device, but it is easy to get wrong. Rolling too few times, using a biased die, or converting results with a home-made script can cut the effective entropy a great deal.
- Compromised tools. A modified wallet or a fake website can show you a phrase that it also reports to an attacker, or one drawn from a small predetermined list.
The practical rule is to use widely reviewed, open-source or well-audited wallet software on a device from a reputable source. Do not write your own generator.
Checking the checksum with a public test phrase
The last word of a phrase carries part of the checksum, so a wrongly copied word often makes the whole phrase invalid. The script below shows this with the public test phrase that appears in documentation. Run it only with this phrase. Never type a real phrase into a script, a terminal, or any networked computer.
# pip install mnemonic
# Use ONLY the well-known public test phrase below. Never type a real phrase into a script or onto a networked computer.
from mnemonic import Mnemonic
m = Mnemonic("english")
test_phrase = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"
print(m.check(test_phrase)) # True: valid words and valid checksum
bad_phrase = test_phrase.replace("about", "abandon")
print(m.check(bad_phrase)) # False: checksum no longer matchesThe checksum is short. For a 12-word phrase it is 4 bits, so roughly 1 in 16 random mistakes in the final word will still pass. A passing checksum means the phrase is well-formed. It does not prove you copied it correctly, and it does not prove the phrase is secure. The test phrase above is valid, yet anyone can use it, and bots watch its addresses. Never put funds on it.
Common mistakes at generation time
| Mistake | Why it hurts | What to do instead |
|---|---|---|
| Generating on a shared or public computer | Malware or a keylogger may record the words | Use your own hardware wallet or a dedicated device |
| Screenshotting or photographing the words | Photos sync to cloud accounts and are easily stolen | Write by hand only, and never capture the screen |
| Using a phrase from a pre-filled card | The seller or a previous owner may know it | Return the device and get a new one |
| Choosing your own words | Human choices are predictable | Let the wallet generate the entropy |
| Generating, then immediately funding without a test | A transcription error may go unnoticed | Verify the backup first (see the chapter on testing) |
| Typing the phrase into a "checker" website | The site may log what you type | Check only with the device or a trusted offline tool |
After generation
When the words are on paper, do not rush to move money. Treat the new wallet as empty until the backup is written, double-checked, and proven by a restore test. Keep the paper out of sight of anyone, and keep it away from phones and cameras. The next chapter covers writing the words down accurately, which is where most real-world errors enter.
Exercise
A seller ships you a hardware wallet in a sealed box. Inside is a card that already has a 24-word phrase printed on it, with a note saying "your recovery phrase, keep it safe". What should you do, and why?
Show answer
Do not use the device or that phrase. A phrase printed before you set up the wallet is known to whoever produced the card, so they could take any funds you deposit. Contact the seller, return the device, and get one from the manufacturer or an authorized reseller. Then generate your own phrase on the device yourself.
Exercise
A 12-word phrase has 128 bits of entropy and a 4-bit checksum. Why does a valid checksum not prove that you copied the phrase correctly?
Show answer
The checksum has only 4 bits, so a random error in the last word has about a 1 in 16 chance of still producing a valid checksum. Also, a mistake that swaps one valid word for another valid word elsewhere in the phrase is only caught if the checksum happens to mismatch. A passing check shows the phrase is well-formed, not that it matches your original. You still need to verify the backup by restoring it.
Exercise
Name two reasons a website that "generates a seed phrase for you" is a bad choice, and name a safer option.
Show answer
The site, or an attacker who has altered it, can record or log the words it shows you, and its randomness may be weak or drawn from a small predictable set. A safer option is to generate the phrase on a reputable hardware wallet, where the entropy is created on the device and the words appear only on its screen.