0% found this document useful (0 votes)
26 views53 pages

Unit III

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

Unit III

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

Blockchain Technology

– IOE411

Dr. Shajulin Benedict


[email protected]
Syllabus
• Introduction – blockchain history, basics, architectures, Types of
blockchain, Base technologies – dockers, docker compose, and
data structures, hashes, Digital Signature - ECDSA, Zero
Knowledge Proof.

• Bitcoins – Fundamentals, aspects of bitcoins, properties of


bitcoins, bitcoin transactions, bitcoin P2P networks, block
generation at bitcoins, consensus algorithms.

• Introduction to Ethereum- Consensus Mechanism -


Implementation, Transactions, demonstrations, Smart Contracts
(Blockchain hyperledger – Fabric architecture, implementation,
networking, fabric transactions, demonstration, smart contracts.)

• Applications – blockchain applications, e-governance, smart


cities, smart industries, anomaly detections, use cases, trends on
blockchains, serverless blocks, scalability issues, blockchain on
clouds.
Blockchain – A new perspective…
• Bitcoin… (Public, Cryptocurrency)
• Ethereum… (Public, Crypto+Application)
• Issues:
• Some organizations do not want their database or strategy to
be shared to others.
• E.g., Govt. organizations or departments.
Blockchain Hyperledger
• Hyperledger Fabric is a platform for distributed ledger
solutions underpinned by a modular architecture
delivering high degrees of confidentiality, resiliency,
flexibility, and scalability.
• It is an enterprise-grade system.
• The current version is release-2.5
• It offers a network of networks.
• It is a permissioned blockchain
• Transaction processing is performed by predefined users.
• Direct access to blockchain data is limited to predefined users.
Thus, only participants that are registered on the blockchain
network can download the ledger.
• It supports private transactions and confidential contracts.
Hyperledger Fabric
• The Linux Foundation founded the Hyperledger project
in 2015 to advance cross-industry blockchain
technologies.
• Hyperledger Fabric offers several pluggable options.
• Ledger data can be stored in multiple formats,
• Consensus mechanisms can be of varying types (in a
pluggable options)
• Contracts could be written in multiple languages
• Different trusted Membership Service Providers are
supported.
• Hyperledger Fabric also offers the ability to create channels,
allowing a group of participants to create a separate ledger of
transactions.
– to privately agree on the terms of interactions
Channels – A Broad perspective

Channels in Hyperledger Fabric


Hyperledger Fabric Functionalities

Identity • Fabric provides a membership identity service (as it is a


permissioned service)
management • It has UserID to authenticate users.

• Hyperledger Fabric enables competing business interests,


Privacy and and any groups that require private, confidential
transactions, to coexist on the same permissioned network.
Confidentiality • Via. channels

Chaincode • Chaincode applications encode logic that is invoked by


specific types of transactions on the channel.
Functionality

Modular design • to provide functional choice to network designers

https://hyperledger-fabric.readthedocs.io/en/release-1.4/functionalities.html
Hyperledger Fabric – Design Features
• Assets
• Asset definitions enable the exchange of almost anything with
monetary value over the network -- from whole foods to
antique cars to currency futures.
• Assets can be represented in binary and/or JSON form.
• Chaincode
• Chaincode is a software that defines an asset or assets
• It is a business logic
• Chaincode enforces the rules for reading or altering key-value
pairs or other state database information.
• A system chaincode is a system-level chaincode that defines
the operating parameters for the entire channel.

https://hyperledger-fabric.readthedocs.io/en/release-1.4/fabric_model.html
Hyperledger Fabric – Design Features
• 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”.
• Privacy
• Hyperledger Fabric employs an immutable ledger on a per-
channel basis.
• A ledger exists in the scope of a channel
– it can be shared across the entire network (assuming every
participant is operating on one common channel)
– OR, it can be privatized to include only a specific set of
participants.
Hyperledger Fabric
• Security & Membership Services
• Hyperledger Fabric provides a transactional network where all
participants have known identities.
• Permissioned membership provides a trusted blockchain
network, where participants know that all transactions can be
detected and traced by authorized regulators and auditors.
• How? Public Key Infrastructure is used to generate
cryptographic certificates which are tied to organizations,
network components, and end users or client applications
(using MSPs).
Hyperledger Fabric
• Consensus
• Consensus is defined as the full-circle verification of the
correctness of a set of transactions comprising a block.
• A unique approach to consensus enables the flexibility and
scalability needed for the enterprise.
• Consensus plays a major role throughout the process
– i.e., it plays a fundamental role in the entire transaction flow, from
proposal and endorsement, to ordering, validation and
commitment.

