What should be less than the target?

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?

MSJ

Posted 2018-04-17T21:18:04.067

Reputation: 11

Answers

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.

Pieter Wuille

Posted 2018-04-17T21:18:04.067

Reputation: 64 874

Thanks very much. So just to be clear it is 0000000000000000004ec916884d8b2cd3dc0e80ab199cc23e528e7dc10fafc6 that is compared to the target? – MSJ – 2018-04-17T21:30:46.270

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 – 2018-04-17T21:54:37.713

Okay, and by LSB did you really mean Lease Significant Byte first as opposed to Least Significant Bit? – MSJ – 2018-04-17T23:29:17.110

There is no distinction between the two when the smallest unit you're looking at is bytes. I mean bits. – Pieter Wuille – 2018-04-17T23:35:06.793