Definition of Blockchain.

A blockchain is an open, distributed ledger that can record transactions between two parties efficiently and in a verifiable and permanent way without the need for a central authority.

Key Characteristics to be remembered:

  • Open: Anyone can access blockchain.
  • Distributed or Decentralised: Not under the control of any single authority.
  • Efficient: Fast and Scalable.
  • Verifiable: Everyone can check the validity of information because each node maintains a copy of the transactions.
  • Permanent: Once a transaction is done, it is persistent and can’t be altered.

Contents of a Block.

Blockchain starts with a block called genesis block. Each block stores the following information in it:

  • Index: Position of the block in blockchain. Index of genesis block is 0.
  • Time stamp: The time when that particular block was created.
  • Hash: Numeric value that uniquely identifies data just like our fingerprints.
  • Previous hash: Hash value of the previous block. For genesis block, this value is 0.
  • Data: Data stored on the node. For example, transactions.
  • Nonce: It is a number used to find a valid hash. To generate this number, the processing power is used.
Courtesy: FreeCodeCamp

Mechanism of Blockchain.

Courtesy: RubyGarage
  • Blockchain works like a public ledger.
  • Any small change in the data value can affect the hash value. Hence, affecting the whole block chain.
  • Every peer in a Blockchain network maintains a local copy of the Blockchain.
  • All the replicas need to be updated with the last mined block.
  • All the replicas need to be consistent — the copies of the Blockchain at
    different peers need to be exactly similar.

Cryptographic Hash Function.

Map any sized data(x) to a fixed size(H(x)).

e.g. H(x) = x % n, 
where x, n = integers
% = modular (remainder after division by n) operations.
x can be of any arbitrary length, but H(x) is within the range [0,n-1].

Important Points about Hash Functions:

  • You can calculate H(x) from x but the reverse is not possible.
  • For even a small change in the value of x, value of H(x) changes. This is called Avalanche Effect.

Merkle Tree/Hash Tree.

  • Every leaf node is labelled with the hash of a data block.
  • Every non-leaf node is labelled with the cryptographic hash of the labels of its child nodes.
  • You can traverse this tree just like you traverse a binary tree.
Courtesy: Hackernoon

Uses of Merkle Tree:

  • Peer to Peer Networks.
  • Bitcoin implementation.

Bitcoin.

  • Bitcoin is a completely decentralised, peer-to-peer, permissionless cryptocurrency put forth in 2009 by Satoshi Nakamoto.
  • Bitcoin is the first blockchain application.
  • It is permissionless , i.e. open to anyone.
  • Bitcoin blockchain size is growing exponentially.
Courtesy: Researchgate

Smart Contract.

  • The term was coined by Nick Szabo, a computer scientist and cryptographer, in 1996.
  • Smart contracts are self-executing contracts with the terms of the agreement between buyer and seller being directly written into lines of code.
  • It is an automated computerised protocol used for digitally facilitating, verifying or enforcing the negotiation or performance of a legal contract by avoiding intermediates and directly validating the contract over a decentralised platform — faster, cheaper and more secure.
  • Crowd funding is an important use of smart contracts.

Advantages of Smart Contracts:

  • Immutable: No one can change it once it is deployed on blockchain.
  • Distributed: All the steps of the contract can be validated by every participating party — no one can claim later that the contract was not validated.
  • Saves money: Since there is no need of third-party to run or maintain the contract, the cost is saved.

Popular Smart Contract Platforms:

  • Ethereum
  • Hyperledger
  • Ripple
  • Rootstock

Structure of a Block(Reference: Bitcoin).

A block has two main components:

  1. Block Header
  2. List of Transactions

1. Block Header:

Contains metadata about a block which includes the following:

  1. Version: Block version number
  2. Previous Block hash: This is used to compute new block hash. Hence, making the blockchain temper proof.
  3. Merkle Tree Root: The root of the Merkle tree is a verification of all the transactions.
  4. Timestamp: The time at which block is mined.
  5. Bits/Difficulty: Difficulty in Bitcoin is expressed by the hash of a Bitcoin block header being required to be numerically lower than a certain target.
  6. Nonce:A 32-bit random number used in blockchain, while calculating the cryptographic hash for a Block.

The last three are collectively called mining statistics.

Courtesy: https://www.blockchain.com/explorer

A block is identified by its hash which is computed using Double SHA256 algorithm.

2. List of Transactions

  • Transactions are organised as a Merkle Tree. The Merkle Root is used to construct the block hash.
  • If you change a transaction, you need to change all the subsequent block hash.
  • The difficulty of the mining algorithm determines the toughness of
    tampering with a block in a blockchain.
Courtesy: https://www.blockchain.com/explorer

