anupam datta cmu fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡a...

42
Anupam Datta CMU Fall 2015

Upload: others

Post on 25-Jul-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

AnupamDattaCMUFall2015

Page 2: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses
Page 3: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

¡  ArationalreconstructionofBitcoin

1.  Startwithstrawmandesign

2.  Identifyweaknesses

3.  Augmentdesignanditerate

Page 4: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

¡  Alice:“I,Alice,amgivingBobonecoin”¡  Alicedigitallysignsmessageandannouncesbitstoeveryone.

¡  Properties§  EstablishmentofAlice’sintent§  Limitedprotectionfromforgery

¡ Weakness§  Coinsarenotunique;canbeduplicated

Page 5: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

¡  Alice:“I,Alice,amgivingBobonecoin,withserialnumber8740348”

¡  Alice:“I,Alice,amgivingBobonecoin,withserialnumber8770431”

¡  Bankissuescoinswithuniqueserialnumbers,keepstrackofwhoownscoins,verifiestransactions

¡  Properties§  EstablishmentofAlice’sintent§  Betterprotectionfromforgery

¡  Weaknesses§  Needtrustedbanktoissuecoins,keeptrackofwhoownscoins,

verifytransactions§  Bankcanlinktransactionstoidentity

Page 6: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

¡  E-cashlectureonNov18§  Retainbank§  Ensurethatbankcannotlinktransactionstoidentity

§  Agentscannotdoublespendtheirelectroniccoins

¡  KeynoveltyinBitcoindesign§  Nocentralizedbank

Page 7: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

¡  Everyonemaintainsacopyofthepublicledger(blockchain)oftransactions(keepstrackofwhoownscoins)

¡  Alice:“I,Alice,amgivingBobonecoin,withserialnumber8740348”

¡  BobuseshiscopyoftheblockchaintocheckthatthecoinisAlice’s;hebroadcastsbothAlice’smessageandhisacceptanceofthetransactiontotheentirenetwork,andeveryoneupdatestheircopyoftheblockchain.

¡  Weaknesses

§  Howtogetserialnumbers?§  Double-spending:WhatifAlicegivesthesamecointoBoband

Charlieatthesametime?

Page 8: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

¡  BobdoesnotverifyAlice’scoinbyhimself.¡  Askseveryoneonthenetworktoverify¡ When“enough”peopleconfirmthatthecoinisindeedAlice’s,Bobacceptsandeveryoneupdatestheirblockchain

¡ Weakness:§  Sybilattack:Alicecreatesmanyfakeagentswholieforher;Alicespendsthesamecoinmanytimes

Page 9: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

¡  Computationallycostlyfornetworkuserstovalidatetransactions

¡  Rewardnetworkusersforvalidatingtransactions

¡  Properties

§  Sybilattackwon’tworkunlessdishonestagentsputinsignificantcomputationalresources

§  Verifiersrewardedwithfixednumberofbitcoinsforabatchoftransactions(detailssoon)

§  Additionalideastoensurethatledgersuccinctlymaintainshistoryofalltransactions(detailssoon)

Page 10: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses
Page 11: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

¡  Apeer-to-peerdigitalpaymentsystem¡  Completelydecentralizeddigitalcurrency

§  Nocentralminttoproducecurrency

§  Nocentralbanktoverifytransactions

§  Onceconfirmed,transactionsareirreversible

§  Predictable,capped,currencysupply

¡  KeyinnovationinBitcoin:coinproductionandverificationisdonebynetworkconsensus

Page 12: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

¡  Thereisactuallynonotionofa“coin”

¡  Bitcoinsareexchangedfrom“wallet”to“wallet”¡  Transactionsareattheheartoftheprotocol¡  Walletsarerepresentedbyaddresses(e.g.,1VayNert…)§  (Anaddressisthepublickeyofthewallet)

Page 13: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

¡  Alicewantstosend1BTCtoBob§  Shepicksatransaction(oragroupoftransactions)thatshehaspreviouslybeentherecipientofandthatcumulativelycontainatleast1BTC

§  ShethenappendsBob’swalletaddresstothetransactionanddigitallysignsit

