Blockchain Explained Blockchain Explained

Most of us think Blockchain as the technology behind Bitcoin. While this was its original purpose, blockchain is capable of so much more…

What is Blockchain?

Blockchain is digital, distributed, immutable and trusted ledger.

Let’s understand each term one by one:-

Blockchain is Digital Ledger

You are familiar with the ledger, which is nothing but a book to record financial transactions. Similarly, Blockchain is a digital ledger which can be programmed to record things, and the things are not limited to financial transactions, but could be anything from government records to land titles, or even purchase orders.

General Ledger

General Ledger

Each line of record in a ledger book can be assumed as a block in blockchain, which are linked together chronologically to form a chain of blocks.

You write a new record in the financial ledger book for any changes in previous transactions. Similarly, If you want to change record in a particular block, you don’t rewrite it. Instead, the change is recorded in a new block.

Blockchain is Distributed Ledger

Let’s assume that I am maintaining a shared ledger book with my friends where everyone records their mutual expenses. Let’s say, I lend $100 to my friend Ben and recorded in a shared ledger. Now my friends Charlie and David know the exact amount of money I lend to Ben and they’ve essentially endorsed the transaction and they made a record of it. Now when next month, Ben asked me how much money had initially lent him, we could easily go to anyone of my friends Charlie or David that have a record of that transaction. When you make new friends, they can also join you in shared ledger.

Similar to a shared ledger, Anyone can opt to connect their computer to the blockchain network as node. In doing so, their computer receives a copy of the blockchain that is updated automatically whenever a new block is added, sort of like a Facebook News Feed that gives a live update whenever a new status is posted.

In this sense, blockchain is distributed and data is shared.

Advantage
  1. Reconciliation is not required as data is shared and each node is having copy of transaction.
  2. High availability as thousands of distributed nodes working in the network, doesn’t matter if few goes down.

Blockchain is Immutable Ledger

Let’s look into the pieces which make up a Blockchain to understand its immutability

  1. transaction: this is details of the transaction that occurred when the block was created

  2. hash: this is a digital fingerprint that represents the transaction in the block and is completely unique. If there is any change in transaction details, the hash would also change. Generally, it’s an alphanumeric sequence generated by applying some crypto algorithm on transaction details

  3. previousHash: this is the hash of the previous block in the chain.

Let’s look at the below example of blockchain. Where transaction is having sender, receiver, and amount details. For simplicity, we are generating hash by just combining transaction details, i.e.

hash = sender + receiver + amount

Please note that Block 1 is the first block in our Blockchain, also known as Genesis Block, is not having previousHash value.

Block 1
transaction     { sender: Ash, receiver: Ben: amount: $100 }
hash            ashben100  
previousHash
Block 2
transaction     { sender: Ben, receiver: Charlie: amount: $200 }  
hash            bencharlie200  
previousHash    ashben100
Block 3
transaction     { sender: Ash, receiver: David: amount: $300 }  
hash            ashdavid300  
previousHash    bencharlie200

Let’s say a hacker attempts to edit the transaction amount in Block 2 from $200 to $999. As soon as they edit the dollar amount of the transaction, the block’s hash will change. The next block Block 3 in the chain will still contain the old previousHash, and the hacker would need to update that block in order to cover their tracks. However, doing so would change that block’s hash. And the next, and so on.

Block 2 (Tampered Amount)
transaction     { sender: Ben, receiver: Charlie: amount: $999 }  
hash            bencharlie999
previousHash    ashben100
Block 3 (Old Previous Hash)
transaction     { sender: Ash, receiver: David: amount: $300 }  
hash            ashdavid300  
previousHash    bencharlie200

In order to change a single block, then, a hacker would need to change every single block after it on the blockchain. Recalculating all those hashes would take an enormous and improbable amount of computing power. In other words, once a block is added to the blockchain it becomes very difficult to edit and impossible to delete.

In this sense, Blockchains are immutable and tamper-resistant.

Blockchain is Trusted Ledger

When you transfer money to someone, you do it through a mediator, generally a bank. Now all the transaction records are centralized within the bank. There are more chances for hackers to tamper with records.

Moreover, when you transfer a crypto currency like bitcoin, which is backed by blockchain technology, there is no mediator involved, essentially all of the nodes, millions in case of crypto currencies, in the blockchain network are mediators, having their own copy of records. If hackers want to tamper with any record, they need to do it in all those million copies of record.

Let’s understand more on this, to become eligible for adding a new block in the blockchain, a node has to solve a very complex math problem and need to provide something called proof of work. Solving puzzle is intensive in terms of computation (time) and electricity consumption (money), which requires time as well as money.