Mining:

  • It is a mechanism to generate hash of the block.
  • Mining involves creating a hash of a block of transactions that cannot be easily forged, protecting the integrity of the entire blockchain without the need for a central system.

Bitcoin Mining:

H(k) = Hash(H(k-1) || T || Nonce)
Here,
H(k-1) = Previous block hash
T = List of transactions
Nonce = Miners find this nonce as per the complexity(number of zeros at the prefix)

Distributed Consensus.

Consensus is the process by which peers agree to the addition of next block in the blockchain.

Distributed Consensus ensures that different nodes in the network see the same data at nearly the same point of time. Hence in case of any failure, the system can still provide a service as the data is decentralised.

To maintain anonymity in this large network, the permission less protocol is used where you don’t need to record your identity while participating in the consensus.

Challenge Response System

The network poses a challenge and each node tries to solve the challenge. The node which solves the challenge first, gets to dictate what set of data or state elements to be added in the network.

This process continues iteratively and ensures that different nodes win the challenge at different runs. Hence, no single node will be able to control the network.

Bitcoin Proof-of-work (PoW) algorithm ensures consensus over a permission less setting based on challenge response.

Every node spends a large amount of computational power to solve the mathematical challenge in each iteration of consensus.

The computational effort expended by the nodes in achieving consensus would be paid for by cryptocurrency generated and managed by the network.

Blockchain as tree.

Suppose two miners found the nonce at the same time, then they will add the mined blocks (2,3) to the previous block (1).

Then, the next miners mined another three blocks (4,5,6) and added them to the previous blocks they found (2,3). This process of mining continues and the blockchain looks like a tree as following:

The longest chain is the accepted chain which is in green colour in the above figure. Other blocks (red colour) which are not the part of blockchain are called orphaned blocks.

Cryptocurrency Applications using Blockchain.

Permissioned Model (Private Blockchain).

  • Users/Participants are known already. Security and Privacy are the main factors in this blockchain.
  • Only the entities participating in a particular transaction will have knowledge and access to it — other entities will have no access to it.
  • The Linux Foundation’s Hyperledger Fabric is an example of a permissioned blockchain framework implementation.

Applications .

  • Asset Movement and Tracking
  • Provenance Tracking: Tracking the origin and movement of high-value items across a supply chain.

How does the tracking works?

  • For every high-value item a digital token is issued by a trusted entity.
  • Every time the asset is forwarded to another party, the digital token is moved in parallel and the transactions are stored on the blockchain.
  • The token works as the certificate of authenticity which makes it harder to deny, steal or forge about the asset.

InterPlanetary File System (IPFS).

IPFS a peer-to-peer (p2p) file sharing system that aims to fundamentally change the way information is distributed across & beyond the globe.

InterPlanetary File System (IPFS) is a protocol and network designed to create a content-addressable, peer-to-peer method of storing and sharing hypermedia in a distributed file system.

Website: https://ipfs.io

How IPFS work?

  • Each file and all of the blocks within it are given a unique fingerprint called a cryptographic hash.
  • IPFS removes duplications across the network and tracks version history for every file.
  • Each network node stores only content it is interested in, and some indexing information that helps figure out who is storing what.
  • When looking up files, you’re asking the network to find nodes storing the content behind a unique hash.
  • Every file can be found by human-readable names using a decentralised naming system called IPNS.

Hyperledger Fabric.

  • A permissioned blockchain framework that provides an enterprise-grade foundation for transactional applications.
  • A shared ledger and smart contracts implemented as “chaincode”.
  • It supports privacy and confidential transactions.
  • It supports channels or subnet of peers which restricts visibility of information.

Website: http://hyperledger-fabric.readthedocs.io/en/release-1.2/

Courtesy: IBM

Conclusion

I will be sharing the notes on the next video which explains cryptographic hash functions in detail in the next article. Till then study the notes, explore the blockchain technology on Google and discuss with your friends.

Keep in mind that this course will cover each of the above studied topic in detail. If you have not registered for this course yet, you can register on this link. Here is a list of FAQs which might help you in understanding more.

Don’t forget to start assignment of the week-1 here. In case you wish to discuss anything from this course with me, feel free to comment below.

This is a series of notes based on the Blockchain Course by NPTEL, which serves as a primer for understanding the blockchain fundamentals. The first post in our series addresses the fundamental question of blockchain.

About MoatFund.

We are continuously assisting people get educated about how rapidly this technology is advancing and revolutionising our world. Our mission is to create a decentralised fund managing protocol operated on smart contracts, which is publicly accessible and can control the entire network of fund managing capabilities on blockchain. Here’s Everything You Need to Know About MoatFund, All In One Place.

--

--

Divya Jain
MoatFund

Jainism Influencer. Writer. Nature cure student. Blogger @ jaindivya.com