Let's pick this example blockheader-hashing in Python:
from hashlib import sha256 import hashlib header = "0000002066720b99e07d284bd4fe67ff8c49a5db1dd8514fcdab610000000000000000007829844f4c3a41a537b3131ca992643eaa9d093b2383e4cdc060ad7dc548118751eb505ac1910018de19b302".decode('hex') print sha256(sha256(header).digest()).digest()[::-1].encode('hex') // result is 00000000000000000020cf2bdc6563fb25c424af588d5fb7223461e72715e4a9
I know that it's part of the protocol and otherwise, a block will not be accepted, but:
- Why do we not accept a hash that ends with all those zeros? Is it because it's easier for a program to calculate
if hash < expected_hash?
- But in this case, I don't understand why do we do not simply accept a hash
sha256(sha256(header).digest()).digest().encode('hex')that is lower than the expected hash? The probability to get that should be as high as the inversed one.
So what's the reason of inversing it?