Codementor Events

Why and What is Block-chain ?

Published Dec 05, 2018Last updated Dec 07, 2018
Why and What is Block-chain ?

BlockChain is the one of the most in trend technologies these days with large area of use. In this post I am going to share my knowledge on Blockchain and what I have learnt in past two months.

Why do we need BlockChain ?

-> In current system, if you want to send money to some of your friend what will you do. You will make transaction request with a bank.
-> Then Bank will process your request and transfer the mentioned amount in your friend’s account.
-> What happened here, you and your friend both trusted the bank to manage your money.
-> There was no real movement of physical bills to transfer the money. All that was needed was an entry in the register that neither you or your friend control.
-> Above is an example of Centralized Trusted System.

Problem with Centralized System !!

-> To establish trust between ourselves, we depend on individual third-parties.
-> For years, we’ve depended on these middlemen to trust each other.
-> You might ask, “what is the problem depending on them?” The problem is that they are singular in number. All it takes is one person/organization to go corrupt, intentionally or unintentionally, and the entire system collapse.
-> In other words, there is a central point of failure.
-> It also consists of problems like double spending , transaction fees and transaction completion time.

What is Block chain and how it solve the current system problems ?

History of Blockchain

-> The first work on a cryptographically secured chain of blocks was described in 1991 by Stuart Haber and W. Scott Stornetta.
-> They wanted to implement a system where document’s timestamps could not be tampered with or backdated. In 1992, Bayer, Haber and Stornetta incorporated Merkle trees to the design, which improved its efficiency by allowing several documents to be collected into one block.
-> It went by mostly unused until it was adapted by Satoshi Nakamoto in 2008. It was implemented the following year by Nakamoto as a core component of the crypto currency bitcoin, where it serves as the public ledger for all transactions on the network.

Block chain Overview & Terminology

->A block chain, is a growing list of records, called blocks, which are linked using cryptography.
->Each block contains a cryptographic hash of the previous block,  a timestamp, and transaction data.
->By design, a block chain is resistant to modification of the data. It is "an open, distributed ledger that can record transactions between two parties efficiently and in a verifiable and permanent way".
->For use as a distributed ledger, a block chain is typically managed by a peer-to-peer network collectively adhering to a protocol for inter-node communication and validating new blocks.
->Once recorded, the data in any given block cannot be altered retroactively without alteration of all subsequent blocks, which requires consensus of the network majority.
->Miners are the special nodes over the network that hold the ledger and ability to contribute in block chain by adding new block.
->To add a block to the block chain miner has to do two things : - Verify the transactions in the block, and - Miner has to find a special key which when combined with hash of previous block, transactions of current block and taken hash satisfy a particular predefined problem.
->In order to find that key, miner need to invest computational power and time, this search for the key is random.
->It will find for the random key until it satisfies the predefined problem.
->First miner to do so, gets the financial rewards.
->Hash is like a fingerprint, it identifies a block and all of its contents and it’s always unique, just as a fingerprint.
->Changing anything inside the block will change the hash of the block and it leads to following block as invalid.
->First block in block chain does not have previous block’s hash and its called Genesis block.

Blockchain as Concept

-> Block chain system based on cryptographic proof instead of trust, allowing any two willing parties to transact directly with each other without the need of any trusted third-party.
-> Transactions that are computationally impractical to reverse would protect sellers from fraud.
->Solution of double spending problem using peer-to-peer distributed timestamp server to generate computational proof of the chronological order of transactions.
->Longest chain not only serve as a proof of the sequence of event witnessed, but proof that it came from the largest pool of CPU power.

Timestamp Server

-> Concept of Block chain is based on Timestamp Server. A timestamp server works by taking a hash of new block of items to be time stamped and widely publishing hash.
-> The timestamp proves that the data must have existed at the time, obviously in order to get into the hash.
->Each timestamp includes the previous timestamp in its hash, forming a chain, with each additional timestamp reinforcing the ones before it.

