Skip to main content
The Merkle Mountain Range is an append-only data structure that powers Lucid’s receipt verification system.

Why MMR?

FeatureStandard Merkle TreeMMR
AppendRequires rebuildO(log n)
Proof sizeO(log n)O(log n)
Append-onlyNoYes
StreamingNoYes

How It Works

Height 3:            15
                   /    \
Height 2:        7        14
               /   \    /    \
Height 1:    3      6   10     13
            / \   / \  / \   / \
Height 0: 1   2 4   5 8  9  11  12
          R1  R2 R3 R4 R5 R6 R7  R8

Ri = Receipt i (leaf node)
Internal nodes = hash(left || right)
Each receipt is a leaf in the MMR. Internal nodes are the hash of their children. The root of the MMR is what gets anchored on Solana.

Inclusion Proof

To prove receipt R3 is in the MMR, you need:
  1. R3’s hash (the leaf)
  2. R4’s hash (sibling)
  3. Node 3’s hash (uncle)
  4. Node 14’s hash (uncle)
This path lets anyone verify R3 is included without downloading all receipts.

API

// Get the current MMR root
const root = await lucid.mmr.root();

// Get a receipt's inclusion proof
const proof = await lucid.receipts.proof(receiptId);

// Verify the proof
const valid = verifyMMRProof(proof.leaf, proof.path, root.hash);

Signer

The session signer creates Ed25519 signatures for each receipt:
const pubkey = await lucid.signer.pubkey();
// Use this to verify receipt signatures offline