7

When a miner hashes a blocksheader and it produces a hash that is lower than the value represented by nBits then the PoW is considered solved.

What exactly does this mean? For example a SHA256 hash has the following structure: c45bc3de9bff9ee27fc7303a3aa4fa8022ab6608d42bbea4d72bbee9b719703b how do you determine whether this is below an nBits value?

1 Answer 1

8

nBits refers to the target. The target is inversely proportional to the difficulty, and is encoded as a compact representation of a 256-bit number. The first byte of the 32-bit field represents an exponent and the remaining 3 bytes encode a mantissa.

target explanation in detail
Image via btcinformation.org

E.g. the first (and maximum) target was 0x1d00ffff, which is the compact representation of 0x00000000ffff0000000000000000000000000000000000000000000000000000, a 256-bit number with the leading 32 bits set to zero, followed by sixteen bits set to one, followed by the remaining bits not defined by the mantissa also being set to zero.

The block hash is usually represented as a hexadecimal number (which include the letters from A–F for the numbers 10-15), but block hashes result from SHA256d hashing and the output of SHA256 is a 256-bit number (hence the name). When miners are searching for a valid block, they create a multitude of block candidates. When one of these candidates' hash digests (interpreted as a 256-bit number) is smaller than or equal than the target, the miner has found a valid block.


You can calculate the difficulty from the target with the following formula:

difficulty = max_target / current_target

where max_target stands for the above mention initial target and corresponds to the minimum difficulty. Alternatively, the formula works out to:

difficulty = 2^208 * 65535 / current_target.
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.