Sign in

Mnemonic phrases and how a wallet gets created

Suggest an edit

The previous lesson ended with a warning: lose the private key and nobody can restore it for you. If the private key is 32 random bytes, how is a human supposed to back that up safely? Almost every wallet solves this by writing the wallet's randomness down as 12 or 24 ordinary English words.

The problem with 32 random bytes

A private key looks like this:

4f3edf983ac636a65a842ce7c78d9aa706d3b113b37b6b1da19c89e5fcca7c84

That is 32 random bytes written as 64 hex characters. This is your entire identity on a blockchain, and nobody can reissue it if you lose it.

Now imagine you have to write that on a piece of paper, store it somewhere safe, and read it back correctly five years from now. You will:

  • Mis-write one character and never notice
  • Lose the paper to a flood, a fire, or just plain misplacement
  • Find it ten years later and not remember which wallet it belonged to

Early cryptocurrency users lost money this way. So in 2013, a standard called BIP 39 was proposed that turned a wallet's randomness into something humans could back up: a short sequence of ordinary English words, called a mnemonic or a seed phrase.

The full pipeline

This is the process that runs when you click "create a new wallet" in any modern wallet application.

Wallet creation pipeline: entropy, mnemonic, seed, then master and child keysFour boxes stacked top to bottom and joined by arrows. Entropy becomes a mnemonic phrase, the mnemonic becomes a seed through PBKDF2-HMAC-SHA512, and the seed derives a master key plus a whole tree of child keys and addresses. 1. Entropy 128 or 256 random bits from the OS entropy source 2. Mnemonic 12 or 24 words from a fixed 2048-word list, plus checksum bits 3. Seed 64 bytes via PBKDF2-HMAC-SHA512 over the mnemonic + optional passphrase 4. Master key + many child keys + addresses a whole tree of key pairs, derived deterministically from the seed

Every stage after the first is deterministic: the same input always produces the same output. This is why a mnemonic written on paper is a complete backup of every key and every address the wallet has ever generated, even ones it hasn't shown you yet.

Stage 1: Entropy

The wallet asks the operating system for high-quality random bytes, called entropy: 128 bits for a 12-word mnemonic, 256 bits for a 24-word one. The bytes come from the OS entropy pool, the same pool that secures TLS connections and SSH sessions on the same machine.

Wallets with weak randomness have produced predictable private keys, and attackers have drained them. The math of the rest of the pipeline only protects you if this first step is unpredictable.

Stage 2: Mnemonic generation

The wallet takes the entropy bytes, computes a short checksum (the first few bits of a hash of the entropy), and appends it to the entropy. The resulting bit-string is split into 11-bit chunks. Each chunk is a number between 0 and 2047, and that number picks one word from a fixed list of 2048 English words, defined once and shared by every BIP 39-compliant wallet.

A 12-word mnemonic looks like this:

army van defense carry jealous true garbage claim echo media make crunch

The wordlist contains no two words sharing a four-letter prefix, no plurals of other entries, and no words easily confused with each other. This is why "rabb" is enough to uniquely identify "rabbit" when typing into a recovery field. The checksum is why entering a wrong word usually triggers an "invalid mnemonic" error.

The mapping from bits to words is reversible, so the words are the entropy itself in readable form, and re-entering them reproduces the same bits. The phrase is not a password that opens a key stored somewhere else.

Stage 3: Mnemonic to seed

The wallet does not compute keys from the words directly. It first converts the mnemonic into a seed with a function called PBKDF2-HMAC-SHA512. PBKDF2 is a key-stretching function: it takes an input and repeatedly hashes it to produce an output, intentionally slowly. Here it runs 2,048 iterations, a deliberate cost that adds milliseconds for a legitimate user but multiplies the work required for an attacker brute-forcing weak mnemonics.

The same computation takes an optional passphrase, which most users don't know exists. If you supply one (any string, of any length), the resulting seed is completely different from the seed you'd get with the same mnemonic and no passphrase. It is sometimes called the "25th word" because it acts like an extra hidden word on top of the visible 12 or 24.

Imagine someone forces you to hand over your mnemonic, at a border crossing or under threat. The mnemonic with an empty passphrase opens one wallet. With your secret passphrase it opens a completely different, hidden one. An attacker who has the mnemonic can drain the visible wallet but cannot reach the hidden one without also knowing the passphrase, and has no way to know the hidden wallet exists at all. This property is called plausible deniability.

The seed is always 64 bytes regardless of mnemonic length, and it is what the rest of the system uses.

Stage 4: Seed to master key, and everything below

The 64-byte seed feeds into a tree-derivation algorithm that produces a master key and then any number of child keys below it. From the master key you can derive child keys, from each child key you can derive grandchildren, and so on, infinitely many key pairs from one seed.

The mechanics of that tree are outside this lesson. The property that matters here is that the entire tree is deterministic: the same mnemonic gives the same seed, and the same seed gives the same tree. Restore the mnemonic on a new device, the wallet runs the same pipeline, and every key and every address shows up in the same order with the same values.

Three rules for handling a seed phrase

The mnemonic is the wallet. Lose it and there is no recovery. Neither the wallet software nor the wallet vendor has a copy, and the chain does not know who you are, only that you control a key derived from it.

Share the mnemonic and you've shared everything. Anyone who sees your 12 or 24 words can reconstruct every private key derived from it on any device. There is no "read-only" version of a mnemonic. A phishing site that asks for your seed phrase is asking for the entire wallet.

The mnemonic plus a passphrase is two different wallets. If you use a passphrase, you must back up both the mnemonic and the passphrase, and you must back them up separately. Lose the passphrase and the funds in the hidden wallet are unreachable even though the mnemonic is intact.

The playground below has a mnemonic-generator node that produces a fresh mnemonic. Use only the test mnemonics it generates. Never paste a real wallet's mnemonic into any web tool, including this one.