Beginner’s Guide to Blockchain Technology – Part II

This is part II of the series and it will focus on concept called hashing.  I will use same metaphor as previous article to explain hashing. If we go back to our example of train, coupler is a mechanism used to connect carriages and engine of the train, as shown in the image below.

 

The coupler come in different shapes and sizes.Buffer & chain, Link & pin and Bell-and-hook are few example of couplers. Just like coupler for train, similar concept is used in Blockchain to connect blocks. The Blocks in Blockchain are linked to its immediate predecessor using hash. The first block in the Blockchain is called “Genesis” block or Block 0 and its link lies out in the system. The below diagram is a simplified version of how Bitcoin Blockchain looks like and generally Blockchains follow same pattern.

 

At this point you might be wondering, what is hashing and how is it useful in the whole Blockchain ecosystem. Worry not, I will try to explain it.

 

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

 

Blockchain mainly uses cryptographic hash functions such as SHA256 and Keccak-256. Example 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 same input through the hash function, you will get same hash value.
  • Efficiency – for any given input, the hash function should be capable of returning the hash value quickly 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 – two different inputs to a hash function cannot have 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 this article off, let’s say a malicious attacker changes a 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.

 

More to follow.

Beginner’s Guide to Blockchain Technology – Part I

I find people use the term ‘Blockchain technology’ to mean different things (i.e Bitcoin/altcoin blockchain, smart contracts etc) which can sometimes be confusing. However most of the time what they are talking about is distributed ledger. Considering Blockchain technology is disrupting industries from voting to banking, having a basic knowledge of it will be useful. Therefore this post is first in the series of posts explaining what is Blockchain technology.

 

The Blockchain is a digital ledger for storing data and the most famous implementation of this technology is the cryptocurrency called Bitcoin. This post will focus on two basic terms used in Blockchain technology, namely transactions and blocks.

 

Before we talk about the terms, let’s take a detour and talk about carriage trains. At this point you might be wondering, what has carriage train got to do with Blockchain. Well it has got nothing to do with Blockchain but it is a metaphor for explaining what transactions and blocks are to Blockchain technology.

 

At its core the passenger train has two components, namely locomotive (engine) and carriage/coach.  All the components are connected via a coupler and there are different types of couples such as Buffer & chain, Link & pin and Bell-and-hook coupler.  In part II, I will explain how coupler fits into the picture and what concept in Blockchain is similar to coupler.

 

The carriage is normally of fixed size and has a limit of how many passengers it can accommodate. To get on the carriage, the passengers have to buy a ticket and ticket will generally have information regarding what time the train departs, platform number and carriage number. If there are any seats available then they will get a confirmation and they can board the train else they have to go on a waiting list/wait for next train.

 

This same principle applies to Transactions and Blocks. So if we go back to Blockchain, transaction is similar to passenger. However transaction can also be something else, just like different types of trains such as freight train and passenger train. Similarly transaction can be a payment or medical record. Therefore you can define Blockchain transaction as a small unit of task that is stored in records. Generally there are two types of transactions, confirmed and unconfirmed. Confirmed transactions go into the blocks where as unconfirmed don’t. This is similar to getting a confirmed ticket to board the train else you have to be on waiting list.

 

The block in Blockchain technology is similar to carriage in train. Basically block is a record of confirmed transactions and different type of Blockchain implementations will have a maximum size for a block. For example, Bitcoin block has a maximum size of 1MB. Each new block will have a reference to the previous block in the blockchain except for the first block. Like in the train we have engine, the first block in Blockchain is called Genesis block.

 

The following picture depicts transactions & blocks in the Blockchain. The block data is where the transactions reside. In Part II, I will explain how hashing is used to connect blocks.