1

Pay to public key hash is used in version 1 bitcoin address. Bitcoin address is calculated by sha-256 -ing the public key followed by ripemd160- ing the result. The result can then be encoded in base 58 after 3 more steps as shown in https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses Version byte and address checksum are added to the ripemd which yeilds same result without them-

This: 010966776006953D5567439E5E39F86A0D273BEE

And this: 00010966776006953D5567439E5E39F86A0D273BEED61967F6

Yeilds same result when encoded, then Why is that done?

1

How could they give the same result? You do RIPEMD160(SHA256(pubkey)). Then you add zero byte 0x0 to this and perform double SHA256. You take the first four bytes and use them as s checksum which means they are control digits which help the wallet determine you didn't misstype the address.

Now you take this whole thing zero-byte+RIPEMD160(SHA256(pubkey))+checksum and you convert it to base58check. Note: zero byte will make the address always start with '1'.

When sender gets a bitcoin address, their wallet converts it from base58check to hex, checks the checksum and removes both the zero-byte and checksum to get RIPEMD160(SHA256(pubkey)). Then it proceeds with scriptPubKey verification.

That's why it is called Pay-to-public-key-hash. Bitcoin address is just a way of encoding a public key hash.

  • Thanks! This also means that there's no way to stop spending of funds in case of a public key- address collision, since it deals with ripemd160 part only. We can know that the public key was different after the transaction has taken place. Or am I missing something? – prof.Zoom Mar 11 '17 at 18:37
  • I'm not sure I understand. Private key is used to derive only one public key. Public key is used to derive only one address. No collisions or weaknesses have been found in RIPEMD160. In case of btc, it would mean you need to first get SHA256 right to be able to use it for RIPEMD collision. – ManfredMacx Mar 14 '17 at 18:58
  • Every private key has a unique public key. Every public key is then sha256'd to get a 256 bits hash. A digest of this hash is then created using ripemd 160. Now, for all of 2^256 unique sha256 to be unique we require a sample space of at least n. See: en.bitcoin.it/wiki/Secp256k1 which is a little less than 2^256. My question is, how can you create 2^256 unique digests using 2^160 bits of ripemd-160 – prof.Zoom Mar 18 '17 at 5:25
  • Ah. Well you can't. For each address there are 2^96 private keys. The collision doesn't happen because of good design of RIPEMD160. – ManfredMacx Mar 18 '17 at 8:38

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.