Introduction to Blockchain using Hyperledger

Introduction to Blockchain using Hyperledger

23/03/19   15 minutes read     412 Naren Allam

blockchain

In this article, we are going to see the introduction of blockchain using hyperledger. Blockchain is a powerful technology with applications in fields such as cryptocurrency, healthcare, insurance, government, music, identification, supply chain, data management, and many more. By understanding the fundamental mechanisms that power blockchain, we can join the conversation and discover use cases for blockchain in our own life and work. This requires no prior knowledge. But, if we have some Python experience, you’ll be able to build a small blockchain library in Python, including a Blockchain class and a Block class. Add functionality to add blocks, create hashes, and verify the chain.

BLOCKCHAIN:

  Blockchain is an immutable transaction ledger, distributed across the nodes in the network. Data is stored in blocks maintain in the form of chain and consists cryptographic hash of previous block in the current block in order to maintain the link between the blocks and make the data tamper proof and secure. Hash of the block is generated based on the data it consists, hence if any change in data makes hash alter and link between the blocks get broken.

Hyperledger Project

  As stated on the Hyperledger’s website,“Hyperledger is an open source collaborative effort created to advance cross-industry blockchain technologies. It is a global collaboration, hosted by The Linux Foundation, including leaders in finance, banking, Internet of Things, supply chains, manufacturing, and Technology.”

Hyperledger frameworks:

  1. Hyperledger Burrow (Permissionable smart contract machine EVM)
  2. Hyperledger Fabric (Permissioned with channel support and smart contract)
  3. Hyperledger GRID (WebAssembly-based project for building supply chain solutions)
  4. Hyperledger Indy (Decentralized identity)
  5. Hyperledger IROHA (Mobile application focus)
  6. Hyperledger SAWTOOTH (Permissioned & permissionless support; EVM transaction family)

Hyperledger Tools:

  Tools used for benchmarking and to know performance of the blockchain, some developed on top of the Hyperledger frameworks to build the applications rapidly with ease.

  1. Hyperledger ARIES (Infrastructure for peer-to-peer interactions)
  2. Hyperledger CALIPER (Blockchain framework benchmark platform)
  3. Hyperledger CELLO (As-a-service deployment)
  4. Hyperledger COMPOSER (Model and build blockchain networks, uses Hyperledger Fabric as platform)
  5. Hyperledger EXPLORER (View and explore data on the blockchain)
  6. Hyperledger QUILT (Ledger interoperability)
  7. Hyperledger URSA (Shared Cryptographic Library)

Hyperledger Fabric:

  Hyperledger Fabric is an open source enterprise-grade permissioned distributed ledger technology (DLT) platform, designed for use in enterprise contexts, that delivers some key differentiating capabilities over other popular distributed ledger or blockchain platforms.

  Fabric is a permissioned blockchain, which means in the network parties can join the network through MSP (Membership Service Provider) which makes only required parties participate in the transactions and can known to each other unlike permissionless network where parties/participants are anonymous. The authorized and authenticated participants can only invoke the transactions and can view the ledger data.

  Consensus protocol in the Fabric makes all the participants agree on the single agreement and provides the transaction validation and ledger sync across all the nodes.

  Hyperledger Fabric has been specifically architected to have a modular architecture. Whether it is pluggable consensus, pluggable identity management protocols such as LDAP or OpenID Connect, key management protocols or cryptographic libraries, the platform has been designed at its core to be configured to meet the diversity of enterprise use case requirements.

Hyperledger Fabric Model:

Following are the key features of Hyperledger Fabric

Assets:
  Assets represents anything that can be exchaged between the trusted parties, e.g., cars, bonds, currency etc. These assets can be modified using the smart contracts by invoking the transaction. Assets represent in form of key-value pairs on the ledger.
Eg., model {"model" : "benz",
		    "owner" : ...
	           }
Chaincode:
  Chaincode an interface to modify the assets by invoking the transactions, it's the business logic. Chaincode functions execute against the ledger’s current state database and are submitted to the network and applied to the ledger on all peers. Defines the assets structure, Transaction or business logic.

Ledger Features:
  The ledger is the sequenced, tamper-resistant record of all state transitions in the fabric. State transitions are a result of chaincode invocations (‘transactions’) submitted by participating parties. Each transaction results in a set of asset key-value pairs that are committed to the ledger as creates, updates, or deletes.

Security & Membership Services:
  Hyperledger Fabric underpins a transactional network where all participants have known identities. Public Key Infrastructure is used to generate cryptographic certificates which are tied to organizations, network components, and end users or client applications. As a result, data access control can be manipulated and governed on the broader network and on channel levels. This “permissioned” notion of Hyperledger Fabric, coupled with the existence and capabilities of channels, helps address scenarios where privacy and confidentiality are paramount concerns.

