Skip to content
Blockchain Association of Cameroon
BAC-L0-FOUND-1123 h

Wallets, mnemonics and derivation

What a wallet actually holds — keys, never funds — and how twelve words generate a hierarchy of accounts.

  • Explain hierarchical derivation from a seed
  • Restore a wallet from its mnemonic phrase
  • State the exact consequences of a compromised seed

A wallet never holds money: it holds keys, and the chain holds the funds. This workshop puts that fact back at the centre, then explains how a twelve-word phrase can generate a whole hierarchy of accounts through a seed and hierarchical derivation. You will work with a toy version of that derivation, clearly distinguished from how the real BIP-39 and BIP-32 standards behave. You will finish with the question that matters most for security: what exactly happens when the seed is compromised, and how to back up and restore without ever putting it at risk?

Lessons 1/4 · 15 min

A wallet holds keys, not funds

The phone that fell in water

Dayo drops his phone into a bucket of water. The wallet app is gone. Has he lost his money? The answer depends on one thing: does he still have his keys (or the seed that generates them)? If yes, he installs an app on another phone and his balance reappears. If not, his funds are still on the chain, but nobody can spend them any more. That difference is the heart of the workshop.

Who is who

  • Funds: a line of the chain's state (a balance, or unspent outputs). They live on the chain, never in an app or on a phone.
  • Key pair: a private (secret) key and the matching public key (workshop 105). Signing a transaction with the private key is the only way to spend what is locked to that key.
  • Address: a public identifier computed from the public key, by a convention specific to each chain. Bitcoin passes the public key through two different hash functions (SHA-256 then RIPEMD-160, not to be confused with the double SHA-256 used for blocks and transactions) then adds an encoding; Ethereum takes the last 20 bytes of a Keccak-256 hash of the public key. In this workshop's exercises we use a toy convention: the first 20 bytes of the SHA-256 of the public key (bytes, not text). It is not the convention of any real chain.
  • Wallet: software or a device that keeps keys, builds transactions, has them signed and displays balances it reads from the chain. It is not the vault of the funds.

Types of wallets

TypeWhere the private key isWhat it changes
Non-custodial, software ("hot")In your appConvenient; exposed if the device is infected
Non-custodial, hardware ("cold")In a dedicated device that signs without revealing the keyReduces exposure; the device can also be lost
Custodial (exchange platform)At a third party that holds the keysThe third party can lose, freeze or refuse; you hold a claim on it, not control

Example: getting the funds back

Dayo had an address A. The funds tied to A remain on the chain after the phone is lost. With a new app and his seed, he recovers the same private key, hence the same address A, hence the same ability to sign. Without the seed, he can still see A's balance (chain data is public) but he can no longer sign.

What this does NOT guarantee

  • Losing the app does not lose the funds; losing the keys does.
  • An address is not an identity: it does not say who controls it.
  • A "secure" wallet does not stop you signing a transaction that you approved by mistake.
  • The chain has no help desk and no "forgot password": nobody can reset a key.

Recap

Funds: on the chain. Private key: the power to spend them. Address: a public name derived from the public key. Wallet: the tool that keeps keys and signs.

Interactive tool

ECDSA P-256 signature

Generate a key pair in your browser, sign a message, then verify the signature.

The private key is created with extractable: false: the browser keeps it in memory and never lets it be exported, and it is neither displayed nor stored. It lives only in this tab: reloading the page loses it.

Public key (SPKI, base64)

No key yet. Generate a pair to sign.

Signature (base64, P1363 format: r ‖ s, 64 bytes)

…

ECDSA with SHA-256 on the P-256 curve. WebCrypto returns r and s concatenated (32 + 32 bytes), not DER encoding.

Verify a signature

Interactive tool

SHA-256 of hex bytes

Paste bytes as hex: the hash covers the bytes, not the text of the digits. A second field is concatenated after the first.

Digest

…

Spaces, newlines and 0x prefixes are ignored.

Lessons 2/4 · 20 min

Mnemonic phrase and seed (BIP-39)

Why twelve words?

