written by
Yi Jie

A Primer On Understanding Seed Phrases, Keys, Wallets, and Addresses

4 min read , November 18, 2023

Introduction

Having spent over a year immersed in the blockchain domain, I've gained invaluable experience with key principles that might seem enigmatic to developers unfamiliar with the blockchain. Here, I'll demystify crucial concepts such as mnemonic seed phrases, private and public keys, wallets, and addresses.

Mnemonic Seed Phrase

A mnemonic seed phrase is safeguarded by anyone using a hardware wallet, like Ledger or Trezor. This phrase acts as a fundamental key to your blockchain wallet, encoding entropy in multiples of 32-bits. BIP-39 illustrates the process of crafting these pivotal 24 words.

According to BIP-39, an initial entropy of ENT bits is generated. A checksum is created by taking the first ENT / 32 bits of its SHA256 hash and appending it to the end of the initial entropy. The concatenated bits are then divided into groups of 11 bits, each representing a number from 0-2047 that corresponds to a word in a wordlist. Finally, these numbers are converted into words and combined to form the mnemonic sentence.

Reference the table below for the correlation between entropy (ENT), checksum length (CS), and the total number of words in the mnemonic sentence (MS).

|  ENT  | CS | ENT+CS |  MS  |
+-------+----+--------+------+
| 128 | 4 | 132 | 12 |
| 160 | 5 | 165 | 15 |
| 192 | 6 | 198 | 18 |
| 224 | 7 | 231 | 21 |
| 256 | 8 | 264 | 24 |

See the BIP-39 documentation for an in-depth explanation:
Bitcoin Improvement Proposals - BIP-0039

The Distinction Between Private Key and Entropy

Entropy refers to the randomness used for secure key generation. A randomly generated 32 bytes entropy is used to create a private key.

Public Keys and How They Become Addresses

There is a common misconception that a public key is a blockchain addresses. It is different.

The Keccak-256 algorithm is used to hash the public key, resulting in a 32-byte hash or 64 characters in hexadecimal form.

In Ethereum addresses, the last 20 bytes (or 40 characters) of this hash are used and prefixed with '0x', resulting in a 42-character Ethereum address.

For Bitcoin, obtaining the address is more complex as it depends on the network (mainnet / testnet). However, it can be derived from the public key. For more information, you can refer to the Wallets & Address section in "Mastering Bitcoin".

Diving into Blockchain Wallets

A blockchain wallet is a digital interface allowing you to interact with the blockchain network, granting you the authority to execute transactions. While Bitcoin may not inherently support smart contracts like Ethereum, its scripting language allows for features like multi-signature wallets. Blockchain wallets can be either hierarchical deterministic (HD) or simple single-key entities.

Hierarchical Deterministic (HD) Wallet

A single private key is capable of creating multiple wallets. BIP 32 does introduce a technique of deriving multiple keys from a master key, which in turn is derived from a seed. The seed results in a master private key and chain code. A "derivation path" is used to derive child keys. This is most commonly used in hierarchical deterministic (HD) wallets. Here, the same master private key and chain code (or same seed) are used to generate a whole tree of key pairs (i.e., multiple wallets) when different derivation paths are used. Each derived key essentially acts as a different wallet, which helps improve security and privacy.

Overview of BIP32 Wallet Derivation

Implications of using deriving child keys with non-hardened path

Non-hardened derivation paths provide the convenience of generating child public keys directly from a parent extended public key and chain code. This feature is particularly useful for creating deposit addresses without exposing private keys.

On the flip side, for added security, hardened paths necessitate the use of the parent's private key in addition to the public key and chain code to generate child keys. Developers must exercise caution: if a non-hardened child private key is compromised along with its parent's extended public key, the security of the entire key tree can be undermined.

It is essential, therefore, to safeguard these keys diligently to prevent any unauthorised access that could potentially expose upper-level private keys and thereby, the entire wallet.

See the BIP-32 proposal for more details on this:
HD Wallets - BIP32 Documentation

Summing up

In the blockchain space, I've learned about important concepts such as mnemonic seed phrases, private keys and entropy, public keys and addresses, and blockchain wallets and hope this knowledge is useful. Here are the key takeaways:

  • Mnemonic Seed Phrase: Hardware wallets require users to record a 12/24-word phrase that serves as the key to their blockchain wallet. This phrase is generated using initial entropy and a checksum.
  • Private Key vs Entropy: While a private key is created from randomly generated entropy, it's important to note that they are not the same. Entropy refers to the measure of randomness used in generating a private key.
  • Public Key vs Address: The public key undergoes hashing using the Keccak-256 algorithm to create a 32-byte hash, which can then be used to generate an address.
  • Blockchain Wallets: These software applications enable users to interact with the blockchain and send funds. There are different types of wallets available, including smart contract wallets and simple private key wallets, each offering various methods to enhance functionality and security.
  • Developers should be vigilant with extended keys, as the HD wallet structure poses certain risks and demands heightened security practices

Supplementary Readings

For those seeking a deeper dive, here are the primary documents discussed: