Hashes are the most important component in the architecture of a block in the blockchain which is generated by Hashing. Hashing is a randomized algorithmic process to calculate a fixed-size output (called as digest) for an input of any size. Look at figure 2, the output will be purely unique and even a single ‘bit’ of change in the input will change the output completely. The algorithmic function used here is called ‘hash function’ which is a one-way function (preimage resistant), which means it is practically impossible to reverse the function and obtain the desired input from a calculated output. Adding to this, it is practically infeasible too to produce the same output from two or more different inputs (second preimage resistant).

**What you will learn:**hide

*Hash (x) = Fixed size digest*

Most of the Blockchains use a hashing algorithm called as Secure Hash Algorithm – 256 (SHA-256) which gives a fixed output of 256 bits (32 characters each of 8 bits) means there are 2256 different possible values. With the growing use of this technology, a larger number of inputs values can exist with a fixed amount of outputs which brings with it the possibility of collusion (Hash(X) = Hash (Y)). However, the probability of this collusion event is very low and thus, SHA-256 is called to be collision-resistant. Every time the data is added to the block, it generates a new hash fingerprint’ (digest) for the list of data. Even a small change in any data among the list will change the fingerprint of the block, making it very convenient to find any change occurring in the database

**Properties of Cryptographic Hash Function**

**Deterministic **

A hash value is a specific or fixed output. It means that no matter how many times you input the data, the result is always the same. The hashes will always be the same length no matter how random their patterns are. This is critical as if you got a different hash value each time, it would be impossible to keep track of the input.

**Quick Computation**

For the blockchain technology to be efficient, a good hash function needs to be one that is performing quick computations for each input. If the process isn’t fast enough, the system won’t be efficient. Every hash results whether a small file or a large file should take the same amount of computation time. Calculating or computing the hash should be fast however difficult it is to fund the input data for a hash.

**Pre – Image resistance**

Being a one-way function is one of the most important properties of a secure cryptographic hash function. It should be practically infeasible to determine the original input using the hash value. The security of a blockchain is highly dependent on this property. The only way possible of finding what the original input is should be if you find the hash of the corresponding or correct input after hashing all the possible combinations. This is practically impossible as the input is randomized.

**Different hashes for every input (Randomized)**

Even if the input data differs by a single digit or letter, the hash function produced a completely different output or hash value. The smallest change has huge ramifications on the output and aids In making the function pre-image resistant. For example, the hash of the word “Hey” and “Heyy” will be completely different. If the hashes were similar in the start and differed only in the end, they would be extremely easy to decipher.

**Collision resistant**

In cryptographic hash functions, each input is supposed to have a unique output or hash value. This makes it collision-resistant. Collisions occur in cases where different inputs are given similar outputs by a hash function. For example, if “12/11/19” is photo and “12/11/19” is a video, but the same output is produced by the hash function, then we call that a collision. In normal circumstances, this should not happen.

**Where is hashing used in Blockchain?**

Hashing is applied in blockchain as seen in some of the examples given below:

- Blockchain addresses are derived using hashing e.g. Bitcoin addresses use SHA2-256.
- Transactions are validated with the use of Hashing which helps in defining cryptographic signatures.
- It is easy to keep track of the transactions of the blockchain with the help of the hash of a transaction.
- In Crypto mining, hashing functions are crucial as a valid nonce is discovered by computing several hashes. The consensus on the blockchain is formed with the help of hashing functions.

## 0 comments

Write a comment