input-output-hk / marlowe

Prototype implementation of domain-specific language for the design of smart-contracts over cryptocurrencies
Apache License 2.0
172 stars 43 forks source link

PLT-4195 - Asset preservation theory #161

Closed hrajchert closed 1 year ago

hrajchert commented 1 year ago

As part of the Marlowe audit, the following problem was found

Screen Shot 2023-03-13 at 17 15 59

Basically, the proof didn't guarantee us that if we deposit 15 ada and 20 djed we won't get 15 djed and 20 ada back, only that we'd get 35 tokens.

The new theory AssetsPreservation solves this by working with a new MultiAsset data type, defined in MultiAssets.thy. The new type defines some type classes for working with MultiAssets as if they were natural numbers.

The lemmas were restructured, removing the need of auxiliary functions to solve the following issues

Screen Shot 2023-03-13 at 17 22 31 Screen Shot 2023-03-13 at 17 23 21

The function moneyInPayment was renamed to assetsInExternalPayment as suggested by the auditors, to mark that we are talking about money transferred from the contract to an external party and not from internal account to internal account.

Screen Shot 2023-03-13 at 17 44 08

I've attached a version of the specification-v3.pdf with a modified section 3.1 and 3.2