A private key is 32 bytes (64 hexadecimal characters): impossible to copy without error. And if you want several accounts, you would need to back up several keys. The BIP-39 standard solves the first problem by encoding a random value as words from a list of 2,048 words; hierarchical derivation (lesson 3) solves the second.

How a phrase is built (real BIP-39)

  1. Draw random entropy of 128 bits (16 bytes). For 24 words, 256 bits.
  2. Compute SHA-256 of that entropy and keep the first 4 bits (entropy bits ÷ 32): the checksum.
  3. Concatenate: 128 + 4 = 132 bits, split into 12 groups of 11 bits. Each 11-bit group is an index from 0 to 2,047 into the list of 2,048 words (2^11 = 2,048). For 24 words: 256 + 8 = 264 = 24 × 11.
  4. The 64-byte seed is obtained with PBKDF2-HMAC-SHA512, 2,048 iterations, the phrase as password and the string "mnemonic" followed by the optional passphrase as salt.

The words are not the key: they encode the entropy; the seed is computed from the phrase itself (step 4), and the keys are derived from the seed.

Example: how many possible phrases?

128 bits of entropy make 2^128 possible values, a number of about 3.4 × 10^38. No attacker can try them all. By contrast, a phrase you choose yourself (a quote, a password "to look nice") has almost no entropy: it can be guessed. Randomness must come from a sound generator.

The 4-bit checksum lets software detect most typing mistakes: if one word is swapped for another from the list, the check still passes one time in 16 (2^−4), so it fails 15 times in 16. It does not prove the phrase is yours: a badly copied but valid phrase leads to another, empty wallet.

The passphrase: one more word that changes everything

Adding a passphrase changes the salt, hence the seed, hence all accounts. There is no error message if the passphrase is wrong: you get another valid and empty wallet. Useful (a stolen phrase without the passphrase gives no access to funds), but it is a second secret to back up.

Real and toy: a boundary not to cross

Different chains add their own rules. Substrate/Polkadot ecosystem tools also use mnemonic words, but their derivation scheme is not BIP-32's: the same words do not necessarily give the same accounts as in a Bitcoin or Ethereum wallet. Check the tool's documentation before restoring.

What this does NOT guarantee

  • The words are not a resettable password: whoever reads them controls the funds.
  • The checksum detects errors, not attacks.
  • A 12-word phrase is safe only if it was drawn at random by a good generator.
  • Two programs that accept the same phrase may derive different accounts (path, passphrase, scheme).

Recap

Entropy → words (with checksum) → seed through PBKDF2 → keys. The words are the only backup, hence the single point of theft.

Interactive tool

Base converter

Edit any of the three fields: the other two follow. Integers can be as large as you like.

  1. 1
  2. 1
  3. 1
  4. 1
  5. 1
  6. 1
  7. 0
  8. 1
  9. 0
  10. 1
  11. 0
Population count: 8 bits set out of 11. 11 significant bits.

Only non-negative integers are handled here.

Interactive tool

HMAC

Message authentication code: a digest that depends on a shared secret. Without the key it cannot be recomputed.

Key format
Message format

HMAC (hex)

…

An empty key is accepted (it is equivalent to a key of zeros).

Lessons 3/4 · 25 min

Hierarchical derivation: BIP-32 and its toy version

One seed, many accounts

From a single seed, a hierarchical deterministic (HD) wallet generates a tree of keys: same inputs, same keys, always. You back up the seed once; accounts can be re-created at will, and you can use a fresh address for each payment received.

Real BIP-32, in summary

  • Master key: compute HMAC-SHA512 of the seed with the key "Bitcoin seed". The first 32 bytes of the result form the master private key, the last 32 the chain code.
  • Child key: compute HMAC-SHA512 with the parent's chain code as key. The data is: for a normal derivation, the parent's public key followed by the 4-byte index; for a hardened derivation (index ≥ 2^31), a zero byte, the parent's private key, then the index. The result is split in two: the left part is added, modulo the order of the secp256k1 curve, to the parent key to give the child key; the right part is the new chain code.
  • Path: a sequence of indices, written for example m/44'/0'/0'/0/0 (the BIP-44 standard gives the levels their meaning: purpose, coin type, account, change, address index). The apostrophe marks a hardened derivation.

The course's toy version

