Merkle Commitment Trees in Mixoor’s Solana Reference Code

How the public Solana reference stores commitment leaves, hashes parent nodes with Poseidon, and returns the data for a Merkle inclusion proof.

By · 3 min read ·

A Merkle root summarizes an ordered set of leaves. An inclusion proof supplies the missing information needed to reconstruct that root from one leaf. Mixoor’s public Solana reference class shows how these two operations fit together for commitment leaves.

Commitment leaves and Poseidon parent nodes

The reference implementation’s insert method stores a leaf that the caller has already computed. To calculate the root, the class combines pairs of child nodes at each level. It applies Poseidon to each pair and uses the precomputed zero value for that level when a sibling is missing.

What getProof returns

The reference class’s getProof method returns sibling values and direction indicators from the selected leaf up the tree. Those indicators preserve the order of the two inputs at each level. The result provides the data used to reconstruct the root from that leaf.

Inclusion proofs and privacy

The inclusion path is one input to a zero-knowledge proof. The reference helper computes that path locally. On-chain verification of the resulting zero-knowledge proof is a separate operation.

A Merkle tree alone offers no privacy guarantees. In a zero-knowledge protocol, it gives the prover a way to establish membership in a commitment set without revealing the entire path. The privacy properties depend on the protocol and the information it exposes.

Does the reference class hash a leaf again when it inserts it?

The insert method stores the supplied leaf directly. Parent nodes are hashed separately while constructing the root.

What does a Merkle inclusion path contain?

It contains the sibling value and its position relative to the selected node at each level, so the root can be reconstructed from the leaf.