Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: spazzdla on July 13, 2015, 06:57:03 PM



Title: How does bitcoin finely change the difficulty target..?
Post by: spazzdla on July 13, 2015, 06:57:03 PM
I have done some reading into mining, it seems the difficulty is based on finding a hash that has X amount of zeros at the start.  If this is the case can't the difficulty really only be changed by rather largely up or down..?

Find a hash with 17 zeros at the start vs 16 is a large difficulty jump, how does the difficulty only change a bit?


Title: Re: How does bitcoin finely change the difficulty target..?
Post by: domob on July 13, 2015, 07:26:32 PM
The notion with "zeros at the beginning" is clear to understand and thus often used in explanations, but not fully correct.  The actual condition is "hash below a certain target value".  In this way, the difficulty (usually expressed as 1/target) can be changed almost arbitrarily and with more gradual steps than just doubling/halving.


Title: Re: How does bitcoin finely change the difficulty target..?
Post by: spazzdla on July 13, 2015, 07:46:09 PM
The notion with "zeros at the beginning" is clear to understand and thus often used in explanations, but not fully correct.  The actual condition is "hash below a certain target value".  In this way, the difficulty (usually expressed as 1/target) can be changed almost arbitrarily and with more gradual steps than just doubling/halving.


AHHH, can you go into that a little more, what do you mean by under a certian target?




Title: Re: How does bitcoin finely change the difficulty target..?
Post by: TierNolan on July 13, 2015, 11:16:01 PM
AHHH, can you go into that a little more, what do you mean by under a certian target?

Imagine that the hash picks a number between 0 and 999,999.

You could say that the difficulty is to count the number of leading zeros.

One zero means you have to get 99,999 or lower (099999 or lower).  That is one in 10 (difficulty 10).

Two zeros means you have to get 9,999 or lower (009999 or lower).  That is one in 100 (difficulty 100) and so on.

You could alternatively just use a threshold.  For a difficulty of 63, you use 1,000,000 / 63 = 15,873.

You don't say that you need 1 zero, you say the number must be 15,873 or lower.  That gives a 1 in 63 chance, so a difficulty of 63.

With the actual hash, it picks a number between 0 and (2256 - 1).   The difficulty is also divided by 232.  A difficulty of 1 means that you have a 1 in 232 chance of a hash being less than the threshold.


Title: Re: How does bitcoin finely change the difficulty target..?
Post by: Mikestang on July 14, 2015, 02:53:30 AM
I have done some reading into mining, it seems the difficulty is based on finding a hash that has X amount of zeros at the start.  If this is the case can't the difficulty really only be changed by rather largely up or down..?

Find a hash with 17 zeros at the start vs 16 is a large difficulty jump, how does the difficulty only change a bit?

Because there are 57 places in the hexidecimal difficulty, and each place has a value 0-9 a-z A-Z that represents and incremental change, so the difficulty can be expressed very precisely.

Check out the wiki on difficulty: https://en.bitcoin.it/wiki/Difficulty


Title: Re: How does bitcoin finely change the difficulty target..?
Post by: spazzdla on July 15, 2015, 03:36:40 PM
AHHH, can you go into that a little more, what do you mean by under a certian target?

Imagine that the hash picks a number between 0 and 999,999.

You could say that the difficulty is to count the number of leading zeros.

One zero means you have to get 99,999 or lower (099999 or lower).  That is one in 10 (difficulty 10).

Two zeros means you have to get 9,999 or lower (009999 or lower).  That is one in 100 (difficulty 100) and so on.

You could alternatively just use a threshold.  For a difficulty of 63, you use 1,000,000 / 63 = 15,873.

You don't say that you need 1 zero, you say the number must be 15,873 or lower.  That gives a 1 in 63 chance, so a difficulty of 63.

With the actual hash, it picks a number between 0 and (2256 - 1).   The difficulty is also divided by 232.  A difficulty of 1 means that you have a 1 in 232 chance of a hash being less than the threshold.


OOOH, I think I kind of get it..

so FFFFFFFFFFFF .... = 1.16 x 10 ^ 77

0000000000 ... 1 = 1 (good luck)

0000000000000******** = 1 x 10 ^22 (for eg)

find a number smaller than 1 x 10 ^ 22

I thinks I get it?


Title: Re: How does bitcoin finely change the difficulty target..?
Post by: TierNolan on July 15, 2015, 05:49:46 PM
find a number smaller than 1 x 10 ^ 22

I thinks I get it?

Yes.  

The target is a floating point number though, A * 256b.  

A is 3 bytes so gives reasonable accuracy.  The b value is 1 byte, so can easily go up to 2256.