Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Blockchain Basics

121 views

Published on

a jargon-free introduction to Bitcoin Blockchain.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Blockchain Basics

  1. 1. blockchain basics November 28, 2018 a jargon-free introduction to bitcoin blockchain
  2. 2. our goal today 1. What’s in a wallet? 2. Where do bitcoins come from? 3. Step-by-step examination of a crypto- transaction
  3. 3. PART 1: Wallets What’s in a wallet?
  4. 4. What’s in a wallet? • Your private key • One of more public key(s) CRYPTO-WALLETS DO NOT CONTAIN COINS CRYPTO-CURRENCY IS NOT STORED ANYWHERE ONLY YOUR CLAIM ON THE CURRENCY IS STORED ON BLOCKCHAIN
  5. 5. Types of wallets Based on where your keys are stored, there are a few different types of wallets: • Desktop • Mobile • Web • Hardware • Paper
  6. 6. Desktop Wallets • Electrum (intimidating UI, secure, advanced features like address tagging, fee adjustments, wallet encryption, signed messages, SPV or API option) • Exodus (modern UI, excellent starter wallet, SPV wallet, altcoin support) • Bitcoin Code (full node wallet, independent verification) • Copay (multi-signature, extra security against theft, good option if you can’t afford a hardware wallet) • Armory (secure, features a variety of encryption and cold-storage options) • Jaxx (easy to use, excellent starter wallet, altcoin support)
  7. 7. Mobile Wallets • Electrum (bitcoin only, watch-only option) • Mycelium (tried and tested security, >100,000 users, iOS and Android, linked debit-card support) • Mobi (support for over 100 fiat currencies, instant cross-border payments, bitcoin only) • Coinbase (>8M users, multisig support, intuitive UI, simple to setup and use) • Blockchain.info (14M users, minimalist design and options)
  8. 8. Web Wallets • Coinbase • Green Adress • BitGo • Xapo • Copay
  9. 9. Hardware Wallets • Ledger Nano S • Trezor • Keepkey
  10. 10. ● Simply a public key and private key printed together ● https://walletgenerator.net/ Paper Wallets
  11. 11. Hands-on Lab Setting up a wallet (or two) Exodus.io Jaxx.io
  12. 12. Part 2: Where do bitcoins come from?
  13. 13. Where do bitcoins come from? Fiat Currency Crypto-currency Controlled by Central Authority (Governments) No Central Authority Printed when Government decides to print more Miners (human) use special software to solve math problems are issued new bitcoins in exchange The special software is called Miner (software) This special software can be run on specialized hardware to speed up mining and generate more bitcoins. This specialized hardware is called Miner (hardware)
  14. 14. Mining in early days ● Math problems were simple enough ● Anyone with a computer and miner (software) could mine bitcoins ● Bitcoins mined at this time are sometimes referred to as ‘CPU-mined bitcoins’
  15. 15. Mining in early years ● Gamers figured out that mining with GPUs was faster ● GPU mining took-off ● But, GPUs consumed more electricity and produced more heat
  16. 16. Mining in mid years • Companies started building Application-Specific Integrated Circuit (ASIC) chips to perform mining operations • ASIC hardware is faster and more energy efficient than GPUs
  17. 17. Mining today ● Contribute your hardware to solving math problems in concert with others ● Purchase into a specialized data center specifically designed for mining ● Share profits in proportion to your contribution
  18. 18. Mining Pool
  19. 19. Why are miners rewarded? Miners are required to validate bitcoin transactions on the network, thereby providing a critical service to the network. If 51% of the network approved the validity of a transaction, it is cleared (added to the blockchain)
  20. 20. Miners provide valuable services • Book-keeping: The bitcoin miner client downloads and syncs in real time the entire blockchain of the bitcoin network • Network guardians: Miners safeguard the network against hacks and validate each transaction • Settlement and Clearing: Blocks validated by miners are added to the blockchain without dependence on a trusted 3rd party • Creation of new bitcoins: Miners are rewarded with bitcoins for contributing processing power and keeping the network safe
  21. 21. Mining Demo
  22. 22. Part 3: Under the hood step-by-step examination of a bitcoin transaction
  23. 23. Hash Functions ● A function that takes an input (of any size) and converts into an output (of fixed size) ● It’s a deterministic function: The output will always be the same for a given input
  24. 24. Cryptographic Hash Functions ● The qualifier ‘Cryptographic’ implies that the hash function ○ is computationally efficient - apply transformation quickly, ○ is collision resistant - hard to find 2 inputs that result in the same output ○ hides information - hard to infer the input by examining the output ○ looks random - well-distributed output - should look random ● Sometimes referred to as a mathematical meat grinder ● Examples include MD5 (Message Digest 5), SHA-256 (Secure HAsh 256) ● Applications include - Digital Signatures, Cryptocurrencies
  25. 25. Digital Signatures • Digital signature is a way of combining a public sequence of numbers with a message • Examples include RSA, DSS • Each Signature includes 2 keys: • signing key (sk) or private key, and • verification key (vk) or public key • It is hard to come up with the signing key if you have the verification key
  26. 26. https://exonum.com/blog/09-27-17-digital- signature/
  27. 27. What is a transaction? Transaction is a digitally signed declaration by one party of it’s intent to transfer some bitcoins they posses to another party
  28. 28. Bitcoin P2P Network
  29. 29. Transaction Workflow ● Everybody can see the ledger ● This is what a network looks like except... BTC LEDGER (State of the Network / Account of all Coins) Ashley 10 Berk 12 David 13 Emre 50 Karen 26 Marie-Louise 70 Nani 123
  30. 30. Transaction Workflow ● Everybody can see the ledger ● No one knows your name ● Your identity is represented by your public key / verification key ● This is what a network looks like, except... BTC LEDGER (State of the Network / Account of all Coins) MIIBOQIBAAJAT+qwrlMhJOkn3VSQQK... 10 FsPkKavfDcE19SFZnuJ4HHA0XMn3xD... 12 TtWttB/pfSh5FT/Wr6B3bRoM7nzWpeq... 13 AiEAnnIGwnywSjvpsecRrp9RTpVqgirn... 50 DesPyX5YO5eXSieI8cV5xs+nDsz6KwIh... 26 WdqKfiE5+YcBAiBP0aaBTe8xk5TNW0h…. 70 wi4V/2ZlZnl6kn+QgtKx+hQC8ZWKvBcb... 123
  31. 31. Transaction Workflow ● Everybody can see the ledger ● No one knows your name ● Your identity is represented by your public key / verification key ● No one knows who you are unless they transact with you in person Governments and Financial Institutions do not like this. BTC LEDGER (State of the Network / Account of all Coins) MIIBOQIBAAJAT+qwrlMhJOkn3VSQQK... 10 FsPkKavfDcE19SFZnuJ4HHA0XMn3xD... 12 TtWttB/pfSh5FT/Wr6B3bRoM7nzWpeq... 13 AiEAnnIGwnywSjvpsecRrp9RTpVqgirn... 50 DesPyX5YO5eXSieI8cV5xs+nDsz6KwIh... 26 WdqKfiE5+YcBAiBP0aaBTe8xk5TNW0h…. 70 wi4V/2ZlZnl6kn+QgtKx+hQC8ZWKvBcb... 123
  32. 32. Transaction Workflow Node with public key , digitally signs a declaration announcing to the network, it’s intent to transfer 10 bitcoins they possess to node with public key . Network’s job is to verify that node with public key , does possess 10 or more bitcoins. BTC LEDGER (State of the Network / Account of all Coins) MIIBOQIBAAJAT+qwrlMhJOkn3VSQQK... 10 FsPkKavfDcE19SFZnuJ4HHA0XMn3xD... 12 TtWttB/pfSh5FT/Wr6B3bRoM7nzWpeq... 13 AiEAnnIGwnywSjvpsecRrp9RTpVqgirn... 50 DesPyX5YO5eXSieI8cV5xs+nDsz6KwIh... 26 WdqKfiE5+YcBAiBP0aaBTe8xk5TNW0h…. 70 wi4V/2ZlZnl6kn+QgtKx+hQC8ZWKvBcb... 123 10
  33. 33. Transaction Workflow At any given time, there are multiple declarations of transactions being proposed to the network. Several of these proposed transactions are combined to form a Merkle Tree. BTC LEDGER (State of the Network / Account of all Coins) MIIBOQIBAAJAT+qwrlMhJOkn3VSQQK... 10 FsPkKavfDcE19SFZnuJ4HHA0XMn3xD... 12 TtWttB/pfSh5FT/Wr6B3bRoM7nzWpeq... 13 AiEAnnIGwnywSjvpsecRrp9RTpVqgirn... 50 DesPyX5YO5eXSieI8cV5xs+nDsz6KwIh... 26 WdqKfiE5+YcBAiBP0aaBTe8xk5TNW0h…. 70 wi4V/2ZlZnl6kn+QgtKx+hQC8ZWKvBcb... 123 10
  34. 34. Merkle Tree https://hackernoon.com/merkle-trees-181cb4bc30b4 10
  35. 35. Using a Merkle tree allows for a quick and simple test of whether a specific transaction is included in the set or not. https://hackernoon.com/merkle-trees-181cb4bc30b4
  36. 36. Why hash transactions? • Reduce the amount of data that needs to be downloaded by a node for verification purposes • Validation proofs are computationally easy and fast
  37. 37. Why Merkle tree? Why not hash all transactions at once? • One branch can be downloaded at a time • Integrity of each branch can be immediately verified even if the rest of the tree is not downloaded yet • If a small block file is damaged, it can be individually downloaded without having to download all the blocks • Merkle tree can reside locally or on a distributed system
  38. 38. Transaction Workflow Merkle tree is created from a set of proposed transactions. Transaction from to is included. Merkle Root summarizing all the transactions is created and stored in the block header. BTC LEDGER (State of the Network / Account of all Coins) MIIBOQIBAAJAT+qwrlMhJOkn3VSQQK... 10 FsPkKavfDcE19SFZnuJ4HHA0XMn3xD... 12 TtWttB/pfSh5FT/Wr6B3bRoM7nzWpeq... 13 AiEAnnIGwnywSjvpsecRrp9RTpVqgirn... 50 DesPyX5YO5eXSieI8cV5xs+nDsz6KwIh... 26 WdqKfiE5+YcBAiBP0aaBTe8xk5TNW0h…. 70 wi4V/2ZlZnl6kn+QgtKx+hQC8ZWKvBcb... 123 10
  39. 39. What’s in a block? ● List of Transactions ● Merkle Root ● Timestamp ● Difficulty Target ● Nonce ● Hash of previous block
  40. 40. Difficulty Target ● Difficulty target is a number that regulates how long it takes for miners to add new blocks to transactions to the blockchain ● The difficulty target adjusts every 2016 blocks (roughly 2 weeks) Why is Difficulty Target important? ● It ensures that blocks of transactions are added to the blockchain at regular intervals, even as more miners join the network
  41. 41. 1. Difficulty adjusts every 2016 blocks. Let’s assume it takes 2 weeks (20160 minutes) to add 2016 blocks. This means that each block is expected to be added in 10 min. TExpected = 10 2. Let’s say more miners joined the network and it took miners, an average of 9 min per block. TActual = 9 3. Calculate (TExpected /TActual) = 1.1 4. New Difficulty (DNEW) = DCURRENT X 1.1 Difficulty Target Calculation
  42. 42. How does Difficulty control time between blocks? Let’s play a simple math game. Assumptions: ● You are given a range of numbers 1-100 where 100 is the RANGEMAX ● You randomly generate a number between 1 and 100 every minute Objective: ● Generate a number below my TARGET
  43. 43. How does Difficulty control time between blocks? TARGET = 50 How long will it take (on average) for you to find a number below my TARGET?
  44. 44. How does Difficulty control time between blocks? TARGET = 20 How long will it take (on average) for you to find a number below my TARGET?
  45. 45. How does Difficulty control time between blocks? TARGET = 10 How long will it take (on average) for you to find a number below my TARGET?
  46. 46. How does Difficulty control time between blocks? The lower the TARGET, the longer it takes for us reach our objective TARGET Time to find reach objective 50 2 min 20 5 min 10 10 min
  47. 47. If instead of providing you the TARGET, I provided you ANOTHER_NUMBER by which to divide the RANGEMAX , we would get the the same result This ANOTHER_NUMBER is called DIFFICULTY_TARGET ANOTHER_NUMBER TARGET (RANGEMAX/ANOTHER_NUMBER) Time to reach objective 2 50 2 min 5 20 5 min 10 10 10 min How does Difficulty control time between blocks?
  48. 48. ● Our assumptions from previous activity are ridiculous for real-world implementations ● Miners are able to generate thousands of numbers (hash values) per minute as opposed to our measly 1 per minute ● To make things worse, there are many miners working on the problem concurrently ● To make DIFFICULTY_TARGET work, MAX_RANGE needs to be big ● Real world MAX_RANGE looks more like: 8972345609248750982347034985702348957202938547029438750928349847 Real World Numbers
  49. 49. ● Real world DIFFICULTY_TARGET looks something like this: 13498.928322 ● Since MAX_RANGE is a big number, we use hexadecimal system to represent numbers as opposed to decimal. In reality, MAX_RANGE range looks more like this: 000000000003ba27aa200b1cecaad478d2b00432346c3f1f3986da1afd33e506 Real World Numbers
  50. 50. ● Difficulty targets control the time it takes to add a block ● Miners are tasked with finding a hash lower than TARGET, as calculated based upon the MAX_RANGE and DIFFICULTY_TARGET ● Hashes are just numbers represented in Hexadecimal Summarizing Difficulty Targets
  51. 51. What’s in a block? ● List of Transactions ● Merkle Root ● Timestamp ● Difficulty Target ● Nonce ● Hash of previous block
  52. 52. NONCE (number used once) Nonce is a random integer between 0 and 4,294,967,296
  53. 53. How is a block made? Hash of the previous block (publicly known) + Current transactions + Nonce (randomly selected) HASH IT Miners are expected to get a valid hash for their candidate block such that the hash of their block headers is below the TARGET
  54. 54. Revisiting Nonce • Nonce is a random integer between 0 and 4,294,967,296 • Miners have to ‘guess’ the nonce when they’re trying to get the hash of their block headers below a TARGET • Typically they do this brute force by incrementing the nonce until they get a valid hash
  55. 55. When a miner succeeds in guessing the nonce… • They can send the block to the network • The network can easily verify if the nonce is correct • Once majority of the network agrees, everyone will add the new block to their blockchains • Miner will pick up the block reward for their efforts
  56. 56. It’s essentially a guessing game In some ways, the miner to guess the right nonce is just lucky to be the first to find the nonce. Once a nonce is found, it can be easily verified. The miner can therefore, easily ‘prove’ that they have performed the ‘work’ to find the correct nonce.
  57. 57. Proof-of-Work ● Has been in use for many years prior to bitcoin ● Applications include: Denial of Service attack prevention, SPAM prevention
  58. 58. Transaction Workflow Transaction, once verified, will change the ledger state to below. BTC LEDGER (State of the Network / Account of all Coins) MIIBOQIBAAJAT+qwrlMhJOkn3VSQQK... 10 FsPkKavfDcE19SFZnuJ4HHA0XMn3xD... 22 TtWttB/pfSh5FT/Wr6B3bRoM7nzWpeq... 13 AiEAnnIGwnywSjvpsecRrp9RTpVqgirn... 50 DesPyX5YO5eXSieI8cV5xs+nDsz6KwIh... 26 WdqKfiE5+YcBAiBP0aaBTe8xk5TNW0h…. 70 wi4V/2ZlZnl6kn+QgtKx+hQC8ZWKvBcb... 113 10
  59. 59. Blockchain is a chain of blocks
  60. 60. What is a blockchain? • is a chain of digital signatures that reflect each bitcoin’s path through the bitcoin network • is a chain of blocks • is a database • is a distributed database • is a distributed ledger • is an immutable distributed ledger
  61. 61. Thank you

×