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

Similar documents
ENEE 457: E-Cash and Bitcoin

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

Problem: Equivocation!

Bitcoin and Blockchain

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

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

Introduction to Bitcoin I

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

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

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

Applied cryptography

Security Analysis of Bitcoin. Dibyojyoti Mukherjee Jaswant Katragadda Yashwant Gazula

Jan Møller Co-founder, CTO Chainalysis

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

Biomedical Security. Cipher Block Chaining and Applications

P2P BitCoin: Technical details

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

Bitcoin. CS6450: Distributed Systems Lecture 20 Ryan Stutsman

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, a decentralized and trustless protocol

Consensus & Blockchain

SpaceMint Overcoming Bitcoin s waste of energy

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

Introduction to Cryptography in Blockchain Technology. December 23, 2018

Ergo platform. Dmitry Meshkov

Analyzing Bitcoin Security. Philippe Camacho

Burstcoin Technical information about mining and block forging

Security: Focus of Control

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

Introduc)on to Bitcoin

Anupam Datta CMU. Fall 2015

EECS 498 Introduction to Distributed Systems

Anupam Datta CMU. Spring 2017

BITCOIN PROTOCOL & CONSENSUS: A HIGH LEVEL OVERVIEW

Ethereum. Campbell R. Harvey* Duke University and NBER. Ashwin Ramachandran Duke University. Brent Xu ConsenSys. Innovation and Cryptoventures

Blockchain Certification Protocol (BCP)

ECC: Peer-to-Peer Electronic Cash with Trustless Network Services

Lecture 6. Mechanics of Bitcoin

Bitcoin (and why it uses SO much energy)

Key Security Issues for implementation of Digital Currency, including ITU-T SG17 activities

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

The Blockchain. Josh Vorick

BLOCKCHAIN Blockchains and Transactions Part II A Deeper Dive

A Gentle Introduction To Bitcoin Mining

Blockchain Bitcoin & Ethereum

Proof-of-Work & Bitcoin

Cryptography and Cryptocurrencies. Intro to Cryptography and Cryptocurrencies

DAVID ANDREWS, FOUNDER RYATTA BLOCKCHAIN FOUNDATIONS

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

Blockchains & Cryptocurrencies

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

Blockchain (a.k.a. the slowest, most fascinating database you ll ever see)

BLOCKCHAIN The foundation behind Bitcoin

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

Technical Analysis of Established Blockchain Systems

Distributed Ledger With Secure Data Deletion

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

Digital Currencies: Algorithms and Protocols

BYZANTINE CONSENSUS THROUGH BITCOIN S PROOF- OF-WORK

Distributed Algorithms Bitcoin

Bitcoin. Arni Par ov. December 17, 2013

CS 251: Bitcoin and Crypto Currencies Fall 2015

Blockchain without Bitcoin. Muralidhar Gopinath October 19, 2017 University at Albany

Transactions as Proof-of-Stake! by Daniel Larimer!

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

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

Realization and Addressing Analysis In Blockchain Bitcoin

BITCOIN MECHANICS AND OPTIMIZATIONS. Max Fang Philip Hayes

Elphyrecoin (ELPH) a Private, Untraceable, ASIC-Resistant CryptoCurrency Based on CryptoNote

Payment systems. Tuomas Aura T Information security technology. Aalto University, autumn 2013

Let's build a blockchain!

Ergo platform overview

Bitcoin a Peer-to-Peer payment solution

Matt Howard and Ajay Patel CIS 556: Cryptography University of Pennsylvania Fall DriveCoin: A Proof of Space Cryptocurrency

Introduction to Cryptoeconomics

SKBI Cryptocurrency Technical Seminar Series Seminar 1: Basics: Cryptography and Transactions

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

Fruitchains: A Fair Blockchain?

Hyperledger fabric: towards scalable blockchain for business

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

Encryption. INST 346, Section 0201 April 3, 2018

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

OpenbankIT: a banking platform for e- money management based on blockchain technology

TURING COMPLETE BITCOIN SCRIPT. White Paper CRAIG WRIGHT, NCHAIN. Electronic copy available at:

Digital Signatures. Luke Anderson. 7 th April University Of Sydney.

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

