Privacy Enhancing Technologies: Department of Computer Science
Privacy Enhancing Technologies: Department of Computer Science
• Ether
• Mined in a way similar to Bitcoin
• Block reward: ~ 3 ETH
• Currently $100+ per ether
• The crypto-fuel for the Ethereum network
• Healthy ecosystem: a form of payment to compensate
the machines for executing the requested operations
• Also, an incentive ensuring that developers write quality
applications (wasteful code costs more)
• High-level languages :
Serpent, Solidity, LLL
• Similar to Java script
• Written contracts are
compiled to EVM code
and deployed on EVM
• Each contract has
unique address on EVM
• Execution?
CS6290: Privacy Enhancing Technologies
Code execution
Transaction
Game playing
Sending & querying
Game
Arcade server
Transaction machine
relaying
Assumptions
▪ The game arcade is trusted
• Game machine has a private key built in
• Game machine can sign transaction with the private key
• The arcade has a local server to relay transactions from
machines
Assumptions
▪ We do not consider the performance/cost issues
• TX delay – how long it takes for the transaction result to
return
• TX rate – how frequent the machine generate transaction
• TX fee – how much it costs the arcade to run the system
Our Contract Design
▪ ERC20 token
• Other standards: ERC223, ERC621, ERC827,etc.
▪ Token rewarding
• Authorized game machines can reward players
▪ Token consumption
• Authorized game machines can consume token for
players to enhance gaming experience
ERC20 – the most widely
adopted standard
12
Start with some reference
implementation
https://www.slideshare.net/Kenneth_hu/20180711-metamask
From contract to blockchain
application
▪ In our case, the game arcade server will run a
local Ethereum node
Machine
Arcade
Public chain server
(Ethereum node)
Machine
When deployed to the real
Ethereum mainnet
▪ Transaction speed matters
• Players desire the token to take effect instantaneously
https://www.coindesk.com/ethereum-price/
How to solve the performance
and cost issue?
▪ This is generally referred to as blockchain
scalability problem
▪ General directions
• Layer 1 – Sharding
▪ Redesign base-layer blockchain protocol
▪ Each TX is only seen and processed by a small shard of nodes
▪ Examples: Zilliqa, Prysmatic Labs Ethereum 2.0
• Layer 2
▪ State channels
▪ Sidechains (aka parachains, childchains)
Scaling technique – state
channels
▪ One-to-one channel for bulk off-chain transactions
• Final settlement on-chain
▪ Example: Lightning Network, Raiden Network,
Counterfactual
https://cdn-images-1.medium.com/max/2000/1*YjHwvs76f1-CgGx43SwvEw.png
Scaling technique – sidechains
▪ A separate chain running in parallel to the main chain
• Independent consensus (e.g., PoA) and configurations
• Data/states can be exchanged between the two chains
▪ Examples: Plasma, POA Network, Parity Bridge, (Polkadot, Cosmos)
https://cdn-images-1.medium.com/max/1600/0*gHDyU65BfvNG-VHn.png
Solution: consortium chain
▪ Game arcades maintain an Ethereum-compatible
consortium chain
• We will bridge the consortium chain with the public chain
▪ Rationale
• We can reuse previously developed components
▪ GameToken contract
▪ Server application
• More flexibility in upgrading and adding new features
• Different games arcades can naturally form a consortium
Solution: consortium chain
▪ The consortium chain can be configured with
• low TX delay – e.g., 1 second block interval
• high TX rate – e.g., unlimited block gas limit
• zero TX fee – e.g., zero transaction gas price
Solution: consortium chain
▪ Game machines only interact with the
consortium chain
▪ Token rewarding and consumption only occur on
consortium chain
110
Total balance of A: 100
A: 110
100 A: 10
Public Consortium
Bridge
chain chain
Solution: consortium chain +
cross-chain bridge
▪ We use Proof-of-Authority (PoA) consortium chain
• Only a set of validators can propose and write blocks
• Each game arcade can run a validator
• Wrongdoing validators can be voted out
• Less de-centralized than PoW, PoS
▪ Example PoA consensus algorithms
• AuthorityRound (Aura)
• Clique
• Tendermint
Solution: consortium chain +
cross-chain bridge
▪ Each validator additionally plays the role of a bridge
• Cross-chain state transfer requires multisig from bridges
• An exchange is approved when a required number of
bridges have signed
Bridge
(validator)
Public Consortium
chain PoA chain
Bridge
(validator)
Multi-sig bridging – the
straightforward way
player A One public transactions
Multiple transaction
Contract pseudo code
exchange n token
hash = H(A | n | txHash)
bridge B1
Contract pseudo code
voter[hash].push( B1
B3)
B2
balance[A] -= n
bridge B2
Enough?
Exchange event
A, n, txHash bridge B3
balance[A] += n
Exchange event
A, n, txHash
bridge B2
All verified?
signatures.push( B2
B3 )
B1
bridge B3
Enough? balance[A] += n