← back to the interactive explainer
White-hat deep-dive · run on self-generated keys only

Why "brainwallets" get emptied

A 256-bit key is unguessable — larger than the atoms in the Earth. But a key you can remember isn't 256 bits of randomness; it's a password with a few dozen bits. And a few dozen bits is enumerable in seconds. Here's the gap, shown on keys we generate ourselves.

A "brainwallet" turns a phrase into a key

The seductive idea: memorize a passphrase, and never store a key anywhere. The wallet just hashes your phrase into the private key:

private key d = SHA-256( "your clever passphrase" ) mod n

No file, no paper, nothing to steal — it's "in your brain." The problem: an attacker can run the exact same hash on every phrase they can think of, and they can think of billions.

The key isn't protected by the 2²⁵⁶ haystack anymore. It's protected only by how hard your phrase is to guess — and humans pick guessable phrases.

Entropy is the whole game

"Entropy" = how many equally-likely possibilities there are. A real random key has 256 bits → 2²⁵⁶ options. A human phrase has far fewer:

SecretRough entropyTime to exhaust*
Random 256-bit key256 bitslonger than the universe
12-word BIP39 seed128 bitsinfeasible
Random 12-char password~72 bitscenturies+
A memorable sentence / quote~30–50 bitshours to days
A famous phrase / single word< 30 bitsseconds

*order-of-magnitude, for intuition. Attackers don't guess randomly — they start with leaked password lists, quotes, song lyrics and dictionaries, so "clever" phrases fall first.

Proof you can run yourself (on a key we make here)

A victim picks the famous xkcd phrase. A tiny attacker dictionary finds it almost immediately — no curve broken, just a guessed password:

# secp256k1 order n, pubkey->address helpers omitted for brevity
import hashlib
def key_from_phrase(p):
    return int.from_bytes(hashlib.sha256(p.encode()).digest(),"big") % n

victim = "correct horse battery staple"      # a "memorable" brainwallet
victim_addr = priv_to_address(key_from_phrase(victim))

dictionary = ["password","bitcoin","hunter2","letmein",
              "correct horse battery staple","satoshi nakamoto"]
for i,guess in enumerate(dictionary,1):
    if priv_to_address(key_from_phrase(guess)) == victim_addr:
        print(f"FOUND after {i} guesses: {guess!r}"); break
# → FOUND after 5 guesses: 'correct horse battery staple'
Output: FOUND after 5 guesses. Real attackers run this with billions of candidate phrases against every funded address on the chain, continuously.

This isn't hypothetical

Public "brainwallet draining" has been documented for years: researchers and attackers precompute the address for millions of common phrases, watch the blockchain, and sweep any that ever receive coins — often within seconds of a deposit. Quotes, Bible verses, song lyrics, "`bitcoin`", a single word — all emptied. The lesson is brutal and simple: if a human can remember it, a machine can guess it.

The fix

Don't derive keys from phrases you invent. Let a real random source do it:

• Use a wallet that generates a BIP39 seed from a hardware random number generator (128–256 bits of true entropy — unguessable).

• A hardware wallet, or any reputable wallet's "create new wallet", does this correctly.

• If you want something memorable, use a long diceware passphrase (6+ random words from a physical dice roll) — that's real entropy, not a phrase you chose because it felt clever.

White-hat rule. Enumerating phrases to study the failure on your own keys is education. Sweeping a stranger's weak brainwallet is theft — the weak key still belongs to its owner. Found one live? Tell the owner, never sweep.