The exercises use a deliberate simplification: the chain code is the key of an HMAC-SHA512 and the data is the parent key (32 bytes) followed by the index as 4 big-endian bytes. The first 32 bytes of the result are the child key, the last 32 the child chain code.

Real BIP-32Toy version
Elliptic curveYes (addition modulo the secp256k1 order)No
Normal/hardened derivationTwo distinct modesA single mode
HMAC dataPublic key (normal) or 0x00 + private key (hardened), then the indexParent key, then the index
Master keyHMAC with "Bitcoin seed"Not covered: values provided
ResultCompatible with real walletsIncompatible: yields no real key

So never reuse this toy for real keys: it illustrates the shape of derivation (HMAC, chain code, index), not its cryptographic content.

Example: reading the structure

With a parent key, a chain code and an index of 5, the toy gives a pair (child key, child chain code). With index 6 you get a completely different pair (avalanche, workshop 104), but always the same at every computation: that is what makes restoring possible. With the hmac tool, enter the chain code as key and the concatenation parent key + index as data, then slice the 64-byte result with the bytes tool.

Why the normal/hardened difference exists

With normal derivation, you can compute child public keys from the parent's public key and chain code alone: a merchant website can thus produce new receiving addresses without ever holding a private key. The flip side: if someone knows the parent's chain code and public key and the private key of a single normal child, they can climb back to the parent's private key. Hardened derivation cuts that link, at the price of not allowing computation from the public key alone.

What this does NOT guarantee

  • A deterministic derivation is not an extra secret: whoever has the seed and the path recomputes everything.
  • Different paths in different software give different addresses from the same words.
  • Each chain has its conventions (curve, address format, scheme): the same mnemonic does not imply the same accounts elsewhere.

Recap

Same seed + same path = same keys, always. Real BIP-32: HMAC-SHA512, elliptic curve, normal/hardened. Toy: HMAC-SHA512 only, and with no real value.

Interactive tool

HMAC

Message authentication code: a digest that depends on a shared secret. Without the key it cannot be recomputed.

Key format
Message format

HMAC (hex)

…

An empty key is accepted (it is equivalent to a key of zeros).

Interactive tool

Byte inspector

Paste hex, cut out a slice and read it as a little-endian or big-endian integer.

Length: 14 bytes

0000020000000a006c1f
00084d5e1d00ffff

Slice as hex

02000000

Little-endian unsigned integer

2

