As far as I can understand the resulting hash should start with difficulty
number of zeroes before a block can be mined. That is: H(HashOfPreviosBlock + nonce) < target
but why is a 64 bit number guaranteed to generate
-
1The nonce is only 32 bits.– Pieter WuilleMay 26, 2022 at 2:35
1 Answer
the resulting hash should start with difficulty number of zeroes before a block can be mined.
No, the hash should be less than the target for the mined block to be valid (acceptable to others).
The often repeated "number of leading zeroes" is not the reality.
The difficulty is not a count of leading zeroes and is not used in Bitcoin's assessment of block-hashes.
H(HashOfPreviosBlock + nonce) < target
The block hash is a hash of much more data than that. It includes, for example, the Merkle root and some other items in the block header.
why is a 64 bit number guaranteed to generate
The nonce is a 32 bit number and it isn't guaranteed that there exists a 32-bit value that would generate a hash less than a target. (See links under "Related" at right of web-page)
For many years it has been necessary for miners to vary much more than the nonce. There is ExtraNonce, selection and order of transactions, contents of coinbase transaction, timestamp, etc.