As we saw earlier that hacker need to tamper with all those millions copies. If adding one block to the blockchain requires spending so much time and money, you can imagine how it will be to tamper with all those millions copies. Certainly it’s not worth the effort and more likely impossible.

In this sense, blockchain technology is trusted.

Blockchain’s Use Cases

1. Bitcoin

Most of the crypto currencies - Bitcoin, Dash, Ethereum, Litecoin, Ripple follows public blockchain. Public blockchains are open to everyone to view and access, also known as permissionless blockchain as you do not require authorization.

Crypto Currencies

Crypto Currencies

The bitcoin protocol is built on the blockchain. Introduced as digital currency, Bitcoin’s pseudonymous creator Satoshi Nakamoto referred to it as “a new electronic cash system that’s fully peer-to-peer, with no trusted third party.”

How Bitcoin Works?

You have all these people, all over the world, who have bitcoin. There are likely many millions of people around the world who own at least a portion of a bitcoin. Let’s say one of those millions of people wants to spend their bitcoin on groceries. This is where the blockchain comes in.

  • When one person pays another for goods using bitcoin, essentially a transaction is initiated. This transactions contains all the necessary information such as sender and receiver, but not the actual names, instead a unique digital signature sort of like a username is used along with amount, timestamp, etc.
    Bitcoin Block
    transaction: { 
                    type: BITCOIN
                    sender: g4h4g5jnsm6bd4b8d0q6d8v4zx5k2la8d9n4c6f8, 
                    receiver: m1n2h3b4b5v6c7xz89sld8ff9d47d9dft47mkd,
                    amount: 25
                    timestamp: dd-mm-yyyy hh:mm:sss
                }
    hash:           ???????
    previousHash:   b4h84nv46sn29n4b5h6j7k8l2l3nx6b3n8l38xn40z54n2bv68c
    
  • This transaction joins the other transactions that have been made on the bitcoin network.
Bitcoin Miners

The bitcoin blockchain is a public blockchain which means anyone can register themselves to be one of the Bitcoin Miner. Bitcoin miners are the nodes in bitcoin blockchain network. All the nodes in the network essentially having a copy of all transactions, and anytime new transactions are made they would be notified with the new block.

  • All the Bitcoin miners in the network start picking up those transactions and validate by looking through all of the transactions that happen in the Blockchain so far that those are also valid.
  • Each Bitcoin miner try to solve the cryptographic hash puzzle, also known as proof of work algorithm. Now, this is the consensus algorithm that public and permissionless blockchains use and essentially this is how they’re able to reach a consensus on which block should be next.
  • As soon as one of the bitcoin miner solves the puzzle, essentially means generated the hash of the next block, what they’ll do is broadcast that hash of the block to all of the other nodes in the network. All the nodes verify the authenticity of the hash and once all approve, it is added as a new block in all the nodes in the network.
  • Bitcoin miner is also rewarded with bitcoins for their work on solving the puzzle. Solving the puzzle also referred as mining
What if one of the bitcoin miner is hacker?

Bitcoin miner is one of the node in bitcoin network, if bitcoin miner is a hacker and they manipulated their own copy of record then bitcoin protocol discourage the existence of such manipulated blockchain through a process called consensus. In the presence of multiple, differing copies of the blockchain, the consensus protocol will adopt the longest chain available.

Why cryptographic hash puzzle is time consuming?

Each node try to solve hash puzzle to generate a unique hash from transaction details using SHA-256 algorithm, this might take less time. But some protocols like bitcoin protocol restrict hash to be generated with 32 leading zeros. Generating a hash with leading or trailing zeros is more complex. Similarly Generating a hash with 10 leading zeros is more computation intensive then 5 leading zeros.

Now you will say that transaction details are fixed, it will generate hash based on these details. How we generate a hash with leading zeros? For this block is having a special field called nonce which is also included to generate hash. Each node do trial and error with keep changing the nonce value until they found the hash with specified leading zeros.

SHA-256 ( nonce + transaction details ) = 00000h3bdju7vb3n9s73nf92n1b38d 


2. Private Blockchain

Blockchain can also be used for business like supply chain, banking and government sectors. They are mostly private blockchains, which are accessible to a select group of authorized users - such as your company, a group of banks, or government agencies. This is also known as Permissioned blockchain.

Private blockchain also uses a consensus algorithm but they are not as complex as public blockchain due to the limited number of nodes.

Nodes in the permissioned blockchain are trusted, so they generally know each other. Besides, they don’t always just represent users but entire organizations. So, in this case, it’s very important that our privacy is one of the main tenants of a permissioned Blockchain.

3. Supply Chain

