Beginners Guide to Blockchain Technology (Part 2)

In part two of beginners guide to blockchain technology series (part 1 here), we will focus on a concept called hashing.  I will use the same metaphor from the previous article to explain hashing. If we go back to our example of the train, the coupler is a mechanism used to connect carriages and the engine of the train, as shown in the image below.

Image title

The coupler comes in different shapes and sizes: buffer and chain, link and pin, and bell-and-hook are few examples of couplers. Just like a coupler for a train, the concept is similar and used in blockchains to connect blocks. The blocks of a blockchain are linked to its immediate predecessor using a hash. The first block in the blockchain is called the “Genesis” block or Block 0, and its link lies out in the system. The below diagram is a simplified version of how the Bitcoin blockchain looks and, generally, blockchains follow the same pattern.

Image title

At this point, you might be wondering: what is hashing and how is it useful in the whole blockchain ecosystem. Worry not, I will explain that in greater detail below.

Hashing is a simple process of taking a variable-length input and creating a fixed size output, which is sometimes called the Digest. Just like different types of couplers for a train, there are also different types of hash functions. Some examples are the murmur hash, CityHash, SHA256, xxHash, and SHA-3.

Blockchain mainly uses cryptographic hash functions, such as SHA256 and Keccak-256. Examples of blockchains using these functions are Bitcoin and Ethereum, respectively.

The main reasons for using cryptographic hash functions for Blockchain lies in its properties, which are:

  • Deterministic — each time you parse the same input through the hash function, you will get the same hash value.
  • Efficiency — for any given input, the hash function should be capable of returning the hash value quickly, or else the system is simply not efficient.
  • Pre-image resistance — given a hash value, it should be difficult to find its input value. It is not impossible to determine the original input from its hash function.
  • Collision resistance — there are two different inputs to a hash function that cannot have the same hash value.
  • Slight change to input — making a small change to the input will change the hash value completely. For example, just changing the first letter of the Iron Maiden song “The Trooper” to “the Trooper” using SHA256 hash function changes the hash value completely.
Input Digest
The Trooper DB934DFF3B19B23DD77EA52DDE8A0DBB8654F1902827CA8D6633D939B8B7C29A
the Trooper E414332ED44FB59942899C6AF443CC89CF392BD112964BAFA7E5C3E2CB4A3D39

Just to cap beginners guide to blockchain technology article off, let’s say a malicious attacker changes data in block 1 of the blockchain. Because of the properties of cryptographic hash functions, any slight change made in block 1 will change the hash value stored in block 2, and this will result in changes in block 3 and so on and so forth. Therefore, it will become very hard for the malicious attacker to compute an alternate chain from Block 1, which will catch-up with and overtake the one true chain.

If you want to learn more about Blockchain, you can download my ebook, “Introduction To Blockchain“.

One Response to “Beginners Guide to Blockchain Technology (Part 2)”
  1. Ashish Bansal December 19, 2018

Leave a Reply