Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: cloudboy on November 08, 2015, 10:05:47 PM



Title: How to hash the genesis block?
Post by: cloudboy on November 08, 2015, 10:05:47 PM
Hi,

I know this question has been rehashed (pun intended) many times, but I'm having trouble generating the genesis block from the raw hex.

From http://webbtc.com/block/000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f.hex
I can see that the raw hex of the genesis block is:

Code:
0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a29ab5f49ffff001d1dac2b7c0101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000

But when I put that into a sha256 online hasher, it returns
Code:
26aeebfa225713245a3a5d3f4ce26eb63fae6ec5316274c8cc0aa4d6852b5522


Title: Re: How to hash the genesis block?
Post by: achow101 on November 08, 2015, 10:39:48 PM
You need to hash the header, which is the first 80 bytes (160 characters). You must hash that as binary data, this site is helpful: http://www.fileformat.info/tool/hash.htm. Then you must hash the sha256 hash of the header also as binary data. Lastly, you must reverse the sha256 bytes to get the hash.


Title: Re: How to hash the genesis block?
Post by: cloudboy on November 08, 2015, 10:56:59 PM
You need to hash the header, which is the first 80 bytes (160 characters). You must hash that as binary data, this site is helpful: http://www.fileformat.info/tool/hash.htm. Then you must hash the sha256 hash of the header also as binary data. Lastly, you must reverse the sha256 bytes to get the hash.

Thanks!