Copyright2009TrendMicroInc.RolandSun,BenHuang2013/09/25BitcoinIntroductionClassification1/18/20201Copyright2009TrendMicroInc.自由平等Classification1/18/20202Copyright2009TrendMicroInc.2013.5•Top3:–China–USA–GermanyClassification1/18/20203Copyright2009TrendMicroInc.思想的源起•哈耶克–74年諾貝爾經濟學獎–晚年最後一本經濟學專著–觀念:既然在一般商品、服務市場上自由競爭最有效率,那為什麼不能在貨幣領域引入自由競爭?–建議:廢除中央銀行製度,允許私人發行貨幣,並自由競爭,這個競爭過程將會發現最好的貨幣Classification1/18/20204Copyright2009TrendMicroInc.技术的步伐•1982年,大衛·喬姆(DavidChaum)提出不可追踪的密碼學網絡支付系統。8年後,他將此想法擴展為密碼學匿名現金系統,即Ecash。•1998年,戴偉(WeiDai)的論文闡述了一種匿名的、分佈式的電子現金系統:b-money。•與此同時,尼克·薩博(NickSzabo)發明了Bitgold,提出工作量證明機制,用戶通過競爭性地解決數學難題,然後將解答的結果用加密算法串聯在一起公開發布,構建出一個產權認證系統。•哈爾·芬尼(HalFinney)則把該機製完善為一種「可重複利用的工作量證明」。Classification1/18/20205Copyright2009TrendMicroInc.技术的步伐•2008.11.1极客中本聰(SatoshiNakamoto),在metzdowd.com的密碼學郵件組中發表了《比特幣:一種點對點的現金支付系統》闡述他對電子貨幣的新構想。–日本京都大学教授–望月新一,16岁普林斯顿,23数学博士•2009.1.3中本聰code第一版Classification1/18/20206Copyright2009TrendMicroInc.Bitcoin•Nocentralmanagementnode•AnonymousClassification1/18/20207Copyright2009TrendMicroInc.技术的步伐•2008.11.1极客中本聰(SatoshiNakamoto),在metzdowd.com的密碼學郵件組中發表了《比特幣:一種點對點的現金支付系統》闡述他對電子貨幣的新構想。–日本京都大学教授–望月新一,16岁普林斯顿,23数学博士•2009.1.3中本聰code第一版Classification1/18/20208Copyright2009TrendMicroInc.挖矿史–第一矿工:哈爾·芬尼(HalFinney)•PGP作者之一•完善工作证明机制•CPU年代Classification1/18/20209Copyright2009TrendMicroInc.第一笔交易–2010.5.21,Laszlo10,000bitcoin–50$--25$–1bitcoin–100$Classification1/18/202010Copyright2009TrendMicroInc.渐渐流行–2011.5.9海盜灣創始人RickardFalkvinge寫了一篇著名文章《為什麼我把我的積蓄全部投入Bitcoin?》•已经升值1000倍•还将升值1000倍•没有税收杂费Classification1/18/202011Copyright2009TrendMicroInc.投资挣钱的显卡•显卡的计算能力约是CPU100倍•其他投资:马向前比特基金Classification1/18/202012Copyright2009TrendMicroInc.Cloudcomputing•矿场市占率超过top500超级计算机能力Classification1/18/202013Copyright2009TrendMicroInc.巨头年代•ASICFPGA–显卡100倍–Avalon•RMB8,000-300,000•退款纠纷–烤猫Classification1/18/202014Copyright2009TrendMicroInc.未来算力•51%攻击Classification1/18/202015Copyright2009TrendMicroInc.BitCoin系统描述•Total2100万货币•每个币可细分10的8次方•P2P网络和密码学支撑Classification1/18/202016Copyright2009TrendMicroInc.系统解决的问题•如何产生货币•如何花钱•系统内的逻辑安全性如何保证Classification1/18/202017Copyright2009TrendMicroInc.系统解决的问题•如何产生货币–POW(工作证明)•生成不易,较验容易•也用于防DDOS,垃圾信息–生成block•目标值•困难度Classification1/18/202018Copyright2009TrendMicroInc.WhatisinBlock?Classification1/18/202019FieldPurposeUpdatedwhenSize(Bytes)VersionBlockversionnumberYouupgradethesoftwareanditspecifiesanewversion4hashPrevBlock256-bithashofthepreviousblockheaderAnewblockcomesin32hashMerkleRoot256-bithashbasedonallofthetransactionsintheblockAtransactionisaccepted32TimeCurrenttimestampassecondssince1970-01-01T00:00UTCEveryfewseconds4BitsCurrenttargetincompactformatThedifficultyisadjusted4Nouce32-bitnumber(startsat0)Ahashistried(increments)4Copyright2009TrendMicroInc.DifficultyoverTimeGraphClassification1/18/202020Copyright2009TrendMicroInc.WhatisTarget?•Thetargetisa256-bitnumberthatallBitcoinclientsshare.•TheSHA-256hashofablock'sheadermustbelowerthanorequaltothecurrenttargetfortheblocktobeacceptedbythenetwork.•Thelowerthetarget,themoredifficultitistogenerateablock.•ThemaximumtargetusedbySHA256miningdevicesis:0x00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFClassification1/18/202021Copyright2009TrendMicroInc.WhatisDifficulty?•Difficultyisameasureofhowdifficultitistofindanewblockcomparedtotheeasiestitcaneverbe.•difficulty=maximum_target/current_target•Difficultychangesevery2016blocks(twoweeks).Classification1/18/202022Copyright2009TrendMicroInc.References•CurrentDifficulty–•CurrentTarget–系统解决的问题•如何花钱–重复开支•P2P广播,相当于投票•进block为准•6个block后没问题•开支的细节–什么时候去借鉴它•设计可信系统Classification1/18/202024Copyright2009TrendMicroInc.Bitcoin•AllnodesinBitcoinnetworkhasacompletetransactionlistfromtheverybeginning•AllthetransactionsareverifiedandconfirmedbypeersClassification1/18/202025Copyright2009TrendMicroInc.Classification1/18/202026Copyright2009TrendMicroInc.WhatisinTransaction?FieldDescriptionSizeversionnumbercurrently14bytesin-counterpositiveinteger1~9byteslistofinputsthefirstinputofthefirsttransactionisalsocalled“coinbase”out-counterpositiveinteger1~9byteslistofoutputstheoutputsofthefirsttransactionspendtheminedbitcoinsfortheblocklock_time4bytesClassification1/18/202027Copyright2009TrendMicroInc.WhatisTransaction?Classification1/18/202028Copyright2009TrendMicroInc.WhatisinInput?Classification1/18/202029FieldDescriptionSizePreviousTransactionhashdoubledSHA256-hasedofa(previous)to-be-usedtransaction32bytesPreviousTxout-indexnonnegativeintegerindexinganoutputoftheto-be-usedtransaction4bytesTxin-scriptlengthnonnegativeinteger1~9bytesTxin-script/scriptSigscriptsequence_nonormally0xFFFFFFFF4bytesCopyright2009TrendMicroInc.WhatisinOutput?Classification1/18/202030FieldDescriptionSizevaluenonnegativeintegergivingthenumberofSatoshis(BTC/10^8)tobetransfered8bytesTxout-scriptlengthnonnegativeinteger1~9bytesTxout-script/scriptPubKeyScriptCopyright2009TrendMicroInc.WhatisTransaction?Classification1/