Blockchain. CS 240: Computing Systems and Concurrency Lecture 20. Marco Canini

Similar documents
Problem: Equivocation!

Bitcoin and Blockchain

Bitcoin. CS6450: Distributed Systems Lecture 20 Ryan Stutsman

EECS 498 Introduction to Distributed Systems

ENEE 457: E-Cash and Bitcoin

CS 4770: Cryptography. CS 6750: Cryptography and Communication Security. Alina Oprea Associate Professor, CCIS Northeastern University

University of Duisburg-Essen Bismarckstr Duisburg Germany HOW BITCOIN WORKS. Matthäus Wander. June 29, 2011

CS 4770: Cryptography. CS 6750: Cryptography and Communication Security. Alina Oprea Associate Professor, CCIS Northeastern University

Bitcoin (Part I) Ken Calvert Keeping Current Seminar 22 January Keeping Current 1

Blockchains & Cryptocurrencies

Computer Security. 14. Blockchain & Bitcoin. Paul Krzyzanowski. Rutgers University. Spring 2019

How Bitcoin achieves Decentralization. How Bitcoin achieves Decentralization

Cryptography and Cryptocurrencies. Intro to Cryptography and Cryptocurrencies

SCP: A Computationally Scalable Byzantine Consensus Protocol for Blockchains

Introduction to Bitcoin I

Smalltalk 3/30/15. The Mathematics of Bitcoin Brian Heinold

Biomedical Security. Cipher Block Chaining and Applications

SpaceMint Overcoming Bitcoin s waste of energy

Applied cryptography

Blockchain, Cryptocurrency, Smart Contracts and Initial Coin Offerings: A Technical Perspective

SmartPool: practical decentralized pool mining. Loi Luu, Yaron Velner, Jason Teutsch, and Prateek Saxena August 18, 2017

