Intro to Blockchain
And, by the way, what the
heck is proof-of-work?
By Jim Flynn
About Jim Flynn
●
Started built & sold tech companies
●
Jobs:
– Software engineer
– Hardware engineer
– Sales executive, CEO, etc.
●
More at jamespflynn.com
●
www.linkedin.com/in/jamespeterf
Agenda
Blockchain Overview1 Blockchain/bitcoin Overview1
Blockchain Overview1 Understanding Proof of Work2
Blockchain Overview1 Proof of Work Demo3
In the beginning...
..or rather
2008
Bitcoin’s Techno-Libertarian Roots
●
Skeptical of authority
●
Dislike centralized power
●
Protective of privacy
●
Alarmed about surveillance
●
Oh yeah, hates taxes
Enter Satoshi Nakamoto
J
?
“A purely peer-to-peer version of electronic cash would
allow online payments to be sent directly from one party
to another without going through a financial institution.”
Satoshi’s Crypto-Currency Commandments
Thou Shalt NOT: Thou Shalt:
1. worship centralized authorities
2. covet they neighbor’s bitcoin
(except with the right private key)
3. alter completed transaction
4. inflate
5. double spend
1. govern thyselves by cons
2. rely’th on incentives
3. have faith in cryptograph
for the geeks shall inherit th
earth
Blockchain Defined
●
Distributed database
●
Good for time-ordered data
●
Not owned or controlled by one entity (bitcoin’s case)
●
Each block connected to previous block
●
Anyone can validate the ledger, which contains a
record of every transaction.
Traditional Way
Our
Business
Our
DB
We did pay!
Your
Business
Your
DB
They didn’t pay!
Bank
Bank
DB
Did they pay?
Blockchain Way
Our
Business
TX
Block
0
TX
Block
1
TX
Block
2
TX
Block
3
TX
Block
5
TX
Block
N
Blockchain - Distributed Ledger
Transaction Block
shows if they paid.
Your
Business
Blockchain Way
Our
Business
TX
Block
0
TX
Block
1
TX
Block
2
TX
Block
3
TX
Block
5
TX
Block
N
Your
Business
Business
1
Business
2
Business
3
Business
4
Business
5
Business
5
Business
6
Business
7
Business
8
Business
9
Business
10
Business
3 Business
Business
Business
Business
Business
Business
Business
Business
Business
Business
Business
Business
Business
Business
Business
Blockchain = Shared Distributed Truth
My database
says X.
My database
says Y.
Blockchain = Shared Distributed Truth
My database
says X.
My database
says Y.
The blockchain says Z.
What does “hash” mean to you?
●
Creates a “fingerprint” of data
– Ex: Hash(“123”) = c74b6bd9a2f7648a
●
SHA256 (used in bitcoin)
– Easily-verified from data
– Cannot recreate the data
Hashes Ensure Blockchain Integrity
TX
Block
0
hash
TX
Block
1
hash
TX
Block
2
hash ...
TX
Block
N
hash
2009 2017
hash hash hash
Hashes Ensure Blockchain Integrity
TX
Block
0
hash
TX
Block
1
hash
TX
Block
2
hash ...
TX
Block
N
hash
2009 2017
hash hash hash
Hashes Ensure Blockchain Integrity
TX
Block
0
hash
TX
Block
1
hash
TX
Block
2
hash ...
TX
Block
N
hash
2009 2017
hash hash hash
Bitcoin Identity
●
You get paid to your public key
– 02a1633cafcc01ebfb6d78e39f687a1f0995c62fc95f51ead10a02ee0be551b5dc
●
You pay with your private key
●
No issuing authority
Is Bitcoin Anonymous?
Dread Pirate Roberts
NobDeath from Above
French Maid
Flush
Number13
Is Bitcoin Anonymous?
Dread Pirate Roberts
NobDeath from Above
French Maid
Flush
Number13
Adding Blocks in Bitcoin
●
Uses “proof-of-work”
●
“Miners” compete to add blocks
– More hash power = higher probability to win
– Reward: 12.5 bitcoins and transaction fees
– Puzzle solved (new block) about every 10 minutes
– Puzzle difficulty adjusted ever two weeks
●
Nodes recognize the longest valid chain
Mining
TX
Block
0
TX
Block
1
TX
Block
2
TX
Block
3
TX
Block
5
TX
Block
6
Miner 1 Miner 2
Prop.
TX
Block
7
Prop.
TX
Block
7
1. Miners race to solve puzzle.
2. Whoever wins, gets to set the next
block & gets a reward.
TX
Block
0
TX
Block
1
TX
Block
2
TX
Block
3
TX
Block
5
TX
Block
6
TX
Block
0
TX
Block
1
TX
Block
2
TX
Block
3
TX
Block
5
TX
Block
6
Mining
TX
Block
0
TX
Block
1
TX
Block
2
TX
Block
3
TX
Block
5
TX
Block
6
Miner 1 Miner 2
Prop.
TX
Block
7
Prop.
TX
Block
7
TX
Block
0
TX
Block
1
TX
Block
2
TX
Block
3
TX
Block
5
TX
Block
6
TX
Block
0
TX
Block
1
TX
Block
2
TX
Block
3
TX
Block
5
TX
Block
6
Mining
TX
Block
0
TX
Block
1
TX
Block
2
TX
Block
3
TX
Block
5
TX
Block
6
Miner 1 Miner 2
Prop.
TX
Block
7
TX
Block
7
TX
Block
0
TX
Block
1
TX
Block
2
TX
Block
3
TX
Block
5
TX
Block
6
TX
Block
0
TX
Block
1
TX
Block
2
TX
Block
3
TX
Block
5
TX
Block
6
TX
Block
7
TX
Block
7
ASIC
Application Specific Integrated Circuit
Mining Pools
Bitcoin Mining Now
“On a high-end desktop...it would take you several hundred
thousand years on average at the early-2015 difficulty level (267
)
to find a valid block.”
Don’t try this at home.
Bitcoin and Cryptocurrency Technologies
Princeton University Press, 2016
Page 112
What the fork?
●
Forks happen when nodes disagree about the longest valid chain.
●
Forks can cause havoc.
●
Built-in incentives to discourage forks.
Scripting
●
Very basic in bitcoin
●
Far more advanced in Ethereum
Simplified Smart Contract Example
parentState = SSA.lookupState(‘055051805’)
kidMaried = MA.lookupMarriageLic(‘055051805’)
publicKey = ‘02a1633cafcc01ebfb6d78e39f6’
If parentState = “Dead” then
If kidMarried = “True” then
Pay(kid.publicKey)
Marriage
Licenses
Death
Records
Beyond Cryptocurrency
●
Supply chains
●
Decentralized organizations
●
Tracking physical assets
●
eVoting
●
Sharing economy – IoT & micropayments
Crypto-coins Galore
Bitcoin Ether Litecoin
Dogecoin
Dash
NEMPeercoin Primecoin Gridcoin
MoneroRipple
Ready to dive in?
Proof of Work
(POW)
●
Look at some code
●
Run some tests
POW = Solve a Puzzle
Find a number that, when combined with
the transaction data, hashes to a value
that’s less than a given tolerance.
1 10 trillion
Probability that a hash will be any one number
on continuum that is within the tolerance is 50%
of 1/10 trillion.
50% change of winning in one try.
Tolerance = 5T
Losing
hashes
Winning
hashes
Half the Time You’re a Winner!
Range of possible hash values
10% change of winning in one try.
10% of the Time You’re a Winner.
1 10 trillion
Losing
hashes
Winning
hashes
Range of possible hash values
Tolerance = 1T
for ( $nonce = 1; $nonce <= $maxTries; $nonce++ )
{
$hash = hash('sha256', $transaction . $nonce);
$start = substr($hash, 0, $zeros);
if ( $start === $lead )
{
echo "<br/>Success! Puzzle solved with nonce = $nonce $end";
echo "Try #" . number_format($nonce) . ": Hash("$transaction.09$nonce")=$hash $end";
break;
}
elseif ($details == "yes") echo "Try #" . number_format($nonce) . ": Hash("$transaction.$nonce")=$hash $end";
}
Solving the Puzzle in Php Code
Loop through nonce values from 1 to the max times you want to try
End Loop
Solving the Puzzle in Pseudo Code
Compute hash of transaction text concatenated with the nonce
If the hash starts with the minimum number of zeros then
Display a success message
Stop
Let’s play!
POW Alternative: Proof of Stake
●
Does not waste as much electricity
●
Vulnerable to a “rewriting history” attack
●
e.g., Peercoin
POW Alternative: Proof of Burn
●
Prove the you made coins unspendable
●
Sometimes used to transfer to new currency
https://assets.kpmg.com/content/dam/kpmg/pdf/2016/06/kpmg-blockchain-consensus-mechanism.pdf
Google: kpmg blockchain consensus
Thanks!
Don’t forget to check my blog
for code and this presentation.
http://jamespflynn.com

Intro to Blockchain - And, by the way, what the heck is proof-of-work?