merkle mode
One proof, a million facts inside it. Merkle mode folds a whole list into a single fingerprint, and the program actually checks your answer.
A normal proof holds one fact. But say you have a list: a thousand scores, a thousand winners, a thousand entries. Making a thousand proofs would cost a thousand deposits. Merkle mode does it with one.
the folding trick
Take your list. Hash each item to get its fingerprint. Now pair the fingerprints up and hash each pair together. Keep pairing and hashing until only one fingerprint is left. That last one is called the root, and it's a fingerprint of the entire list. Change any single item, anywhere, and the root changes. That's a merkle tree, and it's the same trick Solana itself runs on.
In merkle mode, you prove the root. One proof, one deposit, the whole list committed.
the quiz version of verify
Remember chapter 3: a plain verify is a handshake, no answer checked. Merkle mode is the quiz. To verify a merkle proof you bring two things:
- A leaf. One item from the list (its 32-byte fingerprint).
- The path. The handful of neighbor fingerprints needed to re-fold your leaf back up to the root.
The program does the folding math right there on chain. If your leaf and path really fold up into the stored root, the verify goes through. If not, it's rejected with InvalidMerkleProof. No arguing with the math.
The leaf you verified becomes the attestation, so the permanent receipt records which item from the list was proven.
one shot per proof
Verify still closes the proof, so each merkle proof gets one leaf reveal. Pick the item that matters, prove it, done. Need many reveals from one list? Post the same root under several proofs by tweaking the data (for example, hash the root with an index).