L3. Blockchains and Cryptocurrencies Alice E. Fischer September 6, 2018 Blockchains and Cryptocurrencies... 1/16
Blockchains Transactions Blockchains and Cryptocurrencies... 2/16
Blockchains, in theory A Blockchain is a theoretical construct built using cryptography. It has several nice properties, in theory: It is a decentralized, anonymous and public digital ledger, managed by collectively trusted servers. It is indelible, that is permanent and unchangeable. Additions to the blockchain are immediately visible to everyone. A blockchain gives a unique, public, global, and consistent view of its data. The problem is that real implementations cannot fully implement the theory. Blockchains and Cryptocurrencies... 3/16
How a Blockchain Works A blockchain is a ledger (record of transactions) implemented by: A list of encrypted blocks. Each block contains the cryptographic hash of the prior block, linking them together, plus data about a batch of transactions, The chain is managed and maintained by a peer-to-peer network that follows a protocol for communication and validation. Once recorded, the data in a block cannot be changed without changing all subsequent blocks. As time passes, and more blocks are added, it becomes very unlikely, but not impossible, that any change will happen. Blockchains and Cryptocurrencies... 4/16
How Blockchains Grow There are 21 million possible bitcoin. Another one is mined approximately every 10 minutes. Bitcoin was the first cryptocurrency; Ethereum branched from it and uses slightly different protocols. In both, a miner tries to solve a compute-intensive puzzle. When someone solves it, he earns a bitcoin or 5 units of Ether and a new puzzle is initiated. The miner then adds a new block to his current chain and sends the now, longer chain to other miners from his previous contact list 1. 1 If this fails, there are services for finding current miners Blockchains and Cryptocurrencies... 5/16
Storing the Records: Bitcoin Bitcoin is a cryptocurrency built on a blockchain. It is maintained by many miners, all of whom own bitcoins. These copies are distributed among the maintainers and live in the cloud. In January 2017, the blockchain file for Bitcoin was 100 GB and growing. Simply storing the file permanently costs money. Also, transmitting it, or even part of it, on the internet costs both time and money. Blockchains and Cryptocurrencies... 6/16
Proof of Work and Reward The puzzle consists of finding a number y (called the nonce ) such that the SHA-256 hash of the current blockchain together with y yields a hash value that is smaller than the current target. The target is adjusted periodically to cause a bitcoin to be mined about every 10 minutes. The reward for solving a puzzle was initially 50 bitcoin. It was halved in 2012 to 25 and again in 2016 to 12.5 It will be halved again every 4 years until all 21 million bitcoins have been created. In 2018, approximately 78% of all coins had been mined. Blockchains and Cryptocurrencies... 7/16
Extending the Chain Each block in the Bitcoin chain defines the target for the next bitcoin contest. A block contains the newly-found nonce, a new target, and a record of many bitcoin transactions. When a new block is created, all transactions in it have been provisional accepted. The newly extended chain is sent to the miner s peers (by default, 8 peers). Blockchains and Cryptocurrencies... 8/16
The New Block When it is received by a second miner, there are two possibilities: If it is longer than his current chain, he throws out the old chain and adopts the new one. They he stops working on solving the old puzzle and starts on the new one. If is shorter than or the same length as the chain he currently has, the new chain is ignored. The receiving miner offers the new chain to its own peers, and transmits it if the peer does not already have it. This propagation continues until everyone in the world knows. All miners follow this same discard/adopt/propagate rule, with the result that the longest chain will eventually wipe out all shorter ones. Blockchains and Cryptocurrencies... 9/16
Forking A fork happens when two different blocks (call them A and B) are created at the same time in different parts of the network. Both will be propagated to other miners and will eventually reach all of the miners However, propagation may take a while. During that time, both are circulating among the miners, Some will try to add blocks to A, and others to B. Eventually, some node will be working on A when a copy of B comes in, or vice versa. If chain B is longer at that time, the new blocks on A will become orphans and their contents will be discarded. It is as if they never happened. Blockchains and Cryptocurrencies... 10/16
Reaching Consensus In the world of Bitcoin, consensus means that all miners agree on one version of the blockchain. Thus, when a Bitcoin miner records a transaction by including it in a new block, the new block may or may not be permanent. If a fork happens, one version or the other will eventually be discarded by all the miners, producing a consensus. There is no final commit operation and no way to know when consensus has been reached. Blockchains and Cryptocurrencies... 11/16
An isolated network outage is not a problem. An isolated network outage is not a problem. If a miner is offline for a while, he might as well just quit trying to mine. Nothing the miner does during the outage is meaningful. When he reconnects, the protocol is to immediately synchronize with the rest of the internet and get the current version of the blockchain. The same is true if a miner s message is dropped or delayed for a long time. He loses for a while, but easily gets back into the bitcoin contest. Blockchains and Cryptocurrencies... 12/16
Wallets and Owners. A new public/private key pair is created for every transaction. When the transaction is bundled into a block, the block stores the public key of the bitcoin owner. A user s wallet contains a list of his private keys, each one associated with some bitcoin transaction. To use the output in a future transaction, the payer must digitally sign the transaction using the corresponding private key. This makes unauthorized transfers difficult. If the private key is lost, the bitcoin network will not recognize any other evidence of ownership. The coins are then lost and cannot be recovered. For example, in 2013 one user said he lost 7,500 bitcoins, worth $7.5 million at that time, when he discarded a hard drive containing his private key. Blockchains and Cryptocurrencies... 13/16
Transactions A miner is the middleman in any transaction. Here s how Alice transfers a Bitcoin to Bob: Suppose Alice has some bitcoin in her wallet. She creates a transaction request giving a specific amount of coin to Bob, and signs it with her private key. The transaction is then broadcast to all of the miners. Each miner first verifies the validity (no double spending) of the transaction by using its current copy of the blockchain. When a miner includes the transaction in a new block, it is confirmed once. When the next miner wins a bitcoin, it will be confirmed a second time. Blockchains and Cryptocurrencies... 14/16
Average Time for Confirmation. Three confirmations are usually required for payments over $1000, six for over $10,000, and many more for massive transfers. Sites that accept Bitcoin as payment can set their own minimum number of confirmations needed. On the average, it took 17 minutes to confirm a Bitcoin transaction in April, 2018. Getting six confirmations takes about an hour. Imagine making a credit-card transaction at a computer store, and having to wait half an hour to have the transaction cleared. Blockchains and Cryptocurrencies... 15/16
Digital Currency Exchanges Bitcoin exchanges are businesses that allow customers to trade digital currencies for other currencies. They charge transaction fees as commissions for their services. Most digital currencies exchanges operate outside of Western countries, avoiding regulatory oversight and complicating prosecutions DCEs often handle multiple Western currencies, and sometimes maintain bank accounts in several countries. There are many exchanges, some more reliable than others, including : Coinbase, Kraken, Bitstamp, Binanac. A history of major problems is dealt with in the next lecture. Blockchains and Cryptocurrencies... 16/16