<p>Modern wallets are hierarchical deterministic (HD) wallets.</p>
<p>A root key is used to derive an effectively infinite number of private keys using systems such as <a href="https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki" rel="nofollow noreferrer">BIP32</a>.</p>
<p>Each derivation results in a single public/private keypair, and hence a single address at that level.</p>
<p>Prior to the usage of HD wallets, things were a bit more straighforward - every time you requested a new address from the wallet, it would generate a new, random private key and store it in the wallet file, and give you the address created by the public key for the new private key.</p>
<p>The move to HD wallets was done for ergonomic and safety reasons - in older wallets, if you did not make a backup after every new address, you would lose any addresses generated after your most recent backup if the wallet file was lost. With HD wallets, only the root key (commonly a BIP39 mnemonic) must be backed up - all addresses and their keys can be recovered from it.</p>

CC BY-SA 4.0
2020-08-12T11:12:28.510Z
You haven't read it carefully -- I'm not asking about modern wallets
zirnamaraji
CC BY-SA 4.0
2020-08-12T11:13:20.613Z
Not-modern wallets did the same thing, just without a single root key - For each address in a non-deterministic wallet, the wallet software would generate a new, random private key.
Raghav Sood
CC BY-SA 4.0
2020-08-12T11:42:00.107Z
An important point you've left out (regarding traditional wallets) is that several keys are actually generated in advance, so that backups remain relevant for some time after they are created. The wallet would be unusable if you actually had to create a new backup everytime you send or receive money.
Meni Rosenfeld
CC BY-SA 4.0
2020-08-12T11:53:21.480Z
@MeniRosenfeld True, but I figured it was best to give the overall approach rather than specifics - not all non-HD wallets had keypools, iirc, although Bitcoin Core and other commonly used ones generally did
Raghav Sood
CC BY-SA 4.0
2020-08-12T12:22:34.097Z
@RaghavSood: I think this point is a key part of what the OP was asking, even if they didn't necessarily realize it. I don't think "generating multiple keys" is a huge leap - the interesting question is is how can we actually use the wallet when it keeps generating new keys. And pre-generating keys is the missing piece of this puzzle.
Meni Rosenfeld
CC BY-SA 4.0
2020-08-12T14:00:57.447Z
Oh, I see that the discussion had already been had. -- you're both right, in that both parts are necessary to fully understand what's going on. :)
Murch
CC BY-SA 4.0
2020-08-12T08:46:31.157Z
2020-08-12T11:15:21.900Z
2020-08-12T11:15:21.900Z
Raghav Sood
<p>Well, it's very simple. Traditional wallets just generate multiple private keys.</p>
<p>A private key is basically a randomly generated number. You can generate several of those, and store them all in a file.</p>
<p>This poses a challenge with backups, because you have to keep saving new backups - and even if you do, as you continue using the wallet, your coins could be in an address for which the key is not found in your most recent backup.</p>
<p>The solution - which works well in most cases - is to simply generate several (by default 100 I think) keys <em>in advance</em>, and store them in the backup as well. As you use more addresses, keys are chosen out of the pre-generated pool, and more keys are generated in advance to replenish it. This way, a backup can still be relevant long after it was created.</p>