XSN coin. TPoS Setup Guide.

CS Computer Networks 1: Authentication

How Bitcoin achieves Decentralization. How Bitcoin achieves Decentralization

GRADUBIQUE: AN ACADEMIC TRANSCRIPT DATABASE USING BLOCKCHAIN ARCHITECTURE

Reliability, distributed consensus and blockchain COSC412

BitCoin Project. 1 Description. 1.1 Version exchange. 1.2 Ping-Pong. CMSC 417 Computer Networks Fall 2013

Visualizing and Tracing Bitcoin Transactions

The Technology behind Smart Contracts

FiiiCOIN. Yellow Paper. FiiiCOIN Yellow Paper v0.01. A versatile, scalable and energy efficient blockchain technology. Authors.

Bitcoin. Tom Anderson

Secure digital certificates with a blockchain protocol

An Introduction to Bitcoin

Transcription:

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

Questions What problem is Bitcoin solving? Where did it come from? How does the system work? What makes it secure? What determines how much a Bitcoin is worth? Can I trust the Bitcoin system? 2014.01.22 Keeping Current 2

Background: Payments Today Most money movement is virtual Exactly where/what is the money in your bank account? Payment types: Cash = physical movement of hard currency Check = authorizes your bank to move $X from your account, to payee s account Debit card = (ditto) Credit card = you CC co. bank merchant How do these transfers actually happen? 2014.01.22 Keeping Current 3

Payment Information Flow Acct Owner, ID Acct Owner, ID Bank X Bob, B Al, A Balance X/B Y/A:$100 X/B Y/A:$100 Various Intermediaries: Visa/MC, Fed, ACH, SWIFT, CHIPS,... 2014.01.22 $20,490.81 Bank Y $821.00 Bob Balance Bob/X/B agrees to pay Al/Y/A: $100.00 Keeping Current Bob/X/B Al/Y/A $100 Al 4

Payment Information Flow Acct Owner, ID Acct Owner, ID Bank X Bob, B Al, A Balance X/B Y/A:$100 X/B Y/A:$100 X/B Y/A:$100 Various Intermediaries: Visa/MC, Fed, ACH, SWIFT, CHIPS,... 2014.01.22 $20,490.81 Bank Y $721.00 Bob Balance X/B Y/A:$100 Bob/X/B agrees to pay Al/Y/A: $100.00 Keeping Current Bob/X/B Al/Y/A $100 Al 5

Payment Information Flow Acct Owner, ID Acct Owner, ID Bank X Bob, B Al, A Balance X/B Y/A:$100 X/B Y/A:$100 X/B Y/A:$100 Various Intermediaries: Visa/MC, Fed, ACH, SWIFT, CHIPS,... 2014.01.22 $20,590.81 Bank Y $721.00 Bob Balance X/B Y/A:$100 Bob/X/B agrees to pay Al/Y/A: $100.00 Keeping Current Bob/X/B Al/Y/A $100 Al 6

Payment Information Flow Acct Owner, ID Acct Owner, ID Bank X Bob, B Al, A Balance Balance $20,590.81 Bank Y $721.00 Various Intermediaries: Visa/MC, Fed, ACH, SWIFT, CHIPS,... Bob 2014.01.22 Payments are made by changing account balances. Banks are trusted ensses that maintain the records. Keeping Current Al 7

How Payments Happen Movement of money Movement of information Financial System Ledger for tracking account balances 2014.01.22 Keeping Current 8

What problem is Bitcoin solving? Where did it come from? Bitcoin Goals: i. Anonymity ii. Decentralization Replace banks with a peer-to-peer network Base trust on cryptography and proof-of-work Proposed in a 2008 paper Bitcoin: A Peer-to-Peer Electronic Cash System Author Satoshi Nakamoto (pseudonym) Software (open source) released in 2009 2014.01.22 Keeping Current 9

Bitcoin: The Basic Idea Keep a record of transactions A shared public ledger Transaction = transfer of bitcoin among parties Maintained by a peer-to-peer network No single entity controls the network Peers communicate via Internet Use cryptography to secure the ledger Digital signatures on each ledger entry Proof-of-work for acceptance Use functions to create proof-of-work 2014.01.22 Keeping Current 10

