Let’s take an example where Person A is transferring $50 to Person B.
Person A sends a request to his Bank for initiating the transfer, Bank verifies the request and if everything is ok then subtracts $50 Person A ‘s account and adds $50 to the account of Person B. Then bank updates its ledgers to reflect these changes.
If you look at any of the transaction that we do these days are mostly handled by one or more servers managed by a single entity. This entity could be your bank, a social media or an online shop, and they all do a standard action, record your transactions in a centralized database.
You might already be thinking that these entities do not really use a single server or ledger to perform these transactions, that is true even if they have multi-geographic fault tolerant sophisticated server farms to store their ledgers they all are managed and controlled by a single entity. In other words, the entities who records these data has the full control to do any action with their data.
Person A in the above case has to trust that the bank he transacts with will act as he expects, Though this system has been working for some time, there are few drawbacks for this type of transactions and ledgers.
- The entity who owns the ledger has the full control over it and can manipulate the ledgers at it is on will without its customer’s permission.
- The records in this ledger can be easily tampered with by someone who has access to it, means if someone makes some malicious changes to this ledger that can affect everybody who is relying on that ledger. (for example, someone can hack into the bank’s centralized ledger and modify transactions).
- Another disadvantage is the single point of failure. For example, if the bank decides to shut down their service users will not be able to perform transactions.
In the extreme case where a natural disaster wipes out their all data centers, all the transactions from the ledgers will be lost.
- Centralized Ledgers stores data in Silo’s, means, for example, your bank has its ledger, an auditor has his ledger, tax authorities have its ledgers, and they are never synchronized.
- Though it is a centralized ledger from the general point of view, the organizations will have to spend too much of money to build redundancy and scaling to their ledgers. That makes this very expensive
What is BlockChain
In simple terms, Blockchain is a distributed ledger of transactions. All the transactions in the blockchain are encrypted and synchronized between the participants.
Key points about Blockchain
- It is a Distributed Ledger.
- Members of a blockchain network are called Nodes.
- Each node has the copy of the full ledger.
- Nodes use Peer to Peer Network for synchronization.
- All information on the Distributed ledger is Secured by Cryptography.
- By design Eliminates the need for a Centralized Authority to validate transactions by performing peer validations before any transactions
- The transactions are added to ledger based on Consensus from nodes.
- Each valid transaction in the Blockchain is added to a Block
- Blockchain miners create Block
- Multiple Blocks make a Blockchain.
- All Blocks in Blockchain are Immutable.
- It ensures Complete Audit trail of the whole transactions (Verifiability)
I know this is too much to chew on, I promise you will get all these concepts by the end of this article. So be with me and let’s move on…
Distributed Ledgers (DLT)
According to Wikipedia “A distributed ledger is a consensus of replicated, shared, and synchronized digital data geographically spread across multiple sites, countries, or institutions. There is no central administrator or centralized data storage.”
In the Distributed ledger each participating member has a copy of the ledger, In simple terms during any transactions, it updates the ledger of the sender and receiver then broadcast the transaction, The transaction details are updated in the ledgers of all of its participants using peer to peer network.
Peer to peer (P2P) network
Peer to Peer (P2P) is a decentralized communication model where each participating nodes will have the same capabilities. Unlike the client-server model, any node in the peer to peer network can send requests to other nodes and respond to requests by other nodes. The best example for a peer to peer network is BitTorrent.
Any peer can perform a transaction on the P2P network this means When one node can perform a similar transaction at the same time it will end up in conflicts. This is called double-spend problem. Blockchain uses a consensus system to resolve these kinds of conflicts.
We will discuss the double-spend problem and consensus systems in detail in a later post. Let ‘s focus on the basic concepts first.
Cryptography in Blockchain
Due to its nature, any data in a Blockchain is visible to all the members of the network, this makes this data vulnerable and hackable, however, Blockchain uses cryptography to make all the transactions extremely safe and secure.
In simple terms, Cryptography is used for obfuscating (encrypting and decrypting) data. Blockchain leverages two cryptographic concepts in its implementation.
They are the following
- Digital Signature.
What is Hashing
Hashing is a mechanism where any input is transformed to a fixed size output using a hashing algorithm. The input could be of any file type, for example, you can generate a hash of an image, text, music, movie or a binary file.
Whatever may be the size of the file, hashing algorithm guarantees that the output is of a fixed size. (For example, if you create an SHA 256 hash of any file the hash will always be 256 bits.)
Key properties of Hashing.
Any hashing algorithm should adhere to the following principles.
- For a given value the algorithm should always produce the same hash value.
For example, the SHA 256 Hash of the word "Hello World" will be always A591A6D40BF420404A011733CFB7B190D62C65BF0BCDA32B57B277D9AD9F146E
- This means it should be computationally hard or impossible to decrypt the input from the output.
In the above example, we saw the hash value A591A6D40BF420404A011733CFB7B190D62C65BF0BCDA32B57B277D9AD9F146E represents "Hello World". It is impossible to decrypt the word Hello World from the above hash value.
Second pre-image resistance
- This means the hash generated with input should not match with a hash value of a hash value of a different input
For example function hash(“Hello World”) != function hash(“XXX”) where “xxx” is any input other than word “Hello World”
- This means it should be hard or impossible to find two different input (of any size or type) to have the same hash. Collision Resistance is very similar to Second pre-image resistance.
Hashing is commonly used to find the checksum of a file. For example, when you are downloading software from a server the software vendor provides the checksum or Hash of the software package. If the hash of the downloaded software is matched with the hash given by the provider of the file, we guarantee that the software was not tampered with.
Blockchain uses Hashes to represent the current state of the blockchain. Each block in the blockchain may have hundreds of transactions and verifying each transaction individually is going to be very expensive cumbersome. So Blockchain leverages Merkle root to verify the transactions.
> Merkle tree of a Block
In a Merkle tree, each non-leaf node will have the hash of their child nodes. Look at the below diagram to understand the concept of Merkle tree.
Each block in the blockchain has the Merkle root of its transactions and the hash of its previous block. The hash of Merkle root can be used as a definitive mechanism to verify the integrity of the block as even the slightest changes to any of the records in this tree will alter the value of the original Merkle Root.
In other words, the entire state of a Blockchain system can be validated by the hash of its last block which is of 256 bits.
What is a Digital Signature
A classical example of Digital Signature is the website traffic using HTTPS protocol using SSL. SSL uses the digital signatures to ensure the authenticity of the server.
A User generates a digital signature by generating a Public and Private key Pair.
A Public key an a Private key has mathematical relations that tie each other. The private key should be kept as secret and should be used for signing messages digitally. A public key is intended to be distributed publically which should be used by the message recipient to validate the authenticity of the message.
Sender signs all his transactions with his generated private key. This will ensure that only the owner of the account with the private key can do the transaction.
The Reciever or any nodes in the Blockchain verifies the transaction by checking the digital signature of the transaction using the public key.
Key Points to Remember about Hashing in Blockchain
- Hashing is used for verifying the integrity of the transaction
- The digital signature is used for verifying the identity of the performer of a transaction.
For learning more about the Cryptography and Hashing in Blockchain, please visit the following links
What is a Block
We saw that Blockchain is a group of blocks in sequential order, Let’s take a quick peek at what a block is? In simple terms Block is a group of valid and verified transactions. Each block in the blockchain is immutable. Block miners will continuously process new transactions, and new blocks will be added to end of the chain. Each block will have the Hash of the previous block thus ensuring the integrity of the chain.
Every block in a blockchain will have the following information
- Hash of the previous Block
- Timestamp at which the block was created
- List of the transactions that were part of that Block
- Merkle tree of all the transactions in that block
- Nonce – (A random String generated by miner)
- Hash of header of the block which will be used as the Hash of the previous block in the next block
Let’s take a look at a real example of a Block; As you all know Bitcoin is based on Blockchain, To explain a Block I am referring to a block from bitcoin transaction. I had taken a real Block from Bitcoin Blockchain network from www.blockchain.info
You can see that this block has a header and a list of transactions. Transactions and its details can vary depending upon the blockchain implementation since this is a Bitcoin block you will see Bitcoin transactions.
Let’s go through each some of the key datasets in this block header
|Block Id||Unique ID representing this block|
|Number of Transactions||Total number of transactions recorded in that block|
|Height||Total number of blocks preceding to this block on that blockchain, (in this case, there are 505234 blocks created before this block)|
|Timestamp||Time at which this block was created|
|Relayed By||Miner who mined this block|
|Transactions||This shows the hash of each transaction with its details|
We learned that any Block will always have the hash of its previous block attached to it. So its implied that First block (Block 0) of a Blockchain will not have a previous block, and this is known as Genesis Block. Genesis block is almost hardcoded into the applications that use that blockchain.
Block time is the time taken to mine a block. Block time varies from implementation to implementation in the blockchain. To provide security and prevent forking each implementation defines its own block time. For Bitcoin, the block time is 10 mins whereas for Etherium its around 20 seconds.
What is in a transaction
Again I am taking a bitcoin transaction to explain a transaction record in Blockchain. The below transaction shows the transfer of a bitcoin from one address to two recipients which was part of the Block that you had seen in the previous image.
The Tree diagram below shows the related transfers of those bitcoins. This related or audit trail of the asset (Bitcoin in this example) ensures the legitimacy of this transaction.
What is Block Mining
In simple words, Miners are the one who runs a specialized version of the Blockchain software which can add a Block to the Blockchain. The miners get rewarded each time when they add a block to the Blockchain. There may be multiple miners who will compete with each other to create a Block in the blockchain in a network.
Miners keep transaction pool of unconfirmed transactions tries to wrap around them to create a block. They will have to solve a mathematical puzzle to add the block to the blockchain. These mathematical puzzles are to create a hash of the block of a particular nature.
The constants in this puzzle are the following
- Previous Block Hash
- Time Stamp
- Merkle root
The variable in this puzzle is the Nonce. A nonce is a fixed size string that can include both numerical and characters.
Miners keep trying new nonce till they solve this puzzle and the first miner who can solve this wins and broadcast to the network and the block is added to the chain. Then the nodes add this block to their ledger.
Currently, Bitcoin and Etherium use an algorithm called proof-of-work to mine a block,
Below is the illustration of the proof-of-work algorithm.
There are multiple algorithms used by blockchain network for mining and consensus, We will discuss those algorithms in detail in a different post.
Few Usages of Blockchain
The blockchain is an emerging technology and there are a ton of use cases that we can solve with this. Here are the few use cases that can leverage the power of Blockchain.
- Health care records sharing
Privacy of Personal health records is a major concern right now, think about a system where your personal health records can be stored in a blockchain and shared with the doctors within seconds.
- Insurance Claim Processing
We know that Insurance industry is prone to lots of fraudulent claims and fragmented sources of data. Chances of error (intentional or unintentional) are very high. With the Blockchain, we can have more transparent and error-free insurance claims.
- Payments and Banking
The Major issue in the banking and payment sectors are fraud and money laundering. With the transparency Blockchain provides we should be able to eliminate most of these.
- Voting systems
We saw earlier that Blockchain is tamper proof or tamper evident. Implementing a blockchain based voting system can create an unhackable voting system.
- Smart Contracts
Smart contracts allow the self-execution of contracts. (I will cover smart contracts with examples in a different post). Blockchain not only eliminates the need for third-party for smart contract enforcement but also enforces the terms of a contract when the terms are met.
If you look at these use cases the blockchain will be a great choice if we auto validate the transactions using smart devices. In other sense, in order to leverage the full potential of Blockchain, we need to have more IoT sensors which can validate many of these “transactions”.
Food for thought
Imagine you go to a grocery store and pick up a bottle of organic, you are not sure whether this milk is really organic or not, you take your smartphone and scan the QR code of the batch id of the milk, The application lists out the details of dairy farm along with the cattle food they are buying, health history of the all the cows in the farm along with their medical records where you can trace back to each and every detail of what the farm states about the milk… that is the future that Blockchain can offer.
If you look at the Gartner Hype Cycle for emerging technologies 2017 you can see that Blockchain is slowly moving to Trough of Disillusionment and they are expecting this to mature to mainstream adaptation in 5 to 10 years. My feeling is this could be shorter.
Having said that, there are a ton of development going on in the Blockchain field, Both large and small scale players are bringing lots of innovation to the blockchain technology.
Below are few of the current major implementations of blockchain
I don’t think Bitcoin needs an introduction, It is the first digital cryptocurrency and leverages the blockchain technology.
Etherium is an open-source blockchain platform for Blockchain applications and smart contracts. It is the first majorly accepted Blockchain platform. We will cover more on Ethereum in a different post.
We covered the basics of Blockchain here, This is just a beginning. Stay tuned more articles where we will get to more depth on some of the topics that we discussed here.
Thanks for reading and Please leave your feedback in the comments section.