#3 Meetup, 13 Apr 2017
Transfer (who, fromAccount, toAccount, value)
BalanceOf (account)
User X transfers $5 from account A1 to account A5
Database
API
User X
User Y
User Z
Database
API
User X
User Y
User Z
Admin
Authenticate
Enforce Rules
Persist State
Trusted Zone
If users want to query account balance often Bank's API becomes a bottleneck.
Can we do better, can we avoid the bank?
BalanceOf(A) = 10
BalanceOf(B) = 0
BalanceOf(A) = 5
BalanceOf(B) = 5
Transfer(A, B, 5)
a little bit
Account balances are updated once a day.
BalanceOf(A) = 10
BalanceOf(B) = 0
BalanceOf(C) = 0
BalanceOf(A) = 0
BalanceOf(B) = 5
BalanceOf(C) = 5
Day 1
Day 2
Transition
(list of transactions)
transfer(A, B, 5)
transfer(A, C, 5)
+
Transactions
+
Transactions
+
Transactions
Database
API
User X
User Y
User Z
Each user can now query the database locally
(at least during a day)
User X
User Y
User Z
If users can do everything locally the Bank is not needed!
Alice's Public Key
Alice's Private Key
Bob's Public Key
Bob's Private Key
verify with Public
Alice's Private Key
Message
Signature
verify with Public
Alice's Public Key
Message
Signature
Alice sent it!
Given a list of transactions and a previous state
we can compute the current one
transfer(A, B, 5)
Alice's Signature
transfer(B, C, 5)
Bob's Signature
That's a blockchain!
transfer(A, B, 5)
Alice's Signature
transfer(B, C, 5)
Bob's Signature
transfer(B, A, 5)
Bob's Signature
Transactions packed together in blocks,
linked to each other to encode time-relations.
Block Number | 5 |
Date | 18:00 13.02.2017 |
Expected State | (Block Hash) |
Previous Block State | (Chain Link) |
List of transactions |
We don't store the whole State in a block.
Instead we just store a list of transactions, perform transition and check if the State is the same as expected.
No, because of double spend.
User A
User C
User B
Users cannot trust one another.
or propagation time may vary
transfer(A, B, 5)
Alice's Signature
transfer(A, C, 5)
Alice's Signature
Yes, but everyone can submit their own block, how do you know which one is "the correct one"?
Maybe let's try to limit who can submit a new block?
Block Number | 5 |
Date | 18:00 13.02.2017 |
Expected State | (Block Hash) |
Previous Block State | (Chain Link) |
List of transactions | |
Puzzle / Consensus Proof | Block Number + 5 = ? |
We need a puzzle that is:
1. Trivial to validate
2. Difficult to compute
DATA
)
f(
= hash
BlockHash
)
sha256(
= 0x000...
Nonce
Puzzle: Find a Nonce that hashed together with current block hash gives a hash starting with X zeros
Canonical Chain
transfer(A, B, 5)
Alice's Signature
transfer(B, C, 5)
Bob's Signature
transfer(B, A, 5)
Bob's Signature
transfer(B, C, 5)
Bob's Signature
Longest in some metric
Consensus ensures the blocks are produced in expected rate via
Difficulty Adjustment / Protocol Delays
It's incentivized - You will earn money
(and it's called mining)
Bitcoin is the first public blockchain ever.
Block Time | 10 minutes |
Consensus | Proof of Work - hashcash |
State | Account Balances of BTC / UTXO* |
Transactions | Value Transfers* |
Launched | 2009 |
Ethereum is the World Computer
Block Time | 14 seconds |
Consensus | Proof of Work - ethash* |
State | Arbitrary |
Transactions | Turing-complete / programmable |
Launched | 2015 |
Join our slack, mailto:tomasz.drwiega@gmail.com