Talk for CodeMash 2018. Page to end for resources. Some more links (click to expand):
Bitcoin's Insane Energy Consumption Explained: https://arstechnica.com/tech-policy/2017/12/bitcoins-insane-energy-consumption-explained/
The Ethereum-blockchain size will not exceed 1TB anytime soon.
https://dev.to/5chdn/the-ethereum-blockchain-size-will-not-exceed-1tb-anytime-soon-58a
For use rights, please see license agreement below.
2. Basic understanding
Functioning toy blockchain network
Uses for blockchain
Encouraging your participation
Qs - please write down your Qs for the end!
Goals of This Talk
3. “I spend every single day full time, trying to keep up with Bitcoin -
just one currency - and it’s almost impossible.”
-- Andreas Antonopoulos
Blockchain >> Cryptocurrency
Cryptocurrency >> Bitcoin
“It’s HUGE. TREMENDOUS!”
-- Not Donald Trump
4. When I think of blockchain, I think of...
Trust
Ledger
Transparency
Distributed
Private?
Borderless
Encryption
Decentralized?
Cryptocurrency
Smart Contracts
5. We define an electronic coin as a chain of digital signatures.
-- Satoshi Nakamoto,
“Bitcoin: A Peer-to-Peer Electronic Cash System”
Origin of Blockchain
6. What’s a transaction?
● Exchange of value
● Cryptographically signed
● Input = ref. to output
● Output = address, or H(public key)
● Payload
7. The Transaction Sausage
em = SHA256( )MESSAGE:
Give 0.008BTC
to Jane
(r,s) = ECDSA(em,k)
Where:
r = public key
s = signature
k = “random” number
8. The Transaction Sausage
Where:
r = public key
s = signature
k = “random” number
z = left n bits of em
Private key = sk - z(em)
r
Blockchain address = RIPEMD-160(r)
MUST be unique / message,
and either
● random, or
● derived securely,
or you will be very sad.
9. Private and Public Keys
Private key
● Generated using random seed.
● To generate public key.
● To sign data.
● Allows you to spend cryptocurrency.
Public key
● To verify signature.
● To derive address (for receiving).
● To create input for a subsequent transaction
11. Any computing device which:
● Has been granted access to a blockchain network
● Processes transactions & smart contracts, mines, etc.
What is a node?
12. ● Peer-to-peer group of blockchain nodes
● Using a specific chain/tree of blocks
● Builds consensus
● Confirms transactions
● Distributes blockchain apps, blocks, etc.
The network?
13. ● Assembled by one node
● Posted to network
● Accepted (or not) by others
How is a Block Added?
14. ● Creation of a new coin
● Input: coinbase parameter
● N outputs
● Hash function result must obey certain requirements
E.g. Bitcoin uses a derivative of hashcash, a Proof of Work algorithm. Not all blockchains use Proof of Work.
Constructing a Blockchain
What is Mining?
16. Extremely simple hash function:
str = "Blockchain is pretty awesome!"
"%0x" % str.codepoints.reduce(:+)
=> "ae4"
...but this won’t do at all for crypto.
Cryptographic Hash Functions
17. Cryptographic Hash Functions
For general usability:
● Deterministic
● Quick to compute
For usability in cryptography:
● Collision-free (or practically so)
● Hiding
● Puzzle-friendly
● Sensitive to initial conditions
18. Cryptographic Hash Functions
Collision-free: really “collision resistant”
Given hash function H, message m1,
Effectively impossible to find a message
m2 != m1 s.t. H(m1) = H(m2)
Examples: SHA256 (Bitcoin), Scrypt (Litecoin), Cuckoo hash cycles
19. So... blockchain == chain of blocks?
Not really.
● Linked list
OR (more typically)
● Merkle tree -- binary hash tree
...Block 0 B1 B2 Bn-1 Bn
21. nn-1 data
H(nn-1)
nn data
Tamper Detection
n0 data
H(n0) H(nn)
n1 data
H(n1) H(nn-1)
. . .
✓
A payee can verify the signatures to verify the chain of ownership.
-- Satoshi Nakamoto,
“Bitcoin: A Peer-to-Peer Electronic Cash System”
✓ ✓ X
22. Consensus Models
Make honesty rewarding and cheating expensive.
● Assign nodes unique IDs
Honest nodes:
● Validate transactions
● Extend only the longest valid blockchain
● Acceptance: include new block in chain when proposing a
new block
● Are rewarded with cryptocurrency
● Txns can “tip” nodes with transaction fees
23. ● Distributed app
● Free to read
● Cost to write
● Permanent
What’s a Smart Contract?
24. Working blockchain: Ethereum
geth CLI:
● Run local Ethereum network
● Showing balances
● Sending money
● Mining
Solidity language:
● Toy smart contract
● Posting contract to the network
● Posting update to contract
25. ● Proof of Work system
○ Rewards computational power
○ Has centralized mining power
○ Power hog
○ Slow transaction processing*
● Consensus model
○ Can also slow transaction processing*
* Visa: 65k transaction messages / SECOND (capacity as of Aug 2016)
* Bitcoin: < 500k/day
Problems with Blockchain
26. ● What if we lighten computational load, or make use of ASICs* not
beneficial?
■ Scrypt (Litecoin)
■ Cuckoo hash cycles
■ X11: concat different H()
■ Moving target - change H() regularly
* Application-Specific Integrated Circuit, other types include MP3 encoding/decoding, Ethernet, Bluetooth
Proof of Work Alternatives
27. ● Proof of stake
○ Time held
○ Amount held
○ Transactions processed
● “Proof of Love” - reward evangelizers and developers
Proof of Work Alternatives
28. ● What if we made mining do useful work?
○ SETI
○ Protein folding
○ Machine learning
○ Data preservation - Permacoin - storage based
puzzle, distributed storage (Microsoft)
○ Renewables-only mining + use waste heat
○ [ Your great idea here ]
Mining Alternatives
29. ○ Buggy smart contracts (Ethereum DAO, $60M loss)
○ No Kill switch?
○ Gaming the consensus model
○ Malicious nodes (51% attack)
○ Quantum computing?
Other Vulnerabilities
30. ● Digital ID (SelfKey, Ethereum, Metaverse, NameCoin, Rohingya
Project)
● Manufacturing tracking and management (Metaverse + RFID)
● Targeted ads (Basic Attention Token)
● Rewarding content creators (MUSIC, Steem)
● “Smart Economy” - Contracts + ID + Digitized Assets (NEO)
● Enabling international payments (Stellar)
● Secure, socketless distributed OS (ElastOS)
● Gaming/gambling (KittehCoin, BattleCoin)
● Quantum resistant cryptography (IOTA, QRL)
● Proof of ownership/authorship
Blockchain: Not Just About Money
31. Worst-case scenarios
○ Smart contracts + implants
○ Critical Infrastructure failures
■ Food/bev, fuel, pharmaceutical manufacturing & distribution
■ Power grid, transit grid, communications networks
■ Self-driving vehicles
The Dark Future
32. What are some situations where trust is lacking, or eroded?
Could blockchain help here?
● Government corruption
● Health care
● Policing
● Campaign funding
● Behavioral economics
● Lending
● Voting
● [Your Great Idea Here]
The Bright Future
34. carbonfive.com
Credits and Resources
Bitcoin White Paper Satoshi Nakamoto bitcoin.org/bitcoin.pdf
Newline: Cryptocurrency for
Web Developers
Nate Murray www.coursera.org/learn/cryptocurrency
Bitcoin and Cryptocurrency
Technologies
Coursera www.coursera.org/learn/cryptocurrency
Cryptographic Hash Function Wikipedia en.wikipedia.org/wiki/Cryptographic_hash_function
Solidity for Ethereum solidity.readthedocs.io
Geth for Ethereum Github github.com/ethereum/go-ethereum/wiki/Geth
35. carbonfive.com
Credits and Resources, cont.
Visa Facts and Figures, Jan
2017
Visa https://usa.visa.com/dam/VCOM/global/about-visa/d
ocuments/visa-facts-figures-jan-2017.pdf
Bitcoin Wiki https://en.bitcoin.it/wiki/Main_Page
Blockchain 101 Coindesk https://www.coindesk.com/information
Blockchain: Simple
Explanation
Oleg Mazonka, 2016 http://jrxv.net/x/16/blockchain-gentle-introduction.pdf
“Ethereum’s DAO Hacking
Shows that Coders Are Not
Infallible” *
Forbes https://www.forbes.com/sites/francescoppola/2016/0
6/20/the-dao-hacking-shows-that-coders-are-not-infal
lible/#3cf168713983
* Duh.
36. carbonfive.com
Credits and Resources, cont.
SelfKey selfkey.org
Finnish Immigration Service To Help Unbanked Refugees
www.ccn.com/finns-turn-to-blockchain-to-help-unbanked-refugees-enter-the-digital-economy
Canada in 2018 https://cointelegraph.com/news/blockchain-digital-identification-in-canada-coming-in-2018
Swiss town of Zug Issuing Digital IDs
https://bitcoinmagazine.com/articles/swiss-crypto-valley-create-digital-identities-its-citizens-ethereum-blockchain/
Rohingya Project to Give Stateless Rohingyas Digital IDs
http://techwireasia.com/2017/12/humanitarian-group-uses-blockchain-tech-give-rohingyas-digital-id-cards
NSA Quantum Computing Guidance
www.iad.gov/iad/library/ia-guidance/ia-solutions-for-classified/algorithm-guidance/cnsa-suite-and-quantum
-computing-faq.cfm
Permacoin White Paper | Microsoft
www.microsoft.com/en-us/research/publication/permacoin-repurposing-bitcoin-work-for-data-preservation