Consensus:
  Consensus protocol encompasses agreeing upon the order of transactions which the transaction flow is proposal, endorsement, ordering, validation and commitment. Verification of the transactions and the ledger is updated and maintained sync across the peers in the network.

Hyperledger Blockchain Network:


Channel:
  A Hyperledger Fabric channel is a private “subnet” of communication between two or more specific network members, for the purpose of conducting private and confidential transactions. A channel is defined by members (organizations), anchor peers per member, the shared ledger, chaincode application(s) and the ordering service node(s). Each transaction on the network is executed on a channel, where each party must be authenticated and authorized to transact on that channel. Each peer that joins a channel, has its own identity given by a membership services provider (MSP), which authenticates each peer to its channel peers and services.

Membership Service Provider:
  The Membership Service Provider (MSP) refers to an abstract component of the system that provides credentials to clients, and peers for them to participate in a Hyperledger Fabric network. Clients use these credentials to authenticate their transactions, and peers use these credentials to authenticate transaction processing results (endorsements). While strongly connected to the transaction processing components of the systems, this interface aims to have membership services components defined, in such a way that alternate implementations of this can be smoothly plugged in without modifying the core of transaction processing components of the system.

Ordering Service:
  A defined collective of nodes that orders transactions into a block. The ordering service exists independent of the peer processes and orders transactions on a first-come-first-serve basis for all channel’s on the network. The ordering service is designed to support pluggable implementations beyond the out-of-the-box SOLO and Kafka varieties. The ordering service is a common binding for the overall network; it contains the cryptographic identity material tied to each Member.

Peer:
  A network entity that maintains a ledger and runs chaincode containers in order to perform read/write operations to the ledger. Peers are owned and maintained by members.

Types of Peers:

  1. Endorsing peers:
    Endorsing peers are those peers which simulates transactions in an isolated chaincode containers and prepares transaction proposal based on smart contract results . All endorsing peers must have chaincode installed .
  2. Comitting peers:
    These are the peers which dont necessarily have chaincode installed but maintain full ledger of records in their ledger . Main difference between committing and endorsing peers is that committing peers cant invoke chaincode or run smart contract functions and that include both read and write function .
  3. Ordering peers:
    Ordering peers are special type of nodes whose key roles are to receive endorsed transactions from sdk , package them into blocks as per your configuration file and send it to all other peers so that they can validate those transaction and update their ledgers . Ordering nodes keep track of all transactions in their ledger including valid transactions and invalid transactions while endorsing peers and committing peers only contain valid transactions.

Transaction Flow Diagram:

1. The client creates a transaction and sends it to endorsing peers and the endorsing peer simulates a transaction and produces an endorsement signature

1.1 Invokes Membership Service Provider (MSP) to validate if the trusted and authenticated user invokes the transaction.

2. The submitting client collects an endorsement for a transaction and broadcasts it through ordering service. The exact number of “enough” depend on the chaincode endorsement policy. If the endorsement policy is satisfied, the transaction has been endorsed; note that it is not yet committed. The collection of signed TRANSACTION-ENDORSED messages from endorsing peers which establish that a transaction is endorsed is called an endorsement and denoted by endorsement

3. The ordering service delivers transactions to the peers

Use Case: Management of Assets


Description: Management of assets means assigning respective assets to particular party through required process and approvals.

Problem Statement: In area of Land and Agriculture if an organization requires to buy or take lease on land of mining or agriculture require to go through the process and approvals which are not in a stream lined process where there is a chance of hack/modify the asset data by the officials and skip the process which is a huge loss for the government.

Solution: In order to solve this if the whole information is on blockchain which makes tamper proof data and based on required roles and policies only authorized persons can invoke transactions and more over every change is logged with who made it.

1. Mining Company invokes transaction submitting the details related to the mining land.

2. Ministry of mining verifies and approves the request submitted by the mining company, which makes the state of asset changes to mining approved based on required agreements.

3. Ministry of Land & Agriculture approve the request only if it is approved by Ministry of Mining. Finally the asset is issued to the mining company.

4. Ministry of Finance to invoke the query on the ledger to get the whole transactions to provide the statistics.

Use Case: IOT with Blockchain


Description: Accessing the IOT devices through Blockchain provides better security.

Problem Statement: Currently IOT devices are connected to the centralized web server or cloud environment and trasfers data from the devices to the required target applications inorder to provide the analysis or these devices are also controlled remotly through these web servers. There is high chance of security threat of hacking the IOT devices and get control if servers are accessed by non authenticated users.

Solution: IOT devices or contoller will connect to the Hyperledger Fabric node and this node is connected and communicated through the external Hyperledger Fabric node through the channel which can be accessible from the mobile or web application to control the devices by invoking the transactions. IOT devices are only interact with Hyperledger Blockchain Components (Chaincode) which makes it more secure because each transaction is authenticated, validated and committed.