Applications for HD trees
Introduction
The previous section, hd_keys, described how a single master seed can generate an infinite number of cryptographic secrets. This article explains how Ledger applies this concept to develop lightweight, easily recoverable applications for signers.
Coin types
HD trees are useful because developers of different cryptocurrencies reserved a space on the tree . The developers for each cryptocurrency specified a location, called the coin’s path, where users store their private keys. This path is public information because no one can determine the value of your keys without knowing your master node, or mnemonic seed. BIP 44 defines the paths for different cryptocurrencies and the paths used to derive cryptocurrency addresses and private keys. BIP 44, in turn, defers coin type registration to SLIP 44 .
Each cryptocurrency has a node on the tree where all keys for that coin begin. This article refers to it as the coin type root node. Because the tree is hierarchical and deterministic, the same rules that apply to the master node also apply to the coin type root node. An infinite tree of keys descends from the master node, and another infinite tree descends from each coin type root node. As a result, a 24-word mnemonic seed gives you a virtually infinite1 number of Bitcoin addresses, even if you do not use Bitcoin. It also gives you a virtually infinite number of Ethereum addresses.
In the Ledger Ethereum Wallet desktop app, addresses are not derived according to BIP 44. Instead of using the derivation path m / 44’ / 60’ / account’ / change / address_index (as defined by BIP 44 for Ethereum), the Ledger Ethereum Wallet desktop app uses the derivation path m / 44’ / 60’ / 0’ / address_index.
How your wallet finds used addresses
Most BIP 44-compliant HD wallet programs, including the Ledger Bitcoin Wallet desktop app, divide your addresses into accounts. You can distribute your coins across these accounts as you might across multiple bank accounts. For example, you can use separate accounts for savings, donations, and common expenses. Each account contains two virtually infinite chains of addresses: an external chain and an internal chain, commonly called the change address chain. Every address in each chain receives a number, called the address index, starting at 0.
When your wallet software starts for the first time, it searches the blockchain for transactions involving address 0 in each chain. If it finds any transactions, it displays the address and searches for transactions involving address 1. The wallet continues until it finds an address that you have not used. It displays that address and stops searching the chain because it assumes that you have not used any later addresses.2
This process keeps the important information about your transaction history on the blockchain rather than on the signer. If you destroy or reset your wallet, you can enter your 24-word mnemonic seed into a new HD wallet. The wallet then searches the public blockchain for the information it needs.
Summary
A diagram of a hierarchical deterministic wallet; everything in the box labelled “hierarchical deterministic tree” is recoverable if your wallet is lost, destroyed, or reset because it is all derived from the master seed
An HD wallet has three important properties:
- The 24-word mnemonic seed generates the tree that makes up an HD wallet. This seed is all you need to generate your cryptocurrency addresses and sign transactions.
- You do not need to save individual private keys. Even as you receive Bitcoin at more addresses, the corresponding private keys remain available in the HD tree.
- Ledger uses the industry-standard BIPs 32, 39, and 44 for HD wallets. Your 24-word mnemonic seed works with any HD wallet that supports these standards, not only Ledger wallets.
Going beyond cryptocurrencies
Hierarchical deterministic wallets can do more than secure assets on blockchains. You can extend the same concept and use your master seed to derive passwords, PGP keys, and SSH keys.
For example, Ledger developed a Password Manager app . It converts a node on the HD tree into a text password that appears random. When you create a password, you enter a label such as “Google”, “Dropbox”, or “Twitter”. The password’s label encodes the location of its node on the HD tree. When you request the password, the app uses the label to locate the node and convert it into text. You cannot specify your own passwords; the app generates them for you.
Footnotes
Footnotes
-
In this case, virtually infinite = 263 = 9 223 372 036 854 775 808. ↩
-
In this example, we described a wallet that operates with a gap limit of 1. Different wallet software use different values, but BIP 44 currently recommends a gap limit of 20. ↩