findel: secure derivative contracts for ethereum - slides.pdf · 2017. 4. 15. · findel: ethereum...

27
Findel: Ethereum Derivatives Biryukov, Khovratovich, Tikhomirov Introduction Financial Languages Composable Contracts Ethereum Our Contribution Findel DSL Examples Gateways Conclusion 1/18 Findel: Secure Derivative Contracts for Ethereum Alex Biryukov Dmitry Khovratovich Sergei Tikhomirov 1st Workshop on Trusted Smart Contracts In Association with Financial Cryptography 17 7 April 2017, Malta

Upload: others

Post on 25-Aug-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Findel: Secure Derivative Contracts for Ethereum - Slides.pdf · 2017. 4. 15. · Findel: Ethereum Derivatives Biryukov, Khovratovich, Tikhomirov Introduction Financial Languages

Findel: EthereumDerivatives

Biryukov,Khovratovich,Tikhomirov

Introduction

Financial Languages

ComposableContracts

Ethereum

Our Contribution

Findel DSL

Examples

Gateways

Conclusion

1/18

Findel: Secure Derivative Contracts forEthereum

Alex Biryukov Dmitry KhovratovichSergei Tikhomirov

1st Workshop on Trusted Smart ContractsIn Association with Financial Cryptography 17

7 April 2017, Malta

Page 2: Findel: Secure Derivative Contracts for Ethereum - Slides.pdf · 2017. 4. 15. · Findel: Ethereum Derivatives Biryukov, Khovratovich, Tikhomirov Introduction Financial Languages

Findel: EthereumDerivatives

Biryukov,Khovratovich,Tikhomirov

Introduction

Financial Languages

ComposableContracts

Ethereum

Our Contribution

Findel DSL

Examples

Gateways

Conclusion

2/18

... and Smart Contract Developer

Adapted from xkcd.com/1428

Page 3: Findel: Secure Derivative Contracts for Ethereum - Slides.pdf · 2017. 4. 15. · Findel: Ethereum Derivatives Biryukov, Khovratovich, Tikhomirov Introduction Financial Languages

Findel: EthereumDerivatives

Biryukov,Khovratovich,Tikhomirov

Introduction

Financial Languages

ComposableContracts

Ethereum

Our Contribution

Findel DSL

Examples

Gateways

Conclusion

3/18

Contract Programming is Different

I ”Move fast and break things”: unacceptable!

I Real money (property, resources) at stake

I Side-effects often cause trouble (The DAO)

I We need a formally verifiable contract language

Page 4: Findel: Secure Derivative Contracts for Ethereum - Slides.pdf · 2017. 4. 15. · Findel: Ethereum Derivatives Biryukov, Khovratovich, Tikhomirov Introduction Financial Languages

Findel: EthereumDerivatives

Biryukov,Khovratovich,Tikhomirov

Introduction

Financial Languages

ComposableContracts

Ethereum

Our Contribution

Findel DSL

Examples

Gateways

Conclusion

4/18

A Secure Financial DSL Helps

I Avoid misinterpretation

I Standardize templates

I Prove correctness

I Facilitate automated processing

Page 5: Findel: Secure Derivative Contracts for Ethereum - Slides.pdf · 2017. 4. 15. · Findel: Ethereum Derivatives Biryukov, Khovratovich, Tikhomirov Introduction Financial Languages

Findel: EthereumDerivatives

Biryukov,Khovratovich,Tikhomirov

Introduction

Financial Languages

ComposableContracts

Ethereum

Our Contribution

Findel DSL

Examples

Gateways

Conclusion

5/18

Composable Contracts [Peyton Jones et al. 2003]

I Ten primitives to compose complex agreements

I Declarative paradigm

I Implemented as an embedded DSL in Haskell

Example: zero-coupon bond

when (at 2018-01-01) (scale (konst 100)) (one $))

Page 6: Findel: Secure Derivative Contracts for Ethereum - Slides.pdf · 2017. 4. 15. · Findel: Ethereum Derivatives Biryukov, Khovratovich, Tikhomirov Introduction Financial Languages

Findel: EthereumDerivatives

Biryukov,Khovratovich,Tikhomirov

Introduction

Financial Languages

ComposableContracts

Ethereum

Our Contribution

Findel DSL

Examples

Gateways

Conclusion

5/18

Composable Contracts [Peyton Jones et al. 2003]

I Ten primitives to compose complex agreements

I Declarative paradigm

I Implemented as an embedded DSL in Haskell

Example: zero-coupon bond

when (at 2018-01-01) (scale (konst 100)) (one $))

