0% found this document useful (0 votes)
41 views13 pages

Unit-6 BCT

The document provides information on Hyperledger, an open source collaborative project hosted by The Linux Foundation to develop blockchain technologies. It discusses the key Hyperledger frameworks like Fabric, Sawtooth, Indy etc. and explains that Hyperledger Fabric is a modular blockchain platform designed for enterprise use, with components like peers, an ordering service, and a ledger. The document then provides details on how Hyperledger Fabric works, with steps like transaction proposal, endorsement, ordering and updating the ledger.

Uploaded by

Prudhvi Kurakula
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views13 pages

Unit-6 BCT

The document provides information on Hyperledger, an open source collaborative project hosted by The Linux Foundation to develop blockchain technologies. It discusses the key Hyperledger frameworks like Fabric, Sawtooth, Indy etc. and explains that Hyperledger Fabric is a modular blockchain platform designed for enterprise use, with components like peers, an ordering service, and a ledger. The document then provides details on how Hyperledger Fabric works, with steps like transaction proposal, endorsement, ordering and updating the ledger.

Uploaded by

Prudhvi Kurakula
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

UNIT-6

Understanding Hyperledger Fabric: Overview of Open source Hyperledger project,


Hyperledger Fabric- Architecture, Identities and Policies, Membership and Access Control,
Channels, Transaction Validation, Writing smart contract using Hyperledger Fabric.

Hyperledger:

Hyperledger is not a blockchain, but a project that was initiated by the Linux Foundation in
December 2015 to advance blockchain technology. This project is a collaborative effort by its
members to build an open source distributed ledger framework that can be used to develop
and implement cross-industry blockchain applications and systems. The principal focus is to
create and run platforms that support global business transactions. The project also focuses on
improving the reliability and performance of blockchain systems.

Projects under Hyperledger:


There are four categories of projects under Hyperledger. Under each category, there are
multiple projects. The categories are:
 Distributed ledgers
 Libraries
 Tools
 Domain-specific

Currently, there are six distributed ledger projects under the Hyperledger umbrella:Fabric,
Sawtooth, Iroha, Indy, Besu, and Burrow.
Under libraries, there are the Aries, Transact, Quilt, and Ursa projects.
The tools category of Hyperledger includes projects such as Avalon, Cello, Caliper, and
Explorer.
There are also domain-specific projects such as Hyperledger Grid and Hyperledger Labs.
Hyperledger reference architecture:

Hyperledger has published a white paper that presents a reference architecture model that can
serve as a guideline to build permissioned distributed ledgers. The reference architecture
consists of various components that form a business blockchain.
These high-level components are shown in the reference architecture diagram here, which has
been drawn fromthe aforementioned white paper:
Figure :Reference architecture

In the preceding diagram, starting from the left, we see that we have five top-level
components that provide various services. The first is identity, which provides authorization,
identification, and authentication services under membership services. Then, we have the
policy component, which provides policy services.

Hyperledger project:
The Hyperledger project is an open-source collaborative effort created to advance cross-
industry blockchain technologies. It's hosted by The Linux Foundation and counts numerous
organizations, including major players in finance, banking, Internet of Things (IoT), supply
chain, manufacturing, and technology, among its members.

Here are some key aspects of the Hyperledger project:


Diverse Frameworks: Hyperledger hosts a range of blockchain frameworks, each designed
for specific use cases and requirements. Some of the notable ones include:
Hyperledger Fabric: A modular, permissioned blockchain platform designed for enterprise
use. It allows for the creation of private, permissioned networks with high performance and
scalability.
Hyperledger Besu: An Ethereum client developed under the Hyperledger umbrella. It offers
compatibility with the Ethereum mainnet and the Ethereum testnets.
Hyperledger Sawtooth: A modular blockchain platform that separates the consensus process
from the application layer. It's designed to support a wide range of applications.
Hyperledger Indy: A decentralized identity platform designed to enable self-sovereign
identity on the internet.
Hyperledger Burrow: A permissionable smart contract blockchain node that executes
Ethereum EVM smart contract code.
Hyperledger Iroha: A business blockchain framework designed for simple and easy
incorporation into infrastructural projects requiring distributed ledger technology.
Permissioned Networks: Many Hyperledger frameworks are designed for use in
permissioned blockchain networks. This means that participants in the network must be
identified and granted permission to participate.
Focus on Enterprise Use Cases: Hyperledger is primarily focused on creating technologies
suitable for business and enterprise applications. This often involves ensuring privacy,
scalability, and interoperability.
Modular Architecture: Many Hyperledger frameworks are designed with modularity in
mind. This allows components to be replaced or upgraded without affecting the entire system.
Strong Industry Support: The project has backing from a wide range of industries including
finance, supply chain, healthcare, and more. This diverse support base reflects the potential
applicability of blockchain across various sectors.
Collaborative Development: Hyperledger is a collaborative project with contributions from
developers worldwide. It fosters an environment where individuals and organizations can
work together to develop and improve blockchain technologies.
Documentation and Education: Hyperledger provides extensive documentation, tutorials,
and resources to help developers and enterprises understand and use their blockchain
frameworks effectively.
Global Community: With contributors from around the world, Hyperledger has a vibrant
community that actively participates in discussions, development, and events related to
blockchain technology.

