chapter 10: blockchain and cryptocurrencies · history • bitcoin designed to limit the number of...

36
Chapter 10: Blockchain and Cryptocurrencies Cryptocurrencies Bitcoin addresses Blockchain Mining Ethereum Smart Contracts Prof Bill Buchanan OBE http://asecuritysite.com/crypto10 http://asecuritysite.com/encryption

Upload: others

Post on 03-Sep-2019

4 views

Category:

Documents


0 download

TRANSCRIPT

Chapter10:BlockchainandCryptocurrencies Cryptocurrencies Bitcoinaddresses Blockchain MiningEthereumSmartContracts ProfBillBuchananOBE http://asecuritysite.com/crypto10http://asecuritysite.com/encryption

Payments

History

• Bitcoinwascreatedin2009bysomeone knownasSatoshiNakamoto.

• Doesnotrequirethesupportofacentralgovernmentororganisationtoregulateit,norabrokertomanagepayments.

• TheBitcoincurrencyisinsteadcreatedwhenusersmineforit,usingtheircomputerstoperformcomplexcalculationsthroughspecialsoftware.

• Bitcoin(BTC)divisibletothe8thdecimalplace.• BTCcanbesplitinto100,000,000units.• 0.00000001bitcoinisoneSatoshi.

History• Bitcoindesignedtolimitthenumberofbitcoins

thatcaneverbecreated.• Eachtransactionthenhasareward,andtherewardreducesover

time,whichshouldreducethesupplyofthecoins.• In2016,therewardforasuccessfulminingprocesswasreduced

from25BTCto12.5BTC.Thisrewardwillcontinuetoreduceuntilthecurrencyisforked(andwherenewparametersareused),orwhenwereachasaturationlevel.

• Others:Ethereum,Ripple,Litecoin,Monero,EthereumClassic,Dash,Steem,KiloCoinandAugur.

GenesisRecord

Bitcointransactions

Bitcointradingvolume

Bitcoinvalue

Chapter10:BlockchainandCryptocurrencies Cryptocurrencies Bitcoinaddresses Blockchain MiningEthereumSmartContracts ProfBillBuchananOBE http://asecuritysite.com/crypto10http://asecuritysite.com/encryption

BitcoinWalletandAddresses

Privatekey:4c0333a50b7724c71b89df148d83f64d49d896e21701007eeb8cada52744aca2Publickey:0489fc7b8c3f655a10840d35c76ebb5596694045e49e940fb1e7a759da4edf0fafc45bbbea6f5a56abf14c145c529c8eda9d3ad606f3a0bf4ca01ce991d4987b97Wif:5JPmDetQXXvc5aT5efyrg7BxHbH4135owRzq9DD7n2eWQCta5MNAddress:16RAf9CjnstWCfBJGfrzSSMfTeHJVt8QWwSigned:4830450220264c4dce5f1cf0dff8d32d21c5d5cf6baed428b12ae6f8594924246a611e9ee602210096ef8e7054ec7a39f0a35d8de3fd50090b1d125c0e795af8cf3d577b676407ca01410489fc7b8c3f655a10840d35c76ebb5596694045e49e940fb1e7a759da4edf0fafc45bbbea6f5a56abf14c145c529c8eda9d3ad606f3a0bf4ca01ce991d4987b97

Bitcointransaction

Chapter10:BlockchainandCryptocurrencies Cryptocurrencies Bitcoinaddresses Blockchain MiningEthereumSmartContracts ProfBillBuchananOBE http://asecuritysite.com/crypto10http://asecuritysite.com/encryption

Miningprocess

Successfulminers

HashRateTH/s

MiningProcesses

• Hash • 000000000000000000d98e57b83834a2d1f4387a93d06861bcf3ea5fc498bd55

• PreviousBlock • 0000000000000000012138e05f0779765277a9d2ab7e4a2a70882790abf98a0c

Blocks

Chapter10:BlockchainandCryptocurrencies Cryptocurrencies Bitcoinaddresses Blockchain MiningEthereumSmartContracts ProfBillBuchananOBE http://asecuritysite.com/crypto10http://asecuritysite.com/encryption

History

• EthereumwascreatedbyVitalikButerininin2015andwhichbuiltontheBitcoin/Blockchainconceptbyincludedtheconceptofsmartcontracts.

• Afterahack,in2016,theEthereumcurrencysplitintotwo:Ethereum(ETH)andEthereumClassic(ETC).

Ethereumsetup

Gas

• WithinEthereumapplicationswedefinetheconceptofgas.ThisisbasicallytheunitthatisusedtomeasuretheamountofworkthatisrequiredtoperformasingleKeccak-256hash,andwhere30gasareconsumedforasinglehashand6moregasforeach256bitsofdatahashed.Inthiswaythereisamotivationtokeepcontractssmall,astheywillbelesscostly.

Gas

• Gasthusprovidesawaytodefinethefeethatminersreceiveinperformingoperationsontheblockchain.

• ThisdiffersfromBitcoinwhichonlychargesforthenumberofkiloBytesinatransaction.Whenitcomestotheactualpaymentofthetransactionfees,thereisapaymentofethertotheminerswhocreatetheblocks.

Gas

• Ethereumtransactionsthushaveafeeassociatedwiththem.Ifthefeeistoolow,thentheminerswillnotprocessthetransaction.

• Whengasisconsumeditispaidtotheminer,andcannotberecoveredback.

• Ifthetransactionfeeissettoohigh,therearelikelytobemanyeagerminerswhoarekeentoprofitfromthehighfee,andyourtransactionislikelytobeprioritized.

Gas

• Overall,though,minersonlychargefortheworktheyhavedone,andtheywillreturnbackanyexcessgaswhichtheyhavenotused.Aminercandecidewhetheritneedstochangetheuseofgasaccordingtothepriceofgasvarying.ThisovercomesthechangesintransactionfeesthathappeninBitcoin.

Gas

• InEthereum,justlikeBitcoin,thereisablocklimit,soyou'llenduppayingmoreifyouoverspillintoanotherblock(whichmeansyoushouldbeefficientwithyourcodeanddata).

• Thegaspricepertransactionaimstoovercomedenialofserviceandinfiniteloops,andwhere0.00001Etheror1Gasisusedtoexecutealineofcode.IfthereisnotenoughEther,notransactionwillbeperformed.ItalsoaimstomakecodedesignersefficientandnotusewastebandwidthandCPUutilization.

Chapter10:BlockchainandCryptocurrencies Cryptocurrencies Bitcoinaddresses Blockchain MiningEthereumSmartContractsProfBillBuchananOBE http://asecuritysite.com/crypto10http://asecuritysite.com/encryption

SmartContract

pragmasolidity^0.4.0;contracttest2{uinta;functiontest2(){a=1;}functionval()returns(uint){returna;}}contracttest3istest2{uintb=a++;functionshow()returns(uint){returnb;}}

CompilewithSolidity

A Future World?

Chapter10:BlockchainandCryptocurrencies Cryptocurrencies Bitcoinaddresses Blockchain MiningEthereumSmartContracts ProfBillBuchananOBE http://asecuritysite.com/crypto10http://asecuritysite.com/encryption