Rustie Lin Gloria Wang 2 LECTURE OVERVIEW
Total Page:16
File Type:pdf, Size:1020Kb
1 BITCOIN IRL: WALLETS, MINING, & MORE Rustie Lin Gloria Wang 2 LECTURE OVERVIEW 1 WALLET TYPES 2 WALLET MECHANICS 3 MINING 4 REAL WORLD MINING 5 CHANGING BITCOIN 3 TYPES OF 0 USERS 4 TYPES OF USERS KEY COMPONENTS Not every client is a miner What if I don’t have a powerful computer? Not every client has the entire blockchain (160+ GB) What if I just want to send bitcoins with my phone? Not every client is directly connected to the network What if I don’t need to make regular transactions? Not every client has a wallet Image source: Mastering Bitcoin What if I have a separate wallet client? AUTHOR: RUSTIE LIN 5 TYPES OF USERS EVERYONE Image source: http://bitcoinbook-builds.mkvd.net/translations/vi/chapter-6.html 6 WALLET 1 TYPES 7 BITCOIN WALLETS KEY MANAGEMENT ADDRESS: To secure our identity, we 1JJQmRbU9JT9mfxjp756Y need to secure our private MuxV6yksKtbk5 key PRIVATE_KEY: L1fm3iAFdDHwSD3CZuZm How do we manage all of Wp54GXpQ6QzUjmrACVfK our keys? With wallets! KE8BkggW99u3 AUTHOR: NADIR AKHTAR 8 BITCOIN WALLETS WALLET TYPES What do wallets do? ● Keep track of your private key ● Store, send & receive, and list transactions ● Maybe some other related fancy functionality AUTHOR: SUNNY AGGARWAL & RUSTIE LIN 9 BITCOIN WALLETS HOT AND COLD Wallet Forms ○ Smartphone apps ■ Mycelium, AirBitz ○ Online web-wallets Hot Wallet ■ Blockchain.info, coinbase.com ○ Paper Wallets } ■ Bitcoinpaperwallet.com ■ Bitaddress.org ○ Hardware Wallets ■ Ledger, Trezor, Case, KeepKey Cold Storage ○ Brain Wallet } AUTHOR: SUNNY AGGARWAL & RUSTIE LIN UPDATED: NADIR AKHTAR 10 BITCOIN WALLETS HOT WALLETS Wallet Forms ○ Smartphone apps ■ Mycelium, AirBitz ○ Online web-wallets Hot Wallet ■ Blockchain.info, coinbase.com ○ Paper Wallets } ■ Bitcoinpaperwallet.com ■ Bitaddress.org ○ Hardware Wallets ■ Ledger, Trezor, Case, KeepKey ○ Brain Wallet AUTHOR: SUNNY AGGARWAL & RUSTIE LIN UPDATED: NADIR AKHTAR 11 BITCOIN WALLETS HOT WALLETS Image sources: https://blockchain.info/ https://wallet.mycelium.com https://airbitz.co/bitcoin-wallet/ https://www.coinbase.com/mobile AUTHOR: RUSTIE LIN 12 BITCOIN WALLETS COLD STORAGE Wallet Forms ○ Smartphone apps ■ Mycelium, AirBitz ○ Online web-wallets ■ Blockchain.info, coinbase.com ○ Paper Wallets ■ Bitcoinpaperwallet.com ■ Bitaddress.org ○ Hardware Wallets ■ Ledger, Trezor, Case, KeepKey Cold Storage ○ Brain Wallet } AUTHOR: SUNNY AGGARWAL & RUSTIE LIN UPDATED: NADIR AKHTAR 13 BITCOIN WALLETS PAPER WALLETS Image source: https://bitcoinpaperwallet.com/ AUTHOR: RUSTIE LIN 14 BITCOIN WALLETS HARDWARE WALLETS Image sources: https://www.ledgerwallet.com/ AUTHOR: RUSTIE LIN https://trezor.io/ https://choosecase.com/ 15 BITCOIN WALLETS BRAIN WALLETS ● Simply memorize your private key E9873D79C6D87DC0FB6A5778633 389F4453213303DA61F20BD67FC2 Image source: http://ecclezzia.com/articles/10-wierd-ways-brain-tricking/ 33AA33262 AUTHOR: RUSTIE LIN 16 BITCOIN WALLETS BRAIN WALLETS Brain wallets are a mnemonic, or collection of words/phrases ● Convenient way to memorize your private key ● Easier to have something that you can turn into your private key ● Not very secure, as humans aren’t as random as we think we are AUTHOR: SUNNY AGGARWAL & RUSTIE LIN 17 BITCOIN WALLETS KEY STRETCHING multiply scrap submit select adjust end accuse SHA-256 fuel nose hope chair afraid AUTHOR: SUNNY AGGARWAL 18 BITCOIN WALLETS KEY STRETCHING multiply scrap submit select adjust SHA-256end accuse fuel nose hope chair afraid AUTHOR: SUNNY AGGARWAL 19 BITCOIN WALLETS KEY STRETCHING 98cfe008e1fbfc74 770fb828531e18b SHA-256a4c19a0edd20ceb 8fc2396ba436ad6 a1c AUTHOR: SUNNY AGGARWAL 20 BITCOIN WALLETS KEY STRETCHING 98cfe008e1fbfc74 770fb828531e18b SHA-256 a4c19a0edd20ceb 8fc2396ba436ad6 a1c AUTHOR: SUNNY AGGARWAL 21 BITCOIN WALLETS KEY STRETCHING 98cfe008e1fbfc74 770fb828531e18b a4c19a0edd20ceb SHA-256 8fc2396ba436ad6 a1c AUTHOR: SUNNY AGGARWAL 22 BITCOIN WALLETS KEY STRETCHING 98cfe008e1fbfc74 770fb828531e18b a4c19a0edd20cebSHA-256 8fc2396ba436ad6 a1c AUTHOR: SUNNY AGGARWAL 23 BITCOIN WALLETS KEY STRETCHING a4552b084ed7314 415b9367502124b SHA-256f84be086a393bee b0fb51294e2a378 3d0b AUTHOR: SUNNY AGGARWAL 24 BITCOIN WALLETS KEY STRETCHING a4552b084ed7314 415b9367502124b SHA-256 f84be086a393bee b0fb51294e2a378 3d0b AUTHOR: SUNNY AGGARWAL 25 BITCOIN WALLETS KEY STRETCHING a4552b084ed7314 415b9367502124b f84be086a393bee SHA-256 b0fb51294e2a378 3d0b AUTHOR: SUNNY AGGARWAL 26 BITCOIN WALLETS KEY STRETCHING a4552b084ed7314 415b9367502124b f84be086a393beeSHA-256 b0fb51294e2a378 3d0b AUTHOR: SUNNY AGGARWAL 27 BITCOIN WALLETS KEY STRETCHING 0bac829073dced edb6dddff3e07c4 SHA-2568d3bfcd000fd4c2 50b025afbf3fd29 08c98 AUTHOR: SUNNY AGGARWAL 28 BITCOIN WALLETS KEY STRETCHING 0bac829073dced edb6dddff3e07c4 SHA-256 8d3bfcd000fd4c2 50b025afbf3fd29 08c98 AUTHOR: SUNNY AGGARWAL 29 BITCOIN WALLETS CHOOSING A WALLET Image source: https://bitcoin.org AUTHOR: SUNNY AGGARWAL 30 HOW DO I GET BITCOIN? ?????????? “But how do I get bitcoins?” Image source: https://www.reddit.com/r/Bitcoin/ AUTHOR: RUSTIE LIN 31 HOW DO I GET BITCOIN? BITCOIN ATMS Image sources: https://www.google.com/maps https://coinucopia.io/ AUTHOR: RUSTIE LIN 32 HOW DO I GET BITCOIN? EXCHANGES ● Exchanges: ○ https://bitcoin.org/en/exchanges ● Trading between different types of currency ● Centralized and decentralized exchanges, security, easy of access, etc. Image source: https://bitcoin.org/en/exchanges AUTHOR: RUSTIE LIN 33 HOW DO I GET BITCOIN? DECENTRALIZED EXCHANGES Decentralized exchanges don’t rely on a third party service to hold customer’s funds or private keys ● Trades are P2P ● Trustless ● Bitshares, Bisq (ex Bitsquare), Openledger, Airswap, Etherdelta, etc. Image source: https://www.cryptocompare.com/exchanges/guides/what-is-a-decentralized-exchange/ AUTHOR: RUSTIE LIN 34 WALLET 2 MECHANICS 35 SIMPLE PAYMENT VERIFICATION THIN CLIENTS Simple Payment Verification (SPV) is method for verifying if particular transactions are included in a block without downloading the entire block ● Keep track of your transactions only ● Lightweight or thin clients Image source: http://bitcoinbook-builds.mkvd.net/translations/vi/chapter-6.html AUTHOR: RUSTIE LIN 36 SIMPLE PAYMENT VERIFICATION THIN CLIENTS Assumption: Incoming block headers are not from a false chain ● Connect to many different nodes ● Long term, chain is probably honest Stored locally ● Can’t really afford to put the Queried from full nodes entire blockchain on your Incoming tx phone, so having a thin client is Image source: Mastering Bitcoin a decent tradeoff AUTHOR: RUSTIE LIN & MAX FANG 37 MULTISIGNATURE M-OF-N TRANSACTIONS AUTHOR: SUNNY AGGARWAL 38  BITCOIN MECHANICS MULTISIG TRANSACTION Derrick Rustie Gloria Nadir AUTHOR: RUSTIE LIN 39  BITCOIN MECHANICS MULTISIG TRANSACTION Rustie Rustie Rustie Nadir AUTHOR: RUSTIE LIN 40  BITCOIN MECHANICS MULTISIG TRANSACTION Company Rustie Rustie Nadir AUTHOR: RUSTIE LIN 41 BITCOIN MECHANICS KEY GENERATION PRACTICES ● Best practice is to never reuse pseudonyms ● Why? ○ Someone should not be able to determine how much bitcoin you own ○ Compromising one key is independent of the other ones ○ Keys are computationally easy to generate anyways ● Wallet software will handle this AUTHOR: SUNNY AGGARWAL 42 WALLET BACKUPS JBOK WALLETS ● JBOK (Just a Bunch Of Keys) ○ New backup required for every new key pair ○ Or, generate a bunch of keys when first started ○ Not too convenient because you have to store every key pair AUTHOR: RUSTIE LIN 43 WALLET BACKUPS HD WALLETS ● HD (Hierarchical Deterministic) Wallets ○ Deterministic, and more convenient to know a seed, or master key ○ Use a one-way hash function with seed and index number ○ Exchanges use these AUTHOR: RUSTIE LIN 44 BITCOIN WALLETS WALLET BACKUPS AUTHOR: SUNNY AGGARWAL 45 MINING 3 46 RECIPE FOR 3.1 MINING 47 RECIPE FOR MINING OVERVIEW A full-fledged Bitcoin miner must: 0. Download the entire Bitcoin blockchain 1. Verify incoming transactions 2. Create a block 3. Find a valid nonce 4. Broadcast your block 5. Profit! Image source: http://www.coindesk.com/information/how-to-set-up-a-miner/ AUTHOR: NADIR AKHTAR EDITED: RUSTIE LIN 48 RECIPE FOR MINING STEP 0: DOWNLOAD THE BLOCKCHAIN Rustie Gloria ● Get blocks from your peers ● Download the entire Derrick blockchain Nick ○ Start from the genesis block ● Stay up to date Nadir BLOCK HEADER BLOCK HEADER BLOCK HEADER PREV BLOCK PREV BLOCK PREV BLOCK MERKLE ROOT MERKLE ROOT MERKLE ROOT HASH HASH HASH AUTHOR: RUSTIE LIN 49 RECIPE FOR MINING STEP 1: VERIFY TRANSACTIONS ● Listen to the Bitcoin network for transactions ● Unconfirmed (pending) transactions sit in the mempool for a miner to include it in a block ● Verify incoming transactions by running the unlocking script (remember P2PKH and P2SH?) Rustie Gloria Image sources: https://ru-clip.com/video/rVrb6rrRvNQ/what-is-a-mempo Derrick ol-and-how-to-speed-up-unconfirmed-transactions.html https://englishinreims.wordpress.com/toeic-training/prac tice-toeic-listening-part-i/ Nick AUTHOR: RUSTIE LIN Nadir 50 RECIPE FOR MINING STEP 2: CREATE A BLOCK BLOCK HEADER BLOCK HEADER BLOCK HEADER PREV BLOCK PREV BLOCK PREV BLOCK MERKLE ROOT MERKLE ROOT MERKLE ROOT HASH HASH HASH E = H(A || B) F = H(C || D) A = H(TX ) B = H(TX ) C = H(TX ) D = H(TX ) ● Gather transactions into a block 1 2 3 4 TX TX TX ○ Choose whichever transactions Coinbase 2 3 4 you want (most transaction fees) ● Get previous block hash and other necessary metadata AUTHOR: RUSTIE LIN 51 RECIPE FOR MINING STEP 3: FIND A VALID NONCE ● Find the proof-of-work BLOCK HEADER ● Expend computational power PREV BLOCK MERKLE ROOT NONCE