<p>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)</p>

CC BY-SA 4.0
2021-07-12T14:01:47.157Z
This is the correct answer.  The other answers are not only incorrect but lard technical details that obscure the answer.

If I were to improve on your answer it would be to start with a conventional "units" expression:

hashes/block

And then nuance that with "average hashes/block" etc.
user5652
CC BY-SA 4.0
2018-06-04T18:06:51.363Z
2018-06-04T18:06:51.363Z
Acccumulation
<p>Difficulty has units, and these are "Trials / Nonce".  (Trials = Hashes)</p>

<p>It is the number of trials (or hashes computed) per nonce, on average, which will yield a success ( A "success" is defined as finding the variables to the hash function which will yield a result that meets or exceeds the difficulty threshold )</p>

<p>The Equation that governs this is:</p>

<p>HashRate (trials/second) = Difficulty (trials/nonce) * [Blocks_found/Blocks_expected] *  [ Size_of_nonce_space (nonces) / target_block_time (seconds) ]</p>

<p>(Note: This equation is normally used to <em>set</em> the mining difficulty to match the hashrate on the network.<br>
In our case,  we assume that difficulty threshold is <em>matched</em> to the network's HashRate, so Blocks_found = Blocks_expected, and this term reduces to unity)</p>

<p>Currently (February 2020), in the case of bitcoin, to find a block:</p>

<p>Difficulty is 15.5 Tera (trials/nonce) * 1 * ( Nonce space is 2^32 nonces / 600 seconds) =</p>

<p>107.37 Exa (trials / second) is the Hashrate</p>

CC BY-SA 4.0
2020-02-17T19:29:12.910Z
2020-02-18T09:36:36.100Z
2020-02-18T09:36:36.100Z
dbkeys
<h3>Short Answer</h3>

<p>To add to the already helpful answers here.<br>
Simple put difficulty is a scaling parameter it does not have units.</p>

<h3>Long Answer</h3>

<p>To understand what is actually is doing requires a little background:</p>

<p>A bitcoin hash is comprised of 64 hex characters. Or in other words, 16^64 unique encodings (1.15 * 10^77).</p>

<p>The minimum proof of work (PoW) for a Bitcoin is to find a hash which has 8 zero hex characters at the start of the hash:</p>

<pre><code>0x00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff
</code></pre>

<p>Therefore if you were guessing and checking (which the SHA256 algorithm is designed to be a close equivalent to), then you would need to guess 16^8 times before you could expect to find the correct hash (or there is a 1/(16^8) chance of finding the correct hash each time you compute a hash), so if you were hashing at a rate of 4.29 GH/s, you would achieve this in 1 second.</p>

<p>Bitcoin's design is to have a Block Reward every 10 minutes.  Therefore in order to ensure that the coin is mined at this rate, there will need to be an adjustment to the difficulty which is done by adding a zero to the target hash.</p>

<p>A difficulty of 1 is the minimum proof of work.  If another zero is added the difficulty doubles to 2.  It is, therefore, a judge of how many times longer it would take you to find a reward given the same hashing rate. </p>

<h3>Example</h3>

<p>The minimum PoW would be expected to require 16^8 or 4294967296 hashes to solve.  </p>

<p>As of 1/10/2020, the difficulty of Bitcoin is 13798783827516.4.  It would be expected that we would need to go through 5.92653E+22 Hashes before we found a block reward.</p>

<p>If we had a global pool hash rate of 1.0728E+20 Hashes/second.  Then we would find a block every 552.4 seconds or 9.2 minutes.</p>

<p>This is faster than the target of 10 minutes and the average would be taken to determine if it was luck or if indeed the mining pool is hashing at a faster rate and the difficulty would therefore increase.</p>

CC BY-SA 4.0
2020-01-11T00:55:00.243Z
2020-01-11T00:55:00.243Z
malanb5
<p>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.</p>

<p>AFAIK Bitcoin code do not operate on "difficulty". Instead of "difficulty" Bitcoin operates on <a href="https://en.bitcoin.it/wiki/Target" rel="nofollow noreferrer">Target</a> which is more useful in source code.</p>

CC BY-SA 4.0
2018-06-04T13:51:28.833Z
2018-06-04T14:07:12.557Z
2018-06-04T14:07:12.557Z
CoperNick
<p>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:</p>

<pre><code>consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
</code></pre>

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

<p>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...</p>

<p>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:</p>

<pre><code>log2(4306949573981.513) / 4 + 8
= 18.49245089279219
</code></pre>

<p>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.)</p>

<pre><code>0000 0000 0000 0000 0023 bfeb 3a02 1b25 7577 9256 7762 275e b72a d88b 7d50 d7f7
</code></pre>

<p>[*] 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.</p>

CC BY-SA 4.0
2018-06-04T14:57:18.987Z
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
CC BY-SA 4.0
2018-06-04T15:07:50.760Z
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
CC BY-SA 4.0
2018-06-04T17:29:23.307Z
So, is the formula    **SHA256(block+nonce)   <   2^224 / difficulty** ?
Erel Segal-Halevi
CC BY-SA 4.0
2018-06-04T17:37:24.387Z
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 https://en.bitcoin.it/wiki/Difficulty and https://bitcoin.org/en/developer-reference#target-nbits
David A. Harding
CC BY-SA 4.0
2018-06-04T14:50:14.397Z
2018-06-04T14:50:14.397Z
David A. Harding
<p>In various places, e.g. <a href="https://data.bitcoinity.org/bitcoin/difficulty/5y?t=l" rel="noreferrer">here</a> and <a href="https://bitcoinwisdom.com/bitcoin/difficulty" rel="noreferrer">here</a>, 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?</p>

