6

I have read from many sites that an address should change every time a Bitcoin transaction is made. Does the private key change along with the Bitcoin address. How is the address obtained from the public key? Is it the same method of deriving the public key from the private key?

2 Answers 2

9

You have many private keys

Quintessentially, a wallet is a key chain for your private keys plus optional convenience and usability functions. When you create a wallet, at least one but usually lots of private keys are generated. E.g. Bitcoin Core keeps 100 unused private keys in store at all times by default, and whenever you use a new address, this pool of unused keys get topped up again.

You have a different private key for each address

  1. From a private key, you can easily derive the corresponding public key: Together they form an ECDSA key pair on the secp256k1 curve. You cannot easily derive the private key from the public key.
  2. The address is then derived from the public key: First you hash the public key with SHA-256, then you hash the result with RIPEMD-160. The result is then formatted in Base 58 including a checksum.

Therefore, each private-key only corresponds to one address. (Vice versa, each address corresponds to 2^96 private keys, of which any one is sufficient to spend any funds associated with the address, but that doesn't concern us here.)

The above is true for any wallet that uses unrelated private keys. There is also another scheme which is called hierarchical deterministic wallet: There, you create one "master key" from which you can recreate all following keys deterministically.
Simplified:

    Master key:     12378925612143
    key + 1:        12378925612144
    key + 3:        12378925612146
    key + 6:        12378925612149
    key + 10:       12378925612153
    key + 15:       12378925612168
    key + 21:       12378925612174
    key + 28:       12378925612181
    …

As you can see, if you have the master key, and know the derivation rule, you can recreate the same keys again.

This is safe, because even when providing a signature, your private key is never revealed, or even when you reveal one out of your chain of private keys, your derivation rule is still unknown.

Different addresses are for privacy

Why should you actually use a different address every time? Actually, it is fine to use an address for multiple transactions. Most wallets do not do it, to increase privacy: If you use the same address over and over again, it is obvious that all these transactions are related to the same person. By using a new address for every transaction, transactions may still be linked by clever blockchain analysis but it isn't immediately obvious, may be plausibly deniable, or (with some effort) transactions can even appear completely unrelated.

8

If you are posting different questions I suggest, posting them up in different threads. But I'll try to answer all of them.

1) It doesn't work like that. Every address is a pair (private key, public key), the address is made after hashing the public key twice.

So, each address has one private key and private keys are not shared.

So if in one address you have 1 btc, and you want to send 0.5 btc to some other address, usually the wallet software creates a new address that receives the difference minus the tx fee, that's your change address and any further transaction that spends the funds will spend from that address (the change address).

To clarify, address A has 1 btc. You want to send 0.5 btc to some address B.

What happens is, the balance of address A is fully spent into

B          (0.5)    <--- amount you want to spend
C          (0.4999) <--- amount you are left with after spending
fee        (0.0001) <--- transaction fee on spending B
A (total)  (1)      <--- original balance. fully spent

C is your change address, and when you spend your coins again you will spend from C and not from A.

2) The Public Key is obtained with one method related to how the way ECDSA works and the address is obtained by another method, mainly it is double hash of the public key that is encoded in a format called base58check as it includes a checksum to ensure that you didn't type the wrong address, also base 58 is designed to eliminate similarly looking characters, like 0 and O or l and I.

3) For the last question I'd like to refer you to How are bitcoins reassigned

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.