Page 7: Findel: Secure Derivative Contracts for Ethereum - Slides.pdf · 2017. 4. 15. · Findel: Ethereum Derivatives Biryukov, Khovratovich, Tikhomirov Introduction Financial Languages

Findel: EthereumDerivatives

Biryukov,Khovratovich,Tikhomirov

Introduction

Financial Languages

ComposableContracts

Ethereum

Our Contribution

Findel DSL

Examples

Gateways

Conclusion

6/18

Ethereum

I Turing-complete virtual machine

I Key feature: trustless execution

I Perfect match for financial agreements!

Page 8: Findel: Secure Derivative Contracts for Ethereum - Slides.pdf · 2017. 4. 15. · Findel: Ethereum Derivatives Biryukov, Khovratovich, Tikhomirov Introduction Financial Languages

Findel: EthereumDerivatives

Biryukov,Khovratovich,Tikhomirov

Introduction

Financial Languages

ComposableContracts

Ethereum

Our Contribution

Findel DSL

Examples

Gateways

Conclusion

7/18

Ethereum Meets Composable Contracts

I Map declarative DSL to blockchain execution paradigm

I Retrieve and validate external data

I Ensure that execution cost is bearable

Page 9: Findel: Secure Derivative Contracts for Ethereum - Slides.pdf · 2017. 4. 15. · Findel: Ethereum Derivatives Biryukov, Khovratovich, Tikhomirov Introduction Financial Languages

Findel: EthereumDerivatives

Biryukov,Khovratovich,Tikhomirov

Introduction

Financial Languages

ComposableContracts

Ethereum

Our Contribution

Findel DSL

Examples

Gateways

Conclusion

8/18

Financial Derivatives Language (Findel)

I Contract: agreement between issuer and owner

I Contract description defines rights and obligations

I Description is a tree of primitives

I Description and issuer are immutable

I Ownership may be transferred

I Smart contract acts as execution environment

Page 10: Findel: Secure Derivative Contracts for Ethereum - Slides.pdf · 2017. 4. 15. · Findel: Ethereum Derivatives Biryukov, Khovratovich, Tikhomirov Introduction Financial Languages

Findel: EthereumDerivatives

Biryukov,Khovratovich,Tikhomirov

Introduction

Financial Languages

ComposableContracts

Ethereum

Our Contribution

Findel DSL

Examples

Gateways

Conclusion

9/18

Findel Primitives 1/2

I Zero – do nothing

I One – transfer 1 unit of currency from issuer to owner

I Scale(k , c) – multiply all payments by a constant value

I ScaleObs(obs, c) – multiply all payments by anobservable value (think exchange rate)

I Give(c) – swap parties

Page 11: Findel: Secure Derivative Contracts for Ethereum - Slides.pdf · 2017. 4. 15. · Findel: Ethereum Derivatives Biryukov, Khovratovich, Tikhomirov Introduction Financial Languages

Findel: EthereumDerivatives

Biryukov,Khovratovich,Tikhomirov

Introduction

Financial Languages

ComposableContracts

Ethereum

Our Contribution

Findel DSL

Examples

Gateways

Conclusion

9/18

Findel Primitives 1/2

I Zero – do nothing

I One – transfer 1 unit of currency from issuer to owner

I Scale(k , c) – multiply all payments by a constant value

I ScaleObs(obs, c) – multiply all payments by anobservable value (think exchange rate)

I Give(c) – swap parties

Page 12: Findel: Secure Derivative Contracts for Ethereum - Slides.pdf · 2017. 4. 15. · Findel: Ethereum Derivatives Biryukov, Khovratovich, Tikhomirov Introduction Financial Languages

Findel: EthereumDerivatives

Biryukov,Khovratovich,Tikhomirov

Introduction

Financial Languages

ComposableContracts

Ethereum

Our Contribution

Findel DSL

Examples

Gateways

Conclusion

9/18

Findel Primitives 1/2

I Zero – do nothing

I One – transfer 1 unit of currency from issuer to owner

I Scale(k , c) – multiply all payments by a constant value

I ScaleObs(obs, c) – multiply all payments by anobservable value (think exchange rate)

I Give(c) – swap parties

Page 13: Findel: Secure Derivative Contracts for Ethereum - Slides.pdf · 2017. 4. 15. · Findel: Ethereum Derivatives Biryukov, Khovratovich, Tikhomirov Introduction Financial Languages

Findel: EthereumDerivatives

Biryukov,Khovratovich,Tikhomirov

Introduction

Financial Languages

ComposableContracts

Ethereum

Our Contribution

Findel DSL

Examples

Gateways

Conclusion

9/18

Findel Primitives 1/2

I Zero – do nothing

I One – transfer 1 unit of currency from issuer to owner

I Scale(k , c) – multiply all payments by a constant value

