Hierarchical Deterministic (HD) Wallet
2 min read
A Hierarchical Deterministic (HD) wallet is the term used to describe a wallet which uses a seed to derive public and private keys. HD wallets were implemented as a Bitcoin standard with BIP 32. Before this, most wallets generated unrelated keys each time a user required a new address. This format, called a Just-a-Bunch-of-Keys (JBOK) wallet, required the wallet to backup each key individually, a significant inconvenience for both wallets and users. HD wallets can be backed up by storing a single seed of 64 bytes.
The term hierarchical describes the tree-like structure of the keys: the wallet seed derives a single master key, which is used to derive child keys, each which can derive their own children.
Each child key in the tree can be described by its derivation path, which contains information about a key’s depth and index—where it resides within the tree structure. The derivation path tells a wallet how to derive a specific key. The master key is simply refered to as ’m’. For example, the first child of the master key has a derivation path of “m/0”, and the fifth child of that child key has a derivation path of “m/0/4”. The depth of each child is given by the number of levels—each separated by a slash—between itself and the master key, and the index of each child is its number at that level, starting with zero. The key at “m/0/4” has a depth of 2 and an index of 4.
➤ Learn more about derivation paths.
This tree is deterministic: a given seed or master key will always generate the exact same tree of keys. A given master key and a derivation path will generate the same key every time. This allows users to back up a single seed instead of hundreds of keys. It also enables a user to use a parent public key, called an extended public key or xpub of a wallet to generate new addresses without accessing any private keys. This means that a user can keep their private keys in cold storage while using their public keys to continue receiving bitcoin.