# Blockchain

## Summary


Blockchain is an open immutable distributed ledger without centralized control. The ledger is maintained and validated by a peer-to-peer network of computers. Such a ledger could contain any digital asset of value such as cryptocurrencies, land records, birth certificates, insurance claims, concert tickets, the source of diamonds, etc. 

Because digital assets can easily be copied, we need a system that prevents fraud. Traditionally, banks, government bodies and private institutions serve as trusted intermediaries. Blockchain aims to bypass them. It does this using cryptography. No one can tamper transactions recorded in the blockchain due to high computation costs. We may therefore say that trust is established implicitly via cryptography. 

Blockchain was initially used to create and transact a cryptocurrency called Bitcoin. Today, it's anticipated that blockchain can be used for diverse applications and it's set to revolutionize multiple industries.

## Discussion

### Why was Blockchain invented?

The collapse of Lehmann Brothers back in 2008 triggered a global financial crisis from which many economies are yet to fully recover. Perhaps it was this that prompted Satoshi Nakamoto (pseudonym) to think of a method for peers to exchange currencies without involving centralized control. Centralized institutions such as banks fulfil the role of verifying identity, building trust, executing business logic, maintaining records, validating transactions and performing audits. This also implies that consumers are dependent on this controlled system of trust.

Nakamoto proposed introducing a digital currency called Bitcoin and a peer-to-peer method of transacting bitcoins without involving centralized control. Within such a network, centralized authorities and middlemen are not required. They would not be able to take risky decisions using what belongs to you. Peers can transact with one another directly. Blockchain was the technology that Nakamoto invented to power the creation and transaction of bitcoins, although the term "blockchain" does not appear in his influential paper. 


### Could you explain how Blockchain works?

In simple technical terms, transactions/items are grouped into blocks, which are then protected using cryptography. Each block comes with a *hash* that protects the integrity of the block. This hash is computed by *nodes*, which are computers participating in the blockchain network. A completed block is linked to the previous block and this forms a chain of blocks; hence, the name *blockchain*.

Computation of the hash depends on the contents of the current block plus the hash of a previous block. This means that an attacker attempting to tamper a block in the middle will have to recompute the hash values of all subsequent blocks. This is computationally difficult in a distributed system where multiple nodes are working on genuine blocks. Trust in this system is therefore established by the computational complexity of pulling off a successful attack. This complexity is known to be exponential. 

If an attacker attempts to create another version of truth (a parallel chain), the rules of the blockchain will allow only the genuine chain to survive. We call the set of rules *consensus mechanism*. 


### What are the advantages of using Blockchain?

Blockchain has the following advantages: 

    + **Distributed** - Since there's no central control, the government or any other authority cannot bring down the system or suddenly change the rules. Participating nodes in the network are all peers and have equal say in keeping the blockchain operational. Often the term "decentralized" is used but by classical definition, nodes in a decentralized network are connected via a hierarchy whereas those in a distributed network are truly peer to peer. The distributed nature of blockchain makes it robust.
    + **Transparent** - The ledger is public, which means that transactions are visible to everyone participating in the network. Malicious users cannot choose to hide their transactions. Transparency brings with it accountability and verifiability.
    + **Immutable** - Once data goes into the ledger, it cannot be modified. No one can tamper it to serve their personal gains. Thus, blockchain presents a single version of truth. Data is reliable.
    + **Democratic** - Anyone can join or leave the network as they wish. No approvals are required. Nodes are given incentives to validate transactions.

### What are the common criticisms of Blockchain?

Blockchain's first application, Bitcoin, was used to power criminal activities on the darknet via sites such as Silk Road. Users on the Bitcoin network were anonymous and paid for illegal goods using bitcoins.

It's been argued that when Blockchain is applied with access control and to private data, it's integrity is compromised. Likewise, the binding of real world assets to digital equivalents requires some form of centralized authority. 

While indeed the chain is immutable, what goes into a block is determined by who controls the private (secret) key. Though the Bitcoin network is distributed, in reality, nodes are assembled into cartels and a few of them could potentially control the network. 

Validating transactions is compute intensive with each block taking ten minutes. In comparison, Visa processes 45K transactions per second and Google Ads gets 30 billion impressions per day. A single bitcoin transaction consumes 5,000 times more energy than a credit card payment. In terms of memory, storing the entire chain takes up 100 GB for Bitcoin, which is duplicated on every node. 

It's been claimed that transaction costs will go up, the technology is too complex and adoption will not be universal. 


### Can Blockchain be compared with TCP/IP?

Just as TCP/IP changed the way we communicate, Blockchain is going to change the way we exchange value. Just as TCP/IP created the Internet as an open public network without centralized control, Blockchain is creating an open distributed ledger system that can enable all sorts of applications. 

Blockchain, like TCP/IP, is a technological enabler. It's the apps and solutions built on top of blockchain that are going to add value.


