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-5370 - Merkleization formalization #171

Open hrajchert opened 1 year ago

hrajchert commented 1 year ago

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

Screen Shot 2023-03-24 at 12 53 48

This DRAFT PR is an attempt to formalize merkleized contracts.

Two approaches were considered for this task: modify the contract type in the Core session to include the merkleized case, or create a new Merkle session that reuses everything it can from the Core session and prove that both versions are equivalent. We chose the latter approach for the following reasons.

Modifying the Core session would invalidate all current theories, while adding a new Merkle session does not invalidate anything but adds some duplication. For example, the Merkleized and Unmerkleized versions of reduceContractStep are the same, but we need to have both versions since the types are different.

If we modify the Core session, we would have the Merkleized and Unmerkleized versions under the same type, which can make the lemmas for equivalence harder to express. We would probably need to add an isMerkleized proposition and include it as an assumption in the lemmas, while having separate versions, the proposition is implied by the type.

If we decide to keep this approach, the following tasks need to be accomplished: