Slide 1

Slide 1 text

A Breathless Tour of Blockchain Eoin Woods Endava @eoinwoodz 1 licensed under a Creative Commons Attribution-ShareAlike 4.0 International License

Slide 2

Slide 2 text

Agenda • What is Blockchain? • Applications for Blockchain • Blockchain as an Architectural Element • Programming the Blockchain • Summary 2

Slide 3

Slide 3 text

What is Blockchain? 3

Slide 4

Slide 4 text

What is Blockchain? • The enabling technology of Bitcoin • A distributed database without a controlling authority • An auditable database with provable lineage • A way to collaborate with principals without trust • Trust and storage mechanism for cryptocurrencies • Architectural component for Internet-scale systems? 4

Slide 5

Slide 5 text

What is Blockchain? Basic terms 5 Crypto Currencies Ether Distributed Ledger P2P distributed, append-only, transaction list Blockchain cryptographic validation, distributed consensus mechanism Smart Contracts code embedded in the blockchain, manipulates the blockchain state

Slide 6

Slide 6 text

What is Blockchain? Bitcoin network example Miners Bob Alice 6

Slide 7

Slide 7 text

What is Blockchain? Blockchain structure Transaction 1 Transaction 2 Transaction 3 Block Hash Prev Block Hash Transaction 4 Transaction 5 Transaction 6 Block Hash Prev Block Hash Transaction 7 Transaction 8 Transaction 9 Block Hash Prev Block Hash Transaction 10 • Public keys identify participants • Bitcoin addresses identify participants in a transaction (derived from PK) • Cryptographic hashes used to ensure integrity 7

Slide 8

Slide 8 text

What is Blockchain? Consensus Q. How do we know the information on the chain is correct? A. Because everyone agrees – this is “consensus” Blockchains use different types but “proof of work” is common • To create (“mine”) a block you need to solve a hard problem • If you don’t solve the problem then peers will reject your block • Thus forging the blockchain would require a huge amount of work to get your fraudulent blocks accepted (“impossible” without 51% of capacity) Other models including “proof of stake” and “proof of membership” 8

Slide 9

Slide 9 text

Applications for Blockchain 9

Slide 10

Slide 10 text

What blockchains exist? A lot of blockchain implementations exist. A small sample of them are: Bitcoin 2009 Cryptocurrency Litecoin 2011 Cryptocurrency Ripple 2012 Blockchain payment and settlement system Chain 2014 Enterprise blockchain Ethereum 2015 Blockchain dapp platform Hyperledger 2015 Linux Foundation open source blockchain projects R3 Corda 2016 Distributed ledger for the financial industry Multichain 2017 Enterprise blockchain 10

Slide 11

Slide 11 text

Cryptocurrencies – August 2017 10 cryptocurrencies market cap of > $1B Bitcoin is $70B. source: coinmarketcap.com 11

Slide 12

Slide 12 text

Cryptocurrencies – September 2017 11 cryptocurrencies market cap of > $1B Bitcoin is $62B. source: coinmarketcap.com 12

Slide 13

Slide 13 text

Sidenote: Cryptocurrency Volatility 13 source: coinmarketcap.com

Slide 14

Slide 14 text

What is Blockchain being Used For? Trade Settlement and FX Transactions digital ledger that tracks and protects valuable assets verifiable supply chains post-trade processing Keybase Identity management verified data Georgia government records supply chain efficiency 14

Slide 15

Slide 15 text

Properties of a Good Blockchain Application • Multiple separate parties want to cooperate • No central intermediary exists (or is wanted) • Relatively slow moving processes (allow latency) • Well-defined, bounded process • Predictable, simple data access required 15

Slide 16

Slide 16 text

Demo: Browse a blockchain blockchain.info Most public blockchains have a range of associated web based “explorers” • For Bitcoin we’ll use blockchain.info • For Ethereum we’ll use etherscan.io etherscan.io 16

Slide 17

Slide 17 text

Demo: Explore a blockchain • The WannaCry ransomware attackers have 3 bitcoin wallets: • 13AM4VW2dhxYgXeQepoHkHSQuy6NgaEb94 • 115p7UMMngoj1pMvkpHijcRdfJNXj6LrLn • 12t9YDPgwueZ9NyMgw519p7AA8isjr6SMw • We can use blockchain.info to find out how much they have collected in ransom so far and where they sent it • Note: if using the API it returns values in satoshis: there are 10-8 satoshis in a bitcoin, so multiply by 0.00000001 to get BTC 17

Slide 18

Slide 18 text

Blockchain as an Architectural Element 18

Slide 19

Slide 19 text

Characteristics of a Blockchain Ledger • Distributed, replicated “database” • Distribution via a p2p model (no master) • Consensus model used to ensure integrity • Append only “immutable” store • Highly fault tolerant • Eventually consistent 19

Slide 20

Slide 20 text

Adding Smart Contracts • Code stored in a blockchain, executed by the blockchain virtual machine • Programming models vary by platform • Bitcoin - primitive ”Forth” script • IBM Hyperledger – GoLang • Ethereum - Solidity • Ethereum Solidity is our example in this session 20

Slide 21

Slide 21 text

