Spider
Published in

Spider

Blockchain — Demystified: Why is it the buzzword?

Every person would have heard about Blockchain at some point in their lives. Many hesitate to go further about it because of its apparently steep learning curve and the general mysticism shrouding it. It is actually pretty simple to learn the concepts as they are basically rooted on the problems faced by existing financial systems. However, blockchain has taken an interesting turn in this past 5 years. Let's look at all things Blockchain in this article!

“There are tons of articles about Blockchain! Why another one?”, you may ask. Existing ones are too high a level or too diluted. Personally, almost all of the articles I have read raise more questions than give answers. This article is the beginning of a big series that attempts to give answers to those questions that might arise for beginners who are getting started with blockchain and fill the knowledge gap.

Photo by Hitesh Choudhary on Unsplash

What is Blockchain?

I do not want to throw all kinds of jargon at you since I know how much intimidated I felt when I read my first article on Blockchain. Treat the rest of the article (and the series) as a book and grab a cup of coffee :)

The first conceivable idea of Blockchain was put forth only a mere 10 years ago, by a person who goes by the name Satoshi Nakamoto (No one really knows the actual name. Let's call this person ‘X’ for the time being). X proposed an electronic form of currency that can serve as an alternative for the existing fiat currency while still having some real value and as a follow-up, proposed a secure data structure that can store the transaction history and other information. Existing database systems fail easily because these rely on trusting personnel for security. Since the currency itself is digital, one cannot ‘trust’ trust. Blockchain is the data structure that X proposed that can solve this problem, without having the need to trust someone else for the maintenance. As the name suggests, it consists of a sequence (chain) of entities called blocks, which hold some details regarding the transaction. This is the very basic idea behind Blockchain. It has evolved since then.

The blockchain data structure is implemented in such a way that humans need not trust anyone else when it comes to their transactions.

The Blockchain, in the most general sense, is like a singly linked list. It consists of a sequence of blocks, each having pointers to the previous one.

The basic structure. Do not worry if it does not make sense for now. Note how it follows a linked list pattern of having a pointer to a previous block. Image source: spheregen

Before we discuss the problem it solves and how it addresses the serious trust issues we humans have (:D), let us take a look at some of the cryptographic math that powers the blockchain, its architecture and the implementation specifics so that when we actually discuss the problem it solves, we can understand it better.

BLOCKCHAIN LINGO 101

This subsection covers basic concepts about Hashing and Digital signatures. These are essential to understand how blockchains work. Feel free to skip ahead if you already know them.

HASHING

We have heard of functions, right? From our high school (If you are in high school when reading this article, congratulations on knowing about this tech so early), we know that functions are mappings that take in one value as input, does some processing and maps the input to a specific output. A hash function is a function that produces a unique output for every unique input. This property of the hash function is used in a variety of ways. For example, by mapping input to a reduced size output, image compression (with loss of data) is achieved.

Hashing has also found its way into cryptography. In cryptographic hashing, input of any size is converted into output of a fixed size. The defining property is that given the output, it is impossible to determine the input owing to random parameters used in the algorithm. There are a family of algorithms used for cryptographic hashing like MD5, SHA etc. The hash functions themselves can be complex to understand. However, all you need to know (at this point) is that the most secure hash family is SHA-3. It has various algorithms called SHA3–256, SHA3–512 etc where 256 and 512 represent the number of bits in the output. The Blockchain uses Keccak family hashing, which is a superset of SHA-3. The hash information inside a block is basically a hash of some important data.

Notice how a small change in input can produce a totally different output. Source: Wikipedia

It is generally impossible to determine the input to a cryptographic hash function from the output because the algorithm cannot be reverse engineered.

ASYMMETRIC KEY ENCRYPTION AND DIGITAL SIGNATURES

Encryption and decryption are some of the common terms that you hear coming from a cryptographic background. Encryption is the process of converting the plain message to some gibberish using a key K1 and decryption is the process of converting the gibberish back to plain text using another key K2. If K1 and K2 are same, its symmetric key encryption, while if they are not same, its asymmetric key encryption.

In asymmetric key encryption, the key that is used to encrypt is transmitted to everyone who wants to communicate and is therefore called as a public key. The key that is used to decrypt is called the private key and is kept private so that only you can actually decrypt the message and check its contents. This makes sure that snoopers, even though get access to your message, cannot decrypt it.

Never transmit your private key in any channel

Different keys are used. Source: ssl2buy

Why are we talking about it? Well, these concepts are used in enforcing digital signatures. In the context of blockchain, digital signatures are used to verify that is it actually you whose initiating a transaction. Let us see in brief how it works and why is it foolproof.

Suppose you claim that you paid 25 bucks to Bob, then you will have to construct data in such a way that any person at any corner of the world (with your public key) can verify that it was actually you who paid 25 bucks. Moreover, middlemen should not be able to modify any part of the data and get away with it. In a nutshell, the hashed version of the document is encrypted with the sender’s private key and sent along with the document. The receiver decrypts the hash using the sender’s public key and compares both the hashes. If they match, then the document is valid. Since any middleman has no idea of the sender’s private key, they cannot forge a document and encrypt. If they hash in some other way, the final hashes won't match. Therefore, this technique can be used to verify the person whose initiating a transaction. In fact, this technique is already being used by banks to verify transactions. Note that public key is used for verification here since anyone must be able to verify. For more brevity on the topic, I suggest you take a look at this video

The original data and the hashed data is sent so that the recipient verify. Source: GeeksForGeeks

ARCHITECTURE BASICS

This is where the fun begins. A blockchain can be used in a lot of ways. Let us explore the very first-way blockchain was used in.

Let us assume we have our own electronic currency and want to transact with a set of people in a network. Let us call our currency MahiCoin. (This article was published a day after MSD’s birthday :D) Assume that MahiCoins can be exchanged with real currency. This makes preventing false transactions in the chain extremely important. The Blockchain protocol comes with a set of rules on how this can be prevented and who keeps the chain going.

This chain can also be called as a ‘ledger’ since it holds transaction data only. Assume there are three people — Alice, Bob and Charles each of whom has 100 MahiCoins. Since the ledger is a singly linked list, the first-ever block does not have a predecessor and usually contains information on the starting amount of each person. This block, the first block in the chain, is called a genesis block.

Since all the members are in the same system, they are connected with each other and they form a peer-to-peer network. This is a necessary property in a blockchain. In a peer-to-peer network, every node (the computer that the person uses) is connected with every other node and therefore can transact without the need of any middleman. Every node will have the public key of every other node so that transactions can be sent or verified. Further, every node has a copy of the ledger in its local system.

Peer-to-peer networks. Every node has a copy of the entire chain. Source: gyfcat

Blockchain networks are peer to peer networks.

Coming back to our example, if Alice wants to send 10 MahiCoins to Bob, Alice will digitally sign the transaction and send the transaction to Bob and Charles as well (basically every other node) on the network. Other nodes will add the block to its local copy of the chain after verifying the digital signature. This gives every node the power to accept(or reject) a transaction, making the entire network decentralized.

Blockchain networks are decentralized. There is no single authority of power.

Assuming there are no errors and no malicious intentions from Alice, Bob and Charles will add a block to their chain with the transaction details (The transaction that removes 10 MahiCoins from Alice and deposits them to Bob).

WHAT DOES THE BLOCK ACTUALLY CONTAIN?

The block should necessarily contain the hash of the previous block, the data (sender, receiver and the amount to transfer) and the hash of all the contents. The data should be digitally signed.

THE SYSTEM LOOKS INHERENTLY FLAWED!!!

At the surface level, one can easily find out a hundred reasons on how to fool the system. For example, since no one is really interested in knowing from where the digitally signed transaction is coming from, Charles can add a block to his own copy of the chain stating Bob has transferred 50 MahiCoins to Alice and transmit the data. (This is impossible since Charles cannot sign the transaction, but for the sake of argument assume he can). Further, what if Charles sends a transaction stating he transferred 500 MahiCoins to Bob but has only 100 MahiCoins in his account? Since the transaction is digitally signed, every node will assume it is valid and all the nodes will think that Bob has 600 MahiCoins!!! This is where mutual agreement protocols come in.

MUTUAL AGREEMENT — JUST BECAUSE YOU ALONE THINK ITS RIGHT, IT ISN'T

Mutual agreement protocols are an essential part of a blockchain since they determine whether the block actually gets added to the chain. (By protocol, I just mean a set of rules and regulations). At every node, after receiving a transaction and before adding it to the local copy of the chain, the transaction is validated. In a validation process, after verifying the digital signature, every node will go through its local copy of the chain and verify whether the transaction is actually valid. That is, whether the sender has enough balance (according to it). After verifying, it transmits a “yes/no” value to all other nodes, with “yes” being the transaction is valid. If majority of the nodes agree, only then the block is added to the chain. As you can see, the entire structure is based on democracy. This is the fundamental criteria for block addition.

Validation in a peer-to-peer network. Source: gyfcat

In some cases, this process can get computationally expensive as hash computations are involved for block addition and is outsourced to a set of nodes called miners. This solves a lot of interesting problems, but more on that, we shall discuss in the upcoming article.

Every transaction is validated before adding to the chain

THE LONGEST CHAIN PROPERTY

There is another problem. If Alice adds a block on her own and Bob does the same for his chain, which chain is considered final?

Their local chains will start having different lengths. Since they transmit their transaction to every other node, some nodes can accept or reject the transaction. Thereby, the other nodes will start having varying lengths or branch out into a separate chain based on timestamp information. To solve this problem, The node that has the longest chain is assumed to be correct. Every other node synchronizes that chain with its local chain. This longest chain notion is based on the fact that false transactions are rejected by more than half of the nodes.

Only the longest chain is considered final chain.

SUMMARIZING

A blockchain is basically characterized by the following:

a) The data of a block. Note that in our example, we trivialized the data. In practice, a single block may contain thousands of transactions.