<p>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.</p>

<p>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 <a href="https://blockexplorer.com/api/status?q=getDifficulty" rel="noreferrer">this link</a> shows that the current difficulty level is not an integer. </p>

<p>So, what exactly the number called "difficulty" represent?</p>

CC BY-SA 4.0
2018-06-04T13:18:19.553Z
What you meant in "second thought" is probably [Target](https://en.bitcoin.it/wiki/Target)
CoperNick
<mining-theory>
What are the units of "difficulty"?
Erel Segal-Halevi
# What are the units of "difficulty"?

(Asked by: username_0 on 2018-06-04)

In various places, e.g. [here](https://data.bitcoinity.org/bitcoin/difficulty/5y?t=l) and [here](https://bitcoinwisdom.com/bitcoin/difficulty), 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](https://blockexplorer.com/api/status?q=getDifficulty) shows that the current difficulty level is not an integer.

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

**Tags:** mining-theory

> **Comments:**
> **username_1**: What you meant in "second thought" is probably [Target](https://en.bitcoin.it/wiki/Target)  

---

## 5 answers

### Answer by username_6 on 2018-06-04. Score: 9 | Accepted answer

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.

> **Comments:**
> **username_0**: 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?  
> **username_6**: 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.  
> **username_0**: So, is the formula    **SHA256(block+nonce)   <   2^224 / difficulty** ?  
> **username_6**: 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 https://en.bitcoin.it/wiki/Difficulty and https://bitcoin.org/en/developer-reference#target-nbits  

---

### Answer by username_2 on 2018-06-04. Score: 3

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)

> **Comments:**
> **username_3**: This is the correct answer.  The other answers are not only incorrect but lard technical details that obscure the answer.  If I were to improve on your answer it would be to start with a conventional "units" expression:  hashes/block  And then nuance that with "average hashes/block" etc.  

---

### Answer by username_4 on 2020-02-17. Score: 1

Difficulty has units, and these are "Trials / Nonce". (Trials = Hashes)

It is the number of trials (or hashes computed) per nonce, on average, which will yield a success ( A "success" is defined as finding the variables to the hash function which will yield a result that meets or exceeds the difficulty threshold )

The Equation that governs this is:

HashRate (trials/second) = Difficulty (trials/nonce) \* [Blocks\_found/Blocks\_expected] \* [ Size\_of\_nonce\_space (nonces) / target\_block\_time (seconds) ]

(Note: This equation is normally used to *set* the mining difficulty to match the hashrate on the network.  
In our case, we assume that difficulty threshold is *matched* to the network's HashRate, so Blocks\_found = Blocks\_expected, and this term reduces to unity)

Currently (February 2020), in the case of bitcoin, to find a block:

Difficulty is 15.5 Tera (trials/nonce) \* 1 \* ( Nonce space is 2^32 nonces / 600 seconds) =

107.37 Exa (trials / second) is the Hashrate


---

### Answer by username_5 on 2020-01-11. Score: 0

### Short Answer

To add to the already helpful answers here.  
Simple put difficulty is a scaling parameter it does not have units.

### Long Answer

To understand what is actually is doing requires a little background:

A bitcoin hash is comprised of 64 hex characters. Or in other words, 16^64 unique encodings (1.15 \* 10^77).

The minimum proof of work (PoW) for a Bitcoin is to find a hash which has 8 zero hex characters at the start of the hash:

```
0x00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff

```

Therefore if you were guessing and checking (which the SHA256 algorithm is designed to be a close equivalent to), then you would need to guess 16^8 times before you could expect to find the correct hash (or there is a 1/(16^8) chance of finding the correct hash each time you compute a hash), so if you were hashing at a rate of 4.29 GH/s, you would achieve this in 1 second.

Bitcoin's design is to have a Block Reward every 10 minutes. Therefore in order to ensure that the coin is mined at this rate, there will need to be an adjustment to the difficulty which is done by adding a zero to the target hash.

A difficulty of 1 is the minimum proof of work. If another zero is added the difficulty doubles to 2. It is, therefore, a judge of how many times longer it would take you to find a reward given the same hashing rate.

### Example

The minimum PoW would be expected to require 16^8 or 4294967296 hashes to solve.

As of 1/10/2020, the difficulty of Bitcoin is 13798783827516.4. It would be expected that we would need to go through 5.92653E+22 Hashes before we found a block reward.

If we had a global pool hash rate of 1.0728E+20 Hashes/second. Then we would find a block every 552.4 seconds or 9.2 minutes.

This is faster than the target of 10 minutes and the average would be taken to determine if it was luck or if indeed the mining pool is hashing at a faster rate and the difficulty would therefore increase.


---

### Answer by username_1 on 2018-06-04. Score: 0

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](https://en.bitcoin.it/wiki/Target) which is more useful in source code.


---