I ScaleObs(obs, c) – multiply all payments by anobservable value (think exchange rate)

I Give(c) – swap parties

Page 14: Findel: Secure Derivative Contracts for Ethereum - Slides.pdf · 2017. 4. 15. · Findel: Ethereum Derivatives Biryukov, Khovratovich, Tikhomirov Introduction Financial Languages

Findel: EthereumDerivatives

Biryukov,Khovratovich,Tikhomirov

Introduction

Financial Languages

ComposableContracts

Ethereum

Our Contribution

Findel DSL

Examples

Gateways

Conclusion

9/18

Findel Primitives 1/2

I Zero – do nothing

I One – transfer 1 unit of currency from issuer to owner

I Scale(k , c) – multiply all payments by a constant value

I ScaleObs(obs, c) – multiply all payments by anobservable value (think exchange rate)

I Give(c) – swap parties

Page 15: Findel: Secure Derivative Contracts for Ethereum - Slides.pdf · 2017. 4. 15. · Findel: Ethereum Derivatives Biryukov, Khovratovich, Tikhomirov Introduction Financial Languages

Findel: EthereumDerivatives

Biryukov,Khovratovich,Tikhomirov

Introduction

Financial Languages

ComposableContracts

Ethereum

Our Contribution

Findel DSL

Examples

Gateways

Conclusion

10/18

Findel Primitives 2/2

I And(c1, c2) – execute both sub-contracts

I Or(c1, c2) – owner chooses which sub-contract toexecute

I If (obs, c1, c2) – execute one of sub-contracts(depending on observable)

I Timebound(t0, t1, c) – execute c , if within time bounds

Page 16: Findel: Secure Derivative Contracts for Ethereum - Slides.pdf · 2017. 4. 15. · Findel: Ethereum Derivatives Biryukov, Khovratovich, Tikhomirov Introduction Financial Languages

Findel: EthereumDerivatives

Biryukov,Khovratovich,Tikhomirov

Introduction

Financial Languages

ComposableContracts

Ethereum

Our Contribution

Findel DSL

Examples

Gateways

Conclusion

10/18

Findel Primitives 2/2

I And(c1, c2) – execute both sub-contracts

I Or(c1, c2) – owner chooses which sub-contract toexecute

I If (obs, c1, c2) – execute one of sub-contracts(depending on observable)

I Timebound(t0, t1, c) – execute c , if within time bounds

Page 17: Findel: Secure Derivative Contracts for Ethereum - Slides.pdf · 2017. 4. 15. · Findel: Ethereum Derivatives Biryukov, Khovratovich, Tikhomirov Introduction Financial Languages

Findel: EthereumDerivatives

Biryukov,Khovratovich,Tikhomirov

Introduction

Financial Languages

ComposableContracts

Ethereum

Our Contribution

Findel DSL

Examples

Gateways

Conclusion

10/18

Findel Primitives 2/2

I And(c1, c2) – execute both sub-contracts

I Or(c1, c2) – owner chooses which sub-contract toexecute

I If (obs, c1, c2) – execute one of sub-contracts(depending on observable)

I Timebound(t0, t1, c) – execute c , if within time bounds

Page 18: Findel: Secure Derivative Contracts for Ethereum - Slides.pdf · 2017. 4. 15. · Findel: Ethereum Derivatives Biryukov, Khovratovich, Tikhomirov Introduction Financial Languages

Findel: EthereumDerivatives

Biryukov,Khovratovich,Tikhomirov

Introduction

Financial Languages

ComposableContracts

Ethereum

Our Contribution

Findel DSL

Examples

Gateways

Conclusion

10/18

Findel Primitives 2/2

I And(c1, c2) – execute both sub-contracts

I Or(c1, c2) – owner chooses which sub-contract toexecute

I If (obs, c1, c2) – execute one of sub-contracts(depending on observable)

I Timebound(t0, t1, c) – execute c , if within time bounds

Page 19: Findel: Secure Derivative Contracts for Ethereum - Slides.pdf · 2017. 4. 15. · Findel: Ethereum Derivatives Biryukov, Khovratovich, Tikhomirov Introduction Financial Languages

Findel: EthereumDerivatives

Biryukov,Khovratovich,Tikhomirov

Introduction

Financial Languages

ComposableContracts

Ethereum

Our Contribution

Findel DSL

Examples

Gateways

Conclusion

11/18

Example 1/3: Currency Exchange

And(Give(One(EUR)), ScaleObs(exchAddr ,One(USD)))

Page 20: Findel: Secure Derivative Contracts for Ethereum - Slides.pdf · 2017. 4. 15. · Findel: Ethereum Derivatives Biryukov, Khovratovich, Tikhomirov Introduction Financial Languages

