Campbell R. Harvey Duke University and NBER Innovation and Cryptoventures Cryptotransactions Campbell R. Harvey Duke University and NBER
Campbell R. Harvey 2019
The Mechanics Let’s start with Bitcoin transaction mechanics. Simplified example: Alice buys something from Bob and sends him 1 bitcoin Alice Bob 1 BTC Campbell R. Harvey 2019
The Mechanics Examples: Alice 1 BTC Bob Bob generates a random number (private key). There is a public address that is mathematically linked to the random number. Bob sends the public address to Alice Public address can change for every transaction. Alice adds Bob’s address and the amount of bitcoins to a 'transaction' message. Alice signs the transaction Alice broadcasts the transaction on the Bitcoin network for all to see. Campbell R. Harvey 2019
The Mechanics Examples Alice sends to Bob Quoted in satoshi so 50 bitcoins Campbell R. Harvey 2019 Graphics from King, Williams and Yanofsky (2013)
The Mechanics Examples Transaction sent to every Bitcoin node on the Internet (the memory pool) If the transaction is validated (and there is a non-zero transaction fee), it will be included in a block and eventually added to the ledger. Campbell R. Harvey 2019 Graphics from King, Williams and Yanofsky (2013)
The Mechanics Examples continue: Bob buys something from Carol and sends her 1 bitcoin Alice Bob Carol 1 BTC 1 BTC Campbell R. Harvey 2019
The Mechanics Examples Bob sends Carol 1 bitcoin Carol sets up a private key and a public address Bob takes the bitcoin he got from Alice, uses his address and his private key to sign it over to Carol Campbell R. Harvey 2019 Graphics from King, Williams and Yanofsky (2013)
The Mechanics Examples Proposed transaction gets sent to all on network to ensure Bob has not already spent the bitcoin from Alice Other transactions that have occurred since Alice’s original transfer to Bob Campbell R. Harvey 2019 Graphics from King, Williams and Yanofsky (2013)
The Mechanics Examples If transaction validated, then added to a candidate block Campbell R. Harvey 2019 Graphics from King, Williams and Yanofsky (2013)
The Mechanics The ledger All of the blocks are called a blockchain Ledger broken up into 10 minute “blocks” Every block contains a reference to the block before it so you can trace every transaction all the way back to 2009 All of the blocks are called a blockchain Campbell R. Harvey 2019 Graphics from King, Williams and Yanofsky (2013)
The Mechanics 2 Transferring ownership A better metaphor for transferring ownership of bitcoins (instead of serial numbers) is to use the concept of lock boxes. Basically, you're using your private key to open your lockbox and take out the values, then you're inserting it (say, via a one-way slot) into someone else's lockbox that can only be opened with a different key. Campbell R. Harvey 2019
The Mechanics 2 Two people, Alice and Ted, send you bitcoin Ted Campbell R. Harvey 2019 https://www.cryptocoinsnews.com/bitcoin-transaction-really-works/
The Mechanics 2 Contents of the wallet are not mixed up Campbell R. Harvey 2019 https://www.cryptocoinsnews.com/bitcoin-transaction-really-works/
The Mechanics 2 You send 0.15BTC to Bob Campbell R. Harvey 2019 https://www.cryptocoinsnews.com/bitcoin-transaction-really-works/
The Mechanics 2 Spending destroys UTXO (unspent transaction output) and creates new ones Campbell R. Harvey 2019 https://www.cryptocoinsnews.com/bitcoin-transaction-really-works/
The Mechanics 3 Validation Miners compete to add a new block to the chain Need to complete a cryptographic “proof of work” Problem is different for each block and involves a cryptographic hash functions which take an input and delivers an output Each block contains the “Proof of Work” (it is difficult to produce but easy to check) Campbell R. Harvey 2019
The Mechanics 3 https://blockexplorer.com/ Campbell R. Harvey 2019
The Mechanics 3 https://etherscan.io/ Campbell R. Harvey 2019
The Mechanics 3 What is the proof of work? When the miner finds the nonce that works, they “win” the block. They provide the nonce with the block contents and everyone (not just miners) verifies Campbell R. Harvey 2019 Graphics from King, Williams and Yanofsky (2013)
The Mechanics 3 What is the proof of work? The block gets sent to every miner They get the winner’s nonce and verify the hash Work is hard to solve but easy to verify Campbell R. Harvey 2019 Graphics from King, Williams and Yanofsky (2013)
The Mechanics 3 It is a little more complicated … In previous example, there might be an incentive to have a small number of transactions in block This is solved by having miners represent a block (no matter the number of transactions in the block) with only 80 bytes (which is small) The key is to understand what is in it Campbell R. Harvey 2019
The Mechanics 3 80 bytes* 4 bytes: version number (same for all miners) 32 bytes: previous block (same for all miners) 32 bytes: hash of the transactions in the candidate block 4 bytes: time stamp 4 bytes: difficulty of task (same for all miners) 4 bytes: nonce *Each component in hexadecimal or translated to hexadecimal. The hexadecimal is then expressed in little-endian format, i.e. 12345678 in little-endian is 78563412. The string is hashed twice with SHA-256 and final hash is presented in little-endian format. Campbell R. Harvey 2019
The Mechanics 3 Miner will vary the nonce – but a good machine can try all possible 32-bit nonce combinations in less than 1 second (about 4 billion calculations) Time stamp can also be varied (naturally changes after nonces are tried) Miners may also vary the order to which transactions are grouped (in a Merkle tree) Campbell R. Harvey 2019
The Mechanics 3 Hash of the transactions is a Merkle tree (or hash tree) which includes multiple hashes Block averages 2,000 transactions Each data block is a transaction Campbell R. Harvey 2019 https://blockchain.info/charts http://chimera.labs.oreilly.com/books/1234000001802/ch07.html#merkle_trees
The Mechanics 3 Merkle trees very efficient. Note Merkle is Ralph Merkle not Angela Merkel. Campbell R. Harvey 2019 http://chimera.labs.oreilly.com/books/1234000001802/ch07.html#merkle_trees
The Mechanics 3 Lots of hashes! 44 million terahashes per second! Campbell R. Harvey 2019 https://blockchain.info/charts
The Mechanics 3 Lots of hashes! 44 million terahashes per second! 1 million machines to buy 50% of mining power= $1.8b Realistically, you would have buy much more because by the time you get delivery, you will have less than half the hashing power http://www.bitcoinx.com/profit/ [Profitability calculator] Campbell R. Harvey 2019
The Mechanics 3 Miners’ role: Miners’ purpose: Mining code is open source Miners are competitive Miners pool resources and can be strategic Miners’ purpose: New bitcoins are distributed to those that are doing the work Miners provide Proof of Work that makes the network work (i.e., transactions validated and blocks cryptographically linked) so that no trust is needed Campbell R. Harvey 2019
The Mechanics 3 Vulnerability If a mining pool gains a large amount of computing capacity, they can attack the network They could theoretically attempt to rewrite some history (though likely only recent history) Campbell R. Harvey 2019
The Mechanics 3 Vulnerability January 9, 2014 Ghash.io had 45% of all mining Had to appeal to people to exit the pool Campbell R. Harvey 2019 See their press release: https://ghash.io/ghashio_press_release.pdf
The Mechanics 3 Vulnerability Not clear what the incentive is to “take over” If it ever happened, the value of the Bitcoin might disappear Campbell R. Harvey 2019
The Mechanics 3 Vulnerability January 2019: Three pools controlling almost 50% See https://blockchain.info/pools Campbell R. Harvey 2019
The Mechanics 3 Vulnerability January 2019: Three pools control nearly 40% See https://blockchain.info/pools Campbell R. Harvey 2019
The Mechanics What does a mining farm look like? Mongolia Campbell R. Harvey 2019 https://qz.com/1055126/photos-china-has-one-of-worlds-largest-bitcoin-mines/
The Mechanics What does a mining farm look like? Iceland Campbell R. Harvey 2019 http://www.businessinsider.com/photos-of-iceland-bitcoin-ethereum-mine-genesis-mining-cloud-2017-5?op=0
The Mechanics Campbell R. Harvey 2019 See https://bitnodes.earn.com/
The Mechanics 4 Signing: Signing involves: message, your private key and a nonce Anyone can use the message, digital signature coordinates, and public key to verify that the message was created with the private key Three key properties of a digital signature: Authorization (I can/I am the owner) Non-repudiation (I meant to) Integrity (This what I meant) Campbell R. Harvey 2019
The Mechanics Beyond Bitcoin’s Model The mechanics vary across different blockchain implementations. Next, we will explore Ethereum. There will be many similarities such as Hash links of blocks Proof of Work (miners) Digital signatures However, there will be a number of differences Different hashing algorithm Concept of an account balance Activating a computer program to run in their blockchain by sending it funds Money supply rule Campbell R. Harvey 2019