CC BY-SA 4.0
2020-08-12T13:08:51.177Z
but I've heard many times that "a wallet is basically your private key (or private/public pair)" which implies "one"
zirnamaraji
CC BY-SA 4.0
2020-08-12T13:14:39.610Z
The word "basically" hints at the fact that this is a simplification. If "wallet" literally meant "private key", people would have just said "private key" instead of "wallet".
Meni Rosenfeld
CC BY-SA 4.0
2020-08-12T13:14:42.237Z
In general, there's not really a universal definition for "wallet", it can mean different things in different contexts. If the word is confusing, we should try to avoid using it. The Bitcoin-qt software generated multiple private keys, each with their associated address, and stored them in a file. Whether you use the word "wallet" to refer to the software, the address, the file, something else, or some combination of the above, doesn't change the essence of what's actually happening.
Meni Rosenfeld
CC BY-SA 4.0
2020-08-12T13:55:57.540Z
Today, Bitcoin Core and many other wallets use HD wallets to ensure that backups remain valid indefinitely to retrieve funds. Regular backups are still important as otherwise the meta information about transactions would be lost.
Murch
CC BY-SA 4.0
2020-08-12T14:30:31.330Z
@Murch: Please read this comment by the OP - https://bitcoin.stackexchange.com/questions/98502/how-can-a-user-or-wallet-have-multiple-addresses-at-all-if-out-of-a-private-key/98507?noredirect=1#comment111576_98503. And also the specification in the question that the OP is not asking about "this", where "this" is a question and answer regarding HD wallets.
Meni Rosenfeld
CC BY-SA 4.0
2020-08-12T18:17:33.063Z
Although I see that the OP is not specifically asking about modern wallets, I think it is still misleading to declare keypools to be "the solution", since essentially nothing uses this approach anymore as far as I know.
Glenn Willen
CC BY-SA 4.0
2020-08-12T19:51:28.060Z
@GlennWillen: 1. My answer starts with the words "traditional wallets". The solution is the solution to a challenge in traditional wallets. Regardless of the fact that it is now mostly of historic significance. 2. The OP is not just "not specifically asking about modern wallets", they are *specifically not asking about modern wallets*, as per their comment, which I took into consideration while writing this answer.
Meni Rosenfeld
CC BY-SA 4.0
2020-08-13T06:30:36.137Z
Right, and I had read your answer first, since it was on the top, and from the question and your answer it was not clear to me why you didn't mention derivation. Later, I saw Raghav's answer (being on my phone). Either way, even if the asker was asking about "non-modern" wallets, it would make sense to me to mention the modem approach for other readers as a counterpoint.
Murch
CC BY-SA 4.0
2020-08-12T11:40:13.743Z
2020-08-12T11:45:26.793Z
2020-08-12T11:45:26.793Z
Meni Rosenfeld
<p>A user of a wallet, regardelss of a version of a wallet, <strong>can generate as many addresses</strong> as he wants, right?</p>
<p>Since an address is basically a public key, and in &quot;private-public key&quot; cryptograpthy there's only one public key that corresponds to a private key, how is generating <strong>lots of addresses</strong> possible at all?</p>
<p>This <a href="https://bitcoin.stackexchange.com/questions/35983/can-same-private-key-generate-multiple-addresses">Can same private key generate multiple addresses?</a> isn't what I'm asking about.</p>

<wallet><address><private-key><public-key>
How can a user or wallet have multiple addresses at all if out of a private key can be generated only a single public key?
zirnamaraji
# How can a user or wallet have multiple addresses at all if out of a private key can be generated only a single public key?

(Asked by: username_0 on 2020-08-12)

A user of a wallet, regardelss of a version of a wallet, **can generate as many addresses** as he wants, right?

Since an address is basically a public key, and in "private-public key" cryptograpthy there's only one public key that corresponds to a private key, how is generating **lots of addresses** possible at all?

