What is "difficulty" and how it relates to "target"?

25

9

I don't understand what "difficulty" means and how it really relates to "target".

I understand what "target" is - it tells the miners, how small the resulting hash should be. (Basically, how many zeroes are there at the beginning, altough not exactly.)

But I don't understand what "difficulty" is, how it relates to the target and why it's important. I tried to read the article on wiki - https://en.bitcoin.it/wiki/Difficulty - but I don't have a clue what is it trying to say either.

Karel Bílek

Posted 2013-03-28T12:06:00.050

Reputation: 2 385

Answers

20

Difficulty is basically a different representation of the target to make it easier for normal humans to understand it.

Difficulty represents how difficult the current target makes it to find a block, relative to how difficult it would be at the highest possible target (highest target=lowest difficulty). The current difficulty of 6,695,826 means that at a given hash rate, it will, on average, take ~6.6 million times as long to find a valid block as it would at a difficulty of 1, or alternatively, it will take, again on average, ~6.6 million times as many hashes to find a valid block.

Difficulty is the largest possible target (0x00000000FFFF0000000000000000000000000000000000000000000000000000) divided by the current target (as of right now, 0x00000000000002816E0000000000000000000000000000000000000000000000).

Compro01

Posted 2013-03-28T12:06:00.050

Reputation: 957

So the largest possible target is a lifetime constant of the blockchain, but the current target is variable and increases/decreases respectively to maintain a 10-minute block generation? – Olshansk – 2017-06-17T02:21:06.160

1@Olshansk Indeed. – Pieter Wuille – 2017-08-04T09:22:33.673

14

Difficulty is simply the ratio between the max target and the current target. It's easier to speak in terms of difficulty than in terms of the target.

The max target is defined as (2^16 - 1) * 2^208 or approximately 2^224. Since there are 2^256 different values a hash can take, a random hash has a chance of about 2^(-32) to be lower than the max target.

It follows that if the difficulty is D, the target is (2^224 / D) and it takes on average 2^32 * D hashes to find a block.

Meni Rosenfeld

Posted 2013-03-28T12:06:00.050

Reputation: 19 132

Can you relate it to the number of zero's, please? – user153465 – 2017-08-06T16:30:31.580

1The number of zeroes required is 8 + log(D)/log(16). But that is only an approximation. – Meni Rosenfeld – 2017-08-06T23:46:26.327