BLOCKCHAIN Technology & Applications #apiconf2018 BLOCKCHAIN - - PowerPoint PPT Presentation

blockchain
SMART_READER_LITE
LIVE PREVIEW

BLOCKCHAIN Technology & Applications #apiconf2018 BLOCKCHAIN - - PowerPoint PPT Presentation

edoardo conte BLOCKCHAIN Technology & Applications #apiconf2018 BLOCKCHAIN Technology & Applications edoardo conte BLOCKCHAIN Technology & Applications #apiconf2018 BLOCKCHAIN Technology & Applications edoardo conte The


slide-1
SLIDE 1

BLOCKCHAIN

Technology&Applications #apiconf2018

edoardoconte

slide-2
SLIDE 2

BLOCKCHAIN

Technology&Applications #apiconf2018

edoardoconte

BLOCKCHAIN Technology&Applications

slide-3
SLIDE 3

BLOCKCHAIN Technology&Applications

edoardoconte

The Blockchain

slide-4
SLIDE 4

BLOCKCHAIN Technology&Applications

edoardoconte

Distributed and decentralized

Normally, also Decentralized Distributed System

slide-5
SLIDE 5

BLOCKCHAIN Technology&Applications

edoardoconte

Public Blockchains

Possibility to design and deploy Smart Contracts Decentralized and distributed systems Everyone can join and maintain the blockchain

slide-6
SLIDE 6

BLOCKCHAIN Technology&Applications

edoardoconte

Consensus Algorithm

Determine the current builder Necessary to maintain a unique sequence of blocks!

Proof of Work Proof of Stake

slide-7
SLIDE 7

BLOCKCHAIN Technology&Applications

edoardoconte

Proof of Work Proof of Stake

Consensus Algorithm

Non-scalable algorithm Complexity really low Possibility to scale Very complex to implement Costless algorithm Great computational cost

slide-8
SLIDE 8

Blockchain Bridge Client

Distributed network

Read access link for the service Write access link for the service accessing the service accessing the service

BLOCKCHAIN Technology&Applications

edoardoconte

Secure data through Blockchains

Server with important data

slide-9
SLIDE 9

BLOCKCHAIN Technology&Applications

edoardoconte

Permissioned Blockchains

Different authorized entities work together to maintain a common service Standardized encryption and replication protocols Not completely decentralized

slide-10
SLIDE 10

BLOCKCHAIN Technology&Applications

edoardoconte

Hyperledger Fabric

Chaincode (Smart Contracts)

b

Customizable consensus algorithm

c

Full replication

  • f data

a

  • Crash Fault Tolerant
  • Byzantine Fault Tolerant

d State database in

CouchDB or LevelDB

slide-11
SLIDE 11

Structure

BLOCKCHAIN Technology&Applications

edoardoconte

Orderer

Peer Peer

Org1 Org2

CA1 CA2

Peer Peer Endorsing Peer Endorsing Peer

  • Ordering service
  • Consensus algorithm
  • Different organizations
  • Scalability
  • Certificate authorities
  • Endorsing peers
  • Execution of chaincode
slide-12
SLIDE 12

Transaction Flow

Endorsing Peer

Execute

Client

Endorsing Peer

BLOCKCHAIN Technology&Applications

edoardoconte

  • 1. Client sends a

transaction request

  • 2. Execution of Chaincode
  • 3. Sending the results back
slide-13
SLIDE 13

BLOCKCHAIN Technology&Applications

edoardoconte

Order

Client

Orderer

Transaction Flow

Endorsing Peer Endorsing Peer

  • 2. Ordering of

transactions

  • 1. Results sent

to the orderer

slide-14
SLIDE 14

BLOCKCHAIN Technology&Applications

edoardoconte

Validate Orderer

Endorsing Peer Endorsing Peer Peer Peer Peer

Transaction Flow

  • 1. Validation of each block
  • 2. If positive, it goes in

the ledger

Client

slide-15
SLIDE 15

BLOCKCHAIN Technology&Applications

edoardoconte

Orderer

Endorsing Peer Endorsing Peer Peer Peer Peer

Client

Transaction Flow

Validate

  • 1. Validation of each block
  • 2. If positive, it goes in

the ledger

slide-16
SLIDE 16

BLOCKCHAIN Technology&Applications

edoardoconte

Hyperledger Composer

Framework over Fabric

Logic

2

Access Control

3

Modeling language

1

  • Participant
  • Asset
  • Transaction
  • Event
  • Definition of the

transaction logic

  • Javascript code
  • Permissions
  • n resources
  • Complex

conditioned rules

slide-17
SLIDE 17

BLOCKCHAIN Technology&Applications

edoardoconte

Model.cto

/** * Definition of participants */ participant Person identified by username {

  • String username
  • String fullName
  • String email optional
  • String number optional

} participant Manufacturer identified by makerId {

  • String makerId
  • String name

}

slide-18
SLIDE 18

BLOCKCHAIN Technology&Applications

edoardoconte

Model.cto

/** * Definition of assets */ asset Vehicle identified by vin {

  • String vin
  • VehicleDetails vehicleDetails
  • -> Person owner

}

slide-19
SLIDE 19

BLOCKCHAIN Technology&Applications

edoardoconte

Model.cto

/** * Definition of transactions */ transaction ChangeOwner {

  • -> Vehicle vehicle
  • -> Person newOwner

} transaction SellVehicle {

  • VehicleDetails vehicleDetails
  • String vin
  • -> Person owner

}

slide-20
SLIDE 20

BLOCKCHAIN Technology&Applications

edoardoconte

Logic.js

/** * Sell vehicle transaction * @param {org.acme.vehicle.SellVehicle} arg * @transaction */ function onSellVehicle (arg) { }

