edoardo conte BLOCKCHAIN Technology & Applications #apiconf2018
BLOCKCHAIN Technology & Applications edoardo conte BLOCKCHAIN Technology & Applications #apiconf2018
BLOCKCHAIN Technology & Applications edoardo conte The Blockchain
BLOCKCHAIN Technology & Applications edoardo conte Distributed System Normally, also Decentralized Distributed and decentralized
BLOCKCHAIN Technology & Applications edoardo conte Possibility to Decentralized Everyone can join design and deploy and distributed and maintain the Smart Contracts systems blockchain Public Blockchains
BLOCKCHAIN Technology & Applications edoardo conte Determine the current builder Necessary to maintain a unique sequence of blocks! Proof of Work Proof of Stake Consensus Algorithm
BLOCKCHAIN Technology & Applications edoardo conte Proof of Work Proof of Stake Non-scalable algorithm Possibility to scale Great computational cost Costless algorithm Very complex to implement Complexity really low Consensus Algorithm
BLOCKCHAIN Technology & Applications edoardo conte Read access link Write access link for the service for the service Secure data Blockchain Bridge Distributed Server with Client network through important data Blockchains accessing the accessing the service service
BLOCKCHAIN Technology & Applications edoardo conte Not completely Different Standardized decentralized authorized entities encryption and work together to replication maintain a protocols common service Permissioned Blockchains
BLOCKCHAIN Technology & Applications edoardo conte Full replication Chaincode a b of data (Smart Contracts) d State database in Customizable c consensus algorithm CouchDB or LevelDB • Crash Fault Tolerant • Byzantine Fault Tolerant Hyperledger Fabric
BLOCKCHAIN Technology & Applications edoardo conte Peer Endorsing Endorsing Peer Peer Peer • Ordering service • Consensus algorithm Org1 Org2 CA 2 • Different organizations Peer • Scalability CA 1 Peer • Certificate authorities • Endorsing peers Orderer • Execution of chaincode Structure
BLOCKCHAIN Technology & Applications edoardo conte Execute 1. Client sends a Client transaction request 2. Execution of Chaincode 3. Sending the results back Endorsing Peer Endorsing Peer Transaction Flow
BLOCKCHAIN Technology & Applications edoardo conte Order 1. Results sent Client to the orderer 2. Ordering of transactions Endorsing Peer Orderer Endorsing Peer Transaction Flow
BLOCKCHAIN Technology & Applications edoardo conte Peer Validate Peer 1. Validation of each block Client Peer 2. If positive, it goes in the ledger Endorsing Peer Orderer Endorsing Peer Transaction Flow
BLOCKCHAIN Technology & Applications edoardo conte Peer Validate Peer 1. Validation of each block Client Peer 2. If positive, it goes in the ledger Endorsing Peer Orderer Endorsing Peer Transaction Flow
BLOCKCHAIN Technology & Applications edoardo conte Framework over Fabric Modeling language Logic Access Control 1 2 3 • Definition of the • Permissions • Participant • Asset transaction logic on resources • Complex • Javascript code • Transaction conditioned rules • Event Hyperledger Composer
BLOCKCHAIN Technology & Applications edoardo conte Model.cto /** * Definition of participants */ participant Person identified by username { o String username o String fullName o String email optional o String number optional } participant Manufacturer identified by makerId { o String makerId o String name }
BLOCKCHAIN Technology & Applications edoardo conte Model.cto /** * Definition of assets */ asset Vehicle identified by vin { o String vin o VehicleDetails vehicleDetails --> Person owner }
BLOCKCHAIN Technology & Applications edoardo conte Model.cto /** * Definition of transactions */ transaction ChangeOwner { --> Vehicle vehicle --> Person newOwner } transaction SellVehicle { o VehicleDetails vehicleDetails o String vin --> Person owner }
BLOCKCHAIN Technology & Applications edoardo conte Logic.js /** * Sell vehicle transaction * @param {org.acme.vehicle.SellVehicle} arg * @transaction */ function onSellVehicle ( arg ) { }
BLOCKCHAIN Technology & Applications edoardo conte Logic.js const namespace = 'org.acme.vehicle'; // Extracting argument values let vehicleDetails = arg.vehicleDetails; const vin = arg.vin; const owner = arg.owner; const manufacturer = getCurrentParticipant(); vehicleDetails.manufacturer = manufacturer;
BLOCKCHAIN Technology & Applications edoardo conte Logic.js const factory = getFactory(); // Creating the vehicle let vehicle = factory.newResource(namespace, 'Vehicle', vin); vehicle.vehicleDetails = vehicleDetails; vehicle.owner = owner;
BLOCKCHAIN Technology & Applications edoardo conte Logic.js // Updating the registry return getAssetRegistry(namespace + '.Vehicle ’ ) .then ( assetRegistry => { return assetRegistry.add(vehicle); }) Update
BLOCKCHAIN Technology & Applications edoardo conte Logic.js // Updating the registry return getAssetRegistry(namespace + '.Vehicle ’ ) .then ( assetRegistry => { return assetRegistry.add(vehicle); }) Update
BLOCKCHAIN Technology & Applications edoardo conte Permissions.acl rule ManufReadsVehicle { description : "Manuf may read a car only if he made it" participant (manuf): "org.acme.vehicle.Manufacturer" operation : READ resource (vehicle): "org.acme.vehicle.Vehicle" condition : ( manuf.getIdentifier() == vehicle.vehicleDetails.manufacturer.getIdentifier() ) action : ALLOW }
BLOCKCHAIN Technology & Applications edoardo conte ORG1 ORG2 ORDERER 2 Peers 1 Peer Solo CA CA CouchDB CouchDB Network Set Up
BLOCKCHAIN Technology & Applications edoardo conte Node 1 Node 2 Node 3 Node 4 Org 1 Org 2 Org 1 Peer Endorsing Peer Endorsing Peer CouchDB CouchDB CouchDB • API exposed by NodeJs Orderer • Composer SDK in NodeJs Org1 CA Org 2 CA SQL DB SQL DB NodeJs App NodeJs App Client • Each element is a Docker container • Docker Swarm to communicate
BLOCKCHAIN Technology & Applications edoardo conte Opening connection const BusinessNetworkConnection = require('composer-client').BusinessNetworkConnection; module . exports = class Network { constructor ( cardName ) { this.cardName = cardName; this.connection = new BusinessNetworkConnection(); this.definition; this.namespace = 'org.acme.vehicle'; } async connect() { return this.definition = await this.connection.connect(this.cardName); } connection Blockchain
BLOCKCHAIN Technology & Applications edoardo conte Submit Transaction const factory = this.definition.getFactory(); // Submit transaction const tx = factory.newTransaction(this.namespace, 'SellVehicle ’ ); tx.vehicleDetails = vehicleDetalils; tx.vin = vin; tx.owner = factory.newRelationship(this.namespace, 'Person', ownerId); return await this.connection.submitTransaction(tx); Blockchain
BLOCKCHAIN Technology & Applications edoardo conte Submit Transaction const factory = this.definition.getFactory(); // Submit transaction const tx = factory.newTransaction(this.namespace, 'SellVehicle ’ ); tx.vehicleDetails = vehicleDetalils; tx.vin = vin; tx.owner = factory.newRelationship(this.namespace, 'Person', ownerId); return await this.connection.submitTransaction(tx); Blockchain
BLOCKCHAIN Technology & Applications edoardo conte Repositories https://bitbucket.org/hugrave/composer-vehicle-network/ https://bitbucket.org/hugrave/blockchain_server/
BLOCKCHAIN Technology & Applications edoardo conte Benchmark done with 1000 assets GET — > ~ 10 seconds PUT, DELETE — > ~ 100 SECONDS Improvement through Cloud deployment Not real-time applications Performance evaluation
BLOCKCHAIN Technology & Applications edoardo conte Permissions in Hyperledger Composer Rich conditioned language BUT… The ledger remains in plain-text! /var/hyperledger/production/ledgersData/chains/chains/{channel_name}/ PRIVACY
BLOCKCHAIN Technology & Applications edoardo conte DO NOT DESPAIR!
BLOCKCHAIN Technology & Applications edoardo conte Peer 1 Peer 2 Peer 3 Channel 1 Channel 2 Channel 3 Fabric Channels
BLOCKCHAIN Technology & Applications edoardo conte Peer 1 Peer 2 Peer 3 Channel 1 Channel 2 Channel 3 Channel 2 Channel 3 Peer3 joined channel 2 Peer 1 joined channel 3 Fabric Channels
BLOCKCHAIN Technology & Applications edoardo conte Off-chain encryption decryption
BLOCKCHAIN Technology & Applications edoardo conte D B Off-chain NodeJs Org1 encryption decryption Data inserted in the blockchain is encrypted Decryption is possible only with the keys Client1
BLOCKCHAIN Technology & Applications edoardo conte D B Off-chain NodeJs Org1 encryption decryption Data inserted in the blockchain is encrypted Decryption is possible only with the keys Client1
BLOCKCHAIN Technology & Applications edoardo conte D D B B Authorization is a secure keys exchange Off-chain NodeJs Org1 NodeJs Org2 encryption decryption Client1 Client2
Recommend
More recommend