How It Works I (conceptual view) Ledger Address Amount (BTC) a739de01... 25.0 91a43b20... 0.0000035 c91725ba... 0.5... Bitcoin P2P Network Bob Bob s Agent 2014.01.22 Al TransacSon source of funds =... pay- to address = 13579bdf... amount = 1.0 BTC Keeping Current Al s Agent 11

How It Works I (conceptual view) Ledger Address Amount (BTC) a739de01... 25.0 91a43b20... 0.0000035 c91725ba... 0.5 13579bdf... 1.0... Bitcoin P2P Network Bob Bob s Agent 2014.01.22 Al TransacSon source of funds =... pay- to address = 13579bdf... amount = 1.0 BTC Keeping Current Al s Agent 12

How It Works II (slightly more detail)... Bitcoin Network today: 100K nodes Inputs to a Tx are really (pointers to) outputs of recorded Txs Bob s Agent input 0: input 1:... input k: Ledger = Blocks of Recorded Txs Tx Bob 2014.01.22 output 0: addr=135... amount = 24.0 BTC output 1: addr=246... amount = 1.0 BTC Keeping Current Al Al s Agent 13

How It Works II (slightly more detail) Bitcoin Network today: 100K nodes Network Verifies and Records... Ledger = Blocks of Recorded Txs input 0: input 1:... input k: Tx output 0: addr=135... amount = 24.0 BTC output 1: addr=246... amount = 1.0 BTC Txs are first verified, then recorded by being incorporated into a new block. 2014.01.22 Keeping Current 14

How It Works II (slightly more detail) Bitcoin Network today: 100K nodes Network Verifies and Records... Ledger = Blocks of Recorded Txs input 0: input 1:... input k: Tx output 0: addr=135... amount = 24.0 BTC output 1: addr=246... amount = 1.0 BTC An output can be used as an input to another Tx at most once. (No double- spending.) 2014.01.22 Keeping Current 15

Summary So Far Network of peers validates transactions transferring Bitcoins* and creates a ledger (a set of blocks of transactions.) To be explained: What makes this secure? Anonymous? Short Answer: cryptography Longer answer: details of addresses, transactions, blocks, recording Where do Bitcoins originally come from? *Actually, transactions are denominated in Satoshis. One Satoshi = 10-8 BTC 2014.01.22 Keeping Current 16

Background: Digital Signatures Paired keys: Private key, known only to signer Public key, known to anyone who wants to verify Two operations: sig = sign(private key, message) boolean = verify(signature, message, public key) returns true if sig was created with private key paired with the given public key, else (w.h.p.) false Use: prove/verify authenticity of messages Security: infeasible to forge sig without knowledge of public key 2014.01.22 Keeping Current 17

Background: Digital Signatures private key public key Signer Verifier 2014.01.22 Keeping Current 18

Background: Digital Signatures public key message private key sign Signer 2014.01.22 sig Note: for technical reasons, almost always sign (message) rather than message itself. Keeping Current Verifier 19

Background: Digital Signatures message sig public key private key Verifier Signer 2014.01.22 Keeping Current 20

Background: Digital Signatures public key message private key verify public key Verifier Signer 2014.01.22 sig Keeping Current 21

Background: Digital Signatures public key xx fake msg Forger Verifier 2014.01.22 Keeping Current 22

Background: Digital Signatures public key xx fake msg Forger Verifier 2014.01.22 Keeping Current 23

Background: Digital Signatures public key fake xx msg verify Forger Verifier 2014.01.22 Keeping Current 24

Background: Cryptographic Hash Functions Pseudorandom function h: M D M: set of possible messages (infinite) D: set of fixed-length (e.g., 256 bits) bit strings (finite) Use: h(m) is an unforgeable fingerprint of m Properties: Noninvertible: Given x, infeasible to find m such that h(m) = x Collision-resistant: Infeasible to find m and m such that h(m) = h(m ) Efficient: (relatively) easy to compute h(m), given m 2014.01.22 Keeping Current 25