slide-21
SLIDE 21

BLOCKCHAIN Technology&Applications

edoardoconte

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;

slide-22
SLIDE 22

BLOCKCHAIN Technology&Applications

edoardoconte

Logic.js

const factory = getFactory(); // Creating the vehicle let vehicle = factory.newResource(namespace, 'Vehicle', vin); vehicle.vehicleDetails = vehicleDetails; vehicle.owner = owner;

slide-23
SLIDE 23

BLOCKCHAIN Technology&Applications

edoardoconte

Logic.js

Update

// Updating the registry return getAssetRegistry(namespace + '.Vehicle’) .then ( assetRegistry => { return assetRegistry.add(vehicle); })

slide-24
SLIDE 24

BLOCKCHAIN Technology&Applications

edoardoconte

Logic.js

Update

// Updating the registry return getAssetRegistry(namespace + '.Vehicle’) .then ( assetRegistry => { return assetRegistry.add(vehicle); })

slide-25
SLIDE 25

BLOCKCHAIN Technology&Applications

edoardoconte

Permissions.acl

rule ManufReadsVehicle { description: "Manuf may read a car only if he made it" participant(manuf): "org.acme.vehicle.Manufacturer"

  • peration: READ

resource(vehicle): "org.acme.vehicle.Vehicle" condition: ( manuf.getIdentifier() == vehicle.vehicleDetails.manufacturer.getIdentifier() ) action: ALLOW }

slide-26
SLIDE 26

BLOCKCHAIN Technology&Applications

edoardoconte

Network Set Up

ORG1 ORG2 ORDERER

2 Peers 1 Peer Solo CA CA CouchDB CouchDB

slide-27
SLIDE 27

BLOCKCHAIN Technology&Applications

edoardoconte

Node 1

Orderer

Node 2

SQL DB

Node 4 Node 3

Org 1 Endorsing Peer CouchDB Org1 CA Org 1 Peer CouchDB NodeJs App

SQL DB

Org 2 Endorsing Peer CouchDB Org 2 CA NodeJs App

Client

  • Each element is a Docker container
  • Docker Swarm to communicate
  • API exposed by NodeJs
  • Composer SDK in NodeJs
slide-28
SLIDE 28

BLOCKCHAIN Technology&Applications

edoardoconte

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); }

Blockchain

connection

slide-29
SLIDE 29

BLOCKCHAIN Technology&Applications

edoardoconte

Submit Transaction

Blockchain

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);

slide-30
SLIDE 30

BLOCKCHAIN Technology&Applications

edoardoconte

Submit Transaction

Blockchain

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);

slide-31
SLIDE 31

BLOCKCHAIN Technology&Applications

edoardoconte

Repositories

https://bitbucket.org/hugrave/composer-vehicle-network/ https://bitbucket.org/hugrave/blockchain_server/

slide-32
SLIDE 32

BLOCKCHAIN Technology&Applications

edoardoconte

Performance evaluation

Benchmark done with 1000 assets GET —> ~ 10 seconds PUT, DELETE —> ~ 100 SECONDS

Improvement through Cloud deployment Not real-time applications

slide-33
SLIDE 33

BLOCKCHAIN Technology&Applications

edoardoconte

PRIVACY

Rich conditioned language

Permissions in Hyperledger Composer

BUT…

The ledger remains in plain-text!

/var/hyperledger/production/ledgersData/chains/chains/{channel_name}/

slide-34
SLIDE 34

BLOCKCHAIN Technology&Applications

edoardoconte

DO NOT DESPAIR!

slide-35
SLIDE 35

BLOCKCHAIN Technology&Applications

edoardoconte

Peer 1 Peer 2 Peer 3

Fabric Channels

Channel 1 Channel 2 Channel 3

slide-36
SLIDE 36

BLOCKCHAIN Technology&Applications

edoardoconte

Peer 1 Peer 2 Peer 3

Fabric Channels

Channel 1 Channel 2 Channel 3 Channel 3 Peer 1 joined channel 3 Peer3 joined channel 2 Channel 2

slide-37
SLIDE 37

BLOCKCHAIN Technology&Applications

edoardoconte

Off-chain encryption decryption

slide-38
SLIDE 38

BLOCKCHAIN Technology&Applications

edoardoconte

Off-chain encryption decryption

Client1 D B Data inserted in the blockchain is encrypted Decryption is possible only with the keys NodeJs Org1

slide-39
SLIDE 39

Off-chain encryption decryption

D B

BLOCKCHAIN Technology&Applications

edoardoconte

Client1 Data inserted in the blockchain is encrypted Decryption is possible only with the keys NodeJs Org1

slide-40
SLIDE 40

BLOCKCHAIN Technology&Applications

edoardoconte

Off-chain encryption decryption

Client1 Client2 D B D B

Authorization is a secure keys exchange

NodeJs Org1 NodeJs Org2

slide-41
SLIDE 41

BLOCKCHAIN Technology&Applications

edoardoconte

Off-chain encryption decryption

Client1 Client2 D B D B NodeJs Org1 NodeJs Org2

slide-42
SLIDE 42

BLOCKCHAIN Technology&Applications

edoardoconte

CONCLUSIONS

They can rely on a robust architecture

b

Each company checks directly wether the structure

  • f the network is respected

c

Companies may share their data securely

a d Performances may be improved

through Cloud deployment or container optimizations

e Privacy must be taken into

account in order to separate data

slide-43
SLIDE 43

E ndless Possibilities

Thank you for the attention

Edoardo Conte

BLOCKCHAIN Technology&Applications

edoardoconte

slide-44
SLIDE 44