L6 Enterprise Blockchain
L6 Enterprise Blockchain
Blockchain
Enterprise Blockchain
Learning Objectives
Hyperledger Corda
Why Enterprise Blockchain?
Anonymity in peers
Fully transparent
Not scalable
Enterprise Blockchain Features
Accountable
Permissioned Scalable
Pluggable Consensus
Hyperledger
Introduction to Hyperledger
Hyperledger is a global enterprise Blockchain project that provides the architecture, standards,
guidelines, and resources needed to create open source Blockchains and related applications.
Hyperledger
Hyperledger Umbrella Project
Hyperledger Umbrella Project comprises tools, services, and libraries to build Enterprise
Blockchain applications.
Indy
Iroha Burrow
Sawtooth Fabric
Hyperledger Sawtooth
Introduction to Sawtooth
Maintains distributed
Keeps smart contract safe
nature of Blockchain
Sawtooth Features
Parallel Multi
transaction language
support support
Sawtooth
Plug and
Play Seth
Consensus
Sawtooth Architecture
Client
Rest API
● Intermediator between the client and the
validator
● Medium for submitting transactions and
reading blocks
● Performs different operations associated
with Rest methods
Sawtooth Architecture
Validator
Transaction Processors
APIs
Sawtooth Network
Hyperledger Iroha is a simple Blockchain platform that can be utilized to make trusted, secure,
and fast applications that leverage the power of permission-based Blockchain with Byzantine
fault-tolerant consensus.
Hyperledger Iroha
Hyperledger Iroha Features
Client Application
Easy to Deploy
Smart Contracts
Community
Private Blockchain
Hyperledger Iroha Architecture
Step 1
Client initiates the transaction and sends it to the peer through Torii gate
Torii
Client Peer
Transaction
Transaction Flow
Step 2
Peer sends the transaction to the Ordering Service through the Ordering Gate after
performing stateless validation
Step 3
Ordering service collects the transactions and maintains a sequence of them. Transactions
are then put into a block, and they are sent to all peers as Proposals
Ordering Service
Proposals
Step 4
Proposed block reaches the peer, the peer runs the smart contract, and it simulates
the transactions present in that block with the help of a simulator
Proposed Block
Consensus Gate
Peer
Tx1
Tx2
Simulator
Tx3
Transaction Flow
Step 5
All the peers choose a leader based on majority and then the leader confirms the
block to be added to the ledger
Voting
Leader
Peer
Proposed Block
Peer
Tx1
Peer Tx2
Tx3
Hyperledger Indy
Hyperledger Indy
Hyperledger Indy is a distributed ledger used to generate and store decentralized identities,
allowing users to manage and control their digital identities. It stores pointers to identities rather
than private data.
Hyperledger Indy
Importance of Identification in Real World
Phone Number
Machine-generated user ID
How does identity work
over internet?
Email ID
Identification Attributes
Identification allows the user to monitor the type and amount of personal data posted, which
is an essential feature for users' informational autonomy.
High Risk
Low Risk
When you open a
When you buy
bank account
something online
online
Identity Correlations
Email id,
Email id,
family size,
Correlation medical
house
details
details
Email id,
race,
hobby
Decentralized Identifiers
Decentralized Identifiers (DIDs) are the global identifiers generated by the owner and not by
any central authority. They are generated using public and private keys where owner keeps
the private key secret.
Managing DIDs
Hyperledger Burrow is a permissioned Blockchain node built for a multi-chain universe that
executes smart contracts following the Ethereum specifications. It uses Ethereum Virtual
Machine.
Components of Burrows
Application
Gateway
Blockchain Interface
Hyperledger Fabric
Hyperledger Fabric
Hyperledger Fabric is the first distributed ledger platform to support smart contracts written
in general-purpose programming languages rather than domain-specific languages (DSL).
Hyperledger Fabric Architecture
Hyperledger Fabric Features
Performance and
Modularity
Scalability
Pluggable
Smart Contract
Consensus
An X.509 digital certificate is used to represent the identity. The actor specifies and delivers the
certificate when dealing with a fabric network, and the fabric network accepts or rejects it based on
the policy.
Identities in Fabric
Fabric CA is a certificate authority component which can integrate existing registries like LDAP.
MSP leverages fabric CA component.
Helps to revoke
and renew the
certificates
Root and Intermediate CA
Digital certificate are not only issued by Root Certificate Authority but can be issued by
intermediary certificate authority. Root CA authorize intermediate CA to issue certificates.
Certificate Revocation List (CRL)
It is a list of digital certificates that have been revoked by the issuing certificate authority
(CA) prior to their expiration date.
Reasons for Certificates Getting Revoked
privilegeWithdrawn unspecified
2 3
Certificatehold 1 4 KeyCompromise
removeFromCRL 7 5 cACompromise
superseded
Membership Service Provider
One of the features of the Enterprise Blockchain is that the user's should not be
anonymous but known.
Organization
MSP
Organization
Peer1
MSP
The main difference between local and channel MSPs is their scope, not how they work (both turn
identities into roles). At each level of administration, each MSP lists responsibilities and permissions.
Local MSPs and Channel MSPs
Local MSPs are only defined on the file system of the node or user.
A channel MSP is also installed on every node in the channel’s file system and kept synced via consensus.
Source: https://hyperledger-fabric.readthedocs.io/
Channel
Channel 1
Mark Jay
Channel 3
Sam Steve
Policy
It a set of rules that establish the framework for making decisions and achieving results. These
rules often describe a who and a what, such as an individual’s access or rights to an asset.
One of the features that distinguishes Hyperledger Fabric from other blockchains such as Ethereum
or Bitcoin is its policy system.
Types of Policy
Signature Policies
ImplicitMeta policies
A Fabric network’s policies are implemented at many levels. Each policy domain governs a different
aspect of a network’s operation.
System Channel
Application Channel
Source: https://hyperledger-fabric.readthedocs.io/
System Channel Configuration
Every network starts with an ordering system channel. There can only be one ordering system
channel per ordering service, and it must be the first one created.
An application channel also governs which organizations must approve a chaincode before it is
defined and committed to a channel via the Fabric chaincode lifecycle.
Smart Contract Endorsement Policies
A smart contract within a chaincode package has an endorsement policy that specifies how many
peers from different channel members must execute and validate the transaction.
The endorsement policies define the organizations that must endorse the proposal’s execution.
Access Control List
Not everyone in
Blockchain should be
able to see everything on
Blockchain. One should
Handle permission be able to control who Handle permission
for parties sees what in the at channel level as
involved Blockchain network. well
Access Control List
Handle permission
Handle permission
at the channel level
for parties involved
as well
One should be able to control who sees what in the blockchain network.
Peer Introduction
As they host ledgers and smart contracts, peers are critical components of the network.
Peer Introduction
Smart contracts and ledgers are used in networks to encapsulate shared operations
and information.
For these characteristics, a peer is a suitable place to start learning about Fabric networks.
Introduction to Peer Network
The network N in this example is made up of peers P1, P2, and P3, each of whom has their
own instance of the distributed ledger L1.
Fig: https://hyperledger-fabric.readthedocs.io/en/release-2.2/peers/peers.html
To access their copy of the distributed ledger, P1, P2, and P3 use the same chaincode:S1.
Peer Network
Fig: https://hyperledger-fabric.readthedocs.io/en/release-2.2/peers/peers.html
Peer Types
Peers keep track of the network's status and a copy of the ledger. Peers can be
divided into two types:
An application client interacts with the fabric network with the help of peers.
Fabric Network
C1
Application P1
Client
L1
Peers Application Client
An application client interacts with the fabric network with the help of peers.
Fabric Network
C1
C1
P3
P1
Application L1
L1
Client
A1 Channel A2
Ledger Types
The Blockchain contains logs of transactions and maintains the history of the transactions.
Car ID - 657
Owner - Fisher
Car ID - 657
Owner - Leena
Car ID - 657
Owner - Rahul
Car ID - 657
Owner - Pankaj
Car ID - 657
Owner - Joy
Car ID - 657
Owner - Mark
Ledger Types: World State
key-value pair
retrieve data from the fabric faster. type and complex type
compared to history.
State Database
Car ID - 657
Owner - Fisher
By re-processing the ledger, the state database can always be rebuilt. When each peer
validates and commits a transaction, it fills up the value.
The state database presently has two options: an integrated Level DB or an external
CouchDB
World State Database
{Key= house1,
Couch DB queries help to interact with the world state. It can be as simple as reading and
writing to a world state or as complex as writing complex queries.
Query syntax
"selector":{"name": "Mark"},
"fields": ["age","address"],
"limit": 4
}
Couch DB Queries
"selector":{"name": "Mark"}
"fields": ["age","address"]
}
Couch DB Queries
Simple query syntax: Finding the first 20 records where the year
is after 2010
"limit": 20
}
Couch DB Indexing
Query syntax
field age
"index":{"fields": ["age"]},
"name": "age-index",
"type": "json"
}
Couch DB Query
Simple query syntax: Finding the first 20 records where the year
is after 2010
"limit": 20
}
Read-Write Set
Read-Write set, usually referred to as RW set, is used very heavily in Hyperledger Fabric.
It helps committer nodes to validate the transaction and avoid double spending.
Read-Write Set
How is it created?
When the transaction reaches the endorsing peer, this RW set gets created.
RW
Endorsing Peer
RW
Endorsing Peer
Client RW
Endorsing Peer
Read Set
Read Set
key, version
key, version
key, version
Read Set
Read Set
(key="1234", version="1")
(key="1234", version="1")
(key="4561", version="1")
(key="8769", version="1")
Write Set
Write set contains Key and values as depicted below. This is used to write data to ledger.
Write Set
key, value
key, value
key, value
(key="8769", value="Steve")
Read-Write Set
Step1: Committing peer uses the received RW and validates the transaction.
Ledger RW
Committing Peer (key="1234", version="1")
(key="1234", value="Lui",
(key="1234", value="Joe")
version="1")
Read-Write Set
(key="1234",value="Lui", version="1")
Committing Peer
Ledger
Read-Write Set
RW 1
(key="1234", version="1")
(key="1234", value="Joe") (key="1234", value="Joe",
Ledger
RW2
(key="1234", version="1")
(key="1234", value="Jac")
Ordering Service or Node
The client application sends the transaction (RW set) to the Ordering service.
Endorsing Peer
Endorsing Peer
Endorsing Peer
Ordering Service
Fabric Network
Org
Ordering Service or Node
• Raft (Recommended): Raft is a crash-fault-tolerant (CFT) ordering service based on a Raft protocol
implementation.
• Kafka (deprecated in v2.x): Kafka utilizes a ZooKeeper ensemble for management purposes.
• Solo (deprecated in v2.x): The ordering service's Solo version is only meant for testing, and it
A Raft is mainly used for production setup, and it follows a leader-follower model.
O3
Fabric Network
L Org 3
F
O2 01
Org 1
Org 2 F
O4
Org 4
Ordering Service: Raft
O3
Fabric Network
L Org 3
O2
Org 2 F
O4
Org 4
Ordering Service: Raft
• In Kafka ordering, a cluster is under the control of one organization, but in Raft,
every organization can have its cluster, which makes it more decentralized.
Log Entry: Raft peer runs some commands, and a list of these commands is known as a log. Every
Consenter set: A leader peer sends the log to other peers for replication and receives replicated logs
Finite-State Machine (FSM): It is a part of every peer, and it ensures that the sequence of
Quorum: It specifies the minimum number of peers required to approve the transaction
sequence proposal. Example: Out of five peers, three peers need to act and approve.
Leader: It is chosen dynamically and sends the transactions or logs to other peers (followers).
Follower: It receives transaction or logs from the leader and replicates them.
Private Data
Private data helps to accomplish a scenario where certain details need to be shared among
a subgroup of organizations inside one channel instead of showing the information to all the
organizations in that channel.
State
Private data
Ledger
State database
Private Data
P1 P2 P3
Private data collection consists of two parts: one is the private data, and the other is a hash of
that data.
Data hash
private Data
Private Data
Data hash is a peer that is not a member of the subgroup that exchanges private data.
P1 P2 P3
Hyperledger
Client
Network
Hyperledger Fabric Transaction
Endorsing Peer
Endorsing Peer
Client
Endorsing Peer
Hyperledger Fabric Transaction
Endorsing Peers execute the chaincode and report back to the client program
Endorsing Peer
Endorsing Peer
Hyperledger Fabric Transaction
The client application receives the response from Endorsing Peers and checks the response
to see if consensus has been achieved
Client
Verify
Hyperledger Fabric Transaction
The Ordering Node is notified by the client application that a new transaction is being recorded
on the ledger
Endorsing Peer
Endorsing Peer
Endorsing Peer
Ordering Node orders the transactions, generates a block with those transactions, and gives it
back to the Endorsing Peers
Endorsing Peer
Endorsing Peer
Committing Peer
Committing Peer
Hyperledger Fabric Transaction
Peers verify each transaction in the block and notify the client as well
Endorsing Peer
Endorsing Peer
Ordering Node
Endorsing Peer
Committing Peer
Committing Peer
Hyperledger Fabric Transaction
Committing nodes (and the Endorsing nodes) record the copy of the record in their ledger
Endorsing Peer
Committing Peer
Fabric Network
Hyperledger Fabric setup
Set up
Identify Prerequisites Set up Fabric
Prerequisites
Identify Prerequisites
The following Operating System, Software, and tools are required to run Hyperledger in your
System:
Docker Engine
Docker Compose
Git and Curl
Lib tools
NodeJS
Python
Open JDK
Ubuntu Linux
Set up Hyperledger Fabric Prerequisites
Duration: 10 Min.
Problem Statement:
You are given a task to install Hyperledger Fabric prerequisites.
Assisted Practice: Guidelines
Duration: 10 Min.
Problem Statement:
You are given a task to install Hyperledger Fabric.
Assisted Practice: Guidelines
Test network
The test network is a production network replica which has the same
rules as those of the production.
Enterprise network
crypto-config.yaml
docker-compose.yaml
Crypto-config.yaml
This file assists the users to generate public and private keys, digital certificates for peers, and
ordered service using the command cryptogen.
Structure Purpose
This file assists to generate genesis block, which is an appropriate block in Blockchain.
Structure
Purpose
Genesis block
Channel artifacts
Docker containers are used to run the Hyperledger Fabric network. This file contains information about
each Docker container, such as name, image, port, and volumes.
Structure
Purpose
Create containers
Duration: 10 Min.
Problem Statement:
You are given a task to start and stop test network.
Assisted Practice: Guidelines
Hyperledger Explorer provides the user interface to see the operations of the Hyperledger Fabric
network. This tool allows viewing of the blocks, transactions, and chaincode running on the network.
Explorer Features
Dashboard
Channels
6 1
Chaincodes 5 2 Network
3
4 Blocks
Transactions
Dashboard
Dashboard is the home page of the Hyperledger Explorer and displays a set of panels that
shows the latest activity of the Hyperledger Fabric network.
Network
Hyperledger Fabric Network consists of peers and in this section, user can see all the network peers
and their properties. It allows them to check the peers by channel.
Blocks
Like Bitcoin and Ethereum explorer, Hyperledger Explorer shows a user all the blocks and lists of
transactions in that block. Along with that, it shows different properties of the block.
Transactions
The transaction tab helps to view all the transactions. A user can view maximum 100 transactions per
page, and it allows different filter options as well.
Transaction Details
Transaction details show different properties of transaction along with read and write set.
Chaincode
Chaincode
The chaincode tab lists down all the chaincodes deployed per channel and the number
of transactions for that chaincode.
Channel
Channel
The channel tab shows a list of the channels in the Hyperledger Fabric network.
Explorer Architecture
Explorer Architecture
• Presentation Layer
• Backend Layer
• Database Layer
Hyperledger Explorer
Duration: 10 Min.
Problem Statement:
You are given a task to start with hyperledger explorer.
Assisted Practice: Guidelines
Client 1
Client 2
Client 3
Database
Server
Multi Thread Model
Client 1
Thread A
Client 2 Thread B
Thread C
Client 3
Database
Server
Thread
Limitations of Multi Thread Model
Node.js is a server-side and networking runtime environment that is open-source. It is used to rapidly
construct scalable network applications.
Node.js is a single-threaded programming language that executes code using the Google
JavaScript V8 Engine. It runs on any operating system and is platform agnostic.
Features of Node.js
01 02 03 04
Asynchronous
Request
• Node.js is non-blocking, which means it works in
an asynchronous manner.
Response
• Instead of requesting a process first, it accepts
Client Server
Callback additional requests.
• The callback technique is used to send a
synchronized answer to the caller.
Features of Node.js
Event Driven
2. Create a server:
3. Listen:
server.listen(port, function(){
console.log('server at port 3000;);
});
Creating a Web Application
Import module
Define port
• Create server
• Send HTTP header
• Send HTTP data
Duration: 10 Min.
Problem Statement:
You have been tasked to create new server that runs on 4000 port using Node.js.
Assisted Practice: Guidelines
The blocking and non-blocking I/O are illustrated in the image below:
Node Package Manager
npm install <module> -g This syntax is used to install any Node.js module.
This is a manifest file that exists in the project's root directory and contains information about
the project.
This file gets created when a user creates new node project using the npm init command.
Package.json File Elements
Mandatory Element
Optional Element
Fabric-network
This module provides a high-level interface for working with the chain
code that has been deployed. Transactions and queries are examples of
interaction.
Fabric-ca-client
Note
Fabric-client is depreciated and replaced by fabric-network.
Fabric-network Modules
Gateway
This class allows a user to connect to a fabric network and interact with it.
FileSystemWallet
X509WalletMixin
Register
This class helps to register new users to the network. This returns secret as
a response when invoked.
Enroll
This class is used to enroll registered users, and the secret that the user
receives after registration is used as input.
Promise
• Resolved
• Rejected
Promise
Promise solves asynchronous code but brings a lot of complexity. With the introduction of async
functions, code look like it is synchronous, but it is asynchronous in nature and non-blocking
behind the scenes.
File System
The file system is a node module that aids in the input and output of files. For this, Node.js
provides a module called fs.
var fs = require("fs")
Express
Express is a web application framework for online and mobile applications that includes
Node.js.
It assists in the development of single, multi, and hybrid web applications. It is built on top
of Node.js and aids in the simplification of its APIs.
Features of Express
Express is a minimal and flexible Node.js web application framework that provides a robust set
of features to develop web and mobile applications.
Retrieve resources
HTML doc as response
Duration: 15 Min.
Problem Statement:
You have been tasked to create a new app that runs on port 500 using express file approach.
Assisted Practice: Guidelines
Duration: 15 Min.
Problem Statement:
You have been tasked to create new server that runs on 4000 port using Node.js.
Assisted Practice: Guidelines
Steps to be followed to Create Web Application Using Expressjs Node Project Approach:
C R U D
Post Get Put Delete
Create new
resource or Read resource Update Used to remove
update existing data resources resources
resource
R3 Corda
Corda Introduction
Corda is a distributed ledger platform that maintains privacy using smart contracts. It
reduces transaction and record-keeping costs and streamlines business operations.
Corda Features
1 4 Validity and
Ledger
Uniqueness Consensus
2 States 5 Contracts
3 Transactions 6 Flows
Ledger
In Corda, every node has its ledger where that node stores the transactions. This
implies there is no central ledger.
Nodes Visibility
ALICE 1, 7
BOB 1, 5, 6, 7
CARL 2, 3, 4, 5, 6, 9
ED 3, 4, 8, 9
DEMI 2, 3, 8
Reference: https://docs.corda.net/docs/corda-os/4.6/key-concepts-ledger.html
Bilateral Ledger
Reference: https://docs.corda.net/docs/corda-os/4.6/key-concepts-ledger.html
States
States are immutable digital documents that record the existence, content, and current state of a
contract between two or more parties. They are intended to be shared only with those who have the
approval to see them.
Fact 1
Historic State
Price Due Paid
Seller Buyer Remaining Price
(Rs.) Date Price
June ● After changing the state, a new
Joe Fisher 20,000 5000 15,000
2022 state defined as the current
state is created.
● The altered state becomes the
historic state.
Current State ● Historic states are not stored on
Price Due Paid the ledger, but they are still
Seller Buyer Remaining Price
(Rs.) Date Price available, ensuring that they are
June never removed.
Joe Fisher 20,000 20,000 0
2022
Transactions
Transactions are generated wherever there is any output for a given input. These transactions
ultimately get stored in the ledger.
TRANSACTION
CASH0 CASH1
BOND1 BOND2
Contracts
CASH
CONTRACT
BOND
CONTRACT
Flows
A flow is a method for two or more parties to agree on a simple update ledger and is usually
point-to-point.
Reference: https://docs.corda.net/docs/corda-os/4.6/key-concepts-flows.html
Validity Consensus
Validity consensus is the process of checking that the following conditions hold for every
transaction in the transaction chain that generates the inputs to the proposed transaction:
● The transaction is accepted by the contracts of every input and output state
● The transaction has all the required signatures
Reference: https://docs.corda.net/docs/corda-os/4.6/key-concepts-consensus.html
Uniqueness Consensus
● The criterion of uniqueness consensus is that none of the inputs to a proposed transaction are
being used in another transaction.
● A double spend exists if one or more of the inputs have already been used in another
transaction and the transaction request is deemed invalid.
Reference: https://docs.corda.net/docs/corda-os/4.6/key-concepts-consensus.html
Corda Network
Corda Network
Corda network is a peer-to-peer network where each node runs an instance of Corda.
Communication between nodes inside the network is secured and point-to-point.
● Identity Service: This service handles network node identity. It helps add new participants
to the network by verifying their certificate signing requests.
● Network Map Service: This service assists in network mapping where it helps with
message routing and connecting the nodes.
● Support Service: This helps to resolve inquiries related to the above three nodes.
Corda Pre-Production Network
Corda Pre-Production or User Acceptance Testing is a network that allows developers and
businesses to test their CorDapps in a production-like environment.
Pre-Production testing
Deployment of R3Net
Local testing
CorDapp
development
Quality check
Key Takeaways
A. Hyperledger Fabric
B. Hyperledger Iroha
C. Hyperledger Indy
D. Hyperledger Sawtooth
Knowledge
Check
Which Hyperledger project stores digital identities?
1
A. Hyperledger Fabric
B. Hyperledger Iroha
C. Hyperledger Indy
D. Hyperledger Sawtooth
Hyperledger Indy is a distributed ledger used to generate and store decentralized digital identities.
Knowledge
Check
Which Hyperledger Fabric network file helps generate the first genesis block?
2
A. crypto-config.yaml
B. configtx.yaml
C. docker-compose.yaml
D. Genesis.yaml
Knowledge
Check
Which Hyperledger Fabric network file helps generate the first genesis block?
2
A. crypto-config.yaml
B. configtx.yaml
C. docker-compose.yaml
D. Genesis.yaml
configtx.yaml file helps generate the genesis block and the required channel artifacts.
Knowledge
Check
Which node ensures that transactions are in a particular sequence?
3
A. Ordering node
B. Endorsing node
C. Committing node
D. All nodes
Knowledge
Check
Which node ensures that transactions are in a particular sequence?
3
A. Ordering node
B. Endorsing node
C. Committing node
D. All nodes
The sequence of transactions is important in Blockchain and is maintained by the ordering node.
Knowledge
Check
Which app is developed using Corda?
4
A. CordApp
B. Dapp
C. DAO
D. Ndap
Knowledge
Check
Which app is developed using Corda?
4
A. CordApp
B. Dapp
C. DAO
D. Ndap
A. Validity consensus
B. Uniqueness consensus
C. Proof of work
D. Proof of stake
Knowledge
Check
Which consensus type prevents double-spending in Corda?
5
A. Validity consensus
B. Uniqueness consensus
C. Proof of work
D. Proof of stake
The traditional seafood supply chain industry has illegal, unreported, and
unregulated fishing practices. You are required to bring traceability and
accountability to the supply chain through the power of Hyperledger
Sawtooth technology. Perform the following steps:
1. Visit https://demo.bitwise.io/fish/
2. Click SignUp to create an agent
3. Click Add Fish to add a fish that is to be tracked
4. Enter the details of the fish
5. Once the fish is added to the network, you can account for and track
the supply chain