Background: Cryptographic Hash Functions 01001011101010110101000010101111 00001101011010110101011101000100 01101110100110111110111100000101 11010111100001111011010000011111 11010010001110011011111000100011 10100110010110100000100010100010 00011101010001010101010100101011 01010001011011010010100101010010 10100100101101101011011010101101 10110101010101010111101010100000 11111110000100010001010101111110 10100001100110011001100101010011 11110000011100111101011110101100 00000101110101110111110100010010 11010101010011110110101010001001... Bitcoin funcson: SHA256(SHA256(msg)) 0100110101100100 1110010100001011 0011100111100001 0010011010111111 1000101001100001 1010111110110011 0101000001011100 0110111011110100 0100011100000110 0010110010111000 1110011001111010 1011011111101000 0001001011011111 1001100100011010 1100001011100000 0010011101011100 2014.01.22 Message (arbitrary length) or digest (256 bits) Keeping Current 26

SHA-256 is (believed to be) noninvertible 0100110101100100 1110010100001011 0011100111100001 0010011010111111 1000101001100001 1010111110110011 0101000001011100 0110111011110100 0100011100000110 0010110010111000 1110011001111010 1011011111101000 0001001011011111 1001100100011010 1100001011100000 0010011101011100 256- bit value 2014.01.22 Keeping Current 27

Background: Merkle Hash Tree Hashing a collection of messages If a message changes, only that message and its ancestors need to be re-ed Root 2014.01.22 Keeping Current 28

Background: Merkle Hash Tree Hashing a collection of messages If a message changes, only that message and its ancestors need to be re-ed 2014.01.22 Keeping Current 29

Securing Bitcoin Transactions Problem: verify that Tx inputs are authorized to use the values of referenced (earlier) outputs Solution: a simple custom stack-based ( Forth-like ) scripting system for crypto operations Not Turing-complete (no loops) Typical scripts: To spend an earlier output requires to spender to present: public key that es to the address in the output a signature on the (current) transaction that verifies with that public key Scripting system allows more general requirements E.g., require multiple signatures, or sign by two out of three keys 2014.01.22 Keeping Current 30

Securing Bitcoin Transactions Each output of a transaction consists of: Address: Derived from an ECDSA public key (anonymity) A script that specifies conditions to be satisified when spending this output later Typically: prove knowledge of private key corresponding to address by signing the later transaction Each input of a transaction consists of: A reference to an output in a previous transaction Hash of transaction + which output (index in list) A script ( ScriptSig ) that sets up the stack so that the output script returns true In the typical case: public key for the address + signature on the Tx To verify an input: Execute the input script, then the output script of the referenced transaction If the result is true input is verified 2014.01.22 Keeping Current 31

Bitcoin Address Construction ECDSA Private Key (256 bits) ECDSA Public Key (264 or 520 bits) SHA- 256 256 bits RIPEMD- 160 256 bits SHA- 256 00 160 bits SHA- 256 256 bits 2014.01.22 Keeping Current 32

Bitcoin Address Construction ECDSA Private Key (256 bits) ECDSA Public Key (264 or 520 bits) SHA- 256 256 bits RIPEMD- 160 256 bits SHA- 256 00 160 bits SHA- 256 256 bits Checksum 2014.01.22 Keeping Current 33

Bitcoin Address Construction ECDSA Private Key (256 bits) ECDSA Public Key (264 or 520 bits) SHA- 256 256 bits RIPEMD- 160 256 bits SHA- 256 00 160 bits SHA- 256 256 bits 00 160 bits Checksum Base58Check Encoding Bitcoin Address 2014.01.22 Keeping Current 34

Transaction Verification 1. Syntactic correctness 2. Each input references an output that: Is in a recorded in a block Has not already been used as an input (no double-spending) in a recorded (or pending) 3. Each input signature is valid Script returns true 4. Sum of input values sum of outputs 2014.01.22 Keeping Current 35

Securing the Ledger The problem boils down to: How to ensure that the nodes of the network agree on which transactions have occurred? If different parts of the network have different ideas of the state of the ledger, double-spending could occur. Note: peers flood information (e.g., s) to all other peers as soon as it becomes available 2014.01.22 Keeping Current 36

Securing the Ledger Solution idea: Recording a transaction involves proving that a nontrivial amount of computational work has been done Similar to cash (anit-spam) idea Group transactions into blocks = unit of proof of work As long as good guys control most of the compute power of the network, they will determine what the record contains 2014.01.22 Keeping Current 37

