Users and developers don’t interact with the SMT directly; exclusion proofs
are computed and submitted automatically by the
operator-private-channel
service. This page is reference material for operators and anyone building
operator tooling.This page documents the Sparse Merkle Tree design at solana-private-channels
commit
c9e2240, the source of the program deployed to devnet (see
Installation).
Since commit 46a8e24 (2026-09-09), upstream main uses an onchain
withdrawal bitmap instead, and clients generated from main don’t include
the SMT parameters or ResetSmtRoot.Purpose
Private Channels uses a Sparse Merkle Tree (SMT) to guarantee that each withdrawal nonce can only be settled once. When an operator callsReleaseFunds, they must provide two proofs: an exclusion proof that the nonce
does NOT yet exist against the current root, and an inclusion proof that the
nonce DOES exist in the caller-supplied new root. Only after both checks pass
does the program store the new root, making any future attempt to reuse the
nonce provably invalid.
Tree Parameters
- Tree height:
16 - Maximum leaves:
65,536(2^16) - Hash function: SHA-256
- Empty leaf value:
[0u8; 32](32 zero bytes) - Non-empty leaf value:
SHA256([1u8; 32]), stored as the constantNON_EMPTY_LEAF_HASH
Leaf Structure
Each withdrawal occupies exactly one leaf. The leaf position is determined by:NON_EMPTY_LEAF_HASH
(i.e., SHA256([1u8; 32])). An empty leaf is all zeros.
Nonce and Leaf Position
Thetransaction_nonce in ReleaseFunds is a u64. Its position in the tree
is nonce % 65536. Its expected epoch is nonce / 65536. The onchain program
validates that this computed epoch equals Instance.current_tree_index; a
mismatch throws InvalidTransactionNonceForCurrentTreeIndex.
Tree Rotation
nonce % 65536 == 0 (for nonce > 0);
that boundary signals the start of a new epoch. At that point,
operator-private-channel calls ResetSmtRoot before submitting the next
ReleaseFunds:
Instance.current_tree_indexis incremented- The withdrawal root resets to the empty tree
- Nonces from the previous tree epoch are invalidated
Instance.withdrawal_transactions_root onchain before each ReleaseFunds
call; a mismatch triggers a safety shutdown rather than a potentially invalid
proof submission.
Tree rotation is tracked by Instance.current_tree_index: u64, stored onchain.
Verification in ReleaseFunds
Thesibling_proofs argument in ReleaseFunds is exactly [u8; 512]: 16
sibling hashes × 32 bytes each, matching the tree height of 16.
The onchain verification process runs two separate checks in sequence:
verify_smt_exclusion_proofproves the nonce leaf is currently empty against the currentInstance.withdrawal_transactions_rootverify_smt_inclusion_proofproves the nonce leaf is present in the caller-suppliednew_withdrawal_rootargument- Only if both checks pass does the program store
new_withdrawal_rootas the newInstance.withdrawal_transactions_rootand release the tokens
InvalidSmtProof. The root update in step 3 is
atomic with each ReleaseFunds call.