Professional Documents
Culture Documents
Ge Introduction to Blockchains
Orfeas Stefanos Thyfronitis Litos
PhD in Cryptography and Blockchains
University of Edinburgh
11/10/2019
1
Outline
●
Why it works
●
Smart contracts
●
Types, ideas and the future
TM
2
Part I
3
What is a Blockchain?
●
distributed,
●
append-only,
●
transaction ledger
4
What is a Blockchain?
Created by Kirman
from the Noun Project
5
Transactions
Alice Bob
tx
1 BTC 1 BTC
6
Transactions
Input Output
Alice Bob
tx
1 BTC 1 BTC
7
Transaction Graph
8
Many inputs
9
Many outputs
10
Unspent Transaction Outputs (UTXO)
11
Bob has 2 BTC
Bob
1 BTC
Bob
1 BTC
12
Bob pays 1 BTC to Alice
Bob
1 BTC
Bob
1 BTC
Alice
1 BTC
14
Block
●
Contains
transactions
metadata
●
Has unique parent
15
Blockchain
16
Blockchain
tip
18
Mining (a.k.a. writing history)
●
Only valid transactions?
●
Proof of Work? 19
Mining (a.k.a. writing history)
●
Only valid transactions! new tip
●
Proof of Work! 20
Hash function
ε 01
ab 10
bb 11
baa
n-bit
strings integers
21
Hash function
easy
One way: hard
ε 01
ab 10
bb 11
baa
n-bit
strings integers
Collision free: rare
22
Hash function
easy
One way: Bitcoin uses SHA256, e.g.:
hard
ε 01
SHA256( 598324 ) =
ab 10
bb 11
baa 0000000000000000000
d7819fc59c65ca6f3e8f73c
n-bit 6eeadf538aa874a31341fb
strings integers
Collision free: rare
23
Proof of work
def hasProofOfWork(block):
if hasManyLeadingZeroes(SHA256(block)):
return True
return False
25
Forks
Protocol says:
●
Choose longest fork
●
If equal, choose random
26
Nice properties
28
Remember transactions?
Alice Bob
tx
1 coin 1 coin
29
Now add some code!
30
Example 1: Flip a coin
winner = 2 coins
random(Alice, Bob)
Alice give winner 2 coins
1 coin
31
Example 1: Flip a coin
winner = 2 coins
random(Alice, Bob)
Alice give winner 2 coins
1 coin
Don’t use this contract in real life! 32
Example 2: King of the Hill
top = 0
king = null
while (true)
if (user gives x coins
and
x > top)
give king top coins
king = user
top = x
V Xchain
V TM
35
Cryptokitties
36
MakerDao
●
Decentralised stablecoin
●
On Ethereum
●
1 Dai = 1 USD
●
Overcollateralised by floating “Maker”
37
Types of blockchains
●
Permissioned vs Permissionless V
●
Proof of Work vs Proof of Stake V
●
Private vs Transparent TM
V
38
Scalability issue
: 7 txs/sec
: 20,000 txs/sec
Problem: too much redundancy
39
Candidate Solution
40
Crosschain transactions
41
Interconnected blockchains
Specialised blockchains
Separation of duties
Related: Sharding
42
Questions?
Credits:
●
Blockchain by Pablo Rozenberg from the Noun Project
43