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
Ledger P2P distributed, append-only, transaction list Blockchain cryptographic validation, distributed consensus mechanism Smart Contracts code embedded in the blockchain, manipulates the blockchain state
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
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
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
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
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
Distribution via a p2p model (no master) • Consensus model used to ensure integrity • Append only “immutable” store • Highly fault tolerant • Eventually consistent 19
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
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 …
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
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
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 <payee pub key hash> OP_EQUAL OP_CHECKSIG Unlock: <payee signature> <payee pub key> 28
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
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
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
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, …