Let’s take an example, let’s say that there’s a retailer that purchases 25 items in $1000. Now the manufacturer receives the order from the retailer and says, “OK, let’s approve”. Let’s make sure we have enough in the warehouse and let’s work with the shipping company. So, they go to the shipping company and they say, “OK, let’s ship this 100 items” and it’s going to cost them $100 to make the shipment.

Block 1
transaction: { 
                type: BUY
                company: Star Retailer Ltd., 
                items: 25,
                total_cost: $1000,
                discount: $50
             }
hash:           buystartcompanyltd25100050
previousHash:   -
Block 2
transaction: { 
                type: SHIP
                company: Shipping Bird Co., 
                items: 25,
                total_cost: $100,
                dispatch_date: DD MM YY,
                arrival_date: DD MM YY
             } 
hash:           shipshippingbirdco25100ddmmyyddmmyy 
previousHash:   buystartcompanyltd25100050

There are some privacy concerns here,

  • Manufactured should know all the information about retailer and shipment
  • Retailer should not necessarily know about the shipping cost
  • Shipment should not necessarily know about how many retailers spent
  • Other retailers in the blockchain should not know about this retailer and shipment

So in this case, All of the organizations are part of the Blockchain, only the retailer which is part of the transaction that took place should be able to see that information. So, privacy must be part of the Blockchain for the business being able to control who can see particular transaction details.

4. Smart Contracts

One of the most successful business applications of Blockchain technology is something called Smart Contracts. Essentially this is code that’s running on the Blockchain and whenever certain conditions are met, they are automatically executed.

So, in the previous example of supply chain, whenever retailer made that purchase order to the manufacturer for this amount of goods there’s probably a manufacturing agent that double-checks that order has all the necessary information in it, they then probably go to the shipping agency to make sure they can cover the shipment and if the warehouse has the correct amount of goods. They’ll then make a shipment order. Now imagine if we could automate that whole process.

That’s what you can do with Smart Contracts, essentially code that will make sure that all the necessary information is met, and it’ll automatically create the shipment record. If any of those conditions is not met it could automatically release a refund to the retailer. This speeds up the whole process.

Real Estate

Smart Contract can automate the process title deeds, facilitate transactions and even grant access to properties through smart keys. The technology could streamline property sale, saving buyers time and money without the need to any middleman or real estate agent.

5. Cross Border Payments

People working in other countries generally send money back home from remittance agencies which takes hours, sometime few days and also they pay a good amount as fee. Blockchain technology would eliminate those Intermediaries and cut short the transfer time as well as transfer fee.

Blockchain innovators for Cross Border Payments

Blockchain innovators for Cross Border Payments


6. Online Voting

In many countries, voter has to be present at the polling booth to cast their vote. There were always concerns about the authenticity of manual voting and voting machines. Voting is carried out online also in many countries but they also have concerns about security and fraud. Blockchain can successfully eliminate these concerns as it will present a clear record of the votes that have been cast. The tamper-proof feature of a blockchain makes it difficult to hack a blockchain-enabled voting system. With blockchain, voters can cast their vote from the comfort of their home. Citizens residing outside country can also cast their vote. This may result in a significant rise in voter turnout.

West Virginia has implemented a secure mobile voting application using blockchain technology that allows voters to receive, vote, and return their ballots electronically, first kind of project in United States history in 2018.

Companies working on online blockchain voting solution - FollowMyVote, Voatz, Scytl, Clear Ballot, Polyas, Intelivote, SMARTMATIC, electionrunner

7. Inter-bank Payments

The Monetary Authority of Singapore (MAS) announced Project Ubin, which use Blockchain and Distributed Ledger Technology (DLT) for inter-bank payments partnered with a consortium of financial institutions like Bank of America Merrill Lynch, Credit Suisse, DBS Bank, HSBC, JP Morgan, Mitsubishi UFJ Financial Group, OCBC, SGX, Standard Chartered, and UOB

8. Identity Management

Identity of a person includes basic details (name, age, gender, nationality, address, contact, etc) and ID documents like birth certificate, driving license, voter card and unique identity card. These all details could be stored in distributed, secured, immutable blockchain records.

Benefits
  1. Distributed identity management system can be used by many services at the same time across the globe.
  2. Financial Services like banks can use this to verify customer identity for KYC (Know your customer) compliance.
  3. Educational Services like schools, universities can use this to provide academic certificates to student. This solves the problem of verifying the authenticity of certificates and avoid frauds of fake certificate.
  4. Government Bodies can use this to store birth certificates, marriage certificates, land titles to avoid corruption.

Summary

I hope after reading this post, you have a basic understanding of blockchain technology and its practical usage. I will keep updating this post based on my findings. Thanks for reading.

Please read the next post if interested in some Blockchain coding - Blockchain implementation using JavaScript