Learn the fundamentals of blockchain technology and the properties of a blockchain that make it ideal for securing information including financial transactions. We also go into some details of the operation of the Bitcoin protocol as the first real-world example of a successful implementation of blockchain principles. You will come away with an excellent foundation for understanding any Proof of Work based blockchain and an ability to independently evaluate any new blockchain based technology.
2. Objectives
● Build an intuitive understanding of
Blockchain technology
● Understand the problems
Blockchain seeks to address
● Ability to easily understand any new
blockchain based technology
3. What is Blockchain?
● Literally nothing but a “chain of blocks”!
● Simple list of items where each item refers to the previous item
● 2 key properties:
1. Age of any item determined by position in the list
2. Each item’s history easily traced by traveling backward through the list
4. Why might a blockchain be useful?
Let’s imagine a scenario…
● Immutability so that past records cannot be changed
What do we require to ensure trust in our system?
● Verification of account balances
● Protection against copying or counterfeiting leading to Double Spending
● Authentication to prove ownership of assets
5. Verification of Balances
No central authority so how do we make sure no one over spends?
● We need a ledger or list of transactions (Tx) to track who owns what over time
➢ For efficiency periodically group temporally adjacent transactions into a single unit or block
➢ Each block or list of Tx’s refers to the block that came immediately before it
● All transactions verified independently by all participants
● This list must be publicly available or distributed to everyone equally
● Radical departure from traditional privacy!
6. Double Spending Problem
We have several BIG problems so far:
2. How can we come to a consensus or
agreement?
1. How to decide who get to add a new block?
3. How can we prevent history from changing once we agree?
7. Double Spending: Who gets to make changes?
● Node must prove how much computing power or how
many CPU’s it has
● Each node’s share of vote determined by processing
power
● To protect “minority rights” we introduce a bit of luck
So far we have a very democratic system so let’s vote!
“One man, one vote” -> “One CPU, one vote”
How can “one CPU, one vote” be enforced while
remaining fair?
8. One CPU, One Vote
Proof-of-Work = Guessing Game!
Rules for Guessing Game:
1. Choose a number 1-10
2. Multiple guesses (one at a time) allowed
3. First to guess correct answer win
Properties of the Guessing Game:
1. No better strategy than to guess randomly many times
2. Probability of winning proportional to speed of guessing
9. About the Graph7
6
5
4
3
2
1
0
Proof of Work: Hashing
Each node proves completion of computational work by inverting a hash function
Properties of Hash Functions:
1. Maps any size input to output
of fixed size
2. One-way
function3. Deterministic output but appears
random
4. Easily
10.
11. First node to provide a
valid guess is allowed
to add the next block
Difficulty adjusts so that
speed of block creation
remains constant
Block Reward given to
block finder as incentive
for completing work
Consensus when each node independently verifies the block’s hash by adding it to the chain
Proof of Work
12. About the Graph
Lid est laborum dolo rumes
fugats untras. Etharums ser
quidem rerum facilis doloresLid
est laborum dolo rumes fugats
untras. Etharums ser quidem
rerum facilis dolores
Lid est laborum dolo rumes
fugats untras. Etharums ser
quidem rerum facilis doloresLid
est laborum dolo rumes fugats
untras. Etharums ser quidem
rerum facilis dolores
7
6
5
4
3
2
1
0
7
6
5
4
3
2
1
0
Difficulty vs. BTC Price
13. About the Graph7
6
5
4
3
2
1
0
Double Spending: How do we agree on changes?
- Chain with most PoW is definitive
- All Tx’s in orphaned block sent back to unconfirmed or discarded
What if 2 nodes simultaneously submit valid blocks?
Temporary Chain Splits:
- Caused when 2 valid blocks refer to the same previous block
- Results in Double Spending since Tx’s in each block are included in both
blocks
- Longest chain rule resolves situation when next block arrives
Longest Chain Rule:
14. Double Spending: How to prevent tampering?
1. To modify a block I must recompute its hash
2. But changing the hash of 1 block changes the hash of
every following block
3. Since longest chain wins I must do more work than the
entire network in the same time
4. Every time network adds a new block I fall further behind -
Gambler’s Ruin
Why require PoW at all? Surely there must be easier ways!
Thus older blocks have (exponentially) greater assurances of immutability
Consider the predicament of an attacker in PoW regime:
15. T/F - Does BTC guarantee with 100% certainty that
no one can Double Spend?
FALSE
16. We required a system that provides the following:
❖ Verification of Balances
➢ Provided through public blockchain
❖ Prevention of Double Spending
➢ Secured through PoW competition
❖ Prevention of Tampering
➢ PoW confirmations
- Notice we still have not mentioned any particular currency
- Also we have yet to provide provide authentication
17. About the Graph
● Oldest and perhaps simplest public blockchain
● Specified in 2008 by mysterious Satoshi Nakamoto
● Continuously operating since Jan. 2009 without any successful attacks on the network as a whole
● $100+ Billion Total Value (as of Oct. 2018)
● Supply capped at 21 million BTC
● Worth more than every other cryptocurrency combined (as of Oct. 2018)
7
6
5
4
3
2
1
0
7
6
5
4
3
2
1
0
Bitcoin Basics
18. ● Each UTXO is unique and has a definite indivisible value
denominated in Satoshi (1 BTC = 100,000,000 Satoshis)
● UTXO’s used to facilitate transactions
● UTXO’s only unlocked with corresponding Private Key
● Set of all UTXO’s controlled by a single private key = Total Balance
● Set of all UTXO’s = Total Bitcoins in circulation
UTXO’
s
Unit of value in Bitcoin (BTC) called Unspent Transaction Outputs (UTXO’s)
19. ● Used as Input(s)/Output(s) of Transactions
● Multiple UTXO’s can be combined as inputs to transactions
● Input UTXO’s (+ fees) >= sum of Ouput UTXO’s
● Every transaction produces at least 1 UTXO controlled by recipient and at
most 2 UTXO’s (1 for recipient, 1 for “change” returned to sender)
● One time use: Once a UTXO is “spent” it is deleted
UTXO Mechanics
20. T/F - When a transaction is sent the input UTXO(s)
are broken up and change returned to sender.
FALSE
21. BTC Block Creation
1. New Tx “tweeted”
out to all miner
nodes
2. Nodes validate each Tx
& gathers them into a block
3. Each node repeatedly
hashes candidate blocks
to find valid PoW
6. Nodes begin working on next block implicitly accepting previous new block
by including its hash in next block (block created, on avg, every 10 mins.)
5. Nodes independently
validate new block and all Tx’s
in it
4. When valid PoW found,
block tweeted to all nodes
Let us trace a new Tx through the BTC Network:
22. Benefits:
1. Authentication - Ability to decrypt with Public Key implies only Private Key holder could have generated data
2. Integrity - If message changed in any way decryption will fail
Transaction Creation: Public-key Cryptography
● Message encrypted with Private Key may ONLY be decrypted with corresponding Public
Key
Public-key cryptography:
● Random number generated called Private Key
● This number must be kept private! E.g. Password
● ECC algorithm used to generate a unique Public Key from Private Key
● Public Key may be shared. E.g. Username or wallet address
23. Transaction Creation
1. Tx Sender uses Private Key
to unlock input UTXO(s)
3. Tx sender attaches receiver’s
Public Key to signed Tx
2. Sender hashes Tx data and
digitally signs Tx with Private Key
24. 1. Reject Tx if any input UTXO has been is used twice (2x Spending)
2. Reject Tx if any input UTXO never existed
3. Reject Tx if sum of input UTXO’s < sum of output UTXO’s
Transaction Validation
Every node independently checks each Tx for 20 criteria including:
25. Block Hashing
● Nonce appended to block
data to prevent replay attack
● Block data + nonce must be <
current difficulty level
26.
27. Block Validation
Every node independently checks each
new block for 19 criteria including:
1. Must have at least 1 Tx in list of
Tx’s2. Must have valid
PoW3. Each Tx in list must be
valid4. Max size of Block <=
1MB5. Verify previous block
hash6. Verify Merkle root hash of
29. BTC Pitfalls
● Gift and curse of immutability and irreversibility
● Private key based authentication
● Climate change and useless work
● Relatively long 10 minute confirmation time
● Illegal usage
● High fees
30. How to Get Involved
● ICO: Moderate/High Risk, High Potential Reward, High barrier for high
quality
● dApp Development: Moderate Risk, Talent Rare/Expensive
● Mining: Less risk, (Nearly) as easy as Investing, Medium initial
investment
● Investing/Speculating: High risk, Lowest barriers to entry
From Least to Most Technical: