Concept of Software Wallet
A software wallet uses a random number to generate a master private key.
Then, a deterministic, irreversible algorithm generates an arbitrary number of sub-private keys based on the master private key.
Why do we need a "deterministic, irreversible" algorithm? Because "deterministic" ensures that all sub-private keys can be generated from a master private key, while "irreversible" ensures that the master private key cannot be reversed by a sub-private key.
The reason why it is called hierarchical deterministic wallet is that the derivation structure of a private key is a tree structure, where a parent key can be derived from a series of child keys, and each child key can be derived from a series of grandchild keys, and so on, ad infinitum.
When we first create an HD wallet or backup a wallet, a helper word is generated. The helper word is a sequence of English words, and this sequence of words creates the seed, which in turn creates all the private keys. The sequence of words is also the backup of the wallet, which can be restored. And the seed corresponds to the random number of all deterministic wallets.
The advantage of HD wallets is that only the master public key is needed to generate any number of sub-public keys. In other words, new (public) addresses can be generated based on the master public key without the intervention of the private key (master and sub-private keys), and these addresses can actually be controlled by the master private key.
There are advantages and disadvantages, when we expose the helper key, it is also equivalent to giving away all the private keys, and the security of the digital assets you have is zero.
Why do you need so many private keys
The reason why a user needs so many private keys is illustrated by the change mechanism of a Bitcoin transaction.
A bitcoin transaction is a data structure containing an input value and an output value. This data structure is embedded with information about the code that moves a metal from its initial point (the input value) to the destination address (the output value).
When it comes to Bitcoin transaction inputs and outputs, it is important to understand the term UTXO (Unspent Transaction Output), which is the basic unit of a Bitcoin transaction and is an unused transaction output. A single used bitcoin is spread out over hundreds of transactions and hundreds of blocks as a UTXO. In reality, there is no place to store the address or balance of a USD, only a decentralized UTXO that is locked by the owner.
A UTXO can be any value, but as soon as it is created, it is as indivisible as a coin that cannot be cut in half. If a UTXO is larger than the demand for a transaction, it will still be consumed as a whole, but it will be created as a fraction of the transaction.
Here's an example of what this means. If you have a UTXO of 20 rupiah and want to pay 1 rupiah, then your transaction must consume the entire 20 rupiah UTXO and create two outputs: one that pays 1 rupiah to the recipient, and another that pays 19 rupiah in change to your wallet. In this case, most of the transactions in the exchange rate will generate change.
The question arises as to whether the change should be returned to the original address or to a new address. When Satoshi Nakamoto designed Bitcoin, he used a zero return mechanism that creates a new address for each transaction. The benefit of this design is to protect the privacy of the user of the transaction and to avoid some security risks.
In real life, it's like opening several bank accounts in different banks with multiple names and ID cards. Even if someone knows the money flow on each account, they can't trace the money flow back to the real owner of the digital currency, which is the so-called anonymity of Bitcoin.
This is why you should know why a wallet user needs so many private keys, because public and private keys always appear in pairs, each transaction may generate a change address, and the private key corresponding to these addresses storage and backup has become a technical problem of digital transactions. HD wallet by a public key can generate any number of sub-public keys, which greatly solves the hard to use digital wallet.