Lily R.
Lily R.
Dec 14, 2021

Hash Function: The Key to Blockchain

tl;drBlockchains are born through hash functions. A hash function is a system where you give it an input, and it gives you a hash. The hash acts as a key to the block, and what miners are actually doing is that they’re trying to find the hash to verify the block and receive rewards in Bitcoin. Once a miner solves a block and receives their reward, the hash of the solved block gets added to the next block. The previous block’s hash is used to calculate the next block’s hash, resulting in a block of chains or blockchain!
Hash Function: The Key to Blockchain
Hash Function: The Key to Blockchain
How do you rate this post?
Good
Average

Introduction

If you’ve ever wondered how a blockchain works and have been confused with all the technicalities, you are in the right place at the right time! The key to learning more about blockchains is the Cryptographic Hash Function, which is literally the key to the blocks. Before learning more about hash functions and what miners are exactly doing, we must first learn about blocks.

What is a Block Made of?

A block is essentially a collection of records, a list of transactions, documents, smart contracts, etc. In the case of Bitcoin, each block in the blockchain contains a collection of transaction records called a ledger.

Blocks Are Limited

Blocks have a limit for how much data they can store in them. They aren’t unlimited, and once they are full, they get added to the system, and more blocks need to be created. Bitcoin can store an average of 1500 transaction records in one block. Once a block gets full, they need to get verified to be added to the network. This process of verifying and adding blocks is called ‘mining’. We can mine the blocks and verify them by finding their hash.

What Is Hash Function?

A hash function is a system where you give it an input, and it gives you a hash. The hash acts as a key to the block, and what miners are actually doing is that they’re trying to find the hash to verify the block and receive rewards. This system uses complex mathematical algorithms to function, and it is impossible to find the hash’s input. Also, one cannot reverse or predict the hash; the only way of finding the hash is by guessing and checking.

SHA-256 Hash Function

SHA stands for Secure Hashing Algorithm, and 256 refers to the number of 0s and 1s the function gives out. Computers convert these 0s and 1s to numbers and letters, making it a total output of 64 letters. Whether you put in a word or the entire Wikipedia, it will always have an output containing 256 zeros and ones. Computers convert these 0s and 1s to letters and numbers. Here are some facts about the SHA-256 Hash Function you need to know before we go further are:

  • No matter how much data you give it, it will always give 256 zeros and ones.
  • It is infeasible to find two hashes with the same input, and currently, there are no known inputs that generate the same output in SHA-256. However, it was seen in the MD5 hashing function, which happened a few times. Keep in mind that SHA-256 is much more advanced than MD5, though.
  • Changing the input, even very slightly, has a considerable effect on the output and changes it entirely.
  • Calculating a single hash is a speedy process, but calculating the required hash takes much more time.

What Happens to the Hash If You Change A Letter?

We have tested out an example of the hash changing entirely with a slight change, so you can further understand the process and see how much power and resources it takes to find one single hash. Using SHA-256 online, the hash for the word “cryptologist” is ‘c0c51439c1237b90a8237316c19ef4ead080f1eb7988ad067de49f7063a6c568’. However, when you change it to “Cryptologist” it changes to ‘9a90f9d03dedf24ccd26c8ce691b16bf439cdd66131df23efbb0cdb39859abd5’, which is a completely different hash!

Bitcoin requires a special hash with many zeros. The recently solved block at the time of writing this post had this hash: ‘000000000000000000067e3653db7c1152a734fc9c77e49e00b73fc76583206d’, which has 19 zeros at the beginning!

Hash Functions and Proof-of-Work

The hashing function is mainly used for the Proof-of-Work consensus mechanism. It is the mechanism used in Bitcoin, in which miners prove their work by mining and solving the blocks and are rewarded with Bitcoins in return. It is how new Bitcoins are created! Miners currently receive 6.25 Bitcoins each time they mine a new block. However, this will be cut in half due to Bitcoin Halving.

Once a miner solves a block and receives their reward, the miner adds “person X has received 6.25 BTC for solving the block” on the top of the block. Then, the hash of the solved block gets added to the next block. In fact, the previous block’s hash is used to calculate the next block’s hash, resulting in a chain of blocks or blockchain! Whatever data put on the blockchain is written down in history forever, and no one can go back and change anything, i.e., adding more money to their account. If someone tries to go back and edit an old block, all the newer ones change because the hashes are also changed. 

What Are Centralised and Decentralised Systems?

If someone or a group of people have authority over a system and control it, it means the system is centralised. However, the systems where more than one person or group has access to the data and can control it are decentralised. 

Take Bitcoin as an example again. Instead of one person having access to all transactions on Bitcoin’s blockchain, everyone has access to the list and can vote and mine on the blockchain. You can check out this website for a list of recent transactions on the Bitcoin blockchain. 

What If Someone Makes a Fake Vote?

Since decentralisation means everyone can vote, consensus mechanisms are needed to make sure everyone is on the same page. Proof-of-Work, Proof-of-Stake and Proof-of-Authority are examples of different consensus mechanisms. These mechanisms also ensure no one cheats on the network and makes a fake vote.

Since everyone can vote on the system, it’s natural to think, “But what if someone tries to make a fake vote to get Bitcoins in their account?” Well, it is not going to happen, thanks to asymmetric encryption. To learn more about this encryption, you can check this article.

Conclusion

Congratulations! You have made it this far, and it means now you know the importance of hash functions, how they are used to prevent scams, and how decentralisation is more than just an ideology. We hope this article has shed some light on blockchain mechanics without being too technical. Also, we hope it has connected all the pieces of the puzzle you’ve been searching for. Here at Cryptologi.st, we believe knowledge is the key to making confident investment decisions, just like how a hash is used to solve a block!

To quickly compare available options and make the best investment decision, check out our website.

How do you rate this post?
Good
Average

Any advice contained in this website is general advice only and has been prepared without considering your objectives, financial situation, or needs. You should not rely on any advice and/or information contained in this website and before making any investment decision we recommend that you consider whether it is appropriate for your situation and seek appropriate financial, taxation, and legal advice.

© 2022 - Created by Cryptologi.st