0

There is something i am not sure to understand on bitcoin private/public keys and addresses.

A new bitcoin user "U" first generates a private key. He can compute several public keys from this private key.

When he wants to receive bitcoins, the user should generate an address. I do not understand if this address is a public key or if it is 2 different things.

If my "U" user should receive bitcoin from 10 different people, he can generate a single common address for this 10 peoples but they will be able to see "U" balance, and see that he receives 10 transactions. The solution is to generate 10 different addresses. With this solution, each sender will only see its own transaction and won't see the 9 others. I am wrong ?

So, to shortcut, can we say "U" generates 10 "virtual accounts", linked to its private key ?

If so, i do not understand how "U" can computes its own balance: Is there a way for him to recover all public/address he generates from its private key ? Or should user keep all the addresses he generates in a file ?

Thanks

2

A modern Bitcoin wallet program can generate many private-keys, each private-key has a public-key. For the most common transaction types, a Bitcoin-address is derived from the public-key.

As you say it is normal to generate a new address (i.e. a new set of keys) for each transaction. This is because all the transaction data is public knowledge - it is in the replicated journal of transactions we call the blockchain. Anyone can see all transactions for a specific address, so if ten people each pay you 1 BTC to the same address, they can all see that you have received 10 BTC in total at that address. This is a privacy concern. If the addresses are all different, they can't tell which belong to the same person.

In the Bitcoin network there are no accounts, no virtual accounts and no balances.

A wallet can read through the whole transaction journal and add up all the unspent amounts in transactions where the receiving address is one for which the wallet knows it has the corresponding private-key. That way it can present a total amount to the user. People refer to this total as a balance but that's misleading. The Bitcoin network does not keep a record of people's balances. The Bitcoin network does not know how much money anyone has in total. The US Mint does not know how many US one-cent coins I have sitting in a plastic bag on my shelf, it doesn't keep track of my balance or have an account in my name.

The terminology for Bitcoin is a bit muddled. Bitcoin was designed as digital cash. Accounts and balances are associated with banks, not with piles of dollar bills under your mattress or in your leather wallet. If you were talking about cash in the form of paper money and metal coins you wouldn't think about accounts and balances. You'd just want to know the total amount of money you have in paper banknotes and metal coins.

Modern wallets are what is called Hierarchical Deterministic (HD) wallets. From the initial private key (or seed phrase) it is possible to generate all the subsidiary keys and addresses in a predictable and repeatable way. You don't need to make a backup of each generated key and generated address.

| improve this answer | |
0

A new bitcoin user "U" first generates a private key. He can compute several public keys from this private key.

The kind of private key you are referring to is an extended private key which is described in the Bitcoin Improvement Proposal 0032 (BIP32) or, like RedGrittyBrick explained, what powers HD wallets.

An extended private key contains only one "regular" private key in them, and can generate directly only one extended public key.

However, these extended private keys contain also some other information that makes it possible for them to generate other vast amount of child extended private keys that also contain "regular" private keys, and these child extended private keys can have their own vast amount of child extended private keys, and this can go on and on.

When he wants to receive bitcoins, the user should generate an address. I do not understand if this address is a public key or if it is 2 different things.

They are 2 different things. There are also different type of addresses, but excluding the multi-signature kind of addresses, they are all computed by encoding the hash of the public key. So an address is not a public key, but it is derived from it (P2PKH, P2WPKH). The type of address lets you know what kind of Bitcoin technology you are using to lock the BTCs.

If my "U" user should receive bitcoin from 10 different people, he can generate a single common address for this 10 peoples but they will be able to see "U" balance, and see that he receives 10 transactions. The solution is to generate 10 different addresses. With this solution, each sender will only see its own transaction and won't see the 9 others. I am wrong ?

This is exactly why BIP32 was proposed. An extended private key is also referred as a master private key which can generate all the child keys necessary to ensure privacy. Since you can generate with the master key an infinite amount of private keys, and therefore public keys, then you can generate an infinite amount of addresses.

So, to shortcut, can we say "U" generates 10 "virtual accounts", linked to its private key ?

Yes, but remember that they would be linked to the master/extended private key. Each address has its own private key, and the private key is generated by the master key.

If so, i do not understand how "U" can computes its own balance: Is there a way for him to recover all public/address he generates from its private key ? Or should user keep all the addresses he generates in a file ?

I think RedGrittyBrick does an amazing job at explaining why we shouldn't use the term "balance" or "virtual account", etc. But, I guess your question is how can you know how many BTCs you have access to with your master private key, right? well that is the job of the wallet. A wallet must be able to store or generate the addresses that you have used, and then scan the blockchain for Unspent Transaction Outputs (UTXOs) or in other words, unspent Bitcoins that related to those addresses. Then, The wallet adds up all these BTCs to present you with this single final amount that some people wrongly call "balance".

| improve this answer | |
  • Thanks a lot for your answer. There is something i do not understand: Imagine a lose my wallet. I have read i can recover my bitcoins if i keep my private key. So how does it work ? Should i also baclup my UTXOs somewhere ? – Bob5421 Sep 16 at 6:23
  • Try to look up BIP32, BIP44 and BIP39. So, basically wallets try to use standards for address creation, which means that it's pretty easy to know what addresses the wallet is going to try to use first from the hierarchy tree (BIP32) that is derived from the master private key. So if you have you master private key, or you mnemonic phrase, then any wallet can scan the addresses derived following the BIP44 pattern to discover your UTXOs. Not all wallets are the same tho. Try to stick to one that follows BIPs or at least lets you know what protocol for address creation they use. – Oscar Serna Sep 16 at 7:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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