Question about difficulty

Working my way through Bitcoin & Blockchain 101. My question deals with mining difficulty. May be a silly question but here we go: I understand that miners are hashing over and over again to find the nonce (random number) of a block. As long as the hash is lower than the target level, the previous hash is there and the transactions are sound, the block is accepted.

What prevents miners from setting their systems to constantly guess low numbers? By this logic, wouldn’t be possible just to hash 0 or 1 per block and have that be lower than the target number?

1 Like

Hi! Not sure if I understand correctly, are you asking why miners don’t use only low nonces to produce low hashes? That’s not how hashing works. A major property of hashing functions is that you cannot predict what type of input will produce what type of output, a low nonce might easily produce a high hash and vice versa.


@Wayan Is correct. Putting a low nonce does not increase a probability of getting a lower hash. It is random.

The main thing that prevents the miner to be able to “cheat” is the actual SHA-256 algorithm. There is so far no know way to manipulate the SHA-256 function to get only low hashes.

You can always read more in depth of how actually does SHA-256 works on wikipedia.

Hope that helps. If you have any more question, I will gladly answer them.

Thank you Wayan for helping out. :smiley:


@Wayan and @Mauro, thank you for the responses. I think you answered my question. I guess I would need to see what that process looks like for it really to set in. As I saw on the Blockchain 101 course, Ivan goes through blocks and tries number after number to show us that each number isn’t working to produce the right hash.

But, as a miner is trying to find a low number, I don’t understand why they can’t just input a low number. I also don’t understand the difference between a low number and a low hash. I thought hashes had to be a fixed length regardless.

If I’m a miner and I input 0 or 1 or 2, 3, are you saying that the hashes produced from those numbers will also be low?

Is a miner guessing with numbers or hashes? This is where I start to get confused.

1 Like

There is no way to know what will you get once you enter something in SHA-256. A miner is trying to find a low hash, not a low number. Low hash and low number have nothing in common.

Go here:
Try inputting something in the input. For example try 1 then 2, then 3, 4 ,5 ,6 and so on. You will see that a higher number can have a lower hash while a lower number can have a higher hash. What you input does not matter, its all random. And even if you only just input 1 you can see that you get a fixed hash lenght.

A miner hashes all the transactions in a block according to a scheme (merkle tree) to produce a hash that summarizes the entire block: the merkle root.

Then the miner tries to find a number (the nonce) that, when hashed together with the merkle root, produces a hash that is lower than the target.

The word “number” can be confusing here, because both the nonce and the hash and the target are numbers.

The miner is trying out nonces, one after the other. Every nonce is concatenated with the merkle root and the result is hashed, and that new hash is compared to the difficulty target. The miner keeps repeating this process until they find a nonce that produces a hash that is lower than the target.

The length of a hash refers to the number of characters in the hash. It is a matter of notation, not a matter of value. Leading zeros add to the length of a hash, but not to the value.
eg The number 1 can be written as 1 or as 0001. Different length, same value. Conversely, 1000 and 0001 have the same length, but a different value.

That’s because secure hashing algorithms are designed to make it impossible to guess the input from looking at the output. That property is why they can be used in proof of work. An algorithm that produces a low hash when it is given a low nonce and a high hash when it is given a high nonce, would be useless, because then you could use reasoning and deduction to quickly find a suitable nonce. That would defeat the purpose. The purpose of proof of work is not to find a nonce, it is to spend a lot of time and energy trying to find a nonce. And that requires a hashing algorithm that produces an unpredictable output.

The “work” in proof of work is not merely calculating a hash, because calculating a hash is not that hard. The “work” is having to hash over and over and over again, every time with a different nonce, until you find a nonce that produces a hash that is lower than the target.

So why can’t miners just input a low nonce to produce a low hash? Because the hashing algorithm was designed to make that impossible. As a result, the only way to find a suitable nonce it to brute force your way to it, just trying nonce after nonce after nonce until you find a suitable nonce. The purpose of this is that anyone who tries to falsify the ledger will have to go through all this work again, and will most likely not have the time and resources to do so.

@Mauro, i’m still learning, i hope everything i said here was correct?

1 Like

That was a fantastic explanation of the process. Very clear now. Thank you, Wayan! You sound very knowledgable on the subject.

1 Like

Glad to be of service :slight_smile:


Thank you for helping out. Very detailed and on point. :heart:

1 Like