Hyperledger Fabric:

Hyperledger Fabric, or Fabric for short, is the contribution made initially by IBM and
Digital Assets to the Hyperledger project. This contribution aims to enable a modular, open,
and flexible approach toward building blockchain networks.
Hyperledger Fabric is an open-source platform for building distributed ledger solutions, with
a modular architecture that delivers high degrees of confidentiality, flexibility, resiliency, and
scalability. This enables solutions developed with fabric to be adapted for any industry. This
is a private and confidential blockchain framework managed by the Linux Foundation. The
article focuses on discussing Hyperledger Fabric in Blockchain.

What is Hyperledger Fabric ?


Hyperledger Fabric is designed for use in enterprise-level applications, and it is characterized
by its modular architecture, permissioned network, and smart contract functionality, known
as “chaincode”.
The platform provides a high degree of security, privacy, and scalability, and it
supports the development of custom blockchain solutions for various use cases across
industries such as finance, supply chain, and healthcare.
Hyperledger Fabric operates as a network of nodes, where each node performs a specific
function, such as validating transactions, maintaining the ledger, and executing chaincode.
Transactions are validated and ordered by a consensus mechanism, which ensures the
integrity and consistency of the ledger.

How does Hyperledger Fabric Work?


Components:
 Hyperledger fabric is an enterprise-level permission blockchain network. It is made
up of various unique organizations or members that interact with each other to serve a
specific purpose. For example, these organizations can be a bank, financial institution,
or a supply chain network. Each organization is identified and they have a fabric
certificate authority. These organizations are called members.
 Each member of the fabric can set up one or more authorized peers to participate in
the network using the fabric certificate authority. All of these peers must be
authorized properly.
 There is a client-side application connected to the network written with the software
development kit (SDK) of any particular programming language.

Workflow:
For each and every transaction in the fabric, the following steps are followed-
1. Creation of the proposal: Imagine a deal between a smartphone manufacturer
company and a smartphone dealership. The transaction begins when a member
organization proposes or invokes a transaction request with the help of the client
application or portal. Then the client application sends the proposal to peers in each
organization for endorsement.
2. Endorsement of the transaction: After the proposal reaches the endorser peers (peers
in each organization for endorsement of a proposal) the peer checks the fabric
certificate authority of the requesting member and other details that are needed to
authenticate the transaction. Then it executes the chain code (a piece of code that is
written in one of the supported languages such as Go or Java) and returns a response.
This response indicates the approval or rejection of the following transaction. The
response is carried out to the client.
3. Submission to ordering service: After receiving the endorsement output, the approved
transactions are sent to the ordering service by the client-side application. The peer
responsible for the ordering service includes the transaction into a specific block and
sends it to the peer nodes of different members of the network.
4. Updating the ledger: After receiving this block the peer nodes of such organizations
update their local ledger with this block. Hence the new transactions are now
committed.
Hyperledger Fabric Architecture:

Hyperledger Fabric's architecture is designed with modularity and flexibility in mind. It


separates the roles and responsibilities of different network components to enhance
scalability, privacy, and security. Here are the key components:
1.Peers:
 Endorsing Peers: Execute chaincode (smart contracts) and return the results to the
client. They simulate transactions and provide endorsements based on the chaincode's
logic.
 Committing Peers: Maintain the ledger and validate endorsed transactions before