This [Can same private key generate multiple addresses?](https://bitcoin.stackexchange.com/questions/35983/can-same-private-key-generate-multiple-addresses) isn't what I'm asking about.

**Tags:** wallet, address, private-key, public-key


---

## 2 answers

### Answer by username_2 on 2020-08-12. Score: 6 | Accepted answer

Well, it's very simple. Traditional wallets just generate multiple private keys.

A private key is basically a randomly generated number. You can generate several of those, and store them all in a file.

This poses a challenge with backups, because you have to keep saving new backups - and even if you do, as you continue using the wallet, your coins could be in an address for which the key is not found in your most recent backup.

The solution - which works well in most cases - is to simply generate several (by default 100 I think) keys *in advance*, and store them in the backup as well. As you use more addresses, keys are chosen out of the pre-generated pool, and more keys are generated in advance to replenish it. This way, a backup can still be relevant long after it was created.

> **Comments:**
> **username_0**: but I've heard many times that "a wallet is basically your private key (or private/public pair)" which implies "one"  
> **username_2**: The word "basically" hints at the fact that this is a simplification. If "wallet" literally meant "private key", people would have just said "private key" instead of "wallet".  
> **username_2**: In general, there's not really a universal definition for "wallet", it can mean different things in different contexts. If the word is confusing, we should try to avoid using it. The Bitcoin-qt software generated multiple private keys, each with their associated address, and stored them in a file. Whether you use the word "wallet" to refer to the software, the address, the file, something else, or some combination of the above, doesn't change the essence of what's actually happening.  
> **username_3**: Today, Bitcoin Core and many other wallets use HD wallets to ensure that backups remain valid indefinitely to retrieve funds. Regular backups are still important as otherwise the meta information about transactions would be lost.  
> **username_2**: @username_3: Please read this comment by the OP - https://bitcoin.stackexchange.com/questions/98502/how-can-a-user-or-wallet-have-multiple-addresses-at-all-if-out-of-a-private-key/98507?noredirect=1#comment111576_98503. And also the specification in the question that the OP is not asking about "this", where "this" is a question and answer regarding HD wallets.  
> **username_4**: Although I see that the OP is not specifically asking about modern wallets, I think it is still misleading to declare keypools to be "the solution", since essentially nothing uses this approach anymore as far as I know.  
> **username_2**: @username_4: 1. My answer starts with the words "traditional wallets". The solution is the solution to a challenge in traditional wallets. Regardless of the fact that it is now mostly of historic significance. 2. The OP is not just "not specifically asking about modern wallets", they are *specifically not asking about modern wallets*, as per their comment, which I took into consideration while writing this answer.  
> **username_3**: Right, and I had read your answer first, since it was on the top, and from the question and your answer it was not clear to me why you didn't mention derivation. Later, I saw username_1's answer (being on my phone). Either way, even if the asker was asking about "non-modern" wallets, it would make sense to me to mention the modem approach for other readers as a counterpoint.  

---

### Answer by username_1 on 2020-08-12. Score: 5

Modern wallets are hierarchical deterministic (HD) wallets.

A root key is used to derive an effectively infinite number of private keys using systems such as [BIP32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki).

Each derivation results in a single public/private keypair, and hence a single address at that level.

Prior to the usage of HD wallets, things were a bit more straighforward - every time you requested a new address from the wallet, it would generate a new, random private key and store it in the wallet file, and give you the address created by the public key for the new private key.

The move to HD wallets was done for ergonomic and safety reasons - in older wallets, if you did not make a backup after every new address, you would lose any addresses generated after your most recent backup if the wallet file was lost. With HD wallets, only the root key (commonly a BIP39 mnemonic) must be backed up - all addresses and their keys can be recovered from it.

> **Comments:**
> **username_0**: You haven't read it carefully -- I'm not asking about modern wallets  
> **username_1**: Not-modern wallets did the same thing, just without a single root key - For each address in a non-deterministic wallet, the wallet software would generate a new, random private key.  
> **username_2**: An important point you've left out (regarding traditional wallets) is that several keys are actually generated in advance, so that backups remain relevant for some time after they are created. The wallet would be unusable if you actually had to create a new backup everytime you send or receive money.  
> **username_1**: @username_2 True, but I figured it was best to give the overall approach rather than specifics - not all non-HD wallets had keypools, iirc, although Bitcoin Core and other commonly used ones generally did  
> **username_2**: @username_1: I think this point is a key part of what the OP was asking, even if they didn't necessarily realize it. I don't think "generating multiple keys" is a huge leap - the interesting question is is how can we actually use the wallet when it keeps generating new keys. And pre-generating keys is the missing piece of this puzzle.  
> **username_3**: Oh, I see that the discussion had already been had. -- you're both right, in that both parts are necessary to fully understand what's going on. :)  

---

