Ethereum and Blockchain - 1

"If you are not profoundly shocked by quantum mechanics, you haven't really understood it!"        ~ Niels Bohr.

Frankly, I didn't understand what Bohr meant by this quote on quantum mechanics. But ever since I have started to read and experiment with Ethereum and Blockchain, I have started to realize a parallel to Bohr's quote w.r.t this new technology. I do understand that many, would now be wondering "what the hell am I blabbering??". Let me attempt to explain to you my shock through a series of blogs, which will also help me to recollect my learning over time.

To understand Ethereum and Blockchain, one has to understand its parent, the Bitcoin. I first heard of Bitcoin back in 2014 while working on a European startup. Apparently then a Nigerian bus booking company had implemented Bitcoin API to accept payments for bus travel. Although I was intrigued by the term, once I started to read through it I was confused and apprehensive (Nigeria, Cryptocurrency, total anonymity. Its obvious isn't it). I must say at that time I didn't really fathom the importance and the ocean of opportunity the technology provides.


Bitcoin was first envisioned by one Satoshi Nakamoto on a cryptography mailing by publishing a paper titled "Bitcoin: A Peer-to-Peer Electronic Cash System". You can read more about Satoshi Nakamoto and his/her/their identity from the Wikipedia article. Satoshi claimed to have solved the double-spending problem in the published paper. Satoshi also developed the first reference implementation of bitcoin core.

To cut the long story short, bitcoin is basically a digital currency, which can be traded on the internet (like any other currency or commodity). However, no third parties (banks) are involved in these transactions. So for example, if a person A residing in the USA wants to send some money to a person B in Iran, they can do so over the bitcoin network without having to pay heavy transaction fees to banks and at the same time not having to give numerous explanations to their respective Governments.

The key differentiation in transactions involving bitcoin over the transactions involving other currencies is that. in bitcoin transactions, the sender and receiver can be completely anonymous, while the transaction is public! All transactions on bitcoin since its inception are available in public domain (unlike transactions of other currency exchanges). In the above example, both the persons A and B can be completely anonymous. 

The bitcoin network is a peer-to-peer payment network that operates on a cryptographic protocol. Users can send and receive bitcoins(the units of currency on the network), by broadcasting digitally signed messages to the network using bitcoin wallet software.  Computers on the network that host this wallet software are also called as Nodes. Transactions are recorded into a distributed, replicated public database known as the blockchain, with consensus achieved by a proof-of-work system called "mining". 

Bitcoin has been running successfully for the past 6-7 years. The system is the most attacked application on the internet today and still manages to run securely without any outage over the past 7 years. In fact there is an 8 billion dollar bounty on Bitcoin, but no one has managed to bring the system down yet!

Components of Bitcoin:

Blockchain: A public ledger containing the list of all bitcoin transactions since the inception of bitcoin. The blockchain is basically a distributed database, with each node containing a copy of the ledger of all bitcoin transactions. This allows for independent verification of a transaction without the need for a central authority. 

Basically, each node running the bitcoin software records new transactions on its copy of the ledger and then propagates this information to all of its connected node (peer to peer). Every 10 minutes (approximately), the newly added transactions are committed as a block to the existing ledger. Each block that is committed, will always hold a reference to the previous block, which the previous one and so on. Hence the term Blockchain. Once a block has been committed, these are again propagated/published to all connected nodes. The commit is performed by a service called Mining. 

The original bitcoin implementation internally used Berkeley DB for holding these transactions, the latest versions have started to use LevelDB from Google. 

Mining: This is a record-keeping service that ensures the ledger is accurate and up to date. This service will continuously verify the block to see if each block contains a reference to the previous block. and new transactions forming a block are again committed by containing a reference to a hash of the previous block. These hashes are generated using the SHA-256 algorithm. 

In order for a new block to be accepted to the blockchain, the block must contain a new component called "proof-of-work" which is basically a CPU/Memory intensive operation of generating a nonce (a cryptographic sequence of numbers following a defined pattern and difficulty). This proof is easy for any node in the network to verify, but extremely time-consuming to generate. 

Every 2016 blocks the level of difficulty is adjusted depending on the recent performance of the Bitcoin network. Since the mining is time-consuming, CPU and memory intensive operation, each miner is compensated for the mining task (once their version of the block is accepted) with few Bitcoins (approximately 12.5 bitcoins for each successful mining).

Wallets: Like in the real world, a wallet is a place to hold and store money. In the bitcoin world, this a digital storage space to hold/store bitcoins. Bitcoin uses public key cryptography, wherein when a user registers for a wallet, he/she generates a key-pair (a private key and a public key). The wallet will hold these keys.

There are two types of wallets: Full clients, Light clients. Full clients can verify the validity of the transactions against the local copy of the blockchain. Light clients are more useful in low bandwidth networks, they consult with full clients for transaction verification.

Transaction: Transaction is basically a record that documents the movement of money(bitcoin)_from one user to another. The unit of any transaction in bitcoin blockchain is Bitcoin!

On the bitcoin network, everything is decentralized. 
  • Each system called a node can run a wallet (full/light), these will interact with other nodes on the internet using p2p protocol. 
  • There are few specialized nodes called Miners, which are responsible for ensuring proof of the work of the committed block.
  • There is a possibility of many miners coming up with a new proof-of-work at almost the same time (such a scenario is called fork). such a scenario is handled using the consensus algorithm.
  • Each node retains a copy of the entire block-chain thereby being fault-tolerant and secure. Theoretically, an attacker can gain control of the network or alter the contents of the blockchain database only if he/she has access to more than 51% of the network.
Those interested to know more about the technical details of Bitcoin implementation can watch this video by Andreas M Antopolous.

Although bitcoin is an excellent concept, the messages exchanged are too simplistic. Many developers and open source enthusiasts were really excited about the concept of blockchain and wanted to take this forward for probable applications within the Financial Industry. One developer Vitalik Buterin released a paper in November 2013 on Ethereum, which proposed a novel method for developing distributed applications. Buterin was of the opinion that Bitcoin infrastructure was pretty good but the platform required a robust scripting language. Many like-minded developers joined him under a new not-for-profit organization called Ethereum Foundation and built the initial version Ethereum called "Frontier".

Buterin's idea was to make each node of the Bitcoin network more efficient by making it execute robust scripts. In Ethereum each node is called an Ethereum Virtual Machine, which can execute scripts known as Smart contracts. These smart contracts are programs written in a new scripting language called Solidity.

Will document further technical details on the differences between Ethereum and Bitcoin network in the next blog and then move on to example Smart contracts and how blockchain can be helpful in IoT.


Popular posts from this blog

Setting up Private Ethereum TestNet

Ethereum and Blockchain - 2

An use-case for block chain implementation