In various places, e.g. here and here, there are plots of the "difficulty" of bitcoin mining over time. What exactly is the interpretation of these numbers - in what units are they measured?

My first thought was that the "difficulty" is the number of bits that should be zero in SHA256(block+nonce). But, in this case the difficulty should have been a number between 0 and 255, and these sites show much higher numbers.

My second thought was that SHA256(block+nonce) should be at most 2^256-difficulty. But, in this case it should be an integer, while this link shows that the current difficulty level is not an integer.

So, what exactly the number called "difficulty" represent?

  • What you meant in "second thought" is probably Target – CoperNick Jun 4 '18 at 13:18

Difficulty is a multiple of the minimum amount of Proof of Work (PoW) any valid block can contain. In Bitcoin, the minimum difficulty (called difficulty 1) is defined in the code by this byte mask:

consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");

That is, a hash must start[*] with 8 hexadecimal zeros. That's 4 zero bytes, or 32 zero bits.

If you double that difficulty, that's difficulty 2. Double it again and it's difficulty 4, then 8, then 16. At difficulty 16, the hash must have at least 8 + 1 = 9 zeros. Double it again and it's 32, then 64, then 128, then 256. At difficulty 256, the hash must have a minimum of 8 + 2 zeros. Et cetra...

As I write this, the current difficulty is 4306949573981.513. We can see how many minimum zeros that corresponds to by taking its binary log, dividing by the 4 bits that are in in half a byte (one hexadecimal character) and adding the eight zeros from the minimum difficulty:

log2(4306949573981.513) / 4 + 8
= 18.49245089279219

For comparison, here's the most recent block header hash (reformatted into byte pairs for readability). It has 18 zeros, as expected. (Note: if you do this experiment at home, note that the hashes are always allowed to have more zeros; they just can't have less.)

0000 0000 0000 0000 0023 bfeb 3a02 1b25 7577 9256 7762 275e b72a d88b 7d50 d7f7

[*] Bitcoin is weird. We display hashes backwards from most other software, so the zeros that start a block header hash are actually at end if you use any non-Bitcoin software to do the hashing.

  • So, 32+log2(difficulty) is the number of initial bits that should be zero? If so, shouldn't the difficulty level always be a power of two, as in your examples? – Erel Segal-Halevi Jun 4 '18 at 14:57
  • 1
    Yes, that's the number of bits. However, in Bitcoin (unlike hashcash), difficulty can be fractional because the amount of PoW required (the "target") is specified using a byte mask rather than just the number of bits. For example, a byte mask of 00000000ffff...fffe would require on average just doing one more hash than the minimum difficulty. In practice, Bitcoin targets have limited precision, but they're plenty precise enough to provide for very fractional difficulty. – David A. Harding Jun 4 '18 at 15:07
  • So, is the formula SHA256(block+nonce) < 2^224 / difficulty ? – Erel Segal-Halevi Jun 4 '18 at 17:29
  • Difficulty is calculated from the target, which is itself derived from 32 bits in the header of every block. For formulas you can use to calculate it, see en.bitcoin.it/wiki/Difficulty and bitcoin.org/en/developer-reference#target-nbits – David A. Harding Jun 4 '18 at 17:37

Difficulty represents the expected number of hashes it takes to find a valid one. The probability of a hash being valid is inversely proportional to the difficulty. The constant of proportionality is (2^16-1)/(2^48); that is, the probability of a hash being valid is (2^16-1)/(difficulty*2^48)


It means how many times it is harder to mine than in the early days of Bitcoin. In early days it was used some kind of minimum difficulty.

AFAIK Bitcoin code do not operate on "difficulty". Instead of "difficulty" Bitcoin operates on Target which is more useful in source code.

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.