Findel: EthereumDerivatives

Biryukov,Khovratovich,Tikhomirov

Introduction

Financial Languages

ComposableContracts

Ethereum

Our Contribution

Findel DSL

Examples

Gateways

Conclusion

12/18

Example 2/3: European Option

Timebound(t0 − δ, t0 + δ,Or(One(EUR),Zero))

Page 21: Findel: Secure Derivative Contracts for Ethereum - Slides.pdf · 2017. 4. 15. · Findel: Ethereum Derivatives Biryukov, Khovratovich, Tikhomirov Introduction Financial Languages

Findel: EthereumDerivatives

Biryukov,Khovratovich,Tikhomirov

Introduction

Financial Languages

ComposableContracts

Ethereum

Our Contribution

Findel DSL

Examples

Gateways

Conclusion

13/18

Example 3/3: Binary Option

If (orclAddr , Scale(10,One(USD)),Zero)

Page 22: Findel: Secure Derivative Contracts for Ethereum - Slides.pdf · 2017. 4. 15. · Findel: Ethereum Derivatives Biryukov, Khovratovich, Tikhomirov Introduction Financial Languages

Findel: EthereumDerivatives

Biryukov,Khovratovich,Tikhomirov

Introduction

Financial Languages

ComposableContracts

Ethereum

Our Contribution

Findel DSL

Examples

Gateways

Conclusion

14/18

External Data Problem

I Contracts require external data

I Ethereum is isolated from broader Internet

I Our solution: gateways

Page 23: Findel: Secure Derivative Contracts for Ethereum - Slides.pdf · 2017. 4. 15. · Findel: Ethereum Derivatives Biryukov, Khovratovich, Tikhomirov Introduction Financial Languages

Findel: EthereumDerivatives

Biryukov,Khovratovich,Tikhomirov

Introduction

Financial Languages

ComposableContracts

Ethereum

Our Contribution

Findel DSL

Examples

Gateways

Conclusion

14/18

External Data Problem

I Contracts require external data

I Ethereum is isolated from broader Internet

I Our solution: gateways

Page 24: Findel: Secure Derivative Contracts for Ethereum - Slides.pdf · 2017. 4. 15. · Findel: Ethereum Derivatives Biryukov, Khovratovich, Tikhomirov Introduction Financial Languages

Findel: EthereumDerivatives

Biryukov,Khovratovich,Tikhomirov

Introduction

Financial Languages

ComposableContracts

Ethereum

Our Contribution

Findel DSL

Examples

Gateways

Conclusion

15/18

Gateways

I Smart contract pulls and stores external data withtimestamp

I Optional proof of authenticity (e.g., signature underknown public key)

I Findel marketplace queries gateway when needed

I Parties are responsible for updating gateways

Page 25: Findel: Secure Derivative Contracts for Ethereum - Slides.pdf · 2017. 4. 15. · Findel: Ethereum Derivatives Biryukov, Khovratovich, Tikhomirov Introduction Financial Languages

Findel: EthereumDerivatives

Biryukov,Khovratovich,Tikhomirov

Introduction

Financial Languages

ComposableContracts

Ethereum

Our Contribution

Findel DSL

Examples

Gateways

Conclusion

16/18

What Is Done

I Defined a declarative DSL suited for blockchain

I Implemented a marketplace smart contract in Solidity

I Assessed cost of operation (∼ $0.1 per avg operation)1

1As of Jan 2017 at $10 / ether

Page 26: Findel: Secure Derivative Contracts for Ethereum - Slides.pdf · 2017. 4. 15. · Findel: Ethereum Derivatives Biryukov, Khovratovich, Tikhomirov Introduction Financial Languages

Findel: EthereumDerivatives

Biryukov,Khovratovich,Tikhomirov

Introduction

Financial Languages

ComposableContracts

Ethereum

Our Contribution

Findel DSL

Examples

Gateways

Conclusion

17/18

Future Work

I Enforcement: deal with users defaulting on debt

I Model balances using ERC20 Token

I Extend model to support multi-party contracts

I Look into valuation and verification

Page 27: Findel: Secure Derivative Contracts for Ethereum - Slides.pdf · 2017. 4. 15. · Findel: Ethereum Derivatives Biryukov, Khovratovich, Tikhomirov Introduction Financial Languages

Findel: EthereumDerivatives

Biryukov,Khovratovich,Tikhomirov

Introduction

Financial Languages

ComposableContracts

Ethereum

Our Contribution

Findel DSL

Examples

Gateways

Conclusion

18/18

Questions?

I cryptolux.org

I @serg tikhomirov

I [email protected]