ICS 421 & ICS 690. Bitcoin & Blockchain. Assoc. Prof. Lipyeow Lim Information & Computer Sciences Department University of Hawai`i at Mānoa

Ensimag - 4MMSR Network Security Student Seminar. Bitcoin: A peer-to-peer Electronic Cash System Satoshi Nakamoto

Distributed Algorithms Bitcoin

Consensus & Blockchain

P2P BitCoin: Technical details

Bitcoin (and why it uses SO much energy)

Biomedical and Healthcare Applications for Blockchain. Tiffany J. Callahan Computational Bioscience Program Hunter/Kahn Labs

Biomedical Security. Some Security News 10/5/2018. Erwin M. Bakker

Bitcoin, Security for Cloud & Big Data

Chapter 13. Digital Cash. Information Security/System Security p. 570/626

Security Analysis of Bitcoin. Dibyojyoti Mukherjee Jaswant Katragadda Yashwant Gazula

Catena: Preventing Lies with

A Gentle Introduction To Bitcoin Mining

BlockFin A Fork-Tolerant, Leaderless Consensus Protocol April

BITCOIN MECHANICS AND OPTIMIZATIONS. Max Fang Philip Hayes

The Blockchain. Josh Vorick

Security (and finale) Dan Ports, CSEP 552

A Lightweight Blockchain Consensus Protocol

Radix - Public Node Incentives

Jan Møller Co-founder, CTO Chainalysis

Proof-of-Work & Bitcoin

Anupam Datta CMU. Fall 2015

Blockchain for Enterprise: A Security & Privacy Perspective through Hyperledger/fabric

Whitepaper Rcoin Global

Bitcoin/Namecoin/*coin: On Bitcoin like protocols and their relation to other IT-Security issues

GRADUBIQUE: AN ACADEMIC TRANSCRIPT DATABASE USING BLOCKCHAIN ARCHITECTURE

New Cryptocurrency Protocol without Proof of Work

Bitcoin, a decentralized and trustless protocol

Lecture 6. Mechanics of Bitcoin

Ergo platform. Dmitry Meshkov

Fruitchains: A Fair Blockchain?

What is Bitcoin? How Bitcoin Works. Outline. Outline. Bitcoin. Problems with Centralization

Proof-of-Stake Protocol v3.0

Formally Specifying Blockchain Protocols

BLOCKCHAIN The foundation behind Bitcoin

I. Introduction. II. Security, Coinage and Attacks

Upgrading Bitcoin: Segregated Witness. Dr. Johnson Lau Bitcoin Core Contributor Co-author of Segregated Witness BIPs March-2016

Who wants to be a millionaire? A class in creating your own cryptocurrency

CS 251: Bitcoin and Crypto Currencies Fall 2015

BYZANTINE CONSENSUS THROUGH BITCOIN S PROOF- OF-WORK

SOME OF THE PROBLEMS IN BLOCKCHAIN TODAY

About cryptocurrencies and blockchains part 1. Jyväskylä 17th of April 2018 Henri Heinonen

What is Proof of Work?

Hyperledger fabric: towards scalable blockchain for business

Neel Gupte. Index Terms Bitcoin, Cryptocurreny, Block Chain, Hashing, Proof-of-Work, Double-spending, Momentum Method, Proof of Stake.

Ergo platform: from prototypes to a survivable cryptocurrency

Crypto tricks: Proof of work, Hash chaining

Software Security. Final Exam Preparation. Be aware, there is no guarantee for the correctness of the answers!

Lecture 3. Introduction to Cryptocurrencies

Ergo platform overview

Proof of Stake Made Simple with Casper

BLOCKCHAIN Blockchains and Transactions Part II A Deeper Dive

Efficient Data Structures for Tamper-Evident Logging

Keychat: Secure Messaging via Bitcoin. Robert Chen, John Kuszmaul, Yiming Zheng Mentored By Alin Tomescu

Hawk: The Blockchain Model of Cryptography and Privacy-Preserving Smart Contracts. Yashar Dehkan Asl

Payment systems. Tuomas Aura CSE-C3400 Information security. Aalto University, autumn 2014

Let's build a blockchain!

Introduc)on to Bitcoin

Alternative Consensus Algorithms. Murat Osmanoglu

On the impact of propogation delay on mining rewards in Bitcoin. Xuan Wen 1. Abstract

Reliability, distributed consensus and blockchain COSC412

CONSENSUS PROTOCOLS & BLOCKCHAINS. Techruption Lecture March 16 th, 2017 Maarten Everts (TNO & University of Twente)

Information Security. message M. fingerprint f = H(M) one-way hash. 4/19/2006 Information Security 1

TOPPERCASH TOPPERCASH WHITEPAPER REFORM THE BEST OF BLOCKCHAIN

Analyzing Bitcoin Security. Philippe Camacho

Lecture 9. Anonymity in Cryptocurrencies

BITCOIN PROTOCOL & CONSENSUS: A HIGH LEVEL OVERVIEW

Darkcoin: Peer to Peer Crypto Currency with Anonymous Blockchain Transactions and an Improved Proof of Work System

Privacy Enhancing Technologies CSE 701 Fall 2017

An Introduction to Blockchain and Distributed Ledger Technology

Bitcoin Mining. A high-level technical introduction. Konstantinos Karasavvas

Modern key distribution with ClaimChains

Catena: Efficient Non-equivocation via Bitcoin

BBc-1 : Beyond Blockchain One - An Architecture for Promise-Fixation Device in the Air -

How Bitcoin Achieves Decentralization

As a 3rd generation currency, not only are transactions secured, private and fast, you actually get paid for holding DigitalPrice coins.

Radix - Tempo. Dan Hughes Abstract

REM: Resource Efficient Mining for Blockchains

Bitcoin Transaction Fee Estimation Using Mempool State and Linear Perceptron Machine Learning Algorithm

Transcription:

Blockchain CS 240: Computing Systems and Concurrency Lecture 20 Marco Canini Credits: Michael Freedman and Kyle Jamieson developed much of the original material.

Bitcoin: 10,000 foot view New bitcoins are created every ~10 min, owned by miner (more on this later) Thereafter, just keep record of transfers e.g., Alice pays Bob 1 BTC Basic protocol: Alice signs transaction: txn = Sign Alice (BTC, PK Bob ) Alice shows transaction to others 2

Problem: Equivocation! Can Alice pay both Bob and Charlie with same bitcoin? ( Known as double spending ) 3

How traditional e-cash handled problem Bank Alice Bob When Alice pays Bob with a coin, Bob validates that coin hasn t been spend with trusted third party Introduced blind signatures and zero-knowledge protocols so bank can t link withdrawals and deposits 4

How traditional e-cash handled problem Bank Alice Bob When Alice pays Bob with a coin, Bob validates that coin hasn t been spend with trusted third party Introduced blind signatures and zero-knowledge protocols Bank so bank maintains can t link withdrawals linearizable and deposits log of transactions 5

Problem: Equivocation! Goal: No double-spending in decentralized environment Approach: Make transaction log 1. public 2. append-only 3. strongly consistent 6

Bitcoin: 10,000 foot view Public Transactions are signed: txn = Sign Alice (BTC, PK Bob ) All transactions are sent to all network participants No equivocation: Log append-only and consistent All transactions part of a hash chain Consensus on set/order of operations in hash chain 7

Cryptographic hash function ( and their use in blockchain ) 8

Cryptography Hash Functions I Take message m of arbitrary length and produces fixed-size (short) number H(m) One-way function Efficient: Easy to compute H(m) Hiding property: Hard to find an m, given H(m) Assumes m has sufficient entropy, not just { heads, tails } Random: Often assumes for output to look random 9

Cryptography Hash Functions II Collisions exist: possible inputs >> possible outputs but hard to find Collision resistance: Strong resistance: Find any m!= m such that H(m) == H(m ) Weak resistance: Given m, find m such that H(m) == H(m ) For 160-bit hash (SHA-1) Finding any collision is birthday paradox: 2^{160/2} = 2^80 Finding specific collision requires 2^160 10

Hash Pointers h = H( ) (data) 11

Hash chains H( ) prev: H( ) prev: H( ) prev: H( ) data data data Creates a tamper-evident log of data 12

Hash chains H( ) prev: H( ) prev: H( ) prev: H( ) data data data If data changes, all subsequent hash pointers change Otherwise, found a hash collision! 13

Blockchain Append-only hash chain 14

Blockchain: Append-only hash chain prev: H( ) txn 5 prev: H( ) txn 6 prev: H( ) txn 7 Hash chain creates tamper-evident log of txns Security based on collision-resistance of hash function Given m and h = hash(m), difficult to find m such that h = hash(m ) and m!= m 15

Blockchain: Append-only hash chain 16

Problem remains: forking prev: H( ) txn 5 prev: H( ) txn 6 prev: H( ) txn 7 prev: H( ) txn 6 prev: H( ) txn 7 17

Goal: Consensus Recall Byzantine fault-tolerant protocols to achieve consensus of replicated log Requires: n >= 3f + 1 nodes, at most f faulty Problem Communication complexity is n 2 Requires view of network participants 18

Consensus susceptible to Sybils All consensus protocols based on membership assume independent failures which implies strong notion of identity Sybil attack (P2P literature ~2002) Idea: one entity can create many identities in system Typical defense: 1 IP address = 1 identity Problem: IP addresses aren t difficult / expensive to get, esp. in world of botnets & cloud services 19

Consensus based on work Rather than count IP addresses, bitcoin counts the amount of CPU time / electricity that is expended The system is secure as long as honest nodes collectively control more CPU power than any cooperating group of attacker nodes. - Satoshi Nakamoto Proof-of-work: Cryptographic proof that certain amount of CPU work was performed 20

Key idea: Chain length requires work prev: H( ) prev: H( ) prev: H( ) prev: H( ) prev: H( ) txn 5 txn 6 txn 7 txn 8 txn 9 prev: H( ) txn 6 Generating a new block requires proof of work Correct nodes accept longest chain Creating fork requires rate of malicious work >> rate of correct So, the older the block, the safer it is from being deleted 21

Use hashing to determine work! Hash functions are one-way / collision resistant Given h, hard to find m such that h = hash(m) But what about finding partial collision? m whose hash has most significant bit = 0? m whose hash has most significant bit = 00? Assuming output is randomly distributed, complexity grows exponentially with # bits to match 22

Bitcoin proof of work Find nonce such that hash (nonce prev_hash block data) < target i.e., hash has certain number of leading 0 s What about changes in total system hashing rate? Target is recalculated every 2 weeks Goal: One new block every 10 minutes 23

Historical hash rate trends of bitcoin Currently: 8.2 Exahash/s 2 x 10 18 Tech: CPU GPU FPGA ASICs 24

Historical hash rate trends of bitcoin Currently (Nov 17): https://bitcoinwisdom.com/bitcoin/difficulty 11 Exahash/s 2 x 10 18 Tech: CPU GPU FPGA ASICs 25

Why consume all this energy? Creating a new block creates bitcoin! Initially 50 BTC, decreases over time, currently 12.5 New bitcoin assigned to party named in new block Called mining as you search for gold/coins 26

Incentivizing correct behavior? Race to find nonce and claim block reward, at which time race starts again for next block hash (nonce prev_hash block data) As solution has prev_hash, corresponds to particular chain Correct behavior is to accept longest chain Length determined by aggregate work, not # blocks So miners incentivized only to work on longest chain, as otherwise solution not accepted Remember blocks on other forks still create bitcoin, but only matters if chain in collective conscious (majority) 27

Form of randomized leader election Each time a nonce is found: New leader elected for past epoch (~10 min) Leader elected randomly, probability of selection proportional to leader s % of global hashing power Leader decides which transactions comprise block 28

One block = many transactions Each miner picks a set of transactions for block Builds block header : prevhash, version, timestamp, txns, Until hash < target OR another node wins: Pick nonce for header, compute hash = SHA256(SHA256(header)) 29

Transactions are delayed At some time T, block header constructed Those transactions had been received [ T 10 min, T] Block will be generated at time T + 10 min (on average) So transactions are from 10-20 min before block creation Can be much longer if backlog of transactions are long 30

Commitments further delayed When do you trust a transaction? After we know it is stable on the hash chain Recall that the longer the chain, the hard to revert Common practice: transaction committed when 6 blocks deep i.e., Takes another ~1 hour for txn to become committed 31

Transaction format: strawman Create 12.5 coins, credit to Alice Transfer 3 coins from Alice to Bob SIGNED(Alice) Transfer 8 coins from Bob to Carol SIGNED(Bob) Transfer 1 coins from Carol to Alice SIGNED(Carol) Transfer 5 coins from Alice to David SIGNED(Alice) How do you determine if Alice has balance? Scan backwards to time 0! 32

Transaction format Inputs: Ø // Coinbase reward Outputs: 25.0 PK_Alice Inputs: H(prevtxn, 0) // 25 BTC from Alice Outputs: 25.0 PK_Bob SIGNED(Alice) Inputs: H (prevtxn, 0) change address // 25 BTC From Alice Outputs: 5.0 PK_Bob, 20.0 PK_Alice2 SIGNED(Alice) Inputs: H (prevtxn1, 1), H(prevtxn2, 0) // 10+5 BTC Outputs: 14.9 PK_Bob SIGNED(Alice) Transaction typically has 1+ inputs, 1+ outputs Making change: 1 st output payee, 2 nd output self Output can appear in single later input (avoids scan back) 33

Transaction format Inputs: Ø // Coinbase reward Outputs: 25.0 PK_Alice Inputs: H(prevtxn, 0) // 25 BTC from Alice Outputs: 25.0 PK_Bob SIGNED(Alice) Inputs: H (prevtxn, 0) // 25 BTC From Alice Outputs: 5.0 PK_Bob, 20.0 PK_Alice SIGNED(Alice) Inputs: H (prevtxn1, 1), H(prevtxn2, 0) // 10+5 BTC Outputs: 14.9 PK_Bob SIGNED(Alice) Unspent portion of inputs is transaction fee to miner In fact, outputs are stack-based scripts 1 Block = 1MB max 34

Storage / verification efficiency Merkle tree Binary tree of hashes Root hash binds leaves given collision resistance Using a root hash Block header now constant size for hashing Can prune tree to reduce storage needs over time 35

Storage / verification efficiency Merkle tree Binary tree of hashes Root hash binds leaves given collision resistance Using a root hash Block header now constant size for hashing Can prune tree to reduce storage needs over time Can prune when all txn outputs are spent Now: 168GB 36

Not panacea of scale as some claim Scaling limitations 1 block = 1 MB max 1 block ~ 2000 txns 1 block ~ 10 min So, 3-4 txns / sec block size Log grows linearly, joining requires full dload and verification Visa peak load comparison Typically 2,000 txns / sec Peak load in 2013: 47,000 txns / sec 37

Summary Coins xfer/split between addresses (PK) in txns Blockchain: Global ordered, append-only log of txns Reached through decentralized consensus Each epoch, random node selected to batch transactions into block and append block to log Nodes incentivized to perform work and act correctly When solve block, get block rewards + txn fees Reward: 12.5 BTC @ ~8100 USD/BTC (11-22-17) = $101250 / 10 min Only keep reward if block persists on main chain 38

Bitcoin & blockchain intrinsically linked security of blockchain health of mining ecosystem value of currency 39

Rich ecosystem: Mining pools health of mining ecosystem Mining == gambling: Electricity costs $, huge payout, low probability of winning Development of mining pools to amortize risk Pool computational resources, participants paid to mine e.g., rewards split as a fraction of work, etc Verification? Demonstrate easier proofs of work to admins Prevent theft? Block header (coinbase txn) given by pool 40

More than just currency 41

42

More in CS 394 (Spring 18) 43

Sunday topic:? 44