How does one address turn into UNLIMITED addresses?
Using a wallet in the land of crypto is far different than the traditional world. There are new words, new concepts, and, depending on the type of account you make, the process can be confusing. You can create a private key, a keystore file (a private key protected by a password), or a mnemonic phrase (a string of words that can access multiple private keys).
Aside from having different security features, the biggest difference between each of these is that a private key or keystore file only creates one account. Creating a mnemonic phrase gives you control of many accounts, all accessible with that same phrase.
A mnemonic phrase — otherwise known as a “Hierarchical Deterministic Wallet” — generates addresses by taking the phrase and combining it with a piece of information called a derivation path. Together, they create any number of accounts, using Complex Math™ aka cryptography.
Before we try to understand what a derivation path is, let’s look at what the word derive means. The standard definition of derive is “to obtain something from a specified source.” In a mathematical context, the definition is a bit more specific: “To obtain [a function or equation] from another by a sequence of logical steps, for example by differentiation.”
This, put more simply, is to obtain something, from something else, in a very specific way. “Derivation Path” is just a fancy way of saying “this is the thing you use to get all your accounts from your mnemonic phrase.”
This is what a derivation path looks like: m/44’/60’/0’/0’/0
Each of the numbers in that sequence play a part and each changes what the private key, public key, and address would be. If you’re interested in learning a little more about the technical aspects of this, you can read more here. The most important takeaway is that if you want the next address from a phrase, you just increase the last number by one:
Address #1: m/44’/60’/0’/0’/0
Address #2: m/44’/60’/0’/0’/1
Address #3: m/44’/60’/0’/0’/2
Address #99: m/44’/60’/0’/0’/98
(In programming, you start counting at 0. 0…1…2…3… rather than 1…2….3….This different than how we count in our day-to-day lives, so it can be confusing at first.)
Bitcoin and Ethereum operate differently whenever you send a transaction. On the Bitcoin network, when you send coins from one address to another, you typically send your entire balance. Part of what you send goes to a receiver address, and the remainder goes to a secondary, or “change,” address. This is called “UTXO” or “Unspent Transaction Output.” In order to know the balance, you actually have to add up all the UTXO’s. A technical explanation of this can be found here.
Ethereum, on the other hand, uses an account-based system, which operates more like a traditional banking system would. This means that each account, or address, directly spends or receives value. There are several advantages to using this system, such as ease of tracing transactions and how double spending is prevented. It also allows for smart contracts to hold a balance in the same way a “normal” account would. Because of this, each Ethereum address can have a balance, contract code, and data storage, and the system allows the balance to change for any address with each transaction.
The complexity and robustness of the Ethereum Virtual Machine, which executes the contract code, is more easily served by the account method. Having the value, contract, and storage information bound to a single address saves space in the current state of the chain. A more in-depth article on these differences can be found here.
Regardless, the reason behind the mnemonic phrase, derivation path, and seemingly unnecessary complexity comes from Bitcoin. The specification was made before Ethereum even existed and helped solve a very specific problem: it allowed you to send bitcoin to the receiver and send all the “change” to a new address that you controlled without having to create, backup, and secure a new private key each time. Nifty, right?
Derivation paths and HD Wallets in general are a great example of how, slowly but surely, we are improving how we interact with the blockchain. You might have seen one when accessing a wallet via mnemonic phrase or when using a Ledger or a Trezor. Hopefully when you look at a derivation path now, it’s less meaningless numbers and more awe-inspiring technology.