In the early days of the cryptocurrency ecosystem, paper wallets were used, which were nothing more than physical representations of private keys and their corresponding public addresses printed on paper. Although these wallets could be generated deterministically or not, they had significant drawbacks, such as exposing private keys when printed on insecure devices and lacking support for managing exchange addresses.
Later, non-deterministic (non-HD) wallets appeared, where private and public keys were generated randomly and independently. Each time a new address needed to be generated, the private key had to be backed up. This architecture is known as “Just a Bunch of Keys” (JBOK). Although improvements such as the keypool were introduced in Bitcoin Core to pre-generate addresses, the risk of losing unsupported keys remained high.
Deterministic wallets introduced a new architecture that solved this problem. A seed can generate all necessary private keys, allowing full recovery of funds with the seed alone. Over time, this idea evolved into Hierarchical Deterministic (HD) wallets, which use a hierarchical structure to efficiently and securely generate and organize keys.
What is a Hierarchical Deterministic (HD) wallet?
An HD wallet is an advanced type of deterministic wallet that generates all its private and public keys from a single seed, following a hierarchical tree structure. The seed, usually represented by a mnemonic phrase of 12, 18 or 24 words, is the basis for all derived keys.
In a Hierarchical Deterministic (HD) wallet, a Master Private Key can generate multiple child keys, which in turn can generate their own derived keys. This hierarchical structure allows for secure and efficient management of multiple addresses and accounts within a single wallet, simplifying fund management.
Features of HD wallets
- Single seed: The seed allows the generation of all necessary private and public keys. Since it is represented as a mnemonic phrase (according to the BIP39 standard), it facilitates wallet backup and recovery.
- Hierarchical structure: Keys are organized in a hierarchical tree, where a parent key can generate multiple child keys, which in turn can generate their own keys. This allows for clear and orderly management of multiple accounts and addresses.
- Enhanced privacy: Each transaction can use a new address, making it harder to trace funds and improving privacy.
- Security with hardened bypass: There are two types of key derivation: normal and hardened. With normal derivation, knowing a child’s public key could, in some cases, compromise the parent’s private key. However, hardened derivation uses the parent private key to derive the child key, which prevents a compromised child key from deriving the higher private key in the hierarchy (parent key). This feature adds an extra layer of security to key derivation.
- Compatibility: HD wallets are compatible with BIP32, BIP39 and BIP44 standards, ensuring interoperability between different wallets and cryptocurrencies.
- Easy recovery: In case of device loss or damage, the wallet can be easily recovered using the seed phrase.
Key generation process in an HD wallet
- Initial seed: The seed derived from the mnemonic words is used to generate the Master Private Key and the Chain Code using the HMAC-SHA512 algorithm.
- Key derivation:
- The Master Private Key and the Chain Code are the starting point for deriving the Child Keys.
- The child keys are derived using the HMAC-SHA512 algorithm by applying the derivation index (which can be normal or hardened).
- Hierarchical structure: Derived keys are organized in derivation paths that follow a hierarchical scheme, for example:
m / purpose' / coin_type' / account' / change / address_index
Each level of the hierarchy has a defined purpose, making it easier to organize keys and addresses.
Practical applications and use of HD wallets
In addition to providing a solid technological infrastructure, HD wallets are well suited for a variety of everyday and business use cases:
- Individual users: Users can create separate accounts for different financial purposes, such as savings, investments or daily expenses. In addition, the ability to generate new addresses for each transaction enhances privacy.
- Businesses: Businesses can use HD wallets to manage multiple accounts, simplifying accounting. For example, a business can create different accounts within the same wallet for sales, vendor payments, or payroll.
- Exchanges and custodians: HD wallets enable exchanges to efficiently manage a large number of customer accounts without compromising security, simplifying private key management and auditing.
BIP32, BIP43 and BIP44 standards
- BIP32: Introduced HD wallets and defined how keys are derived hierarchically from a single seed. This allows generating a Master Private Key and deriving multiple child keys in a secure way.
- BIP43: Introduced the possibility of defining a purpose in the derivation paths, which adds flexibility to the hierarchical structure of HD wallets.
- BIP44: Defined a standard for the derivation of multiple accounts within an HD wallet, allowing clear and secure organization of funds in different accounts and cryptocurrencies.
Conclusion
Hierarchical Deterministic (HD) wallets provide a robust and efficient solution for cryptocurrency management thanks to their implementation of the BIP32, BIP43 and BIP44 standards. By using a single seed to generate multiple hierarchically organized keys, they not only simplify account and cryptocurrency management, but also strengthen user security and privacy.
The ability to derive new addresses for each transaction and the additional protection provided by hardened derivation minimizes the risk of compromising higher-level keys, making them an essential tool for users and businesses looking to protect their funds.
Not all deterministic wallets are HD, but most modern wallets have adopted the Hierarchical Deterministic structure because of its advantages in terms of organization, security, and flexibility. HD wallets represent a significant technological leap by offering a hierarchical structure that facilitates the management of multiple accounts and improves both security and flexibility in the use of cryptocurrencies.
In the next article, we will explore multi-signature wallets, which are a more advanced option for distributing control among multiple signatories, providing greater security and redundancy. Don’t miss it!
Resources:
[1] Bitcoin Developer Reference – Wallets
[2] Bitcoin Developer Guide – Wallets
[3] Understanding HD Wallets
[4] BIP32 – Hierarchical Deterministic Wallets
[5] Learn Me A Bitcoin – HD Wallets
[6] Bitcoin Wiki – Deterministic Wallet
[7] Image – BIP32 Key Derivation Diagram
At Block&Capital, we strive to create an environment where growth and success are accessible to all. If you’re ready to take your career to the next level, we encourage you to join us.
Last posts