Blocks Group transactions together for recording Block header depends on s included + previous block Root of Merkle tree, of previous block included Blocks form a (backward) chain Change any bit in any have to change all subsequent blocks Block Header version (4) target (4) nonce (4) Hash of Previous Block Header (32 bytes) Merkle Root of Included TransacSons (32 bytes) TransacSon 0 TransacSon 1... Smestamp (4) 2014.01.22 Keeping Current 38

Recording Blocks: Proof of Work Only blocks with (header) < target are added to the chain Bitcoin network s job: find headers with this property Known as mining or solving a block Requires computational work Once a block header is found with the desired property, the block is forwarded to all peers, who validate and then accept it (i.e., add it to the chain) Block Header version (4) target (4) nonce (4) Hash of Previous Block Header (32 bytes) Merkle Root of Included TransacSons (32 bytes) TransacSon 0 TransacSon 1... Smestamp (4) 2014.01.22 Keeping Current 39

Mining (a.k.a. solving a block) Task: Given a set of s, latest block s, current time and target, find a block header such that (header) < target Because () acts like a random function, only approach is brute force: h = (header) while (h >= target) { modify header; // increment nonce h = (header); } Target value determines probability of success Target is adjusted regularly (every 2016 blocks) to keep block generation rate approximately 6 blocks/hour 2014.01.22 Keeping Current 40

Mining: Numbers as of 2014.01.22 Target value: 0000000000000002666600000000000000000000000000000000000000000000 Block header must start with 63 0 bits! Equivalent: Flip a coin 63 times heads every time Probability = 2-63 10-19 Goal is for the network to solve a block every 10 minutes So: Network-wide rate 1.5 x 10 16 /s With 120K nodes 125 GHash/sec/node (!) Most mining nowadays uses special h/w General-purpose servers GPUs ASICS 2014.01.22 Keeping Current 41

How it Works III incoming transacsons Blockchain Verify Clients pending (valid) transacsons Miners... 2014.01.22 Keeping Current 42

How it Works III incoming transacsons Blockchain Verify Clients pending (valid) transacsons Miners... 2014.01.22 Keeping Current 43

How it Works III incoming transacsons Blockchain Verify Clients pending (valid) transacsons Miners... 2014.01.22 Keeping Current 44

How it Works III incoming transacsons Blockchain Verify Clients pending (valid) transacsons Miners... 2014.01.22 Keeping Current 45

Forks in the Block Chain The block chain may fork if multiple blocks are solved at about the same time Once one branch becomes longer, it becomes the main branch No bound on how long this may take! Blockchain... Miners 2014.01.22 Keeping Current 46

Forks in the Block Chain The block chain may fork if multiple blocks are solved at about the same time Once one branch becomes longer, it becomes the main branch No bound on how long this may take! Blockchain... Miners 2014.01.22 Keeping Current 47

Forks in the Block Chain The block chain may fork if multiple blocks are solved at about the same time Once one branch becomes longer, it becomes the main branch No bound on how long this may take! Blockchain... Miners 2014.01.22 Keeping Current 48

Remaining (Technical) Questions Where do Bitcoins originally come from? Nonce + time fields only allow a few billion tries for a header, but several quintillion tries required to solve a given header! 2014.01.22 Keeping Current 49

Coinbase Transaction Transaction 0 in each block is special Its inputs are ignored in validation...but do affect the Merkle root for the block, thus expanding the space of possible es for a given set Output(s) controlled by the one solving the block Originally a reward for solving blocks Total outputs = reward amount + xaction fees Inputs outputs = transaction fee 2014.01.22 Keeping Current 50

Coinbase Transaction Reward determined by formula Reward = (50 x 100000000) >> (height / 210000) Decreases every 210,000 blocks 4 years Fell to 25 BTC at block 210,000 (January 2013) Will fall to 12.5 BTC at block 420,000, etc. Becomes 0 at block 6,930,000. Eventual total of all coinbase transactions: 2,099,999,997,690,000 satoshi 21M BTC Thereafter, mining reward exclusively from transaction fees 2014.01.22 Keeping Current 51