The blockchain is central to the functioning of Bitcoin. But it is not just limited to Bitcoin, it can do much more, even beyond cryptocurrencies.
What is a Blockchain?
At a practical level, a blockchain serves as a public ledger. It bears a validated record of all cryptocurrency transactions. Group of transactions makes a block of fixed size (1 MB in case of the Bitcoin blockchain). Each new block is added to the block-chain using the principles of cryptography. This ensures that it is very difficult to tamper with the blockchain.
The information that exists on the blockchain is shared with all the full nodes/computers that are connected to the blockchain network. Every node has a full copy of the blockchain. The system ensures that every node has the same copy of the blockchain and is always open for inspection.
The blockchain technology was first implemented by Satoshi Nakamoto (pseudonym) in 2008, to make it possible for a decentralized digital currency system based on a peer-to-peer network (Bitcoin) exist.
Elements of a Blockchain
- A distributed network terminals called Nodes.
- Each Node maintains a copy of the block-chain.
- New blocks are validated and added to this block-chain.
- A block contains a list of transactions.
- The information on the block-chain is public.
- Cryptography techniques provide security
We use money as a medium of exchange. The fiat money is official and authentic because of the government’s guarantee. Hence it is a legal tender. We transact money virtually through the use of banks. Physical exchange of fiat does not need the use of a ledger. Digital exchange requires an authority to maintain the transaction records. Banks are a centralized authority that carries out this task.
Hence there is no requirement of a third party to track the ownership and validate transactions. Your bank account is primarily a list of debits and credits. The central bank or government brings on new money and banks facilitate the use of this money for transactions.
Cryptocurrencies aim to replicate this whole system using the block-chain technology. They make possible a peer-to-peer decentralized digital currency without the need for a trusted third party.
How Blockchain Works
Each network participant keeps a copy of the entire blockchain. Consensus mechanisms (like proof-of-work and more) verify the newer transactions.
Cryptography protects the blockchain by making it hard to tamper it. A block contains a list of validated transactions and other information including its order in the block-chain. The first block is the ‘genesis block.’ and subsequent blocks form a chain using cryptography.
Miners perform the work of validating the blocks of transactions. The incentive being transaction fees and block rewards.
To manipulate data on the block-chain, one will have to manipulate the intended block and all the related blocks preceding it. This is possible, but only when the attacker can exceed the majority computational power of the network (51% attack).
Chain of Blocks
The blockchain is an ordered data structure with the back-linked list of blocks. A block contains a list of transactional data. Also, each block refers to the previous block in the chain. We can visualize the blockchain as a vertical stack of blocks on top of one another. The first block serves as the foundation block or the genesis block. Terms like block ‘height’ and ‘top’ block become intuitive this way. Block height is the distance from the genesis block to the reference block. The top block is the most recent block of the blockchain.
A hash serves as a block identifier and is placed on the header of the block. It is generated using a cryptographic hash algorithm like SHA256. The footer of the block has the hash ID of the previous or parent block. This sequence of hashes linking each block to its parent creates a chain of blocks.
A parent block can temporarily have multiple blocks attached to it. These ‘child blocks’ all refer the same hash of the parent block. This happens because miners discover different blocks simultaneously. Eventually, the longest chain of blocks resolves this.
Any alteration of the information in a parent block changes the hash value. Consequently, the hash of the child block also changes. This, in turn, changes the hash of the grandchild bock, and so on. This cascade effect ensures that any modification of a block’s data means a recalculation of the hash for that block and all the subsequent blocks. This requires enormous computing resources something of the tune of more than 51% of what the blockchain is functioning with. Hence, as more blocks keep piling up, the security of the information keeps getting robust. Hence, as more blocks join the blockchain, the probability to alter the chain becomes infinitesimal.
Bitcoin full nodes maintain a copy of the blockchain starting from the genesis block. As new blocks keep joining the chain, the chain grows. A node receives incoming blocks from the network. It will validate these blocks and then link them to the existing blockchain. The node examines the block header of the incoming block and crosschecks for the “previous block hash.” After which the node successfully establishes a link.
Merkle tree is a binary tree containing cryptographic hashes. It efficiently summarises the information contained in the block. Hence, makes it easy to verify the integrity of the large sets of data contained in the blockchain. In computer science, ‘tree’ denotes a branching data structure. The ‘tree’ has the ‘root’ on top and ‘leaves’ at the bottom.
Consider four transactions L1, L2, L3 and L4. These transactions are hashed and form the leaves of the Merkle tree (HL1, HL2, HL3, HL4). We have a parent node by hashing a pair of leaf nodes. For example, we get the parent node HL12 by hashing HL1 and HL2. Similarly, we hash HL3 and HL4 to get the parent node HL34. We now hash HL12 and HL24 to get HL1234.
HL1234 is the Merkle root of all the transactions that make this block. The block header stores it. The Merkel tree is a binary tree and even number of leaf nodes must be always available. In situations where a block is made with an odd number of transactions, the last transaction is accounted again. The requirement of an even number of leaf nodes is met this way. A Merkel tree with an even number of leaf nodes is also known as a ‘balanced tree.’
In Bitcoin, the cryptographic hash algorithm uses SHA256 twice, hence also known as double-SHA256. No matter the number of transactions, we always end up with a single Merkle root of 32 bytes.
Simplified Payment Verification (SPV)
With the use of Merkle trees, it is easy to check for any tampering of the transactions. A node can just download few block headers to identify a transaction’s inclusion in a block. As it uses fewer resources, Merkle tree provides for efficiency.
When the data of a transaction is altered, its hash value also changes. Also, all the subsequent hash values it is a part of. The node only needs to check this Merkle path to check for any tamper. Hence, Merkle path makes it possible for Nodes to not maintain a full blockchain. Such nodes are called simplified payment verification (SPV nodes). They use Merkle paths to verify transactions without downloading full blocks. SPV nodes just block headers.
The Blockchain Technology is a revolutionary and foundational technology. It has the potential to transform business operating models in the long term. In areas of financial transactions, asset ledgers and decentralized social networking, we can expect a significant impact. Second-generation programmable blockchains use smart contracts to make the blockchain versatile.
With increasing focus on the idea of the blockchain technology, more innovations are bound to take place, thereby increasing the capability of this technology. Hence, the success of the blockchain technology depends on how well it can find a variety of uses for itself and becomes mainstream.