3

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? isn't what I'm asking about.

2 Answers 2

6

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.

8
  • but I've heard many times that "a wallet is basically your private key (or private/public pair)" which implies "one" Aug 12, 2020 at 13:08
  • 5
    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". Aug 12, 2020 at 13:14
  • 1
    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. Aug 12, 2020 at 13:14
  • 1
    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
    Aug 12, 2020 at 13:55
  • @Murch: Please read this comment by the OP - bitcoin.stackexchange.com/questions/98502/…. 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. Aug 12, 2020 at 14:30
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.

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.

6
  • You haven't read it carefully -- I'm not asking about modern wallets Aug 12, 2020 at 11:12
  • 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. Aug 12, 2020 at 11:13
  • 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. Aug 12, 2020 at 11:42
  • @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 Aug 12, 2020 at 11:53
  • @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. Aug 12, 2020 at 12:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.