committing them to the blockchain. They ensure the transactions meet the
endorsement policies.
2.Ordering Service:
 Consists of a set of nodes responsible for ordering transactions and packaging them
into blocks.It ensures a consistent order for transactions across all peers in the
network.
3.Ledger:
Consists of two components:
 World State Database: Represents the current state of the blockchain. It's a key-
value store reflecting the latest values for all keys.
 Blockchain (Transaction Log): Records all transactional activity. It stores all the
transactions in a chronological order.
4.Chaincode:
 Also known as smart contracts. These are executed by endorsing peers in response to
transaction proposals. Chaincode defines the rules and logic for how transactions
should be processed.
5.Membership Service Provider (MSP):
 Manages digital identities of participants in the network, including peers, clients, and
orderers.
 Provides authentication and authorization capabilities.
6.Channels:
Private sub-networks that enable specific participants to conduct transactions privately. Only
the participants in a channel can view and endorse the transactions within it.
7.CouchDB (Optional):
An external database that can be used as the world state database. It provides advanced
querying capabilities.
8.Fabric Certificate Authority (CA):
A component responsible for managing identities within the network. It issues, renews, and
revokes certificates for network participants.

Identities in Hyperledger Fabric:


Identities in Hyperledger Fabric are represented by X.509 certificates and private keys. Each
participant, whether it's a client, peer, or orderer, has a unique identity in the network. These
identities are managed by the Membership Service Provider (MSP) and play a crucial role in
authentication and authorization.
1.Registration:
A new participant is registered with the Certificate Authority (CA) to obtain an enrollment
certificate, which includes a public key and a corresponding private key.
2.Enrollment:
Once registered, the participant uses the enrollment certificate to obtain a signed membership
certificate from the CA. This certificate authenticates the participant's identity.
3.Membership Service Provider (MSP):
Manages the lifecycle of identities in Hyperledger Fabric. It defines the rules for how
certificates are issued, renewed, and revoked.

Policies in Hyperledger Fabric:


Policies in Hyperledger Fabric are rules that define how transactions are processed and
validated within the network. They play a crucial role in achieving consensus and ensuring
network security.
1.Endorsement Policies:
Define the requirements for endorsing a transaction. For a transaction to be considered valid,
it must receive endorsements from the specified number of endorsing peers.
2.Channel Policies:
Define who has access to a specific channel. They determine which organizations can
participate in a private and what actions they can perform.
3.Channel Access Control Policies:
Define who has access to specific resources within the network. They govern permissions for
invoking chaincode, querying the ledger, and more.
4.Validation Policies:
Determine the criteria for validating a transaction before it's committed to the ledger. This
includes ensuring that the transaction meets the endorsement policy.
Policies are crucial for maintaining trust and security within the network. They
provide a framework for establishing consensus among participants and defining the rules for
transaction validation.
By combining identities and policies, Hyperledger Fabric creates a robust and secure
environment for conducting transactions in a permissioned blockchain network.

Membership and Access Control:


Membership Service Provider (MSP):

Role: Manages digital identities of participants in the network (peers, clients, orderers).
Responsibilities:
 Issuance of Certificates: Issues X.509 certificates to participants during registration.
 Renewal and Expiry: Handles the renewal and expiration of certificates.
 Revocation: Manages the process of revoking certificates if needed.
 Verification and Authentication: Verifies the authenticity of participants based on
their certificates.
 Organizational Affiliation: Associates participants with specific organizations within
the network.
Identity Lifecycle:
 Registration: Participants request enrollment with the Certificate Authority (CA) to
obtain certificates.
 Enrollment: The CA issues enrollment certificates, which include a public-private
key pair.
 Certificate Renewal: MSP manages the renewal process to ensure participants have
up-to-date certificates.
 Certificate Revocation: In case of compromised keys or other security issues,
certificates can be revoked.
Access Control:
Access control policies in Hyperledger Fabric are used to define who has permission to
perform specific actions in the network. These policies include:
 Endorsement Policies: Specify which peers must endorse a transaction for it to be
valid.
 Channel Policies: Determine who has access to a specific channel and what actions
they can perform.
 Access Control Lists (ACLs): Define permissions for specific resources, such as
