Mining In a Blockchain (Part- 2 The Cryptographic Puzzle)

Mining In a Blockchain (Part- 2 The Cryptographic Puzzle)

Arpan Pandey
·Dec 22, 2021·

3 min read

Subscribe to my newsletter and never miss my upcoming articles

Play this article

Table of contents

  • The Statement
  • The Leading Zeroes
  • The Puzzle
  • The Difficulty
  • Wrapping Up

In the last very short post here, we saw how a special value is used to vary the hash of the block. You may also recall that this value is called the Nonce. So now, its time to continue our journey deep into the fundamentals of what makes a blockchain. This time we will be taking a closer look at The Cryptographic Puzzle.

The Statement

So at the beginning of this post let's just make a statement very loud and clear.

The hash is just a number.

Now, many of you may already know this but for those of you who don't let's explore how. For example, 7eb720cb71f1bf1d0b4c2f6442d0148d775fdd473ea3f33a28bd893a21d7e5b4 is a real SHA-256 Hash. Now, you may have already noticed that this is not a number, it has characters like e, f etc. Let's explain how. This my friends is a hexadecimal number. The hexadecimal format has 16 characters. These are the numbers 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and then some alphabets a, b, c, d, e, f. Here a denotes 10, b denotes 11, c denotes 12 and so on. Got it? Good. Now you may ask but why are you telling me this? Let's find out, shall we?

The Leading Zeroes

To begin, let's take another hash number for example. 0000000000000cdfc787f30000cb1cc929720e369ea1a116224559137af96844
Notice how this number has some zeroes in the beginning. But, why in the world does it matter if it is a number or a bunch of characters. Well because, numbers are special because the have a value. And as you may remember from your elementary school math class that zeroes in the front of a number don't have a value.

All Possible Hashes.png Look at this diagram, it represents all the hashes that can exist. Since, these hashes are hashes are numbers, we can compare them and easily determine which one is bigger and which one is smaller. Also, you should take notice that the more the leading the zeroes, lesser will be the value of the number.

The Puzzle

Now, the blockchain system sets a target. The hash of this block along with the nonce should be lesser in value than this target. Let's put our hashes in the table once again. Hashes with target.png Let's say that the target was 00000000000062b4fccaebda5722f9d4d22465eab2ac0285b43f794ed71ee704. Our seconds hash would clearly be below the target and that is what we (or the miners) want. Now, this is where the nonce comes into play. The miners can easily change the nonce and try to get an acceptable hash value.
Quick Trivia: The nonce that gives us the accepted hash is called the golden nonce.

The Difficulty

You may already know that the hash itself is unpredictable and changes rapidly due to The Avalanche Effect. If you don't then, I suggest reading my post on the same.

Wrapping Up

That was it, folks! Today, you learnt about one of the key aspects of a blockchain. See you in the next one!

Did you find this article valuable?

Support Arpan Pandey by becoming a sponsor. Any amount is appreciated!

See recent sponsors Learn more about Hashnode Sponsors
 
Share this