What is Blockchain Hashing?

A hash is like a fingerprint, a long record consisting of some digits and letters.

Each block within the blockchain is identified by a hash, generated using some cryptographic hash algorithm.

Technically hashing is the process of converting an input of any length into a fixed size string of text using a mathematical function. This means that any text, no matter how long it is can be converted into an array of numbers and letters through an algorithm.


How does the hashing function work?

 

Different hash functions will produce outputs of differing sizes, but the possible output sizes for each hashing algorithm is always constant. For instance, the SHA-256 algorithm can only produce outputs of 256 bits, while the SHA-1 will always generate a 160-bits digest.

How does a hashing function work?

  • The message to be hashed is called an input
  • The algorithm used to do so is called a hash function
  • The hash value is called output

To illustrate, let’s do an example:

The hash function generates a unique code from every different input. 

A cryptographic hash function needs to have some qualities to be useful:

The same input must always generate the same output. Regardless of how many times you put the data through the hashing algorithm, it must consistently product the same hash with identical characters in the string

The input cannot be deduced or calculated from the output. There should be no way to reverse the hashing process to see the original data set.

Any change in the input must produce an entirely different output.

The hash should be of fixed number of characters, regardless the size of type of data used as an input.

Creating the hash should be a fast process that doesn’t make heavy use of computing power.

 

How does the hashing function work?

Each block contains the hash of the previous block which creates a chain of blocks and is the main element behind blockchain architecture’s security

The sequence of hashes linking each block to its parent creates a chain going back all the way to the first block ever created, known as the genesis block. 

Since every block of the chain contains the hash of the previous one, it i not possible to modify any block without changing the entire chain.

The chain works as an immutable digital ledger.

Let’s simplify everything. 

Here a chain in which every block has been hashed and the hash is included in the following one:

 

If an anonymous attacker removes, adds or modifies any data/transaction in the first block, the hash #1 will change:

 

Hash#1 is included as part of the contents in block 2. But because of that, hash #2 will change too and the error will propagate to every block of the chain after the block under attack.
The user will declare the chain invalid. 

 

This cascade effect ensures that once a block has many generations following it, it cannot be changed without forcing a recalculation of all subsequent blocks.

Because such a recalculation would require enormous computation (and therefore energy consumption), the existence of a long chain of blocks makes the blockchain’s deep history immutable. 

That’s it guys. Please leave a comment down below for any question you have about this article and I’ll be answering! Remember, we are all here to learn and there are no stupid questions 🙂

Thank you !

 

Leave a Reply