chaincode invocation or ledger query.
Channels:
Definition: Channels are private sub-networks within a Hyperledger Fabric network.
Purpose:
Allow a subset of network participants to conduct transactions privately.
Transactions within a channel are only visible to participants in that channel.
Key Points:
 Each channel has its own ledger and set of endorsing peers.
 Participants can be part of multiple channels.
 Channels are a way to implement privacy in a Hyperledger Fabric network.
Transaction Validation:
1. Endorsement Phase:
Role: Determines whether a transaction is valid based on the chaincode's logic.
Process:
 The client sends a transaction proposal to the endorsing peers.
 Endorsing peers simulate the transaction using the chaincode and return the results.
 The endorsement results include read and write sets.
2. Ordering Phase:
Role: Orders transactions into blocks and distributes them to all peers in the network.
Process:
 Endorsed transactions are sent to the ordering service.
 The ordering service creates a block of transactions in a specified order.
 The block is broadcasted to all peers.
3. Validation Phase:
Role: Ensures that transactions meet the endorsement policy before committing them to the
ledger.
Process:
 Peers validate the endorsements against the endorsement policy.
 If the endorsements are valid, the transactions are committed to the ledger.
4. Commit Phase:
Role: Updates the ledger and state database with the committed transactions.
Process:
 The validated transactions are appended to the ledger.
 The world state database is updated to reflect the new state.
5. Consensus Mechanism:
Practical Byzantine Fault Tolerance (PBFT): Ensures that a transaction is considered valid
if it receives endorsements from a specified number of endorsing peers.
Other Consensus Mechanisms (if used): Depending on the network configuration, different
consensus mechanisms may be employed.
These processes ensure that transactions in Hyperledger Fabric are executed, validated, and
recorded in a secure and reliable manner. The modular architecture and use of channels allow
for a high degree of customization and privacy in transaction processing.

Writing smart contract using Hyperledger Fabric


Writing a smart contract for Hyperledger Fabric involves using a programming language like
Go (or JavaScript for Hyperledger Fabric 1.4 and earlier versions) to define the logic that will
be executed on the blockchain.

Below, I'll provide an example of a simple smart contract written in Go for Hyperledger
Fabric. This contract will keep track of a key-value pair in the ledger.
// SPDX-License-Identifier: Apache-2.0
package main
import (
"fmt"
"github.com/hyperledger/fabric-contract-api-go/contractapi"
)
// SimpleStorageContract defines the Smart Contract structure
type SimpleStorageContract struct {
contractapi.Contract
}
// KeyValue represents a key-value pair
type KeyValue struct {
Key string `json:"key"`
Value string `json:"value"`
}
// Set stores the key-value pair in the ledger
func (s *SimpleStorageContract) Set(ctx contractapi.TransactionContextInterface, key string,
value string) error {
keyValue := KeyValue{
Key: key,
Value: value,
}

// Convert the key-value pair to bytes


keyValueBytes, err := json.Marshal(keyValue)
if err != nil {
return err
}

// Store the key-value pair in the ledger


err = ctx.GetStub().PutState(key, keyValueBytes)
if err != nil {
return fmt.Errorf("failed to put state: %v", err)
}

return nil
}

// Get retrieves the value for a given key from the ledger
func (s *SimpleStorageContract) Get(ctx contractapi.TransactionContextInterface, key string)
(*KeyValue, error) {
// Retrieve the value from the ledger
keyValueBytes, err := ctx.GetStub().GetState(key)
if err != nil {
return nil, fmt.Errorf("failed to read from world state: %v", err)
}
// If the key does not exist, return nil
if keyValueBytes == nil {
return nil, nil
}
// Unmarshal the value into a KeyValue struct
var keyValue KeyValue
err = json.Unmarshal(keyValueBytes, &keyValue)
if err != nil {
return nil, err
}
return &keyValue, nil
}
In this example, we define a smart contract named SimpleStorageContract with two
functions: Set and Get.

Set takes a key and value, converts them to a KeyValue struct, and stores it in the ledger.
Get retrieves the value for a given key from the ledger.
Remember to import the necessary packages (fmt, github.com/hyperledger/fabric-contract-
api-go/contractapi, and encoding/json) and set up your development environment with the
Hyperledger Fabric SDK and tools.

Additionally, you'll need to package this code into a chaincode and deploy it to a Hyperledger
Fabric network. The deployment process involves writing a client application that interacts
with the blockchain network and deploys the chaincode.

You might also like