https://www.youtube.com/watch?v=1ORrdusUzeg
Blockchain Fabric Architecture
• The blockchain runs programs called chaincode, holds
state and ledger data, and executes transactions.

MSP-Membership Service Provider


Transaction Flow

• Starts with an API request from the client —


We want to write some data to the
Blockchain

• Ends with an API response to the client —


the block is committed in the Blockchain for
your data

• Assumptions:
• a channel is set up and running.
• The application user has registered
and enrolled with the organization’s
Certificate Authority (CA) and received
back necessary cryptographic material,
which is used to authenticate to the
network.

https://hyperledger-fabric.readthedocs.io/en/release-1.4/txflow.html
Transaction Flow
• A Client, such as an iOS app, sends an API request to a Backend server
with Hyperledger Fabric SDK — I want to write some data to the
Blockchain
• The SDK sends a Transaction Request to the Peer(s) for the
endorsement
• The Peer(s) endorses (signs) the Transaction Request and returns it to
the SDK (, also, the Peer performs Chaincode / Smart Contract
execution at this point, before endorsing the transaction proposal)
• The SDK sends a transaction to the Orderer (& Kafka) for the
transaction ordering service
• The Orderer orders the transactions, forms block and broadcasts it to the
Peers
• The Peer(s) notifies the SDK — the block is committed in the Blockchain
for your data (, also, the Peer performs transactions validation and block
commitment at this point, before notifying the SDK)
• The SDK (the Backend server) sends an API response to a client — the
block is committed in the Blockchain for your data
https://hyperledger-fabric.readthedocs.io/en/release-1.4/txflow.html
Getting Started -- Fabric
• Download SDKs (go, Nodejs, Java, Python)
• The Hyperledger Fabric client SDK provides a structured
environment of libraries for developers to write and test
chaincode applications.
• The SDK is fully configurable and extensible through a
standard interface. Components, including cryptographic
algorithms for signatures, logging frameworks and state
stores, are easily swapped in and out of the SDK.
• Prerequisites
• Docker and Docker compose
• Golang
• Samples and binaries are available. Download them.

https://hyperledger-fabric.readthedocs.io/en/latest/glossary.html
https://hyperledger-fabric.readthedocs.io/en/latest/getting_started.html
Smart Contracts -- Chaincode
• A smart contract defines the rules between different
organizations in executable code.
• Applications invoke a smart contract to generate
transactions that are recorded on the ledger.
• Chaincode is a piece of code that implements the
smart contracts for businesses.
• i.e., chaincode contains smart contracts.
• Chaincodes are written in go or java or nodejs which
holds the business logic.
• It is installed and instantiated through an SDK or CLI
onto a network of Hyperledger Fabric peer nodes,
enabling interaction with that network’s shared ledger.
• Multiple smartcontracts can be implemented in on
chaincode.
Smart contracts -- Chaincode
• Examples
Chaincode Interfaces
• Init() method
• Init is called when you first deploy your chaincode.
• As the name implies, this function is used to do any
initialization for chaincodes.
• Invoke() method
• Invoke is called when you want to call chaincode functions to
do real work (i.e. read and write to the ledger).
• These two interfaces are also named as stub
interfaces
Chaincode program structure (golang)
• Step 1:
• Package main
• Step 2:
• Import packages

• Step 3:
• Define chaincode
Chaincode program structure (golang)
• Step 4:
• Implement chaincode interface

• These interfaces are mandatory for all chaincodes


• Init function is executed whenever there is instantiation or
upgrade to chaincodes.
Chaincode program structure (golang)
• Step 5: Add functions to chaincode

• Step 6: Finalize chaincode


Golang
• https://tour.golang.org/welcome/1
• Learn packages, variables, functions
• Flow control statements
• For loop
• If—else
• Switch
• Defer -- A defer statement defers the execution of a function until
the surrounding function returns.
• structs, arrays, slices, and maps
• Slices -- An array has a fixed size. A slice, on the other hand, is a
dynamically-sized, flexible view into the elements of an array. For
eg. var s []int
• Methods and interfaces
• Concurrency
• A goroutine is a lightweight thread managed by the Go runtime.
Hyperledger Fabric (Implementation)
Hyperledger Fabric (Implementation)
Hyperledger Fabric (Implementation)
Hyperledger Fabric (Implementation)
Hyperledger Fabric (Implementation)
Hyperledger Fabric (Implementation)
• Organizations involved
• Orderer – 1
• Channel – 1
• No.of Peers -2
– Org1→ iiitkottayam.com
– Org2 → aic.com

