How is hash160 calculated from an unseen public key?

3

2

I was looking thru Block explorer at an address with a balance. It has never been spent from thus the public key is unknown. If the public key is unknown, how can Block explorer calculate the hash160 of the public key?

joe

Posted 2013-03-07T23:40:22.440

Reputation: 211

Answers

7

Because an address is the Hash160 (=RIPEMD160(SHA256(x))) of the public key. The transaction output lists that 160-bit hash directly.

When redeeming such an output, you provide both the public key (which must hash to the value given in the output) and a signature (which must be valid for the given public key).

Pieter Wuille

Posted 2013-03-07T23:40:22.440

Reputation: 54 032

i'm used to seeing hash algos referred to as SHA256 or RIPEMD. what is Hash160?joe 2013-03-08T04:02:42.487

1@joe Hash160 = RIPEMD160(SHA256(m)) (note that plain RIPEMD is a different, broken hash and bitcoin doesn't use it)CodesInChaos 2013-03-08T11:19:29.263

3Edited. In Bitcoin-speak, Hash(x) = SHA256(SHA256(x)) and Hash160(x) = RIPEMD160(SHA256(x)).Pieter Wuille 2013-03-10T16:13:58.360

as a related question, what is really stored in a wallet in regards to keys? just the priv keys or priv keys and pub keys? i ask since the pub keys can be derived from the priv keys.joe 2013-03-16T15:43:20.610

The Public Key Hash is equivalent to the bitcoin address, without the Base58Check encoding. RIPEMD160(SHA256(PubK)) == Base58.decode(Address) ?Haddar Macdasi 2015-03-24T23:27:39.207