1

When I go to BlockExplorer and observe the hash of block 514441's header I see it to be:

0000000000000000004ec916884d8b2cd3dc0e80ab199cc23e528e7dc10fafc6

However when I obtain the header of block 514441 from:

https://blockchain.info/rawblock/0000000000000000004ec916884d8b2cd3dc0e80ab199cc23e528e7dc10fafc6?format=hex

and I double hash the first 640 bits using Java's SHA256 implementation I get the following (they are byte reversals of each other):

c6 af 0f c1 7d 8e 52 3e c2 9c 19 ab 80 0e dc d3 2c 8b 4d 88 16 c9 4e 00 00 00 00 00 00 00 00 00

Which is the actual block header hash that has to be less than the target value?

2

Which is the actual block header hash that has to be less than the target value?

Both.

SHA256 produces an array of 32 bytes as output. Bitcoin treats those 32 bytes as a 256-bit LSB integer (least significant bit first). It is this integer that is compared to the target.

However, as humans are used to seeing numbers formatted in MSB order (most significant bit first), that too is what happens in Bitcoin. The formatting with the zeroes up front is not the output of the hash function. It is the output of the hash function, interpreted as an LSB-encoded integer, and then formatted in hexadecimal in MSB order.

| improve this answer | |
  • Thanks very much. So just to be clear it is 0000000000000000004ec916884d8b2cd3dc0e80ab199cc23e528e7dc10fafc6 that is compared to the target? – MSJ Apr 17 '18 at 21:30
  • That depends what you mean by "00000...afc6". If that is your way of writing an integer with the most significant hex character first, yes. – Pieter Wuille Apr 17 '18 at 21:54
  • Okay, and by LSB did you really mean Lease Significant Byte first as opposed to Least Significant Bit? – MSJ Apr 17 '18 at 23:29
  • There is no distinction between the two when the smallest unit you're looking at is bytes. I mean bits. – Pieter Wuille Apr 17 '18 at 23:35

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.