CRYPTOCURRENCY &
BLOCKCHAIN
Nguyen Trung Thong
[email protected]
Blockchain Basics
and Consensus
Class 4 Overview
• Review of Blockchain Design
• Consensus through Proof of Work
• Bitcoin Mining
• Native Currency
• Network
• Other Consensus Protocols
• Conclusions
4
Review - Blockchain Technology
timestamped
auditable database network consensus protocol
append-only log
Secured via cryptography Addresses ‘cost of trust’
• Hash functions for tamper (Byzantine Generals problem)
resistance and integrity • Permissioned
• Digital signatures for consent • Permissionless
Consensus for agreement
5
Bitcoin – Technical Features
• Cryptography & Timestamped Logs
• Cryptographic Hash Functions
• Timestamped Append-only Logs (Blocks)
• Block Headers & Merkle Trees
• Asymmetric Cryptography & Digital Signatures
• Addresses
• Decentralized Network Consensus
• Proof of Work
• Native Currency
• Network
• Transaction Script & UTXO
• Transaction Inputs & Outputs
• Unspent Transaction Output (UTXO) set
• Scripting language 6
Cryptography:
Communications in the presence of adversaries
Scytale Cipher Enigma Machine Asymmetric Cryptography
Ancient Times 1920s - WWII 1976 to today
© Luringen on Wikimedia Commons. License CC BY-SA. All rights
Image by the CIA and is in the public domain via Image is in the public domain via Wikipedia.
reserved. This content is excluded from our Creative Commons license.
Wikimedia Commons.
For more information, see https://ocw.mit.edu/help/faq-fair-use/
7
Cryptographic Hash Functions
One-Way Data Compression
© Source unknown. All rights reserved. This content is excluded from our Creative Commons license. For more information, see
Data Commitment https://ocw.mit.edu/help/faq-fair-use/
8
Timestamped Append-only Log - Blockchain
9
Image is in the public domain.
Merkle Tree – Binary Data Tree with Hashes
10
Image is in the public domain.
Asymmetric Cryptography & Digital Signatures
Guarding against Tampering & Impersonation
Digital Signature without Hash
Shyam Nandan Kumar et al. Review on Network Security and Cryptography. © Science
11 and Education Publishing. All rights reserved. This content is excluded from our Creative
Commons license. For more information, see https://ocw.mit.edu/help/faq-fair-use/
Asymmetric Cryptography & Digital Signatures
Guarding against Tampering & Impersonation
Digital Signature with Hash
Shyam Nandan Kumar et al. Review on Network Security and Cryptography.
12
Bitcoin Address
Determined by – but not identical to - Public Key
13
© Source unknown. All rights reserved. This content is excluded from our Creative Commons license. For more information, see https://ocw.mit.edu/help/faq-fair-use/
Decentralized Networks
Permissionless Blockchains -
Byzantine Generals Problem
Unknown participants
Attack!
Attack! ? ?
Retreat ?
?
Retreat
Security based on:
Attack!
• Consensus protocol &
• Native currency
14
Hashcash – Proof of Work (Adam Back, 1997)
Proposed to address E-mail Spam and Denial of Service attacks
• Requires computational work to find a hash within predetermined range
E-mail
or
Header
Hash
© Source unknown. All rights reserved. This content is excluded from our Creative Commons license. For more information, see https://ocw.mit.edu/help/faq-fair-use/
• Difficulty defined by Hash outputs’ # of leading zeros
• Proof of Work can be Efficiently Verified 15
Blockchain – Proof of Work
Innovation – Chained Proof of Work for Distributed Network Consensus & Timestamping
© Cryptographics.info. All rights reserved. This content is excluded from our Creative Commons license. For more information, see https://ocw.mit.edu/help/faq-fair-use/
16
Blockchain – Proof of Work
17
Image by Anders Brownworth. Used with permission.
Blockchain – Proof of Work
18
Image by Anders Brownworth. Used with permission.
Blockchain – Consensus supports Longest Chain
19
Image by Meek Mark on Wikipedia . CC BY.
đ khó bng chng công vic BITCOIN
Bitcoin Proof of Work Difficulty
• Targets 10 minute average block generation time
đưc xác đnh bi s 0 đng đu đu ra ca hàm băm đ gii quyt bng chung công vic
• Defined by the # of leading zeros Hash output requires to solve proof of work
điu chnh khon 2016 khi - khong hai tun mt ln
• Adjusts every 2016 blocks - about every two weeks
ln hơn 18 s 0
• Currently, > 18 leading zeros (out of 64 hexadecimal characters)
• Block 541974 (9/18/18)- 18 leading zeros
0000000000000000001104a863046dfbad1a2941128815669623ff93c2a3945f
• Genesis Block (1/3/09) – 10 leading zeros, though only required 8
000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
20
Bitcoin Mining Difficulty
21
Source: Blockchain.com Courtesy of Blockchain Luxembourg S.A. Used with permission.
Bitcoin Network Hash Rate
22
Source: Blockchain.com Courtesy of Blockchain Luxembourg S.A. Used with permission.
Bitcoin Mining Evolution
Application Specific Integrated Circuit
(ASICs) 2013 – 2018
4 – 16 TH/S
Image by InstagramFOTOGRAFIN on Pixabay.
Graphics Processing Units
(GPUs) 2010 – 2013
20 - 300 MH/S
Central Processing Units Image is in the public domain.
(CPUs) 2009 – 2010
Modern Mining Factory
2 - 20 MH/S
Image by Axel Castillo. CC0 Public Domain.
Image by MiNE on flickr. CC BY 23
Bitcoin Mining Hashrate Distribution
24
Courtesy of Blockchain Luxembourg S.A.
Source: Blockchain.com – 9/18/18 (4 day avg.) Used with permission.
Native Currency
Economic Incentive System
‘Monetary Policies’ vary widely
• Bitcoin - BTC
• Created through Coinbase Transaction in each block
• ‘Monetary Policy’ preset in Bitcoin Core
• Creation originally 50 Bitcoin per block
• Reward halves (1/2s) every 210,000 blocks
• Currently 12.5 BTCs created per block – thus ‘inflation’ 4.1%
• Currently 17.3 million BTC; capping at 21 million BTC in 2040
• Market based transaction fee mechanism also provided for in Bitcoin Core
• Ethereum
• Currently 3 ETH per block – thus ‘inflation’ 7.4%
• Recent proposal to decline to 2 ETH per block in 11/18
• Fees paid in Gas (109 Gas per ETH) for computation are credited to miners
25
Network
nút lưu tr toàn b d liu ca block t khi nó đưc hình thành trong h thng blockchain
• Full Nodes – Store full Blockchain & able to Validate all Transactions
ta bt node là nhng giao dch sau thgian dài s đưc xoá đ gim bt b nh lưu tru
• Pruning Nodes – Prune transactions after validation and aging
không lưu tr toàn b mà ch lưu tr block header, phù hp vi các tài nguyên nh như đin thoi
• Lightweight Nodes - Simplified Payment Verification (SPV) nodes – Store
Blockchain Headers only
• Miners – Performs Proof of Work & Create new Blocks - Do not need to be a
Full Node có th là nhóm t chc qun lý các miners hp tác đào vi nhau,... chia phn thưng cho các miners khi đào đưc
• Mining Pool Operators
• Wallets – Store, View, Send and Receive Transactions & Create Key Pairs
vùng nh tm thi, chưa đưc xác nhn nhưng mng li đã kim tra cơ bn
• Mempool – Pool of unconfirmed (yet validated) Transactions 26
GIAO THC ĐNG THUN THAY THE
Alternative Consensus Protocols
ngu nhiên la chn các nút thông qua h thng phân cp
Generally Randomized or Delegated Selection of Nodes to Validate next Block
• May have added mechanism to confirm Block Validators’ Work
Randomized Selection May be Based upon:
• Proof of Stake – Stake in Native Currency
• Proof of Activity - Hybrid of POW and POS kt hp pow và pos
• Proof of Burn – Validation comes with Burning of Coins
• Proof of Capacity (Storage or Space) – Based upon Hardware Space
Delegated Selection May be Based upon Tiered System of Nodes
Major Permissionless Blockchain Applications still use Proof of Work – though:
• DASH is a hybrid of POW with a tiered system of ‘Masternodes’
• NEO uses a Delegated protocol of ‘Professional Nodes’
27
Conclusions
Reviewed Bitcoin Design Features
• Timestamped Append-only Logs (Blocks)
• Secured through Cryptographic Hash Functions & Digital
Signatures
Decentralized Network Consensus
• Consensus through Proof of Work
• Native Currency
• Network
Transactions Ledgers
• Transaction Inputs & Outputs
• Unspent Transaction Output (UTXO) set
• Scripting language
30