Skip to main content

A Formally Verified Static Analysis Framework for Compositional Contracts

  • Conference paper
  • First Online:
Financial Cryptography and Data Security (FC 2020)

Part of the book series: Lecture Notes in Computer Science ((LNSC,volume 12063))

Included in the following conference series:

Abstract

A (commercial or financial) contract is a mutual agreement to exchange resources such as money, goods and services amongst multiple parties. It expresses which actions may, must and must not be performed by its parties at which time, location and under which other conditions.

We present a general framework for statically analyzing digital contracts, formal specifications of contracts, expressed in Contract Specification Language (CSL). Semantically, a CSL contract classifies traces of events into compliant (complete and successful) and noncompliant (incomplete or manifestly breached) ones.

Our analysis framework is based on compositional abstract interpretation, which soundly approximates the set of traces a contract denotes by an abstract value in a lattice. The framework is parameterized by a lattice and an interpretation of contract primitives and combinators, satisfying certain requirements. It treats recursion by unrestricted unfolding. Employing Schmidt’s natural semantics approach, we interpret our inference system coinductively to account for infinite derivation trees, and prove their abstract interpretation sound.

Finally, we show some example applications: participation analysis (who is possibly involved in a transfer to whom; who does definitely participate in a contract) and fairness analysis (bounds on how much is gained by each participant under any compliant execution of the contract).

The semantics of CSL, the abstract interpretation framework and its correctness theorem, and the example analyses as instances of the abstract interpretation framework have all been mechanized in the Coq proof assistant.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 89.00
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 119.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    If desirable; “code is law” by contract parties fixing the association of a specific immutable contract manager is a possibility, not a necessity in this framework.

  2. 2.

    Available at https://ayertienna.github.io/csl_formalization_wtsc20.zip.

  3. 3.

    “Predicate” in the sense of a formula denoting a Boolean-valued function.

  4. 4.

    Coq sources: https://ayertienna.github.io/csl_formalization_wtsc20.zip.

  5. 5.

    See www.deondigital.com.

  6. 6.

    Unfair in the sense of providing unexpected gains or losses to participants. Note that under the adage of “code is law” an unfair contract is still a contract that cannot be changed: it is what it is.

  7. 7.

    The pattern of pseudonymous parties collateralizing participation in a contract by depositing money with a trusted third party is common and practically unavoidable: The parties being pseudonymous, they could just walk away once they owe more than they are owed. This may explain why each Ethereum-style smart contract is “born” with an associated Ether account.