Timestamp Server.png

Proof-of-Work

->The proof-of-work involved scanning for a value that when hashed, such as with SHA-256, the hash begin with number of zero bits.
->The average work required is exponential in the number of zero bits required and can be verified by executing a single hash.
->Proof-of-work is implemented by incrementing a nonce in the block until a value is found that given the block’s hash the required zero bits.

Proof of Work.png

-> Once proof-of-work is done, that block cannot be changed without redoing the work. As later blocks are chained after it, the work to change the block would include redoing all the blocks after it.
->Proof of work is essentially one CPU one vote. The majority decision is represented by the longest chain, which has the greatest proof-of-work effort invested in it.
->If a majority of CPU power is controlled by honest nodes, the honest chain will grow the fastest and outpace any competing chains.
->To modify a past block, an attacker would have to redo the proof of work of the block and all the blocks after it and then catch-up with and surpass the work of honest nodes.
->To compensate for increasing hardware speed and varying interest in running nodes over time, the proof-of-work difficulty is determined by moving average targeting an average number of blocks per hour. If they are generated too fast, the difficulty increases.
->A Proof-of-Work algorithm is essentially an algorithm that generates an item that is difficult to create but easy to verify. Given an output, it is extremely difficult to calculate the input, but given the input and the output, it is pretty easy to verify if the input leads to the output.

Block chain network

->The steps to run network are as follows:
- New transactions are broadcast to all nodes.
- Each node collects new transactions into a block.
- Each node works on finding a difficult proof-of-work for its block.
- When a node find a proof-of-work, it broadcasts the block to all nodes.
- Nodes accept the block only if all transaction in it are valid and not already spent.
- Nodes express their acceptance of the block by working on creating the next block in the chain, using the hash of the accepted block as the previous hash.
->Nodes always consider the longest chain to be the correct one and will keep working on extending it.

Transactions

->Owner will do the transaction by digitally signing a hash of the previous transaction and the public key of next owner.
->A payee can verify the signatures to verify the chain of ownership.
The problem of course is the payee can’t verify that one of the owners did not double-spend.
->We need a way for the payee to know that the previous owner did not sign any earlier transaction.
->For our purposes, the earliest transaction is the one that counts, so we don’t care about later attempts to double spend.

Trans.png

-> The only way to confirm the absence of transaction is to be aware of all transactions.
-> In Centralized trusted party system, it was aware of all transactions and decided which arrived first.
-> To accomplished this without trusted party, transaction must be publicly announced, and we need a system for participants to agree on a single history of the order in which they were received.
-> The payee needs proof that at the time of each transaction, the majority of the nodes agreed it was the first received.

Transactions in Block chain

->A single block in Block chain consists of multiple transactions.
Transactions in block are hashed in Merkle tree, with only the root included in the block’s hash.
->Old blocks can be compacted by stubbing off branches of the tree. The interior hashes do not need to be stored.

TransBlock.png

Transaction Verification

User need to verify first that he is having longest proof-of-work chain and obtain the Merkle branch linking the transaction to the block it’s time stamped in.
He can’t check the transaction for himself, but by linking it to a place in the chain, he can see that a network node has accepted it and blocks added after it further confirm the network has accepted it.

TransVerify.png

Privacy

->The traditional banking model achieves a level of privacy by limiting access to information to the parties involved and the trusted third party.
->The necessity to announce all transactions publicly precludes this method, but privacy can still be maintained by breaking the flow of information in another place: by keeping public key anonymous
->The public can see that someone is sending an amount to someone else, but without information linking the transaction to anyone.
->A new key pair should be used for each transaction to keep them from being linked to a common owner.

I hope this post will clear your basic understanding of BlockChain. Do leave comment if you have any queries, Thank You.

Discover and read more posts from Maninder Singh
get started
post commentsBe the first to share your opinion
meenakshi sachdeva
5 years ago

Interesting post.

Show more replies