b) The type of blockchain. In some variant of blockchains, a miner may not be compulsory because not much computation might be involved. (The purpose it solves might be different than our use case- Eg. Ethereum). Also, in some blockchains, access is restricted. That is, not all nodes might have access to transact. (Eg. Hyperledger)

c) The consensus protocol used to select which node is going to mine and validate the incoming data. (Eg. Proof-of-work, proof-of-stake, etc) — More on that in the upcoming article.

d) The cryptocurrency, and its conversion to real money. In our case, MahiCoins ❤.

e) The timestamp information. In any chain, all the blocks are arranged in the timestamp order.

A blockchain has the following properties:

a) Peer to peer: Every node has the address and the public key of every other node. This eliminates the need for any third party completely.

b) Decentralized: The entire decision-making power is distributed equally among the nodes. A single node cannot decide on behalf of all nodes.

c) Immutable. This is a consequence of hashing. Changing some data in the middle alters the hash of the data completely. Since it follows a singly linked list principle, this altered hash is a predecessor of some other block and therefore, that block’s previous hash pointer has to be changed, which results in changing the hash of that block and so on. This change further propagates and by virtue of the longest chain protocol, no other node will agree to the changes :)

IT IS NOT ALL ROSES

Blockchains are computationally intensive to sustain and thereby time intensive as well. This may not suit for all kinds of applications, especially time-critical ones. Care must be taken to decide where exactly this tech should be used.

