4

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?

3

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.
8
  • Okay, my question is then how is a hashoutput below that? This sounds super dumb, but I mean it has letters etc in it? Is it because we convert the hashoutput to a binary value? And then if that has a value lower than the nBit then we have solved the proof of work problem? Thanks for the help by the way! – no nein Jul 27 '17 at 16:00
  • @nonein: Hey, I've updated my answer to cover your follow-up questions. – Murch Jul 27 '17 at 16:41
  • Thanks! So in effect the A's etc are all numbers, thus making the whole thing correspond to a string of numbers? – no nein Jul 27 '17 at 18:04
  • Hexadecimal is a base sixteen number system. Each position may have values from 0-15 (as the decimal system can have values of 0-9 and the binary system can have values of 0-1). The sixteen "digits" are represented by 0-9 and A-F, where A stands for 10 and F stands for 15. – Murch Jul 27 '17 at 18:49
  • 1
    @Ansjovis86: Thanks for prompting me to update my answer. :) – Murch Apr 21 at 15:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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