Crypto Hash Function Explained

You are currently viewing Crypto Hash Function Explained

Crypto 101 – Part 5

In the first four parts of the Crypto 101 series, we have discussed the basics, mining and mining processes.

Today, I am doing a post on the “Hash” function that’s crucial to mine crypto and essential to the blockchain security infrastructure.

Consider the following example

The “Explain It Like I’m Five” Version

I tell three friends that I’m thinking of a number between one and 100, and I write that number on a piece of paper and seal it in an envelope. My friends don’t have to guess the exact number; they just have to be the first person to guess any number less than or equal to the number I am thinking of. And there is no limit to how many guesses they get.

Let’s say I’m thinking of the number 19. If Friend A guesses 21, they lose because of 21>19. If Friend B guesses 16 and Friend C guesses 12, they’ve both theoretically arrived at viable answers because of 16 < 19 and 12 < 19. So there is no “extra credit” for Friend B, even though B’s answer was closer to the target answer of 19.

Now imagine that I pose the “guess what number I’m thinking of” question, but I’m not asking just three friends, and I’m not thinking
of a number between 1 and 100. Instead, I’m asking millions of would-be miners, and I’m thinking of a 64-digit hexadecimal number. So
now you see that it’s going to be extremely hard to guess the correct answer.

Here is an example of how the Hash is used If we take the sentence “Donkeys live a long time” and wish to encrypt it

We apply a hash algorithm to it; we will get 6e04f289. This value is known as a hash. Crypto miners need to solve for a 64 digits.

Subscribe to unlock content

Loading...
64-Digit Hexadecimal Number What Is a “64-Digit Hexadecimal Number”? hexadecimal number provided to them to reach the solution. Here is an example of such a number: 0000000000000000057fcc708cf0130d95e27c5819203e9f967ac56e4d f598ee The number above has 64 digits. As you probably noticed, that number consists not just of numbers but also letters of the alphabet. Why is that? To understand what these letters are doing in the middle of numbers, let’s unpack the word “hexadecimal.” As you know, we use the “decimal” system, which means it is base 10. This, in turn, means that every digit of a multi-digit number has ten possibilities, zero through nine. “Hexadecimal,” on the other hand, means base 16, as “hex” is derived from the Greek word for six and “deca” is derived from the Greek word for 10. In a hexadecimal system, each digit has 16 possibilities. But our numeric system only offers ten ways of representing numbers (zero through nine). That’s why you have to stick letters in, specifically letters a, b, c, d, e, and f. Use in the Mining Process If you are mining crypto, you do not need to calculate the total value of that 64-digit number (the Hash). In crypto-mining terms, that undisclosed metaphorical number in the envelope is called the target hash. What miners are doing with those massive computers and dozens of cooling fans is guessing at the target Hash. Miners make these guesses by randomly generating as many “nonces” (number only used once) as possible, as fast as possible, and the nonce is the key to generating these 64-bit hexadecimal numbers. A nonce is 32 bits in size in Bitcoin mining— much smaller than the Hash, which is 256 bits. Therefore, the first miner whose nonce generates a less than or equal Hash to the target hash is awarded credit for completing that block and is awarded the spoils of 6.25 BTC. The difficulty level of the most recent block at the time of writing is about 17.59 trillion, meaning that the chance of any given nonce producing a hash below the target is one in 17.59 trillion. Not great odds if you’re working on your own, even with a tremendously powerful mining rig. As this is a slightly complex subject, I will stop here and let you digest it.