Tuesday, February 9, 2016

Blockchain - How it works

While the detailed functionality of how Blockchain works depends on the individual framework / tool you choose for implementing block chain.

Blockchain mainly consists of 2 components – the P2P network and the distributed database.

·         P2P network: A mechanism used by different computers in the network to communicate the change in the database. This change to the state may be called as transaction.
 o    This network consists of different nodes which are connected to each other and is decentralized from the other node.
o    If any node fails or shuts down, no problem, we still have the data and the processing happens on the other available node.
o    Since the data is available is available on any node, we cannot clearly tell from where the data is coming from, which is good since you cannot censor based on where the data is or who sent it.

·         Database: This is the distributed database which is present in different nodes in the network and it stores the entire history of the data.

o    As and when the users create transactions, the transactions are are added to the pool of pending transactions. The transactions are collected as blocks, and when it creates the block, the block stores the transactions in the same order in which it retrieves. A signature is placed on the block which is modified every time someone changes the transaction or tamper the transaction in the block. In this case, the block notifies all the other nodes that the tampering has happened.
o    The block also maintains a pointer to the previous block to maintain the history of changes happened in the Blockchain.

When a new message (transaction) is sent to the block chain, the following happens.

§  The message is sent to the nodes in the Blockchain. The message may be sent to any node(s). Each nodes sends the message to the neighbouring nodes.
§  Quickly the message gets distributed to different nodes in the network.
§  The Actual database which is distributed across different nodes.
§  The nodes in the Blockchain process the transaction and communicates that it is successful or failed.

How the nodes are processed, how many nodes process the transactions, how the bidding works depends on the Blockchain platform you choose.
Since Bitcoin is an implementation of Blockchain, we can see how bitcoin works at a high level.
-          A wants to send 5$ to B.
-          Every user has his own private key to prove his identity and create a signature. A get’s B’s public key and creates a transaction and send it to the Blockchain using the wallet application. A wallet is an app (may be mobile app) which knows the user as it has the private key and knows how to send the transaction to the Blockchain.
-          Bitcoin requires the signature of the user to prove the user of the account. The signature is created based on the private key of the user and the transactional message.
-          These signatures cannot be copied and reused since the signatures are unique to each transaction.
-          As and when the transactions occur, the transactions are sent to the pool of pending transactions (blocks) which also maintains the order in which it receives the transaction. The transactions execute in the same order in which it is received.
-          The bit coin miners (or participants) choose a transaction from the pending pool and try to solve a mathematical problem which they use to bid for processing the transaction.
-          The miner then verifies if A has enough bitcoin to make a transaction to B.
-          When the bitcoin miner is then choosen and validates the transaction, a small % of bitcoin is rewarded for the processing. Finally B’s account is updated with A’s transaction amount.
-          If someone tries to tamper the B’s public key to a different public key, then the block signature is modified and other nodes are notified of the tampered activity. Thus the system works even if one node fails or not trustable or slow.

Blockchain technologies


The Blockchain implementation can be public or private depending upon the use case:
There are many Blockchain technologies that can be categorized under Blockchain 2.0 protocol projects such as NXT, Master coin, ethereum, Bitshares, Blocksign, Codius.
While most of the projects in the Blockchain technologies seem to be solving a problem for a particular use case or adding as a new feature, Ethereum takes a different approach.
Ethereum is a platform and a programming language that helps users to build decentralized applications. It is a general purpose crypto currency platform that can run all blockchains and protocols Each node in the network runs a full EVM (Ethereum virtual machine) for smart contract execution.

A smart contract is a program written by Blockchain developers and pushed to the Ethereum which gets deployed in multiple nodes for execution. This internally uses peer to peer protocol and libraries to exchange information between different nodes. Multiple nodes bid for running the process and executed the contract. The information is shared between other nodes. If a node is tampered, the other nodes in the network is aware of this change. 

1 comment:

  1. Invest in Ethereum on eToro the World’s Best Social Trading Network!

    Join 1,000,000's who have already discovered smarter strategies for investing in Ethereum.

    Learn from experienced eToro traders or copy their trades automatically!

    ReplyDelete