Blockchain tech comes with its own disadvantages as well. Whether the pros outweigh the cons depends on your application. Photo by Thomas Jarrand on Unsplash

This gets us to the last part of this article. Why.

Can’t I use normal currency? Why undergo this entire process?

You can keep using fiat. However, there are some problems with the existing financial system.

Middlemen: When you initiate any transaction, you communicate with a bank, which is a trusted third party. The third-party charges a “service-charge” (duh). However, with blockchain, you can directly communicate with the person you intend to transact with, without any service charge.

Centralization: Existing financial systems are centralized. A centralized database holds all key information in one place and can be easily modified. To put into perspective how critical this is, bribing the right people, a person can modify any data that you have shared with the government. With blockchain, all of that is prevented since the system is immutable and everyone has the power to potentially restrict transactions.

Opacity: No one really knows what data a system collects internally. Unfortunately, we become aware only when a massive scam is put to light. With blockchain, everything is transparent. Every node has a local copy of the chain and therefore can look at all the data.

All these promising features are indeed convincing enough. Blockchain has found its way into every field of technology. This disruptive tech has revolutionized various industries — from health care to gaming. This era of decentralized web is even regarded as the Web 3.0. (Web 1 being static HTML pages and Web 2 being able to render dynamic content)

CONCLUSION

This is just a broad overview of the Blockchain technology that has revolutionized the way we think. I hope the reader gets a better idea of blockchain after reading this. I also hope your cup of coffee is finished, by now (xD). The objective of the series is to enable people to see blockchain as a potential option and develop on the same.

Since this is an emerging technology, I personally believe more and more innovations will come from startups and people like us and not from well-established companies. The need of the hour is to set up blockchain scaling platforms that allow users to innovate on top of the platform. Companies like Matic are performing a wonderful job of it.

We have come a long way, from the world’s first cryptocurrency (called BitCoin, invented by the same X we discussed at the start of the article), to the world’s first Blockchain-Powered phone, but there is still a long way to go.

Stay tuned for other articles in this series, In the next article, we will talk about how you can go ahead and implement your own cryptocurrency!

Happy coding!

REFERENCES

Blockchain for beginners — 101bockchains.com — A neat explanation on the blockchain intrinsics

History of blockchain — tradefinanceglobal.com — Takes us through the first steps of blockchain along with its market value

3Blue1Brown — How does BitCoin Actually work — A Youtube video that beautifully illustrates the working of Bitcoin.

Read the next article on the series — Blockchain — Demystified: Creating Your Own Cryptocurrency!

This article is published as a part of the ‘Blockchain Series’ under Spider Research and Development Club, NIT Trichy on a Web Wednesday!

--

--

--

Spider, the Research and Development Club of National Institute of Technology, Tiruchirappalli is a group of people enthusiastic about technology and innovation.

Recommended from Medium

All about DAOs — are the organizations of tomorrow here today?

THE WONDER OF TRON-MINING-500trx bonus

CoinEx Institution | The Dark Forest Rule in the Blockchain World

In tune with Singapore — Iomob on Tour

Citizen’s Beta Preview

Cosmic Universe X Hermes DeFi Partnership

7 Companies Protecting Your Food with Blockchain

7 Companies Protecting Your Food with Blockchain

How to Launch an NFT Collection on your own?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
N Praveen Chandhar

N Praveen Chandhar

A wacky Web Developer and a ML enthusiast in his 3rd epoch of Undergraduation.

More from Medium

InPoker introduces Bullish Hours — daily time periods for multiplying leaderboard points

Canoemobile returns to Cedar River

#2 How to find the language school in the US?

Indecent Exposure