¡ WhenBobsubsequentlywantstospendthe1BTC,allhehastodoistorepeattheoperation

Page 14: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

¡  Bobnowhas1BTC§  HewantstosendittoCharlie…§  …whilekeepingitforhimselfatthesametime

¡  TopreventthisBob(andAlicebeforehim)hasto

broadcastthetransactiontoeverybodyintheBitcoinnetwork

¡  Thenotherpeerscanverifythatthetransactionisnotadouble-spend

¡  Oncethisisdone,thetransactionisembeddedforeverinapublicledger

Page 15: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses
Page 16: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

SignA(TransferXtoB) SignA(TransferXtoC)SignA(TransferXtoB)

Longestchainwins

Slidecredit:JoeBonneau

Page 17: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

IN:scriptSig...scriptSig...

OUT:scriptPub

A,5.9

...

...

IN:scriptSigA

OUT:scriptPubB,5.0

scriptPubA,0.9

IN:scriptSigAscriptSigA

OUT:

scriptPubC,10.0

IN:scriptSig...

OUT:

scriptPubA,9.2

...

Slidecredit:JoeBonneau

Page 18: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

1.  {"hash":"7c4025...",//serialnumber:hashoftransaction2.  "ver":1,//protocolversion3.  "vin_sz":1,//no.ofinputs4.  "vout_sz":1, //no.ofoutputs5.  "lock_time":0,//transactionfinalizedaftertime6.  "size":224,//no.ofbytesintransaction7.  "in":[//inputoftransaction7-118.  {"prev_out"://inputisanoutputofaprevioustransact.9.  {"hash":"2007ae...",//serialnumberofprevioustransact.10.  "n":0},//outputnumberofprevioustransact.11.  "scriptSig":"304502...042b2d..."}],//signatureandpubkeyofsender12.  "out":[ //outputoftransaction12-1413.  {"value":"0.31900000",//outputs0.319BTC14.  "scriptPubKey":"OP_DUPOP_HASH160a7db6fOP_EQUALVERIFY

OP_CHECKSIG"}]}//scriptforverifyingtransaction

Page 19: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

scriptPubKey: OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG

IN:scriptSig...scriptSig...

OUT:scriptPub

A,5.9

IN:scriptSigA

OUT:scriptPubB,5.0

scriptPubA,0.9

<sig> <pubKey> OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG

scriptSig: <sig> <pubKey>

Redemptionscript:

Slidecredit:JoeBonneau

Page 20: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

<sig> <pubKey> OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG

<sig> ✓<pubKey>

<pubKey>

<pubKeyHash>

<pubKeyHash>

Slidecredit:JoeBonneau

Page 21: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

https://en.bitcoin.it/wiki/Script

Page 22: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses
Page 23: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

¡  Coinproductionisembeddedintheverificationprocess

¡  Verifiers(“miners”)verifybatchesoftransactionsatonce§  Inexchangeforwhichtheyareallowedtoadda“creation”transactiontothebatchandgivethemselvesafixedamountofmoney▪  50BTCoriginally,25BTCnow,dividedbytwoeverysooften

§  Verificationiscombinedwitha“proof-of-work”schemetoensure▪  Thattransactionshavepropertimestamping▪  Thatcurrencyproductionisrate-limited

Page 24: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

¡  Minerssolveacryptographicpuzzle:Findxs.t.H(x||l)<ywherelisthebatchoftransactions.

¡  Thereisnogoodalgorithmtosolvethis(H isacryptographicallysecurehashfunction)§  Brute-force:tryx=0, x=1, x=2, x=… §  The lower y, the harder the puzzle

¡  Difficulty is tunable and is (by edict) designed to be inversely proportional to the total computational power of the network

¡  The goal is to have one block every ten minutes §  Predictable supply of currency (independent of the difficulty) §  But this limits how quickly transactions can be verified ▪  At least 10 minutes, usually 60 minutes is recommended

Page 25: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

¡  Inadditiontothebonustheygetformining,minersget“transactionfees”§  Leftover“change”voluntarilyleftintransactions

¡  Becausethebonusisdecreasingovertime,theexpectationisthattransactionfeeswillincreaseovertimetomakeupforlostminingrevenue

Page 26: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

Courtesy:BrianWarner

Page 27: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

•  264hashesperblock(every10minutes!)•  275hashesin2013o  Inexchangefor~US$250M

•  Consuming>100MW

Slidecredit:JoeBonneau

Page 28: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses
Page 29: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

¡  Becomeaminer§  Nowadaysonlyprofitableifdedicated(ASIC)hardware

¡  Buyatanexchange§  CampBX,Bitstamp,BTC-e,Coinbase…§  (Mt.Goxbeforetheywentbankrupt)§  Veryhighconcentrationonexchangesthroughwhichmoneyisexchanged▪  Exchangesfailprettyoften…

§  Increasinglyscrutinizedbyregulators¡  Buyfromindividuals

§  SatoshiSquareinNYC

Page 30: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

¡  Asaspeculativeinstrument§  PeopleinvestinBTC,bettingonitsrisingvalue§  Dominantusethusfar

Page 31: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

¡  Asacurrency§  Onlycurrencyacceptedonundergroundmarketplaces(SilkRoad,Evolution,…)▪  (ExceptforLiteCoin,whichisacloneofBitcoin)▪  Becauseofits“anonymityproperties”▪  Stillrelativelymodest▪  EntireSilkRoadrevenuerepresentedin1sthalfof2012about$15M/annum

§  Gambling,pokersites▪  Largenumberoftransactions,volumenotveryhigh

§  Otherusesstillintheirinfancy▪  Campaigncontributions,onlinestores(e.g.,Overstock),etc

Page 32: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses
Page 33: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

¡ Walletsarepublic/privatekeypairs§  Cancreateasmanyasyouwant§  Thinkofthemaszero-costpseudonyms

¡  ThereisnocentralauthorityissuingBitcoinsorvettingtransactions

¡  ThismeansBitcoinisanonymous,right?NO!

Page 34: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

¡  Anonymityhereimpliesunlinkabilityoftransactions¡  Theentireledgerofalltransactionsisavailable,forever

§  Technicallyinacompressedform,buttransactionchainscanallbereconstructed

¡  Evenifyouaddintermediarydummystepswallets,linkingthesourceandthedestinationofatransactionmaybedonebygraphanalysis…§  Somethingthatcomputerscientistsknowhowtodo!▪  Reid&Harrigan,2011▪  Shamir&Ron,2012 ▪  Meiklejohnetal.,2013

¡  Familiesofwalletscanbepooledtogetherasbelongingtothe

sameactualuser…¡  …andifsomehowyoucangettheuser’sidentity,thegameisover

Page 35: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

¡ Mixers

¡  DidAlicegive10BTCtoCharlesorDaisy?

Mixer

Alice

Bob

Charles

Daisy

10BTC

10BTC

10BTC

10BTC

Page 36: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

¡  Mixersinpractice

¡  Needtoalsointroducearbitrarydelays¡  Introductionofchangeaddresses,etc¡  Mixercanbedishonest!

Mixer(keeps5%)

Alice

Bob

Charles

Daisy

5BTC

10BTC

4.75BTC

9.5BTC

Page 37: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

¡  It’sunclearhowgoodexistingBitcoinmixersare§  Keydifferencewithmessagemixing(Tor,mixnets)▪  Youcan’timplementarbitrary“padding”–moneyhastogosomewhereeventually

§  Possiblemeasure:taint▪  Amountofmoneythatcanbetracedbacktoagivensource

§  Recentresearchsuggestsexistingmixersarenoteffectiveordownrightdishonest

Page 38: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

¡  Slides2-10,15,18,21aremine¡  ThankstoNicolasChristinforallotherslides

Page 39: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

bitcoinwisdom.com

Page 40: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

bitcoinwisdom.com

Page 41: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

Slidecredit:JoeBonneau

Page 42: Anupam Datta CMU Fall 2015course.ece.cmu.edu/~ece734/fall2015/lectures/22-18734-bitcoin.pdf¡A rational reconstruction of Bitcoin 1. Start with straw man design 2. Identify weaknesses

Chilkootpass,Klondike1898

Slidecredit:JoeBonneau