ETHEREUM

Bitcoin on steroids
Max Kaye
https://xk.io
About Max
- Bitcoiner since 2010
-
NMC/BTC mining pool 2011
- Treasurer of the Bitcoin Asn of Aust
General Overview
How do you replace ALL financial institutions with
cloud based trust free fully transparent apps?
Can we design a network to do ANYTHING
that crypto-protocols will ever be capable of?
Bitcoin does one thing, like a calculator.
Ethereum does all things, like a CPU.
- Ephemeral Scripts (one use only)
-
Forms Transaction Tree
- Requires Human Interaction
- Users and Programs indistinguishable
- Restrictive script
- Reusable Dapps (distributed apps)
- Dapp <-> dapp interaction
- Markets, Meta-coins, CFDs, Dropbox, Gambling
- Trustless, deterministic, transparent
- Turing complete scripting language
A new protocol
- Why
- Lite clients for contracts
- Better scripting capabilities
- Bitcoin's scripting system is very restricted
- Bitcoin's scripts cannot store data
- Bitcoin's scripts are one-time use
-
Ethereum has a turing complete scripting
language with the above capabilities - Flexible implementation
- Design for well-suited-ness
(down for merkle trees and block structure)
merkle trees
- Leaves are 'hashed up'
- Each leaf hashed with its partner
- Process repeated till n = 1
-
Produced cryptographically authenticated data (not like ECC)
(down for merkle proofs)

- node.getHash() =
- hash(
- child[0].getHash()
- ++
- child[1].getHash()
-
)
Merkle Tree Proofs
Task: Prove H010 is in H.
(down for block struct)
-
Solution:
-
H010 ++ H011 = H01
-
H01 ++ H00 = H0
-
H0 ++ H1 = H

- Known
- H010, H
- Given
- H011, H00, H1
Block Structure
-
Uncles: GHOST Protocol
- Collected in merkle tree
-
TX Merkleroot
- All TXs (like Bitcoin)
- State Merkleroot
- Hash tree of all current states
- Proves current DB for an app

Contract (DAPP) structure
- Dapp creation:
- send script to special address
- Dapps are stored in their own data stores
- Execution starts at byte 0, but can jump anywhere
- Ideally data is stored at index > 1000 (or so)
(down for transactions)
Transactions
All TXs are in the form:
[nonce, destination, value, [data-0, data-1, ...], v, r, s]
-
nonce - guarantee unique tx-hash
-
destination - an address or contract-hash
-
value - amount of money to debit
-
data-n - the nth data item (input to contracts)
-
v, r, s - signature, pubkey recoverable
(down for state)
State - What is it
A contract's state is its current data-store
-
S[n] + TX :=
- S[n+1]
-
New states created with the application of transactions.
-
Each block contains a list of transactions which are successively applied in order to generate the next state.
-
S[n] + Block :=
- for each k in Block.txs
- S[n+k+1] :=
- S[n+k] + Block[k]
-
The k:v data-store associated with each contract is stored as a separate state in the state merkle tree
-
Root in the block header.
Simple Contracts
Insert-once DB
if tx.value < block.basefee * 200:
stop
if contract.storage[tx.data[0]] or tx.data[0] < 100:
stop
contract.storage[tx.data[0]] = tx.data[1]
TX: [nonce, NAMECOIN1, 2*10^12, [google.dns, 8.8.8.8], r, s, v]
Datastore: {
0x00 : 0x22,
0x01 : 0xc8,
...
"google.dns" : "8.8.8.8"
}
Simple Contracts CONT
Authenticated DB
if tx.value < block.basefee * 200:
stop
key = sha256( tx.data[0] )
if contract.storage[key] == 0:
contract.storage[key] = tx.data[1]
contract.storage[key + 1] = tx.sender
else:
if contract.storage[key + 1] != tx.sender:
stop
contract.storage[key] = tx.data[1]
TX: [nonce, NAMECOIN2, 2*10^12, [google.dns, 8.8.8.8], r, s, v]
Datastore: {
0x00 : 0x22,
0x01 : 0xc8,
...
0x7dfc...efa8 : "8.8.8.8",
0x7dfc...efa9 : 0x92b0a63599b0...,
}
Simple Meta-coin
(spot the bug)
if tx.value < 100 * block.basefee: stop elif contract.storage[1000] != 0: from = tx.sender to = tx.data[0] value = tx.data[1] if to <= 1000: stop if contract.storage[from] < value: stop contract.storage[from] = contract.storage[from] - value contract.storage[to] = contract.storage[to] + value
else: contract.storage[MYCREATOR] = 10^18 contract.storage[1000] = 1
QUESTIONS
- m@xk.io
- https://xk.io
- github.com/XertroV
these slides: slid.es/maxkaye/ethereum
Bitcoin Tips:

test contracts
Track and store Bitcoin header-chain
Track and store merkle branches
Track and store Bitcoin payments
ETHEREUM
By Max Kaye
ETHEREUM
- 2,709