Block chain application development
Block chain application development: Hyperledger Fabric- Architecture, Identities and Policies, Membership and Access Control, Channels, Transaction Validation, Writing smart contract using Hyperledger Fabric, Writing smart contract using Ethereum, Overview of Ripple and Corda.
Hyperledger Fabric |
An implementation of blockchain technology that is intended as a foundation for developing blockchain
applications for the enterprise.
What is Hyperledger Fabric?
Hyperledger Fabric is a relatively new business flowchart. Many types of modern blockchain models are available, but in spite of that, Hyperledger Fabric has many unique features. Whether these characteristics are advantages or disadvantages often depends on the context.
- Hyperledger Fabric is a open source platform for distributed ledger solutions in industrial level.
- A modular architecture,Delivers high degrees of confidentiality, resiliency, flexibility and scalability.
- The Linux Foundation (the same corporation behind the Linux Operating System) launched the Hyperledger blockchain initiative in December 2015.
- This project was established as a core for both the collaborative production of fully accessible blockchain technology and distributed ledgers.
- Like other blockchain technologies, it has a ledger, uses smart contracts, and is a system by which participants manage their transactions.
- Breaks from some other blockchain systems is that it is private and permissioned.
- Hyperledger is based on blockchain but its not a crypto currency.
- There is no mining, just order system do it.
- Now available on all major clouds: Google Cloud, AWS, Oracle, SAP, and more.
Why Hyperledger Fabric?
It is not easy to compare Hyperledger Fabric to any other blockchain network like Bitcoin or Ethereum. As you know that most of the networks of blockchain is used for public but Hyperledger is not intended for public use. Hyperledger Fabric developed over time with the help of an open-source community focused primarily on enterprise-grade use cases. So, let’s see what these are –
- It is a Modular and permissioned architecture.
- You must protect your data or keep some of it private.
- No “mining” or native crypto-currency required for consensus.
- Smart contracts is support data model such as structured data, account model, unstructured data etc.
- Smart contract support for multiple programming languages such as JavaScript, Java, Go, etc.
- You want to control your access to the network.
- To Execute-order-validate vs order-execute
What is a advantages of Hyperledger Fabric
- Permissioned membership
- Performance, scalability, and levels of trust
- Data on a need-to-know basis
- Rich queries over an immutable distributed ledger
- Modular architecture supporting plug-in components
- Protection of digital keys and sensitive data
Execute-Order-Validate
Hyperledger Fabric architecture for transactions: – in contrast with order-execute model
Separate transaction flow into 3 steps
- Execute: execute transaction, validate then endorsing it
- Order: order transaction
- Validate: validate transactions with endorsement policy, then commit to ledger
How Hyperledger Fabric Service Works?
Let’s see the example:
Client A = The application user
‘Peers’ installed ‘chaincode’
‘Channel’ instantiate chaincode
Chaincode defines transaction instructions and food price
Client A send a request to purchase food
SDK creates transaction proposal
transaction proposal is a request to invoke a chaincode
User credential produce a unique signature for this proposal
Endorsing peers verify & execute transaction
Endorsing peers verify transaction proposal
Endorsing peers execute the transaction, but NOT UPDATE ledger
Sent back proposal response(endorsing peer’s signature + delta set)
Client B application verifies endorsing peer signatures and compares the proposal responses
The application broadcast transaction proposal and response to Ordering Service
Ordering Service receives transactions from all channels in the network
Order transactions by channel, creates blocks per channel
Blocks are delivered to all peers on the channel
Validate that there are no changes for delta set
Transactions in the block are tagged as valid or invalid
Each peer appends block to the channel’s chain
For valid transactions the delta sets are committed to db
Q : Endorsement Policy??
A : Which peer nodes, How many of peers need to endorse for given smart contract.
Q : Application User?
A. Client who invoke or query chaincode User should be registered & enrolled with Organization’s CA
Q : Channel?
- Channel allows a group of participants to create a separate ledger
- Provide a mechanism for private communications and private data
Q : Endorsing Peer?, Peer?
- Endorsing peers verify & execute transaction
- Peer which install chaincode can be endorsing peer
- Endorsing peer create signed transaction response using its own chaincode
- All the peer in the channel is committing peer
- Committing peer receive blocks, validate then commit to ledger
- Endorsing peers verify transaction proposal
- Endorsing peers execute the transaction, but NOT UPDATE ledger
- Sent back proposal response(endorsing peer’s signature + delta set)
Hyperledger Fabric: Fabric consist of below major components
let’s review the components that comprise it.
- Client
- Peer
- Orderer
- Fabric CA,
- Ordering service
- Channel
- Chaincode
- Security & Membership Services:
- Identity
- Policies
Client
- Clients are applications that act on an individual’s behalf to offer transactions over a network.
- A. Client who invoke or query chaincode
- User should be registered & enrolled with Organization’s CA
Fabric CA
The Hyperledger Fabric CA is a Certificate Authority (CA) for Hyperledger Fabric.
It provides features such as:
- registration of identities, or connects to LDAP as the user registry
- issuance of Enrollment Certificates (ECerts)
- certificate renewal and revocation
- consists of both a server and a client component.
- Every single operation that is executed inside hyperledger fabric must be cryptographically signed with this certificate.
- You can add attributes, roles
- Certificates are X.509 standards.
- You can remove the necessity of certificates if you don’t need it.
- Chaincodes read this data and make business decisions.
Peer
- Peer is the place where the ledger and the blockchain data is stored.
- You must have more than one peer in production.
- One peer may be part of many channels.Every single channel is inside the peer.
- It endorse any update of the ledger.
- You can create backup of the ledger from the peer
Ordering Service
- Ordering service is actually the heart of consensus algorithm and the heart of hyper ledger fabric.
- Main role is to provide the order of operations.
- before committing anything to ledger it must pass through the ordering service.
- it is responsible for verification, security, policy verification etc.
Channel
- Channel is a private “subnet” of communication between two or more specific network members.
- A channel is defined by members (organizations), anchor peers per member, the shared ledger, chaincode application(s) and the ordering service node(s).
- Each peer that joins a channel, has its own identity given by a membership services provider (MSP).
- they have different ledgers, different height of blocks, policies, stories, rules.
- completely isolated instance of hyper ledger fabric.
- never exchange data.
- outside of a channel , one can’t even see that there is a channel.
- you can make a policy who can see the data in the channel and who can make an operation.
- every single party inside a channel must agree about other parties.
Chaincode
- A chaincode typically handles business logic agreed to by members of the network, so it similar to a “smart contract”.
- All your business logic is inside the chaincode.
- Its written in Go. Implementation of java and javascript are on the way.
- Chaincode me installed in every peer and channel.Policy must be provided.
Security & Membership Services:
In Permissioned membership participants know that all transactions can be detected and traced by authorized regulators and auditors.
MSPs occur in two domains in a blockchain network:
- Locally on an actor’s node (local MSP)
- In channel configuration (channel MSP)
Identity
- Each actors in a network peer, orderer, client, admin have some digital identity in the form of certificate X.509.
- This identity is used to verify at each and every step of a transaction, in order to check if the source of the transaction is from a valid source.
Policies
Policies reside in the Channel configuration, but in some cases, it resides in chaincode too. policies test whether the signer or signers of some data meet some condition required for those signatures to be considered ‘valid’.
There are two types of policies
Signature Policy: It is powerful and specifies policy as a combination of evaluation of rules for MSP principles. It supports a combination of AND, OR and NOutOf.
Implicit Meta policy: This is less flexible and only valid in context for configuration. It aggregates the result of evaluating policies deeper in the configuration hierarchy, which are ultimately defined by Signature Policies.
BlockChain Technologies Notes
InfoKhajana.com covered the following topics in these notes.
- Introduction of Blockchain (Notes)
- Applications of Blockchain Technology (Notes)
- How Blockchain Transaction Works? (Notes)
- Digital Signature (Notes)
- Types of Blockchain & Smart Contracts (Notes)
- Understanding the Cryptocurrency and Its Benefits Notes
- Basic Cryptographic primitives used in Blockchain Notes