### What could be typical use cases of Blockchain?

Blockchain is being regarded as a foundational technology, poised to create huge impact to our traditional social-economic systems. Use cases are diverse. Depending on the extent of novelty and complexity, they can be categorized as single use, localized use, substitution, and transformation. While many applications are already out there, Blockchain may take a couple of decades to reach its full potential. 

Here are some use cases:

    + MUSE platform enables music streaming platforms to offer artists a way to monetize.
    + IBM has partnered with food giants to trace the source of contaminated foods. In general, supply chains are going to be transformed.
    + Blockchain is enabling new sharing services including sharing of compute time, storage, SMS and more.
    + Consumers can sell excess energy to their neighbours directly than sell it to the utility company.
    + Land title registration, birth certificates, medical records and identification documents are some examples where blockchain can lower costs and prevent fraud.
    + In stock trading, settlements that currently take days or weeks can happen in seconds. Middlemen are also eliminated.

### Are there applications where blockchain should not be used?

Blockchain may be an overkill for many applications where a shared database may suffice. For performance and energy efficiency, a database is better. 

If your app has multiple readers but only one writer, blockchain is not required. Even if there are multiple writers but they all trust one another and your systems are well protected, blockchain is not required. Even if the writers don't trust one another, but they do trust a third-party, blockchain is not required. 

Many have come up with decision models or flowcharts to help you decide if your app requires blockchain or to select the right type of blockchain. 


### Is Blockchain standardized?

No, Blockchain is not a standard. There's no standardization body or industry consortium defining it. Blockchain is a technology that's based on cryptography and peer-to-peer network.

While Blockchain as proposed by Satoshi Nakamoto can be used in its original form, anyone can also modify it to suit their application. This implies that applications built with Blockchain will not interwork with one another. For example, Bitcoin and Ethereum are both built with Blockchain technology but these are two independent applications that won't work together.

Having said that, there are attempts to standardize the technology. Overseen by The Linux Foundation, Hyperledger is one such effort. R3 and Enterprise Ethereum Alliance are also standardizing it within their scope of interests. Microsoft's Coco is more of a framework than a standard. It's goal is to enable Blockchain adoption in enterprises. 


### What exactly is a block in Blockchain?

A simple analogy is that blocks are like pages in a traditional ledger and the entire blockchain is the ledger. A block therefore encapsulates multiple transactions. In the case of Bitcoin, a block has 500 transactions on average and consumes 1MB space on average. 

A block consists of a header, a Merkle summary built from transaction identifiers, and the list of transaction identifiers. The header itself includes hash of the previous block, version info, current timestamp and nonce. Hash of the current block will become part of the next block's header. 

As an example, you may study Bitcoin Block #525510, which was generated in March 2018.


### Can you enumerate some technical foundations of Blockchain?

Blockchain has brought together existing technologies in an innovative manner:

    + Computations are not partitioned and distributed to the nodes. All nodes in the network do the same computations.
    + Users sign transactions with their private keys while others verify using the corresponding public keys. These keys are generated using the well-known RSA algorithm.
    + The cryptographic hash computed per block is really a fixed length output based on an input of any length. Bitcoin uses SHA-256 to create a 256-bit hash. Given the hash, it's impractical to determine the contents of the block. It's also almost impossible for different contents to result in the same hash.
    + Each transaction in a block has its own hash and these hashes are arranged into a Merkle tree.
    + Each block contains a nonce. Most computer power at a node is expended in finding a suitable nonce such that the resulting hash on the block is valid.


## Milestones

1991

In a paper titled *How To Time-Stamp a Digital Document*, Haber and Stornetta note two necessary properties of digital timestamps: timestamp the data (not the medium in which it appears) so that it's impossible to change the data without anyone noticing it; make it impossible to falsify the data and its timestamp. Their solution uses cryptographic hash functions, signatures and distributed trust. All these would later play important roles in the invention of Blockchain. 

Mar  
1992

Bayer et al. improve the efficiency and reliability of digital timestamping. They propose the use of **Merkle trees** (invented in 1980 by R.C. Merkle) instead of linked lists that link transactions. Computation is reduced from \(N\) steps to \(log\_2N\) steps. 

2008

Someone going by the pseudonym Satoshi Nakamoto publishes technical details of a new peer-to-peer electronic cash system, one that avoids centralized banks or intermediaries. He calls it *Bitcoin*. The term *Blockchain* is not used in this paper though the idea is clear: chain blocks based on their hashes with timestamps. 

Jan  
2009

Bitcoin is launched using blockchain technology. It's the first application of blockchain. 

Mar  
2013

As some nodes on the Bitcoin network upgrade to version 0.8, others continue mining with version 0.7. An incompatibility between the versions creates a *fork*, which is basically an alternative chain. Bitcoin loses values but later regains as nodes rollback to version 0.7.