I do a sort of bitcoin 101 presentation for folks where I work. In one of the recent sessions, someone asked why the proof of work difficulty requires a minimum number of leading 0s. Why not 1s or something else?
Not understanding the math behind it in-depth, the best answer I can come up with is that the protocol requires that the proof of work hash (hash of nonce and block data) should be equal to or lower than the difficulty target. Hence, you can interpret it as having to contain a certain number of leading 0s.
Is there a better explanation?
Thanks!
Here's a code snippet of how hash target was adjusted (it was effectively multiplied by the ratio of actual time taken over the time desired by satoshi) -- https://github.com/bitcoin/bitcoin/blob/4405b78d6059e536c36974088a8ed4d9f0f29898/main.cpp#L716.
Here's a code snippet where the comparison was actually made -- https://github.com/bitcoin/bitcoin/blob/4405b78d6059e536c36974088a8ed4d9f0f29898/main.cpp#L2345
– Randy Aug 09 '21 at 00:59