How LeafPay works
LeafPay is an experimental private-transfer pool on Solana devnet. The current pool, leafpayv2, accepts SOL deposits. A note contains the private values needed to prove ownership later; the browser stores it locally, so exporting a backup matters.
Commitments and proofs
Each deposit adds a Poseidon commitment derived from its amount, nullifier, and asset identifier. The commitment is public, but its inputs are not. To withdraw or move value, the client constructs a Groth16 proof that it knows a valid note in the pool and that the requested state transition follows the circuit's rules. The on-chain program verifies the proof against the current Merkle root.
A withdrawal also reveals a nullifier hash. The program records it and rejects a second attempt to spend the same note. The recipient is bound into a relayed withdrawal proof, so a relayer that pays the network fee cannot redirect the payout. Amounts, timing, and other on-chain activity remain public; privacy depends on how many plausible deposits exist and how the service is used.
Merkle tree and historical leaves
The on-chain pool keeps a 16-leaf buffer and the peaks of a Merkle mountain range. When the buffer fills, its root is merged into the peaks. This keeps on-chain tree state compact instead of storing every historical leaf in the pool account.
Clients still need historical commitments to build a proof path. At each group of eight leaves, the transaction includes a Solana Memo instruction containing the batch number and those eight commitments. The program checks the memo and requires a known leaves-indexer account in the transaction. A client can then find indexed transactions through Solana RPC and reconstruct the leaves. Every 4,096 full batches (65,536 leaves), a subtree root is also indexed to reduce how much history a client needs to rebuild for a large tree.
Indexing uses public chain data, but it still depends on an RPC provider to retrieve that data. Fetching signatures is only the first step; the client must also fetch and parse the relevant transactions. The number of RPC calls varies with the note's position and the provider's limits.
Nullifier shards
LeafPay v2 stores spent nullifier hashes in sorted shard accounts. A SHA-256 digest of the nullifier hash determines which branch of the shard tree should contain it. When a shard fills, a separate split instruction creates two child shards and redistributes its entries. This makes a previously spent note detectable without creating one account per nullifier.
The program charges a 0.0003 SOL pool fee per spent nullifier to fund shard growth. In a local 64-nullifier test, the shard accounts held 67.4% less rent than 64 separate minimum-size marker accounts. That is a storage comparison, not a claim about total transaction fees or compute use on mainnet.
Client and program responsibilities
The client constructs Merkle paths, generates proofs, and assembles transactions. The on-chain program verifies proofs, checks the pool state and memo requirements, records nullifiers, and moves funds. The API can broadcast a transaction that the user's wallet has already signed or relay a recipient-bound withdrawal proof; it does not hold deposit wallet keys or generate private notes for clients.
LeafPay remains devnet software. Multi-asset deposits and a private note inbox are ideas for later work; they are not supported by the current pool.