Little-endian signed integer (two's complement)

2

Big-endian unsigned integer

33,554,432

Big-endian signed integer (two's complement)

33,554,432

Bytes reversed (hex)

00000002

UTC date of the slice (little-endian): 1970-01-01T00:00:02Z

For example a block header timestamp. It can be read from the slice above.

2009-01-03T18:15:05Z

Lessons 4/4 · 20 min

Compromised seed, backup and restore

The question that matters: what exactly is lost?

Dayo photographs his 12-word phrase "so as not to forget it". The photo syncs to an online storage account that is later hacked. What are the consequences, exactly?

If someone obtains the phrase (and the passphrase, where there is one), they obtain the seed, hence:

  • All the keys of the tree, for every path they try, including accounts you have not yet created.
  • On all chains whose tools derive from that seed by a scheme they know.
  • The power to sign transactions the chains will accept as coming from you: the chain cannot tell the owner from the thief.

And what they do not obtain:

  • They cannot cancel or rewrite past transactions.
  • They learn nothing about your other passwords.
  • They do not affect accounts derived from a different seed.

There is no revocation

There is no "change password" procedure on a chain. The only response is to move the funds to keys of a new seed, generated on a healthy device, starting with the highest values. It is a race: a thief watching your addresses can move the funds before you, which is why you must not let the seed be exposed. An undisclosed passphrase limits the damage, but it is not recoverable either if you lose it.

Backing up without exposing yourself

  • Write the phrase by hand on paper (or engrave it on metal), never in a photo, a message, a synced note, an email or an online notes manager.
  • Keep at least two copies in two different safe places (fire, theft, flood).
  • Keep the passphrase apart from the phrase.
  • Test the restore: on another device or with another tool, restore with a small amount, check the expected addresses appear, and only then trust the backup.

Example: "my balance is zero"

Dayo restores his 12 words in a different app and sees a zero balance. Are his funds lost? Almost certainly not: the likely causes are a different derivation path or coin type, a forgotten passphrase, another scheme (Substrate instead of BIP-32), or a typing mistake that gave a valid but different phrase. The repair: find the original tool's path and scheme, not panic or type the phrase into a "recovery" website.

What this does NOT guarantee

  • An untested backup is not a backup.
  • A paper copy protects against failure, not against theft or fire.
  • A phrase "deleted" after use on a device is not necessarily gone: cache, keyboard history, clipboard.
  • A hardware wallet protects against malware at signing time, not against someone who has read your phrase.

Recap

Compromised phrase = all present and future accounts compromised, with no revocation. Response: move the funds to a new seed. Prevention: offline backup, separate copies, tested restore.

Guided lab

The browser neither generates nor validates a real BIP-39 phrase, and that is by design: you never type a real phrase into a web page. The exercises use fictitious values and the toy derivation described in lesson 3, which is not compatible with BIP-32. Real offline generation, deriving several accounts and restoring in another tool make up the independent lab, to be done with a test wallet holding no value.

A browser is no substitute for a real terminal: this lab trains reading and reasoning; the real hands-on practice is in the independent lab.

A certified account is required

Graded activities record results in your name and are the basis for a credential. They therefore need a complete certified file and a current consent. Filling in the file does not verify your identity; the Secretariat can verify it afterwards ("Verified" badge).

  1. 1.Derive an address (toy convention)

    Apply the toy convention from lesson 1 to the compressed public key provided: hash the key's BYTES (not the hex text) with the hexhash tool and keep the first 20 bytes, that is 40 hexadecimal characters. This convention is not that of any real chain.

    Interactive tool

    SHA-256 of hex bytes

    Paste bytes as hex: the hash covers the bytes, not the text of the digits. A second field is concatenated after the first.

    Digest

    …

    Spaces, newlines and 0x prefixes are ignored.

  2. 2.Derive a child key (toy version)

    With the hmac tool, compute HMAC-SHA512 taking the parent chain code as KEY (hexadecimal) and as DATA the parent key followed by the index as 4 big-endian bytes (8 hexadecimal characters). Use the bytes tool to cut the 64-byte result: the first 32 are the child key, the last 32 the child chain code. Fictitious values, nothing real.

    Interactive tool

    HMAC

    Message authentication code: a digest that depends on a shared secret. Without the key it cannot be recomputed.

    Key format
    Message format

    HMAC (hex)

    …

    An empty key is accepted (it is equivalent to a key of zeros).

    Interactive tool

    Byte inspector

    Paste hex, cut out a slice and read it as a little-endian or big-endian integer.

    Length: 14 bytes

    0000020000000a006c1f
    00084d5e1d00ffff

    Slice as hex

    02000000

    Little-endian unsigned integer

    2

    Little-endian signed integer (two's complement)

    2

    Big-endian unsigned integer

    33,554,432

    Big-endian signed integer (two's complement)

    33,554,432

    Bytes reversed (hex)

    00000002

    UTC date of the slice (little-endian): 1970-01-01T00:00:02Z

    For example a block header timestamp. It can be read from the slice above.

    2009-01-03T18:15:05Z
  3. 3.Restore: a zero balance

    Answer the multiple-choice question: a person restores their twelve words in another tool and sees a zero balance. Rule out the impossible causes, then choose the most plausible cause and the right course of action. Rely on lessons 2, 3 and 4.

  4. 4.Consequences of a compromised seed

    Answer the multiple-choice question describing a leaked seed. Carefully distinguish what the attacker can do (present and future accounts, all the chains concerned) from what they cannot do (rewrite history, reach another seed).

Security exercise — Key hygiene: what must never touch a disk, a clipboard or a conversation

Dayo has just opened a wallet and written down his 12 words on paper. Then, in a single evening, he performs three actions in a row: (1) he photographs the phrase "just in case", and the photo syncs automatically to his online storage; (2) a "wallet checker" website promises to check that his phrase is valid, and he types it in; (3) someone presenting as "wallet support" writes to him on a messaging app and asks for the phrase to "reactivate his account".

Dayo's wallet holds funds on several chains, all derived from this single phrase.

Check question: what is the right course of action for Dayo, given what he has already done? Answer the multiple-choice question that follows this scenario.

Workshop quiz

Eight questions drawn from a larger pool, 70% to pass. It opens once every lab checkpoint is passed. You can retake it: the draw changes.

A certified account is required

Graded activities record results in your name and are the basis for a credential. They therefore need a complete certified file and a current consent. Filling in the file does not verify your identity; the Secretariat can verify it afterwards ("Verified" badge).

Independent lab (outside the site)

Not graded online: do it on your own machine and publish it to your Git repository.

To do on your own machine, outside the site

Write then test a realistic backup-and-restore procedure that works without specialised hardware. Use only a test wallet holding no value, never a phrase already used elsewhere.

  1. Offline (airplane mode, network off) and on a trusted device, generate a 12-word phrase in a BIP-39/BIP-32 tool whose documentation you have read (an open-source software wallet or an official BIP-39 tool). Check in its documentation that it works offline. Write the phrase down by hand.
  2. Derive at least three accounts (for example three indices) and note, for each, the path or scheme used and the public address.
  3. Write the procedure step by step: where to write, where to store two copies, how to keep any passphrase apart, who must know what.
  4. Wipe the wallet from the device and restore it in a different tool of the same family (BIP-39/BIP-32, same chain) following only your document. Check that the three addresses are identical. If they differ, document why (path, coin type, passphrase): this will be the most instructive part. To go further, try the same restore in a tool from another ecosystem (for example Substrate/Polkadot) and explain why the addresses are expected to differ: lesson 2.
  5. Have a peer review your document; they must complete the restore without talking to you.

Never photograph or copy the phrase into a connected device. Destroy the test phrase at the end.

Takeaways

  • A wallet keeps keys and signs; funds live on the chain. Losing the app is not losing the funds, losing the keys is.
  • BIP-39: random entropy → words with a checksum → seed through PBKDF2; the words are the backup, hence the target of theft.
  • BIP-32: one seed generates a key tree through HMAC-SHA512, a chain code and a path; hardened derivation protects the parent key.
  • The exercises' derivation is a toy (HMAC only, no curve): it illustrates the shape, it produces no real keys.
  • A compromised seed compromises all present and future accounts, with no revocation: move the funds to a new seed; prevent it with an offline backup and a tested restore.

Common misconceptions

  • Misconception : My crypto is stored in my wallet app.

    In fact : Funds are chain data. The app keeps the keys that allow spending them and displays what it reads from the chain.

  • Misconception : If I restore my 12 words elsewhere and the balance is zero, my funds have vanished.

    In fact : Almost always, the tool derives another path, scheme or passphrase. The funds are intact on the chain; you must find the right derivation, without ever typing the phrase into a "recovery" website.

  • Misconception : If my phrase's checksum is valid, the phrase is the right one.

    In fact : The 4-bit checksum (for 12 words) catches most typos, but roughly one wrong phrase in sixteen passes it. A valid but different phrase gives another, empty wallet.

  • Misconception : If my seed leaks, I change my password and everything is fine.

    In fact : A seed is not a password: there is no change procedure on the chain. You must move the funds to keys of a new seed before the attacker does.

Glossary

Wallet
Software or a device that keeps keys, builds and signs transactions and displays balances read from the chain. It does not contain the funds.
Mnemonic phrase (BIP-39)
A sequence of words from a list of 2,048 that encodes random entropy and a checksum, and from which the seed is computed.
Seed
A 64-byte value, computed from the phrase by PBKDF2, from which all the wallet's keys derive.
Chain code
A 32-byte value attached to each key of the HD tree, used as the HMAC key to derive children.
Hardened derivation
Derivation of a child key (index ≥ 2^31) that uses the parent's private key and prevents climbing back to it from the public key.
Derivation path
A sequence of indices, written for example m/44'/0'/0'/0/0, that designates a key in the HD tree.
Passphrase
An optional secret added as salt to the seed computation: a different passphrase gives an entirely different wallet, with no error message.