Lecture Notes #1: The Rise of Blockchains and Distributed Ledgers PDF

Summary

These lecture notes cover the rise of blockchains and distributed ledgers, discussing issues in current centralized financial systems, the 2008 Global Financial Crisis, and the emergence of alternative financial systems like Bitcoin. The document is from OntarioTech Business & IT, suitable for undergraduate study of economics and technology.

Full Transcript

Lecture Notes # 1 The Rise of blockchains and distributed ledgers Edited by Nadia Massoud Revised by Xinyao Zhou Outline  What are the issues with our current centralized financial System (e.g. central bank, commercial banks and stock market)?  What are the causes of the 2...

Lecture Notes # 1 The Rise of blockchains and distributed ledgers Edited by Nadia Massoud Revised by Xinyao Zhou Outline  What are the issues with our current centralized financial System (e.g. central bank, commercial banks and stock market)?  What are the causes of the 2008 Global Financial Crisis (GFC)?  Why did an alternative financial system (Bitcoin) emerge? 2 What are the issues with our current centralized financial System (e.g. central bank, commercial banks and stock market)? What is the meaning of “Centralized Financial System”? What are the main entity in the “Centralized Financial System”? 3 What are the issues with our current centralized financial System (e.g. central bank, commercial banks and stock market)? A financial system where a central authority manages financial assets and goods, while users are not aware of the rules behind the system they use or not have access to the key information. The centralized system includes financial intermediations such as commercial banks, investment banks and stock exchanges. 4 The centralized financial system Households FI Corporation (Brokers) Deposits Cash FI Cash (Asset Equity, bond, Transformers) and others 5 Simplified Commercial Firm and FI Balance Sheet Commercial Firm Financial Intermediary Assets Liabilities Assets Liabilities Real Assets (Plant, Primary Primary Secondary Machinery) Securities (Loan, Securities Securities Debt, Equity) (Loan, Debt, (Deposits and Equity) Insurance Policies) 6 Banks’ assets and liabilities Commercial Bank Assets Liabilities Primary Secondary Securities Securities - Loans - Deposits - Reserve - Capital Then how does commercial bank make money? It depends on the spread of the interest rate. E.g. for loans, the interest rate is 3%, but the deposit is 1%. Then the rate spread is 2%, this is the way commercial bank make money. 7 FI are very important to economy. They support lots of business. They are the core of the economy in nowadays. What happened if banks are in trouble? Many people will be impacted. And in some extreme case, if there is a bank run, we may experience financial crisis. 8 The problem with banks What happens if too many people want to withdraw their money at the same time? 2019 1873 2007 9 Recent Bank Run in US Silicon Valley Bank Collapse 10 Proposed solution Government guarantees of deposits. Canadian Deposit Insurance Corporation (CDIC) insure bank deposits of up to $100,000 per insured category. - Banks will pay for this insurance How is deposit insurance really financed? How does it cause banks to behave? How the bank could increase the profit? 11 The fundamental problem “Maturity transformation” Assets Liabilities Duration of liabilities = short-term - i.e., demand deposits Loans Demand deposits Duration of assets = long-term - i.e., mortgages or loans to businesses Reserves Capital 12 Outline  What are the issues with our current centralized financial System (e.g. central bank, commercial banks and stock market)?  What are the causes of the 2008 Global Financial Crisis (GFC)?  Why did an alternative financial system (Bitcoin) emerge? 14 Major Innovations in the Nature of Banking Led to Financial Crisis The traditional banking Regulatory requirements Banks innovated by creating model began to tighten Basel I & new instruments and Basel II & III: strategies issues short-term deposits that traditional banking model offered securitization of nonstandard are used to finance the bank’s an insufficient return (spread) to mortgage assets extension of longer-term loans compensate the bank for proprietary trading & creation of assuming these substantial risk hedge funds exposures. increased use of derivatives like credit default swaps. 15 The Traditional Securitization Process: Pass through Create new legal entity: Special Purpose Vehicle (SPV) The SPV purchases the assets (newly originated loans) from the originating bank for cash generated from the sale of ABSs. The SPV sells the newly created asset backed securities to investors such as insurance companies and pension funds. Is this risky? 16 A New Securitization Process: Structural Investment Vehicle (SIV) The SIV does not simply pass through the payments on the loans in its portfolio to the Asset Backed security (ABS) investors Investors have no direct rights to the cash flows on the underlying loans in the portfolio; rather, they are entitled to the payments specified on the SIV’s debt instruments. From investor perspective, is Commercial papers riskier than ABS? From bank perspective, is the SIV riskier than SPV? 17 SIV Versus SPV The expected return from the SIV is very high => it became very popular in the years leading up to the financial crisis in 2008. Whereas an SPV only earns the fees for the creation of the asset-backed securities Hedge funds (e.g. owned by Citicorp and Bear Stearns) adopted this investment strategy. Until the 2007–2008 crisis, these instruments appeared to offer investors a favorable return/risk trade-off (i.e., a positive return) and an apparently small risk given the asset-backing of the security. 18 SIVs used short-term commercial paper and interbank loans to finance their asset portfolios, they were subject to more liquidity risk than were traditional banks. Bank deposits are explicitly and implicitly insured. Consequently, if the value of its portfolio declined SIV versus due to deterioration in credit conditions, the SIV Traditional might be forced to sell long-term, illiquid assets in order to meet its short-term liquid debt obligations. Bank Assets Liabilities This was a key part of the contagion mechanism by which the subprime market Loans Demand deposits credit crisis was transmitted to other markets and institutions during the crisis. Reserves Capital 19 The 2008 financial crisis contained three separate but related phases 1. The first phase hit the national housing market in the United States in late 2006 through early 2007, resulting in an increase in delinquencies on residential mortgages. 2. The second phase was a global liquidity crisis in which overnight interbank markets froze. (Investors were not interested in refinancing the commercial paper that back SIV). 3. The third phase has proved to be the most serious and difficult to remedy and was initiated by the failure of Lehman Brothers in September 2008. 20 Why DID the Lehman Brothers' failure have A big Impact on the market? Until the failure of Lehman Brothers, large financial institutions were thought to be too big to fail (TBTF) because of their importance to the operation of global financial markets. Market lost TRUST, and confidence in the centralized financial system. 21 Watch this video: https://www.youtube.com/watc h?v=TsLlpa_Rii0 22 Outline What are the issues with our current centralized financial System (e.g. central bank, commercial banks and stock market)? What are the causes of the 2008 Global Financial Crisis (GFC)? Why did an alternative financial system (Bitcoin) emerge? 23 Bitcoin Lehman Brother failure and loss of trust in centralized financial system. The failure of the centralized financial system attract cyberpunk people’s attention. This group of people, led by Satoshi Nakamoto, redesign a financial system which is decentralized, which means they don’t require centralized third party to back up the payment. Satoshi Nakamoto: October 2008 proposed a “peer to peer electronic cash system” 24 In 2008, Satoshi wrote the white paper for bitcoin. This paper connecting a broad range of areas together, including finance and cryptography. The paper provide technical foundation and advocate to use a so-called blockchain technology to realize the trading without the help of third party. Satoshi advocate and ask cyberpunk people to build decentralized financial system together. Lots of people in this community join him and devote lots of time to build this network. They worked together by creating a program and testing the program. By Jan 3, 2009, the program is launched. Which is the same date that the second bailout for banks in financial crisis, in which billions of dollars are poured into the financial system. Which actually reward the ingenuity of the system as said in the video. And this is also the date that this peer-to- peer electronic cash system was born. 25 Intelligent redesign of the financial system Bitcoin network is launched, January 3, 2009 26 Peer to peer The early breakthroughs Industries now being disrupted 27 Peer to peer payments: who guarantees and regulates them? Payment connected to credit card companies Payment by mobile phone application connected to bank account Payment system use consensus of the network 28 A distributed ledger with shared responsibility for updating 29 Summary The issues with our current centralized financial System: The causes of the 2008 Global Financial Crisis (GFC): An alternative financial system (Bitcoin) emerged in our economy to: 30 Lecture Notes # 2 The Rise of blockchains and distributed ledgers Edited by Nadia Massoud Revised by Xinyao Zhou Outline What are the issues with our current centralized financial System (e.g. central bank, commercial banks and stock market)? What are the causes of the 2008 Global Financial Crisis (GFC)? Why did an alternative financial system (Bitcoin) emerge? What are the potential advantages of “a medium of exchange based on cryptographic proof” as cited by Nakamoto 2008 white paper? What is the difference between Bitcoin and bitcoin? 2 First Cryptocurrency The background technology developed between 1982 and 1989 by Prof. David Chaum and his team at Berkeley, who developed two concepts: Bill Gates offered Chaum $100 A system for detection of double-spending million to take DigiCash public. Development of Cryptography: blind signature, using hash functions. Gates had contacted him offering to integrate ecash into every copy of In 1990, Chaum founded DigiCash in Amsterdam The first electronic payment was sent in 1994 Windows 95, a seemingly perfect Digi.cash declared bankruptcy in 1998. deal, yet Chaum declined. 4 Bitcoin White Paper: To create a medium of exchange using cryptography technology First, what we are trying to find? We are trying to find a digital currency that act as a medium of exchange (currency). Then, why use cryptography technology? It conceal information and secure the transaction and prevents hacking and theft. We need to use cryptography to realize three key functions: Secure its transactions Verify the transfer of assets Control the creation of additional units – monetary system Redesign the whole financial system. Cryptocurrencies use decentralized control as opposed to centralized electronic money and central banking systems. 5 Definition of Blockchain If you read the white paper, actually, you don’t see the word – blockchain at all. It is a term created later. But Satoshi defined the concept of chain. The chain Satoshi referring to contains two folds of meaning. 1. When I’m spending bitcoin for the current transaction, I can trace the source of bitcoin in my wallet to its origin through a chain to verify it is an unspent bitcoin. (prevent double spending) - Wallet vs Account 2. When we are spending bitcoin, it takes 10 minutes to finish the transaction. All the transactions happened within this 10 minutes will be stored into a block and chained to the blockchain that stores all the historical transactions. Another key feature Sequence of block can not be changed or reversed. (Banks can change or reverse transaction) 6 Definition of Blockchain A blockchain is a distributed and decentralised database of records that may include digital events, such as code execution, or simple transactions. Each transaction or digital event is stored in a ‘block’, that is connected to other blocks in a chain. Blockchains can’t be edited (implying can’t be reversed). Verification is through consensus. The system is secure as long as honest nodes collectively control more CPU power than any cooperating group of attacker nodes. 7 A distributed ledger or blockchain Nakamoto (2009) Genesis Block The figure shows how does the transactions can be connected each other: 1. The transaction is traced using the hash that belong to the previous transaction that generated the BTC. 8 2. The signature is related to the private key and it can be verified from the previous public key. Advantage of Bitcoin Nakamoto cited three potential advantages of “a payment system based on cryptographic proof”: No need for verification by a (costly) middleman No need for merchant to trust the customer Mininum risk of fraud 9 What is Bitcoin? A stateless, decentralized, “algorithmic” currency Exists only in cyberspace, and its value is based on confidence in its software and network Bitcoin / USD exchange rate: July 17, 2010 1 Bitcoin = $ 0.05 (launch) December 12, 2013 1 Bitcoin = $1,242.00 September 4, 2015 1 Bitcoin = $ 227.00 February 11, 2017 1 Bitcoin = $ 7,900.01 February 20, 2019 1 Bitcoin = $ 3,922.27 September 17, 2019 1 Bitcoin = $ 10,136.00 November 10, 2021 1 Bitcoin = $ 66,953.34 November 9, 2022 1 Bitcoin = $ 15,757.20 January, 2024 1 Bitcoin = $ 40,987.60 September, 2024 1 Bitcoin = $ 58,166.22 January, 2025 1 Bitcoin = $ 99,524.32 10 Blockchain isn’t cryptocurrency Blockchain is a technology that enables movement of the digital currency from one person to another Its cryptocurrency is referred to as “bitcoin”. The bitcoin network is referred to as “Bitcoin”. 11 bitcoin Bitcoin Bitcoin Ecosystem - A Network 12 9,472 GLOBAL BITCOIN NODES DISTRIBUTION Reachable nodes as of Sep 17th, 2019 13 Summary of Bitcoin Ideology Bitcoin’s decentralized, open network allows economic agents to interact directly on a peer-to-peer basis No role for Trusted Third Parties to validate transactions No role for Government to resolve disputes This design could convey not only payments, but also securities, commodities, real estate, etc. Reflects the ambitions of the cypherpunk movement Personal communication, including payments, should be private Privacy must be protected by technology, not laws and governments The advent of the computer age creates enormous risks and enormous opportunities 14 Problems with the “trusted third party” Corruptibility Monopolist transaction fees Ability to “rewrite history” by changing the ledger Single point of failure Control over users’ data Rationing access Competitive advantage Political exclusion 15 What was Satoshi Nakamoto trying to do?  Create an electronic payment system as good as cash  Cash is superior to credit cards in several ways:  transactions are non-reversible except by the seller  transactions do not require “trust” between the parties  no third party needs to provide verification  no fees are necessary  In Nakamoto’s words: “... costs and payment uncertainties can be avoided in person by using a physical currency, but no mechanism exists to make payments over a communications channel without a trusted [third] party.” 16 This is a typical cypherpunk spirit. Important Bitcoin milestones  Bitcoin is proposed by Satoshi Nakamoto via an online posting, October 2008.  First Bitcoin mined by Nakamoto and sent to Hal Finney, January 3, 2009.  First purchase with Bitcoin by Laszlo Hanyecz : two pizzas for 10,000 BTC.  Request posted on May 17, 2010 and accepted by Jeremy Sturdivant on May 22, 2010.  https://blockchain.info/tx/a1075db55d416d3ca199f55b6084e2115b93 45e16c5cf302fc80e9d5fbf5d48d?  U.S. Treasury Financial Crimes Enforcement Network issues first regulatory guidance for virtual currencies, March 2013.  U.S. regulators, including Bernanke, comment favorably upon Bitcoin at a U.S. Senate committee hearing, November 2013. 17 Summary The issues with our current centralized financial System: The causes of the 2008 Global Financial Crisis (GFC): An alternative financial system (Bitcoin) emerged in our economy to: The potential advantages of “a payment system based on cryptographic proof” as cited by Nakamoto 2008 white paper? The difference between Bitcoin and bitcoin? 18 Study questions  Why an alternative financial system (Bitcoin) did emerge in our economy?  Market lost TRUST, and confidence in the centralized financial system.  What are the potential advantages of “a payment system based on cryptographic proof” as cited by Nakamoto 2008 white paper?  No need for verification by a (costly) middleman  No need for merchant to trust the customer  Mininum risk of fraud  What was Nakamoto trying to achieve with Bitcoin in comparison to credit cards?  Create an electronic payment method as good as cash. Cash is superior to credit cards in several ways  What is the difference between Bitcoin and bitcoin?  Bitcoin refers to the technology that enables movement of the digital currency from one person to another  bitcoin is the cryptocurrency of the Bitcoin.  The Bitcoin innovation is more impressive than Uber an AirBnB, why?  Different from the existing peer to peer application, Bitcoin is based on consensus instead of a trusted third party. It is a true decentralized system. 19 Lecture Notes # 3 How Does Blockchain work? Edited by Nadia Massoud Revised by Xinyao Zhou Outline 1. Logic of the Blockchain 2. Encrypting data with hash functions 3. Timestamp Server - Example of transaction 4. Storing large amounts of data 5. Updating the blockchain 6. Incentive & Mathematically Metered Supply 7. Network 8. Immutability of the Blockchain 9. Governance of Bitcoin 2 1. Logic of a blockchain Source: Ethereum white paper Each transaction n is encrypted (using hash) into Tx(n). Each new block n includes: The new transaction, Tx(n-1) An encryption of the previous block, S(n - 1). Two implications of this structure: Even if Tx(1) = Tx(2), we will have S(1) ≠ S(2), making it impossible to recover the raw data If Tx(n) is changed, every block n, n+1, n+2,... , will also change 3 “Message verification and transmission error detection by block chaining” U.S. patent granted to IBM scientists in 1976 4 Outline 1. Logic of the Blockchain 2. Encrypting data with hash functions 3. Timestamp Server - Example of transaction 4. Storing large amounts of data 5. Updating the blockchain 6. Incentive & Mathematically Metered Supply 7. Network 8. Immutability of the Blockchain 9. Governance of Bitcoin 5 2. Encrypting data with hash functions Developed at IBM in early 1950s https://emn178.github.io/online-tools/sha256.html Input Output (SHA-256) Faculty of Business and IT 344686d4aa0901e7e6ee306a5c67f57f77801864d99 486cf6aa674560a131133 Ontario Tech University 1082ff35a4156e3f367bad862fc0aa54b2665cd70367 f7f72c4b1815abc4c98b Finance Major f9cf7d31fbf5040964057f5ee90fe052930e5071c5b4 0595ffe2b95765d9e8bd 6 What is a hash function? A “digital fingerprint” A person can prove their identity by matching their fingerprint with one stored in a database Someone who breaks into the database and steals the fingerprint cannot use it to re-create (reverse engineered) the person, or even tell what the person looks like - The SHA256 data cannot be decrypted 7 Input to a hash function Input can be anything that can be stored in digital form Text Data Video, music, photographs Fingerprints, irises Etc. Limit: 2.09 exabytes So large it would take 220 years just to read in. 1 exabytes equals 1 billion gigabytes 8 What does a hash function do with the input? Why can’t be decrypted? Input is converted to a hexadecimal “hash” by scrambling it in a way that is impractical to invert For example, “Take every third digit in the file, multiply that number by 7, add the digits together and divide the total by every fourth number in the file. Append every number not used in the previous calculation to the number you have, etc...” 9 Output from a hash function Fixed length, generally 64 or 128 characters (0/1) Tells you nothing about the length of the input 16 possible characters in each space Digits 0 through 9, letters a through f Number of possible outputs = 1664 or approximately 1.16 x 1077 Small changes in input will drastically change the output Cannot use patterns of characters in the output as a roadmap for recovering the input, even if you know the hash function that generated the output Only trial-and-error decryption will work 10 Test this yourself https://emn178.github.io/online-tools/sha256.html (select different hash functions on the right side of page) Input: Toronto is the World's most liveable city Output: ea4e4588bae479948bdb12a441cacdf74b08c1f799bccad79bf8510fdd7bea39 SHA 256: ea4e4588bae479948bdb12a441cacdf74b08c1f799bccad79bf8510fdd7bea39 SHA3-256: ff8c86fc70c6e93befc1cd302e567ff02f939bf67f0824be4efd4648ca0da8ec SHA3-512: 60d875bdb193fecca13bef5e8a2add70c0690dcae69ed7932983ef394d2f4550c64bc58ffd4d514e48c5786b0cd0da29b 80c620bc56dc1f9a846985696afe622 11 Outline 1. Logic of the Blockchain 2. Encrypting data with hash functions 3. Timestamp Server - Example of transaction 4. Storing large amounts of data 5. Updating the blockchain 6. Incentive & Mathematically Metered Supply 7. Network 8. Immutability of the Blockchain 9. Governance of Bitcoin 12 3. Timestamp Server A timestamp server works by taking a hash of a block of items to be timestamped. Each timestamp includes the previous timestamp in its hash, forming a chain, with each additional timestamp reinforcing the ones before it. 13 4. Storing large amounts of data: The concept of hash trees is named bundle it into blocks using Merkle after trees Ralph Merkle who patented it in 1979. Challenge: Storing all the previous information as well as allowing for verification 14 Verification simplicity To verify that a transaction is part of a block (or a hash tree), one needs the specific transaction details and the hash values of the higher level non branches. Merkel tree not only allow for verification, but also make the miner’s job easier to verify the transactions. To verify that Tx0 is in the block, one needs the details of - Tx0 - Hash1 and - Hash23 With this one can quickly recalculate Root Hash and verify that Tx0 is part of this block. 15 Reclaiming Disk Space Merkel tree also allow us to save storage space without reducing liability of the data. How? Spent transactions (i.e. used as an input in a new transaction) can be discarded to save space. Merkle tree enables this without breaking the block’s hash. The image below shows the pruning after removing Tx0, Tx1 and Tx2. 16 Source: https://govidat.github.io/blog/post/blockchain-basics-merkle-tree/ Example of a transaction The input in this transaction imports 50 BTC from output #0 in transaction f5d8 The script contains two components, a signature and a public key - Previous tx: is a hash of a previous transaction, i.e. the previous block code. - ScriptSig: is the first half of a script which is based on the buyer private key From (buyer) to (Seller) Value: 50 bitcoin Bitcoins are divisible down to 8 decimal place. 1 satoshi = 0.00000001 BTC ScriptPubKey: The location of the recipient of Bitcoin. It is a short script that explains what conditions must be met to claim ownership of bitcoins. It is the second half of a script 17 Hot and Cold Storage for Private Key Cold storage is not online, and so the hot storage and the cold storage won't be able to connect to each other across any network. put a key in a single place — whether locked in a safe, or in software, or on paper. Difficult to manage its availability for digital transaction. Hot storage using different forms of cryptography by taking a piece of data and store it in such a way that availability and security increase at the same time. 1. Secret sharing: divide our secret key into some number N of pieces. We want to do it in such a way that if we're given any K of those pieces then we'll be able to reconstruct the original secret, but if we're given fewer than K pieces then we won't be able to learn anything about the original secret. Issues: The key can be stolen when it is reconstructed on the machines 2. Threshold Cryptography: starts with secret sharing but produce signatures in a decentralized fashion without ever reconstructing the private key on any single device. (two-factor signature). 3. Multi-signatures: Bitcoin script directly allows you to stipulate that control over an address be split between different keys. 18 Poll Question Which of the following statements is false? 1. Merkel Tree can be used to verify any kind of data stored 2. The Merkle hash indicates the tree depth 3. Merkel Tree can be used to manage storage space 4. The ROOT of Merkel tree can be decrypted 5. Unspent transactions can be discarded to save space. 19 Outline 1. Logic of the Blockchain 2. Encrypting data with hash functions 3. Timestamp Server - Example of transaction 4. Storing large amounts of data 5. Updating the blockchain 6. Incentive & Mathematically Metered Supply 7. Network 8. Immutability of the Blockchain 9. Governance of Bitcoin 20 Haber and Stornetta (1991) A trusted third party takes responsibility for coding blocks The chain is posted publicly, becoming a distributed ledger that can be verified by anyone Nakamoto’s (2008) crowd-sourcing solution Network members compete to create new blocks Anyone can join the network and take part A reward goes to the fastest (seigniorage of new coins) 21 Why Bitcoin network does eliminate the “trusted third party”? No gatekeeper controls access Could exclude certain agents Could play favorites, in exchange for side payments No monopolist transaction fees No ability to change the ledger arbitrarily No single point of failure vulnerable to hacking, operator error or hardware failure No rationing of market hours; available 24-7-365 Greater user control over data 22 A nonce is an arbitrary number that can be used just once in a cryptographic communication. It is often a random or pseudo-random number issued in an authentication protocol to ensure that old communications cannot be reused in replay attacks. A valid “nonce” must be discovered by trial-and-error, such that the hash function for the entire block will be less than or equal a critical value. Creates a high cost for hackers Proves that the miner has invested resources in the security of the network. 23 The block header contains The block version number A timestamp The hash used in the previous block The hash of the Merkle root The nonce The target hash 24 Blockchain demo https://andersbrownworth.com/blockchain/ There are two explainer concept videos and tabs to try yourself. 25 6. Incentive & Mathematically Metered Supply Minting of Bitcoin started with the Genesis block, which is a special transaction that starts a new coin owned by the creator of the block. Bitcoin Maximum supply is 21,000,000. 26 New Bitcoin is created (minted) Through Rewards Miners are incentivized by reward for competing to build a block. The reward in bitcoin started with 50 bitcoin. It’s halved every 4 years It is now 6.25 coins The incentive can also be funded with transaction fees. 27 In-Class Exercise 1. Do you prefer capped supply of currency or unlimited supply? Explain your answer 2. Compare the limited supply of Bitcoin with our current monetary system? 3. What is the impact of limited supply on inflation? 28 7 Network Steps to run the network are as follows: New transactions are broadcast to all nodes. Each node collects new transactions into a block. Each node works on finding a difficult proof-of-work for its block. When a node finds a proof-of-work, it broadcasts the block to all nodes. Nodes accept the block only if all transactions in it are valid and not already spent. Nodes express their acceptance of the block by working on creating the next block in the chain, using the hash of the accepted block as the previous hash. Nodes always consider the longest chain to be the correct one and will keep working 29 To be a Bitcoin miner, you have to join the Bitcoin network and connect to other nodes. Once you’re connected, there are six tasks to perform: 1. Listen for transactions. First, you listen for transactions on the network and validate them by checking that signatures are correct and that the outputs being spent haven’t been spent before. 2. Maintain block chain and listen for new blocks. You must maintain the block chain. You start by asking other nodes to give you all of the historical blocks that are already part of the block chain before you joined the network. You then listen for new blocks that are being broadcast to the network. You must validate each block that you receive — by validating each transaction in the block and checking that the block contains a valid nonce. 3. Assemble a candidate block. Once you have an up‐to‐date copy of the block chain, you can begin building your own blocks. To do this, you group transactions that you heard about into a new block that extends the latest block you know about. You must make sure that each transaction included in your block is valid. 30 To be a Bitcoin miner, you have to join the Bitcoin network and connect to other nodes. Once you’re connected, there are six tasks to perform: Cont’D 4. Find a nonce that makes your block valid. This step requires the most work and it’s where all the real difficulty happens for miners. 5. Hope your block is accepted. Even if you find a block, there’s no guarantee that your block will become part of the consensus chain. There’s bit of luck here; you have to hope that other miners accept your block and start mining on top of it, instead of some competitor’s block. 6. Profit. If all other miners do accept your block, then you profit! At the time of this writing in early 2015, the block reward is 25 bitcoins. In addition, if any of the transactions in the block contained transaction fees, the miner collects those too. So far transaction fees have been a modest source of additional income, only about 1% of block rewards. 31 Satoshi Nakamoto on mining technology 2009 posting “We should have a gentleman's agreement to postpone the GPU arms race as long as we can for the good of the network.” “It's much [easier] to get new users up to speed if they don't have to worry about GPU drivers and compatibility.” “It's nice how anyone with just a CPU can compete fairly equally right now.” 32  Mining is computationally intensive, with supercomputers specially configured to look for nonces at very high “hash rates”  Generally located in bunkers where electric power is cheap  Iceland Icelandic Bitcoin mine  Inner Mongolia The New York Times  Tibet  Venezuela 33 A miner’s economic problem Balancing capital cost (hardware) against operating cost (energy), real estate cost, and maintenance/IT personnel cost HOW DIFFERENT IS THIS FROM A COMMERCIAL BANK Estimating erosion of market share DATA CENTER? Quick obsolescence of hardware due to innovation = faster competitors Market entry when Bitcoin price rises = more competitors Replacing hardware and re-selling units into the secondary market for used miners Hedging currency risk / storing or liquidating Bitcoin revenue Hardware cost Power cost Revenue in BTC 34 There are also some interesting strategic considerations that every miner has to make before they pick which blocks to work on. Which transactions to include. Miners get to choose which transactions they include in a block. The default strategy is to include any transaction which includes a transaction fee higher than some minimum. Which block to mine on. Miners also get to decide on top of which block they want to mine. The default behavior for this decision is to extend the longest known valid chain. Choosing between blocks at the same height. If two different blocks are mined and announced at around the same time, it results in a 1‐block fork, with either block admissible under the longest valid chain policy. Miners then have to decide which block to extend. The default behavior is to build on top of the block that they heard about first. When to announce new blocks. When they find a block, miners have to decide when to announce this to the Bitcoin network. The default behavior is to announce it immediately, but they can choose to wait some time before announcing it. 35  Mining pools  Syndicates of miners who work together and agree to share the rewards  Similar to lottery pools involving many people who purchase tickets and share the prizes equally  Cloud mining  Using background computing power that would otherwise be idle 36 Are mining pools a good thing? Advantages Mining is much more predictable for the participants and they make it easier for smaller miners to get involved in the game. makes it easier to upgrade the network Disadvantages they are a form of centralization lowers the population of people actually running a fully validating Bitcoin node. 37 38 Blocks Mined Per Day Bitcoin was set up to try to track the difficulty level (hashing capacity) in the total network and to adjust the difficulty of the next batch of blocks every 2016 block (nominally every 2 weeks). The aim is to try to have the next 2016 blocks take 2 weeks to complete. next_difficulty = (previous_difficulty * 2016 * 10 minutes) / (time to mine last 2016 blocks) 39 An estimation of hashrate distribution amongst the largest mining pools as of 19 Sep 2019 May 10th, 2021, 4 day average Massoud 40 https://blockchain.info/pools Summary of topics 1. Logic of the Blockchain 2. Encrypting data with hash functions 3. Timestamp Server Example of transaction 4. Storing large amounts of data 5. Updating the blockchain 6. Incentive & Mathematically Metered Supply 7. Network 8. Immutability of the Blockchain 9. Governance of Bitcoin 41 In class exercise #3 Use this website https://blockchain.info/ to find the following: 1. Blocks: for the last 2 blocks what was: hight, hash, miner, size 2. Transactions: for the last 2 transaction what was the time and the amount 3. What is the range of the Average Fee? 4. What is the Average Value? 5. Is the Difficulty increasing or decreasing? 6. What is the range of the Hashrate? 7. What is Mempool? 8. Using $US, what is the return in on Bitcoin, start day of acquiring one bitcoin was in August 17th, 2014, August 17th 2016, August 17th 2017, August 17th 2018, August 17th 2019 9. What is the range of the Tx per day? 10. What is the range of Unconfirmed transactions? 42 On Oct 3, 2019. 1:55pm Using $US What is the return on Bitcoin, start day of acquiring one bitcoin was in Jan 3rd, 2014, Jan 4th, 2016, Jan 3rd 2017, Jan 3rd, 2018, Jan 3rd, 2019 Massoud 43 Outline 1. Logic of the Blockchain 2. Encrypting data with hash functions 3. Timestamp Server - Example of transaction 4. Storing large amounts of data 5. Updating the blockchain 6. Incentive & Mathematically Metered Supply 7. Network 8. Immutability of the Blockchain 9. Governance of Bitcoin 44 8. Immutability of the Blockchain: Forking attack. The simplest attack is a forking attack and the obvious way to profit to perform a double spend. A pays B A pays A’ Economic problem for A: 1. loss of revenue from building those extra block and the deflation in the value of her currency.. 2. It is a horse race, statistically it is difficult race to do since you have also 51% chance also of wining 3. Trade off of revenue from double spending and the loss of revenue (variable and fixed and deflation of currency) 45 Competition among miners creates the indelibility of data on a blockchain Fraud = rewriting old transactions Prohibitively difficult to recreate a block; nonces must be found for all subsequent blocks before honest miners code the next block Implication: transactions are indelible, but also irreversible Note potential conflict if two miners each discover a valid block without knowing of 46 Source: Mark Montgomery / IEEE Spectrum one another  Bitcoin is run from an “open source” computer code, and “governance” equates to control of this code  The source code can be read and modified by anyone, and the new version then placed into circulation  The new version of the code can be adopted by miners one by one, creating a “fork” in the blockchain  A new fork will become the new blockchain if followed by 51% or more of the network  One CPU, one vote  Not one address, one vote 47 Type of Forks Hard Fork: is a radical change to a network's protocol that makes previously invalid blocks and transactions valid, or vice-versa. A hard fork requires all nodes or users to upgrade to the latest version of the protocol software. Soft Fork: In blockchain technology, a soft fork is a change to the software protocol where only previously valid transaction blocks are made invalid. Because old nodes will recognize the new blocks as valid, a soft fork is backwards- compatible. This kind of fork requires only a majority of the miners upgrading to enforce the new rules, as opposed to a hard fork that requires all nodes to upgrade and agree on the new version. With a soft fork, only one blockchain will remain valid as users adopt the update. Whereas with a hard fork, both the old and new blockchains exist side by side, which means that the software must be updated to work by the new rules. 48  Myth: Bitcoin supply is fixed at 21 million (= monetary policy by algorithm)  Correct: Bitcoin supply can be increased by changing the source code with 51% consent (= monetary policy by the mob) (= monetary by sabotage, by anarchy, etc.) 49  “The system is secure as long as honest nodes collectively control more CPU power than any cooperating group of attacker nodes.”  Nakamoto (2008)  What could go wrong? A “51% attack”  This could be done for a variety of motives  Personal gain: theft or counterfeiting of extant Bitcoins  Economic destabilization  Rival currency sponsors  Rogue governments  Nations at war  Terrorists 50  Brute force: invest enough to double the existing CPU power of the network  In 2017, to build from scratch a mining power equal to 51% current approximate cost is close to $660 million. (The market capitalization of Bitcoin was at 17.1 billion)  In 2019, to build from scratch a mining power equal to 51% current approximate cost is close to $2.9 billion (The market capitalization of Bitcoin was at 117.81 billion U.S. dollars.) 51 As of March 2017, a Bitcoin mining machine that produced 14 terahash per second (TH/s) could be bought for $2,300. TH/s represents the number of times a machine can execute instructions per second. It would take 286,000 of the aforementioned 14 TH/s machines to produce 4,000,000 TH/s, which was the hash rate of the Bitcoin network at the time. How much does it take to conduct a 51% attack? Hence, Bitcoin’s network could be re-created with a $660 million spend, which would give an attacker control of 50 percent of the network. Yes, 50 percent, because if the hash rate started at 100, and an attacker bought enough to re-create it (100), then the hash rate would double to 200, at which point the attacker has a 50 percent share. 52 51% attack on Bitcoin Gold Bitcoin Gold was born as a hard fork of Bitcoin blockchain in October 2017 Used a proof-of-work that disabled the use of specialized equipment (e.g. ASICs) for mining operations Goal was to achieve a higher level of resilience through decentralized mining structure Several 51%attacks during May 16-19 double spent $18 million worth of Botcoin Gold Loss of confidence in Bitcoin Gold and decline the exchange rate Only 0ne-sixth of what it was at time of attack and number of transaction declined to less than one-third 53 54 Key question Why was Bitcoin Gold subject to successful 51% attack, while Bitcoin itself has not been? Is the fixed cost in cryptocurrency mining crucial in answering this question? 55 56 Wait for six blocks (one hour)? Source: https://www.buybitcoinworldwide.com/confirmations/ 57 Summary of topics 1. Logic of the Blockchain 2. Encrypting data with hash functions 3. Timestamp Server Example of transaction 4. Storing large amounts of data 5. Updating the blockchain 6. Incentive & Mathematically Metered Supply 7. Network 8. Immutability of the Blockchain 9. Governance of Bitcoin 58 In-Class exercise 1. What is the main ideology of Bitcoin? 2. What is logic of a blockchain and its implication? 3. What is a hash function? 4. What are Merkle Trees and what problems do they Solve? 5. How Bitcoin white paper suggested to verify the posted transactions on the blockchain? 6. Why a 51% attack on Bitcoin did not happen so far? 59

Use Quizgecko on...
Browser
Browser