What are Hierarchical Deterministic (HD) Wallets?
|— Hierarchical Deterministic (HD) wallets allow you to manage a near infinite number of accounts with just one secret recovery phrase|
— HD wallets were introduced with the BIP-39 standard, and today they are the most popular type of wallet due to their convenience.
— HD wallets let you back up your entire wallet in ease, plus, they also allow you to recover your original wallet on whichever HD wallet interface you choose.
Hierarchical Deterministic Wallets: they may seem complex, but in fact, they only exist to make your life easier. Without them, you wouldn’t be able to recover your wallet with ease, never mind all of the accounts associated with them. But what are they exactly?
Well, put simply HD wallets are all about convenience. Let’s see how exactly:
What Is a Hierarchical Deterministic (HD) Wallet?
A hierarchical deterministic wallet is a crypto wallet that uses a hierarchical structure to derive key pairs (your public and private keys). To explain, each crypto wallet can generate multiple key pairs, with each key pair controlling a separate account. HD wallets generate their key pairs in several layers, with each layer responsible for generating the next layer of key pairs.
To explain the significance of this, let’s first dive into the problem they are trying to solve.
The Origin of HD Wallets
In the past, non-deterministic (ND) Bitcoin wallets used to generate random key pairs for controlling accounts. These two codes were not related to each other, despite making up the two integral pieces of the same account. This resulted in users having to back up each key pair individually. So, if you had 3 accounts, you’d have to record the private and public keys for each of those accounts—so six codes in total— and store them somewhere safe.
For just three accounts, this method is not exactly detrimental. However, when managing multiple accounts, each with their own unrelated key pairs, this was quite impractical.
Bitcoin Improvement Proposal 32 (BIP-32) provided the solution to this problem in 2012. In short, it introduced a hierarchical tree-like structure for wallets, wherein a random number called the entropy is the foundation, allowing you to derive an almost infinite number of private keys..
What are HD wallets for?
So, you might be wondering, what are HD wallets for exactly?
The main reason for HD wallets is convenience. With just one single code, you can back up an almost infinite number of accounts.
Another reason you may want to use an HD wallet is for privacy. With this method, it’s easy to set up a new account for a single transaction and manage it from the same interface as all of your other accounts.
For example, let’s say you run a blog and allow for Bitcoin donations. To accept the donations, you’ll need to share your public address. However, the blockchain is transparent, so anyone with your public address can see all of the funds in that account.
With HD wallets, you can set up an account for a single purpose, and share the public key to that account without anyone knowing the address of the master account. And you can do this as many times as you like with the confidence you can manage all of those accounts with a single secret recovery phrase.
How do Hierarchical Deterministic (HD) Wallets work?
All HD wallets start with a long random number called the entropy. This long number contains the same information as your secret recovery phrase, it’s just in a less human-readable format.
Your HD wallet then uses the entropy to generate the master private key, also called the extended private key (xPRIV). And it also generates an extended public key (xPUB), which will show the balance of all of the accounts managed by the xPRIV if found. Thus, keeping your xPUB private is probably a good idea if you don’t want the public to know your overall crypto holdings.
Each time you add a new account, your wallet derives a new private key from that extended private key(xPRIV). And it does so using a trapdoor function; meaning it’s very easy to work out the associated private keys using the master private key, but impossible to work out the master private key with a private key further down the hierarchy.
Next, your wallet will derive a public key from your newly created private key. Again, your wallet uses this trapdoor function, meaning your public key is suitable to share with the public: it will only show the balance in that specific account and allow you to receive funds. Importantly, since it’s derived directly from them, it retains a cryptographic link to the private key and the xPRIV too. This allows you to restore each account at the bottom of the hierarchy with a private key at any level above it.
At this point, it’s important to note that the same input will always result in the same output. To reiterate, a wallet will always derive the same key pairs with the same input. This means the only information you need to record is your secret recovery phrase. Your SRP points to your master keys, which in turn point to all of its private keys further down the hierarchy. That’s why HD wallets are so much more secure and accessible than previous iterations.
Hierarchical Deterministic (HD) Wallets: Why They Are So Important
In short, HD wallets are important to help you manage your crypto wallet’s backup. Without these types of wallets, you’d be stuck writing down every single public and private key for every single account controlled by your crypto wallet. And then if you lost the physical store of your keys, it would be impossible to recover your account.
HD wallets give you the ability to restore all of the accounts in a crypto wallet with a simple mnemonic which is easily readable and recordable. Plus, since it’s a standardized method and your crypto is stored on the blockchain, you can restore an entire wallet’s contents on any other interface. In short, HD wallets allow you to exercise true control over your assets, choosing to use whichever interface you please without forfeiting your custody. Because if not self-custody, then why crypto?