A general implementation of Merkle Mountain Range proofs for Orderbooks
- Create a general Rust library for generating orderbook proofs using Merkle Mountain Ranges
- Create a RISC0 compatible library
The design choices around Merkle Mountain Ranges is fairly new, and is largely experimentative. The basic feature of MMR is that it is an append-only data structure with guarantees on
- Ordering (No order that came after got filled before if the same price)
- Fair Execution (No worse price got the trade at time of execution)
MMR designs allow for a bunch of choices:
-
Append on the right only? Or left too?
-
Updatability of existing elements ir immutable records? Immutable records might require extra data structures to hold some information.
-
What data to reveal in the executions and to what level of orderbook obfuscation is needed. prove computation? Or prove privacy?
The Merkle Mountain Range library used is: https://github.com/nervosnetwork/merkle-mountain-range
Create orderbook specific merkle mountain range structure and functions as a starting point.
Workflow:
- User submits order received receipt showing leaf position.
- Orderbook hidden
- Orders are matched off chain (off MMR) and executions are revealed.
- Verification1: call
calculate_root
function using the executions asproof_items
to check these orders belonged to the tree - Verification2:
- Verification3: