@@ -3,3 +3,121 @@ sidebar_position: 9
3
3
---
4
4
5
5
# HD Wallet and Seed
6
+
7
+ Introduction to Hierarchical Deterministic Wallets (HD Wallets) and Seeds.
8
+
9
+ For detailed technical information, please refer
10
+ to [ BIP-32] ( https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki )
11
+
12
+ ![ img.png] ( /img/bitcoin-hd.png )
13
+
14
+ ## 1. Hierarchical Deterministic Wallet (HD Wallet)
15
+
16
+ The Hierarchical Deterministic Wallet (HD Wallet) is a wallet structure proposed by Bitcoin Improvement Proposal 32 (
17
+ BIP-32). An HD wallet generates all private keys and public keys from a single seed, allowing users to manage multiple
18
+ addresses with a single backup and offering excellent scalability and security.
19
+
20
+ ## 2. Key Concepts
21
+
22
+ ### 2.1 Seed
23
+
24
+ The seed is the core of an HD wallet. It is a randomly generated initial value used to generate all key pairs in the
25
+ wallet. The seed is typically created by mixing random entropy provided by the user with random numbers generated by the
26
+ wallet software.
27
+
28
+ ### 2.2 Mnemonic
29
+
30
+ A mnemonic is a sequence of easily memorable words that represent the seed. This method not only makes it easier for
31
+ users to back up and restore their wallet but also reduces the risk of forgetting or losing the seed. Mnemonics usually
32
+ consist of 12, 15, 18, 21, or 24 words selected from a standardized word list.
33
+
34
+ The steps to generate a mnemonic are as follows:
35
+
36
+ 1 . ** Generate Random Entropy** : Create random numbers.
37
+ 2 . ** Calculate Checksum** : Hash the random numbers using SHA-256 and take the first few bits as the checksum.
38
+ 3 . ** Combine Data** : Combine the random numbers with the checksum.
39
+ 4 . ** Split Data** : Divide the combined data into 11-bit binary blocks.
40
+ 5 . ** Map to Word List** : Map each 11-bit binary block to a word in the standardized word list.
41
+
42
+ ### 2.3 Master Key
43
+
44
+ The master key is the first key pair generated from the seed, consisting of a master private key and a master public
45
+ key. The master key is the starting point of an HD wallet, from which all child keys can be derived.
46
+
47
+ ### 2.4 Child Key
48
+
49
+ Child keys are derived from the master key or other child keys. HD wallets use a hierarchical structure where multiple
50
+ child keys can be derived from a single master key, and each child key can further derive more child keys. The
51
+ derivation process is deterministic, meaning the same seed will always generate the same sequence of keys.
52
+
53
+ ### 2.5 Extended Public Key (xpub) and Extended Private Key (xpriv)
54
+
55
+ Extended public keys (xpub) and extended private keys (xpriv) contain additional information to support the hierarchical
56
+ structure of HD wallets.
57
+
58
+ - ** xpub** : Contains the public key, chain code, and derivation path information, allowing the generation of child
59
+ public keys without knowing the private key.
60
+ - ** xpriv** : Contains the private key, chain code, and derivation path information, allowing the generation of child
61
+ private keys and child public keys.
62
+
63
+ ### 2.6 Derivation Path
64
+
65
+ The derivation path is a string that represents the path from the master key to a specific child key. It is usually
66
+ written in a slash-separated notation, such as ` m/44'/0'/0'/0/0 ` . Each number represents a level of child key, with ` ' `
67
+ indicating hardened derivation and numbers without ` ' ` indicating non-hardened derivation.
68
+
69
+ - ** m** : Represents the master key.
70
+ - ** 44'** : Indicates adherence to the BIP-44 standard.
71
+ - ** 0'** : Represents the coin type (0 for Bitcoin).
72
+ - ** 0'** : Represents the account.
73
+ - ** 0** : Represents the receiving address.
74
+ - ** 0** : Represents the address index.
75
+
76
+ ## 3. How HD Wallets Work
77
+
78
+ The operation of HD wallets involves the following steps:
79
+
80
+ 1 . ** Generate Seed** : The user provides random entropy, and the wallet software generates the seed.
81
+ 2 . ** Generate Master Key** : The seed is used to generate the master private key and master public key.
82
+ 3 . ** Generate Child Keys** : The master key and chain code are used to generate child keys, which can further generate
83
+ more child keys.
84
+ 4 . ** Manage Keys and Addresses** : Extended public keys and extended private keys allow the generation and management of
85
+ numerous addresses.
86
+
87
+ ## 4. Advantages of HD Wallets
88
+
89
+ HD wallets have several advantages over traditional wallets:
90
+
91
+ 1 . ** Simplified Backup** : Users only need to back up the seed or mnemonic once to recover all keys and addresses.
92
+ 2 . ** Excellent Scalability** : HD wallets can generate an unlimited number of child keys and addresses, accommodating
93
+ various use cases.
94
+ 3 . ** Enhanced Security** : Extended public keys do not contain private key information, allowing the generation of child
95
+ public keys without exposing private keys.
96
+ 4 . ** Standardization** : HD wallets follow standards such as BIP-32, BIP-39, and BIP-44, ensuring compatibility and
97
+ interoperability.
98
+
99
+ ## 5. Application Examples
100
+
101
+ ### 5.1 Creating an HD Wallet
102
+
103
+ 1 . ** Generate Mnemonic** : Generate 12 mnemonic words using random entropy, such
104
+ as: ` abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about ` .
105
+ 2 . ** Generate Seed** : Create the seed from the mnemonic.
106
+ 3 . ** Generate Master Key** : Use the seed to generate the master private key and master public key.
107
+ 4 . ** Generate Child Keys** : Use the master key and chain code to generate child keys, such as the
108
+ path ` m/44'/0'/0'/0/0 ` .
109
+
110
+ ### 5.2 Recovering a Wallet
111
+
112
+ 1 . ** Enter Mnemonic** : The user inputs the backed-up mnemonic.
113
+ 2 . ** Generate Seed** : Recover the seed from the mnemonic.
114
+ 3 . ** Generate Master Key** : Use the seed to recover the master private key and master public key.
115
+ 4 . ** Generate Child Keys** : Use the master key and derivation path to recover child keys and addresses.
116
+
117
+ ## Summary
118
+
119
+ Hierarchical Deterministic Wallets (HD Wallets) achieve simplified backup, excellent scalability, and enhanced security
120
+ through the structured generation and management of seeds, mnemonics, master keys, and child keys. Extended public
121
+ keys (xpub) and extended private keys (xpriv), along with derivation paths, have made HD wallets widely used in Bitcoin
122
+ and other cryptocurrencies. Understanding the principles and key concepts of HD wallets can help better manage and use
123
+ cryptocurrency assets.
0 commit comments