References

  1. Amani, S., Bégel, M., Bortin, M., Staples, M.: Towards verifying Ethereum smart contract bytecode in Isabelle/HOL. In: Proceedings of the 7th ACM SIGPLAN International Conference on Certified Programs and Proofs, pp. 66–77. ACM (2018)

    Google Scholar 

  2. Andersen, J., Bahr, P., Henglein, F., Hvitved, T.: Domain-specific languages for enterprise systems. In: Margaria, T., Steffen, B. (eds.) ISoLA 2014. LNCS, vol. 8802, pp. 73–95. Springer, Heidelberg (2014). https://doi.org/10.1007/978-3-662-45234-9_6

    Chapter  Google Scholar 

  3. Andersen, J., Elsborg, E., Henglein, F., Simonsen, J.G., Stefansen, C.: Compositional specification of commercial contracts. In: ISoLA (Preliminary Proceedings), 30 October 2004, pp. 103–110 (2004)

    Google Scholar 

  4. Andersen, J., Elsborg, E., Henglein, F., Simonsen, J.G., Stefansen, C.: Compositional specification of commercial contracts. STTT 8(6), 485–516 (2006). https://doi.org/10.1007/s10009-006-0010-1

    Article  Google Scholar 

  5. Annenkov, D., Elsman, M.: Certified compilation of financial contracts. In: Proceedings of the 20th International Symposium on Principles and Practice of Declarative Programming, PPDP 2018, pp. 5:1–5:13. ACM, New York (2018)

    Google Scholar 

  6. Annenkov, D., Nielsen, J.B., Spitters, B.: Towards a smart contract verification framework in Coq. In: Proceedings of the 9th ACM SIGPLAN International Conference on Certified Proofs and Programs (CPP) (2020)

    Google Scholar 

  7. Bahr, P., Berthold, J., Elsman, M.: Certified symbolic management of financial multi-party contracts. In: Proceedings of the ACM International Conference on Functional Programming (ICFP), August 2015. SIGPLAN Not. 50(9), 315–327

    Google Scholar 

  8. Bartoletti, M., Zunino, R.: Verifying liquidity of bitcoin contracts. Cryptology ePrint Archive, Report 2018/1125 (2018). https://eprint.iacr.org/2018/1125

  9. Benton, N., Hur, C.-K., Kennedy, A.J., McBride, C.: Strongly typed term representations in Coq. J. Autom. Reason. 49(2), 141–159 (2012). https://doi.org/10.1007/s10817-011-9219-0

    Article  MathSciNet  MATH  Google Scholar 

  10. Bhargavan, K., et al.: Formal verification of smart contracts. In: Proceedings of the 2016 ACM Workshop on Programming Languages and Analysis for Security-PLAS 2016, pp. 91–96 (2016)

    Google Scholar 

  11. Chatterjee, K., Goharshady, A.K., Velner, Y.: Quantitative analysis of smart contracts. CoRR, abs/1801.03367 (2018)

    Google Scholar 

  12. Chen, X., Park, D., Roşu, G.: A language-independent approach to smart contract verification. In: Margaria, T., Steffen, B. (eds.) ISoLA 2018. LNCS, vol. 11247, pp. 405–413. Springer, Cham (2018). https://doi.org/10.1007/978-3-030-03427-6_30

    Chapter  Google Scholar 

  13. DAML: Digital Asset Modelling Language. https://daml.com/

  14. Deon Digital: CSL Language Guide. https://deondigital.com/docs/v0.39.0/

  15. Egelund-Müller, B., Elsman, M., Henglein, F., Ross, O.: Automated execution of financial contracts on blockchains. Bus. Inf. Syst. Eng. 59(6), 457–467 (2017). https://doi.org/10.1007/s12599-017-0507-z

    Article  Google Scholar 

  16. Harz, D., Knottenbelt, W.J.: Towards safer smart contracts: a survey of languages and verification methods. CoRR, abs/1809.09805 (2018)

    Google Scholar 

  17. Henglein, F.: Smart digital contracts: algebraic foundations for resource accounting. Oregon Programming Languages Summer School (OPLSS), Smart Digital Contracts, Lecture 2, June 2019

    Google Scholar 

  18. Henglein, F.: Smart digital contracts: contract specification and life-cycle management. Oregon Programming Languages Summer School (OPLSS), Smart Digital Contracts, Lecture 3, June 2019

    Google Scholar 

  19. Henglein, F.: Smart digital contracts: introduction. Oregon Programming Languages Summer School (OPLSS), Smart Digital Contracts, Lecture 1, June 2019

    Google Scholar 

  20. Henglein, F., Larsen, K.F., Simonsen, J.G., Stefansen, C.: POETS: process-oriented event-driven transaction systems. J. Log. Algebraic Program. 78(5), 381–401 (2009)

    Article  Google Scholar 

  21. Henriksen, T., Serup, N., Elsman, M., Henglein, F., Oancea, C.: Futhark: purely functional GPU-programming with nested parallelism and in-place array updates. In: Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), Barcelona, Spain, June 2017, pp. 556–571. ACM (2017). HIPEAC Best Paper Award

    Google Scholar 

  22. Hildenbrandt, E., et al.: KEVM: a complete semantics of the ethereum virtual machine. In: Proceedings of the 31st IEEE Computer Security Foundations Symposium (CSF) (2018)

    Google Scholar 

  23. Hvitved, T.: A survey of formal languages for contracts. In: Fourth Workshop on Formal Languages and Analysis of Contract-Oriented Software (FLACOS 2010), pp. 29–32 (2010)

    Google Scholar 

  24. Hvitved, T., Klaedtke, F., Zălinescu, E.: A trace-based model for multiparty contracts. J. Log. Algebraic Program. 81(2), 72–98 (2012)

    Article  MathSciNet  Google Scholar 

  25. Kowalski, R.: Algorithm = logic + control. Commun. ACM 22(7), 424–436 (1979)

    Article  Google Scholar 

  26. Larsen, C.K.: Declarative contracts. Mechanized semantics and analysis. Master’s thesis, University of Copenhagen, Denmark (2019). https://ckjaer.dk/files/thesis.pdf

  27. Luu, L., Chu, D.-H., Olickel, H., Saxena, P., Hobor, A.: Making smart contracts smarter. In: Proceedings of the 2016 ACM SIGSAC Conference on Computer and Communications Security, CCS 2016, pp. 254–269. ACM, New York (2016)

    Google Scholar 

  28. McCarthy, W.E.: The REA accounting model: a generalized framework for accounting systems in a shared data environment. Account. Rev. LVII(3), 554–578 (1982)

    Google Scholar 

  29. Nielsen, J.B., Spitters, B.: Smart contract interactions in Coq. arXiv preprint arXiv:1911.04732 (2019)

  30. Nikolic, I., Kolluri, A., Sergey, I., Saxena, P., Hobor, A.: Finding the greedy, prodigal, and suicidal contracts at scale. arXiv:1802.06038v1 [cs.CR], arXiv, February 2018

  31. Peyton Jones, S., Eber, J.-M., Seward, J.: Composing contracts: an adventure in financial engineering (functional pearl). SIGPLAN Not. 35(9), 280–292 (2000)

    Article  Google Scholar 

  32. Schmidt, D.A.: Natural-semantics-based abstract interpretation (preliminary version). In: Mycroft, A. (ed.) SAS 1995. LNCS, vol. 983, pp. 1–18. Springer, Heidelberg (1995). https://doi.org/10.1007/3-540-60360-3_28

    Chapter  Google Scholar 

  33. Lamela Seijas, P., Thompson, S.: Marlowe: financial contracts on blockchain. In: Margaria, T., Steffen, B. (eds.) ISoLA 2018. LNCS, vol. 11247, pp. 356–375. Springer, Cham (2018). https://doi.org/10.1007/978-3-030-03427-6_27

    Chapter  Google Scholar 

Download references

Acknowledgements

We would like to thank the anonymous referees for their critical and helpful comments.

This work has been facilitated by financial support from Deon Digital and Innovation Fund Denmark for the project Formal verification for formal contracts under contract number 7092-00003B.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Fritz Henglein .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2020 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Henglein, F., Larsen, C.K., Murawska, A. (2020). A Formally Verified Static Analysis Framework for Compositional Contracts. In: Bernhard, M., et al. Financial Cryptography and Data Security. FC 2020. Lecture Notes in Computer Science(), vol 12063. Springer, Cham. https://doi.org/10.1007/978-3-030-54455-3_42

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-54455-3_42

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-54454-6

  • Online ISBN: 978-3-030-54455-3

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics