1

I'm implementing my own cryptocurrency and I found it that saving the "hash difficulty” as the leading off (0) bits of a 256 bit number in a SHA-256 hash is the most intuitive.

I'm struggling to find a way to calculate the bitcoin equivalent “target” from that number.

Additionally I wonder why it is not implemented that way in the bitcoin protocol? Does it cause too harsh steps of difficulty?

2

I'm struggling to find a way to calculate the bitcoin equivalent “target” from that number.

Your difficulty recalculation algorithm will need to be completely different then. The easiest way to change it is to just start with an initial difficulty with all bits set and then bit shift this number as needed to get a target with some set number of leading zeros.

Additionally I wonder why it is not implemented that way in the bitcoin protocol? Does it cause too harsh steps of difficulty?

Because it only allows for the difficulty to double or halve. Furthermore, there are only 256 possible difficulties so this is not at all ideal nor would it work particularly well. This means that the target would usually be too high or too low. By using a target value, the difficulty can be adjusted to far more levels (2^256 possible difficulties) to better match the network hashrate.

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.