The Blockchain Josh Vorick
Bitcoin is a currency. Blockchain is a technology.
What is a blockchain? A decentralized database that ● anyone can add to and no one can delete from
The Bitcoin blockchain
Why You Should Care ● Bitcoin ● Agenda Transactions ○ Mining ○ Mining Pools ○ Scalability ○ Other blockchain applications ●
Why you should care
Many are comparing the blockchain to TCP/IP
$1 Billion invested into blockchain-related startups
$110,000 median “blockchain engineer” starting salary
In case money isn’t enough... Trustless, decentralized networks ● Remove third parties ● Smaller fees ○ Don’t need to trust a central authority ○ Corruption-proof (e.g. Bitcoin is a safe haven from bank crisis) ● Privacy ● Completely Digital ● Trustless ● Removes Third Parties ●
time to get technical
The Bitcoin blockchain
Digital Signatures Public key (verification key) ● Secret key (signing key) ● Sign a message with your secret key ● Verify that a signature is valid using their ● public key
Cryptographic Hash Deterministically maps an input string to ● a fixed length output Output looks like a random number ● Collision resistant ● HASH 6d324eff6c3f40c14c24642f 82272e8b16bc158a67a6e6 4e8c511e534dbb7c8d
a0cd8d94408af12bc1bdb677ca47d86b049c448e 00000000000000000000000 00000000000000000000000 300568b5015c396a56827ea70fe8d2bf473ea9be8 00000000000000000000000 00000000000000000000000 265a6b39e9d1e3e0581db2b25a4cc061a6de9ff44 b30a314400b44ebad3d1af844cdb40b58bcf35632 00000000000000000000000 00000000000000000000000 152bf825718912eaa0f65b4a780c0581983570796 b7a8eced52f936e2b106e8191227c351415b8f525 0 00000000000000000000000 00000000000000000000000 f994077ca002460cc3b6f9e45776042f9cbe8cd644 00000000000000000000000 00000000000000000000000 1dc891fe4daf5a7ce22bb0e7c04e3253ff37542514 e3967e7dca8518310f8851301e33ad1b831aaae1 00000000000000000000000 00000000000000000000000 ca1ec6c31639dd54691c4987ede6c3228bf453c01 dc1a1f67242d601473c2f533f6b30a31440c3b6f9e 00 01 45776042831 hash hash hash hash 2ca5cfc1a35679225c87410c2039dce459f67138 5feceb66ffc86f38d952786c6d696c79c2dbc239dd 0a13032d6e91709e88effb654657fcb620432caa2 57bb432fbc63aa7588e8a66329e4534b6567fd2f4f 4e91b46729d73a27fb57e9 dc1f37db32871eb5e3a2aa7 26f91caa5f9b01396d4f98 c8a23b8d19aad4d3c037c23b
cryptographic hash (blake2b) (non-cryptographic) hash def myHash(str): hash = 5831 for c in str: hash = hash * 33 + int(c) return hash
Transactions are complicated
Sender ● What’s in a Transaction? Recipient ● Amount ● the super duper basics Signature ●
txn 1 Alice -> Bob 25 Btc -Alice
Sender ● Recipient ● What’s Really in a Transaction? Amount ● List of inputs ○ the super basics List of outputs ○ SUM(in) = SUM(out) ○ Signature ●
txn 1 Alice -> Carol 15 Btc (see txn x ) -Alice txn 3 Carol -> Dave 25 Btc (txn 1 +txn 2 ) -Carol txn 2 Bob -> Carol 10 Btc (see txn y ) -Bob
txn 1 15 Btc to Carol see txn x -Alice txn 3 25 Btc to Dave see txn 1 , txn 2 -Carol txn 2 10 Btc to Carol see txn y -Bob
txn 1 15 Btc to Carol see txn x -Alice txn 3 20 Btc to Dave 5 Btc to Carol see txn 1 , txn 2 -Carol txn 2 10 Btc to Carol see txn y -Bob
Sender ● Recipient’s public key ● What’s Really Really in a Transaction? Amount ● List of inputs ○ the basics List of outputs ○ SUM(in) = SUM(out) + Miner fee ○ Sender’s signature ●
txn 1 15 Btc to pk C see txn x sign(txn 1 , sk A ) txn 3 20 Btc to pk D 4.999 Btc to pk C see txn 1 , txn 2 sign(txn 3 , sk C ) txn 2 10 Btc to pk C see txn y sign(txn 2 , sk B )
txn 1 15 Btc to pk C see txn x sign(txn 1 , sk A ) txn 3 20 Btc to pk D 4.999 Btc to pk C see txn 1 , txn 2 sign(txn 3 , sk C ) txn 2 10 Btc to pk C see txn y sign(txn 2 , sk B )
Sender ● Recipient’s public key ● Amount ● What’s Really Really Really in a List of inputs ○ List of outputs ○ Transaction? SUM(in) = SUM(out) + Miner fee ○ Script ● Multisig ○ Locktime ○ Puzzles ○ etc ○ Sender’s signature ●
Mining
Miners ● Get sent transactions ● Compile them into blocks ● Add their blocks to the blockchain
If miners add blocks willy-nilly, the blockchain will quickly become inconsistent
Give the miners a hard puzzle Miners work on puzzle ● Whoever solves it shows the network their solution ● Their block gets added to the blockchain ● Puzzle is called “proof of work” ●
Proof of Work Used to prevent fraud ● DoS attacks ○ Spam ○ Blockchain! ○ Make it computationally hard to do something ● e.g. “You can’t access my website unless you do work” ●
Example challenge m = “Challenge text” ● n = ??? ● target = 0x0ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ● Find some n such that hash(m + n) < target ●
target = 0x0ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xa34adb8461404adfab8d08e6cbdb24029e1bb0a8d906d0 “Challenge Text0” hash 80d01842ce57ee9156 0xcc6122116e95dae6279fdb241497f92e5f50093a35a5c7d “Challenge Text1” hash c010f1f357d43ed6c 0x669a60a2bcefaa27cad56b0d9754bbaf7cc596d2b80978 “Challenge Text2” hash 2345d99e8b53e5f3bd 0x85a38de18ed2a5246c778c4888b72ee62e6464e243070 “Challenge Text3” hash 55a55afd995dd548576 0x67618f5b9a7f6358609f96eab68c610f375f1a580f7d9bb9 “Challenge Text4” hash 9d628c8ee8ba21fa 0x04f0d5919eccd435de1521c5234663971bf0e9113b129f2 “Challenge Text5” hash f689d586596dbe4fc Lucky!!
Miner code!! Version 2 def mine(Block, target): def mine(Block, target): n = 0 n = 0 while true: b = hash(Block) h = hash(Block + n) while true: if h < target: h = hash(b + n) return n if h < target: n++ return n n++ Block up to 1MB => hashing is SLOW
Now we only hash Block once, right? No :(
How can we do this faster?
Block hash
Block b 0 b 1 b 2 b 3 b 4 b 5 b 6 b 7 b 8 b 9 b 10 b 11 b 12 b 13 b 14 b 15 hash
Block b 0 b 1 b 2 b 3 b 4 b 5 b 6 b 7 b 8 b 9 b 10 b 11 b 12 b 13 b 14 b 15 hash
Block b 0 b 1 b 2 b 3 b 4 b 5 b 6 b 7 b 8 b 9 b 10 b 11 b 12 b 13 b 14 b 15 hash hash hash
Block b 0 b 1 b 2 b 3 b 4 b 5 b 6 b 7 b 8 b 9 b 10 b 11 b 12 b 13 b 14 b 15 hash hash hash
Merkle tree b 0 b 1 b 2 b 3 b 4 b 5 b 6 b 7 b 8 b 9 b 10 b 11 b 12 b 13 b 14 b 15 hash hash hash hash hash hash hash hash hash hash hash hash hash hash hash
Merkle tree b 0 b 1 b 2 b 3 b 4 b 5 b 6 b 7 b 8 b 9 b 10 b 11 b 12 b 13 b 14 b 15 hash hash hash hash hash hash hash hash hash hash hash hash hash hash hash
Merkle tree b 0 b 1 b 2 b 3 b 4 b 5 b 6 b 7 b 8 b 9 b 10 b 11 b 12 b 13 b 14 b 15 hash hash hash hash hash hash hash hash hash hash hash hash hash hash hash
Sweet! Let’s Mine!
1 ~720,000,000,000,000,000,000 Chance of solving a block on the first try
= Chance of being struck by lightning 1,977,098 times in one second
1 ~20,000,000,000 Chance of solving a block in 1 hour on a $300 CPU
1 ~100,000,000 Chance of solving a block in 1 hour on a $300 GPU
1 ~240,000 Chance of solving a block in 1 hour on a $370 ASIC
≈$1 per day (amortized)
Mining Pools
Use a Central Server to Run the Pool Mine blocks for the server ● Submit ‘partial blocks’ to server ● e.g. when you almost beat the target ○ Types ● slush ○ Pay-per-Share ○ Luke-Jr’s ○
P2Pool Using a blockchain to create a mining pool ● Miners in the pool have their own side-blockchain ● Not used commonly due to network latency ●
14,695,844 PetaFLOPS Tianhe-2 operates at just 33.86 PetaFLOPS
What if we replaced the hash with meaningful work?
Related Topics Decentralized Computing ● P versus NP? ○ Homomorphic encryption ● Compute on encrypted data ○ Still really slow ○
Scalability
230,000 transactions every day
Other Applications
All blockchains: Have transactions ● Have miners ● Use Merkle trees ● Have similar scalability issues (for now) ●
Trade custom assets ● Make bets ● Leverage ● Hedging ●
Turing complete block chain ● Smart Contracts ● Platform for other blockchain ● applications
Decentralized prediction ● market People bet on events’ ● outcomes Get precise forecasts on any ● event
Decentralized eBay ● Create your own store and ● sell to peers on the network No fees / restrictions ●
Add the hash of a document ● Proof of Existence to Bitcoin’s block chain Enables to prove you had that ● document on that date
Add an ownership layer to the ● Internet Enable artists to know ● when/where their art is being used Allow users to easily pay ● commissions Enable for limited editions of ● digital art
Recommend
More recommend