Example: Ethereum Solidity Smart Contract contract Coin { // The keyword "public" makes those variables readable from outside. address public minter; mapping (address => uint) public balances; // Events allow light clients to react on changes efficiently. event Sent(address from, address to, uint amount); // This is the constructor whose code is run only when the contract is created. function Coin() { minter = msg.sender; } function mint(address receiver, uint amount) { if (msg.sender != minter) return; balances[receiver] += amount; } function send(address receiver, uint amount) { if (balances[msg.sender] < amount) return; balances[msg.sender] -= amount; balances[receiver] += amount; Sent(msg.sender, receiver, amount); } } 21 // More details later …

Slide 22

Slide 22 text

Quality Properties of a Distributed Ledger Useful Qualities • Append only • Security (integrity, non- repudiation, availability) • High fault-tolerance • No single point control or trust • Embedded immutable logic • Dynamic, evolving ecosystem Problematic Qualities • (very) eventual consistency • computationally expensive (generally) • Limited query model • Lack of privacy • lack of throughput scalability (generally – 10s txn/sec) • Lacking maturity 22

Slide 23

Slide 23 text

Aside: Storing Data • Blockchains not designed for large data items • Some (Bitcoin) optimised for many small transactions • Large data stored “off chain” • e.g. IPFS and Swarm • Store pointer in blockchain 23

Slide 24

Slide 24 text

Integrating Blockchain Blockchain Application (Dapp) Conventional Application Blockchain (e.g. Ethereum) Immutable Storage (e.g. Swarm, IPFS) object references queries, transactions, smart contract invocations 24

Slide 25

Slide 25 text

Thinking Point: Applying Blockchain • What could you use blockchain for? • At work or to change the world! • What problems would it solve or introduce? Recap • distributed, highly reliable, auditable, immutable database, not requiring trust between participants • smart contracts can embed computation in it • but slow, eventually consistent, limited queries 25

Slide 26

Slide 26 text

Programming Blockchain 26

Slide 27

Slide 27 text

Smart Contracts • The “programming” bit of blockchain technology • Code in the blockchain executed by the runtime • Any participant can add a smart contract (for a fee) • Contract usually mutates the state of the blockchain • add another transaction • Transforms blockchain to a dynamic system • A bit like triggers and stored procedures in RDBMS 27

Slide 28

Slide 28 text

Bitcoin “Script” • Very simple “FORTH-like” virtual machine • Constrained programming model of “locking” and ”unlocking” scripts • Locking script (“scriptPubKey”) defines constraints to execute the transaction • Unlocking script (“scriptSig”) satisfies the constraints to allow execution • Small number of “op codes” for use in scripts. Example Lock: OP_DUP OP_HASH160 OP_EQUAL OP_CHECKSIG Unlock: 28

Slide 29

Slide 29 text

Bitcoin “Script” OP_DUP OP_HASH160 OP_EQUAL OP_CHECKSIG Stack based execution: (Push 2 arguments) OP_DUP OP_HASH160 (Push argument) OP_EQUAL (= T) OP_CHECKSIG (= T) 29

Slide 30

Slide 30 text

Ethereum Solidity • Most popular contract language for Ethereum • Turing complete, object-oriented language • Inheritance and user-defined types • Compiles to bytecode that runs on the EVM • Emerging eco-system of frameworks and tools 30

Slide 31

Slide 31 text

Ethereum Solidity contract Coin { // The keyword "public" makes those variables readable from outside. address public minter; mapping (address => uint) public balances; // Events allow light clients to react on changes efficiently. event Sent(address from, address to, uint amount); // This is the constructor whose code is run only when the contract is created. function Coin() { minter = msg.sender; } function mint(address receiver, uint amount) { if (msg.sender != minter) return; balances[receiver] += amount; } function send(address receiver, uint amount) { if (balances[msg.sender] < amount) return; balances[msg.sender] -= amount; balances[receiver] += amount; Sent(msg.sender, receiver, amount); } } Contract Typed state Event for log (and callback) Functions to operate on state 31

Slide 32

Slide 32 text

Solidity & Ethereum Development Ecosystem 32 Geth Eth Pyethapp Clients for JS, .NET and Java Development Tools Mist Wallet MetaMask ether.camp

Slide 33

Slide 33 text

Summary 33

Slide 34

Slide 34 text

Key Concepts 34 Distributed Ledgers • p2p append-only transaction stores Blockchains • cryptographically validated ledgers Smart Contracts • immutable code changing blockchain state

Slide 35

Slide 35 text

What is Blockchain? • A novel type of distributed transaction store • Append-only, auditable, fault tolerant, secure by design • Can be slow and high-latency by accident • Most host “smart contract” code to provide secure computations 35

Slide 36

Slide 36 text

Some Applications 36 Value Transfers: securities clearing, payments Verifiable Records: property registers, supply chain, loyalty points Identity: verifiable digital identity, passports Verifiable Storage: immutable storage of digital assets Decentralised Notary: proof of existence of digital asset Currencies: Bitcoin, Ether, Litecoin, …

Slide 37

Slide 37 text

To Find Out more • Bitcoin – bitcoin.org • Ethereum – ethereum.org • Solidity - solidity.readthedocs.io • Truffle - truffleframework.com • Embark - github.com/iurimatias/embark-framework • Dapp - dapp.readthedocs.io • IPFS – ipfs.io • Swarm - swarm-gateways.net • News – coindesk.com, cryptoinsider.com (and many others) 37

Slide 38

Slide 38 text

Eoin Woods Endava eoin.woods@endava.com @eoinwoodz Thank You 38