• Program Flow
• Generates certificates using cryptogen
• Generates genesis block (Orderer)
• Generates channel configuration → channel.tx
Hyperledger Fabric (Implementation)
Hyperledger Fabric (Implementation)
Hyperledger Fabric (Implementation)
Hyperledger Fabric (Implementation)
Hyperledger Fabric (Implementation)
• Identity
• Membership
• Peers
• Smart Contracts and Chaincode
• Ledger
• Ordering Service
• Private Data
• Channel Capabilities
• Use-Cases
Other frameworks under HyperLedger

Fabric

Iroha

Sawtooth

Burrow

Indy
Major Blockchains
• Bitcoin (Studied earlier)
• Bitcoins are virtual currencies
• Also called as cryptocurrency.
• Technologies such as public key, digital signature, hash, P2P,
Proof-of-Work
• Ethereum (Studied earlier)
• Ethereum is an open source distributed public blockchain
network; Ethereum is public;
• It is named as an internet built on neutral, open-access
infrastructure, controlled by no company or person.
• It includes smart contracts – written in solidity (high level
programming language).
• Solidity is statically typed scripting language which does the
process of verifying and enforcing the constraints at compile-
time as opposed to run-time.
• Ethereum has its native cryptocurrency called Ether &
Ethereum Wallet
Major Blockchains
• Ripple Consensus Network
• Ripple platform has been designed on open-source distributed
consensus ledger, and local currency referred as XRP.
• It is developed for digital asset exchanges, banks, payment
providers, and corporate who want to send money globally...
• Ripple allows quick, safe, secure and free financial
transactions around the globe without charge back.
• More towards global financial market.
• It is mainly meant for international wire transfers in a secure
manner.
• Hyperledger
• Studied earlier

https://www.ripple.com/
Major Blockchains
• R3’s Corda
• It is a distributed ledger using open source protocol which is
used to supervise, record, and sync the financial agreements
with the controlled financial institutions.
• Permissioned or private blockchain platform.
• Corda eliminates the unnecessary global sharing of data.
• In Corda, consensus is accomplished at individual deals and
not at the system level.
• It directly allows regulatory and supervisory observer nodes.
• Hence, they are legally bounded to financial sectors.
• It doesn’t have cryptocurrency.

• R3 (financial agreements platform) and Ripple (financial


transfer platform) mutually joins for effective dealing of money.
Diff between Corda, Hyperledger, and
Ethereum
VMWare Blockchain
• https://labs.hol.vmware.com/HOL/catalogs/lab/4689
VMWare Blockchain
• HOL-2088-01-EMT - VMware's Blockchain - Getting
Started
• Blockchain is a decentralized distributed ledger
• A team of nodes involved in the blockchain network
would be responsible for deciding the updates on
blockchains.
• Two types of implementation in VMware
• Permissioned
• Permissionless
• Scalable Byzantine Fault Tolerance consensus
algorithm
VMWare Blockchain
Lab
• Steps:
• Launch Chrome
• Login
[email protected]
– VMware1!
• VMWare Blockchain UI Navigation pane
– Deploy – to create a new consortium
– Dashboard contains
– Nodes involved and their health status
– Number of blocks
– Deployed contracts
– Current block with indexing
– Transactions (hashes)
Dashboard
Smart Contracts - UI
• Options available are
• Connect with truffle (Ethereum blockchain)
– Truffle is a development environment, testing framework, and
asset pipeline all rolled into one.
• Deploy – to manually deploy smart contracts
Blocks – UI
• Current block and indexing
• Reverse chronological order
Blocks -UI
• Individual block shows the hashes (incl. parent
hashes)
Transactions – UI
• Status of blocks and their indexing the blockchain
APIs - Appearance
• You could try the APIs using Try it Out option!
API - advantages
Add User
Users in VMware Blockchain
• Org User - The end user who wants to use an
application built on blockchain or is engaging in
transactions. For example, this might be an individual
buying or selling an asset.
• Org Developer - A person who is managing and
writing smart contracts or applications that will
leverage the blockchain infrastructure.
• Org Admin - A person who is responsible for
managing an organization, including managing the
Org Users.
• Consortium Admin - A person responsible for
managing which Orgs are members of a Consortium.
• Systems Admin - A person responsible for managing
a blockchain implementation.
AWS blockchain
• https://aws.amazon.com/blockchain/

You might also like