Solana Circuit
The Solana flow is gated by a Groth16 proof produced from a single Circom 2 template, basic, defined in basicSolana.circom. Six dimension-specialized variants instantiate it for the dimensions the on-chain program supports:
File
Parameters (tokenCount, inputCount, outputCount, treeDepth)
basicSolana1x2x1.circom
(1, 2, 1, 25)
basicSolana1x2x2.circom
(1, 2, 2, 25)
basicSolana1x6x1.circom
(1, 6, 1, 25)
basicSolana1x6x2.circom
(1, 6, 2, 25)
basicSolana2x2x1.circom
(2, 2, 1, 25)
basicSolana2x6x1.circom
(2, 6, 1, 25)
treeDepth = 25 is the depth of the Merkle path the circuit verifies for each input UTXO and for the access-token tree.
The on-chain program dispatches to the verifying key matching Dimensions(tokenCount, inputCount, outputCount) - 1×2×1 for transact2, 1×6×1 for transact6, 1×2×2 for transfer2, 1×6×2 for transfer6, 2×2×1 for swap2, 2×6×1 for swap6.
All hashing inside the circuit is Poseidon over BN254. Stealth-address derivation uses BabyJubJub via circomlib.
Public signals
The component main declarations expose the same set of public inputs across every variant:
rootHashHinkal
rootHashAccessToken
mintAccountPart1[tokenCount]
mintAccountPart2[tokenCount]
inNullifiers[tokenCount][inputCount]
outTimeStamp
extraRandomization
amountChanges[tokenCount]
outCommitments[tokenCount][outputCount]
calldataHashPlus the circuit's outputs (also public by virtue of being signal output):
Every public signal above is read by the on-chain program through ParsedPublicSignals and used to gate state transitions:
rootHashHinkalis checked against the rolling root buffer viamerkle.root_hash_exists.rootHashAccessTokenis the access-token Merkle root the prover claims membership in.mintAccountPart1/mintAccountPart2together encode the SPL mint as a 256-bit value split into two 128-bit limbs (BN254F_ris shorter than 32 bytes). The handler reassembles them and checks against the providedMintaccount.inNullifiersare matched against theNullifierAccountPDAs the caller supplies; non-zero ones are flipped tois_used = true.outCommitmentsare inserted into the commitment Merkle tree.extraRandomizationis required to be non-zero — see "Stealth address" below.amountChangesdrives deposit / withdrawal accounting. Negative ⇒ withdrawal, positive ⇒ deposit, zero ⇒ pure shielded-to-shielded.calldataHashis the Poseidon binding to recipient, signer, encrypted outputs, fees, CPI instructions, and remaining accounts; recomputed by the program inget_hashed_calldata.swapperAccountAdditionalSeed(output) — bound into the swap PDA derivation, prevents proof reuse against a different swapper PDA.
Private inputs
These never leave the prover.
What the circuit proves
Per token leg i ∈ [0, tokenCount) and per input slot j ∈ [0, inputCount):
Mint range -
MintAccountValidatorenforcesmintAccountPart1[i], mintAccountPart2[i] < 2^128. Each part is a 128-bit limb; together they encode a full 256-bit Solana mint key.Mint hashing -
mintAccountHashed[i] = Poseidon(mintAccountPart1[i], mintAccountPart2[i]). Used as the token tag inside every commitment so commitments stay BN254-sized regardless of mint length.Mint distinctness - for every pair
i ≠ j,mintAccountHashed[i] ≠ mintAccountHashed[j]. A 2-token swap cannot collapse to a single token leg.Owner public key -
publicKey = Poseidon(shieldedPrivateKey). Bound to the access-token check below.Per-input stealth public key -
inPubKey[i][j] = StealthAddressCalculator(shieldedPrivateKey, inRandomizations[i][j]). Each input UTXO can carry an independent randomization so different deposits do not share an on-chain identifier.Input commitment recomputation -
OriginalCommitmentCalculatorrebuildscommitment = Poseidon(amount, mintAccountHashed[i], inPubKey[i][j], timeStamp), returning0ifamount == 0so empty input slots act as padding.Input amount range -
OverflowPreventer(inputCount)boundsinAmounts[i][j]soinputCountof them cannot overflowF_r.Signature -
signature[i][j] = Poseidon(shieldedPrivateKey, commitment[i][j]). Acts as the spending signature for the UTXO.Nullifier -
nullifier[i][j] = Poseidon(commitment, signature)(zero when commitment is zero). Forced to equal the publicinNullifiers[i][j].Membership proof -
MerkleRootCalculator(treeDepth)recomputes the commitment Merkle root frominCommitmentSiblings[i][j]/inCommitmentSiblingSides[i][j]and forces it to equalrootHashHinkalwheneverinAmount[i][j] != 0(ForceEqualIfEnabledskips empty slots).Output commitments - for each output slot
(i, k),OriginalCommitmentCalculatorrebuildsPoseidon(outAmount, mintAccountHashed[i], outPublicKey, outTimeStamp)and forces equality with the publicoutCommitments[i][k].Output amount range -
OverflowPreventer(outputCount)bounds eachoutAmount[i][k]. Negative outputs cannot be encoded (the bit-decomposition rejects them).Conservation per token -
Σ inAmounts[i] + amountChanges[i] = Σ outAmounts[i].amountChanges[i]is the only non-private-balance term; it is what the on-chain program reads as deposit (positive) or withdrawal (negative).Access-token gate -
AccessTokenChecker(treeDepth):re-derives
publicKey = Poseidon(shieldedPrivateKey)and forces it to equal the localpublicKeysignal,computes
accessToken = Poseidon(shieldedPrivateKey, publicKey),rebuilds the access-token Merkle root from
accessTokenSiblingsand forces equality withrootHashAccessToken. The root is checked against the access-token tree on-chain only when the per-mint limit requires it.
Stealth address output -
extraRandomizationis fed throughStealthAddressCalculatoragain to produce the extra-randomized key the new commitments are addressed to:extraRandomizedStealthAddress = Poseidon(signs, H0Ay, H1Ay)extraRandomizedStealthAddressSigns,H0Ay,H1Ayare the compressed BabyJubJub coordinates that let an external observer reconstruct the keys of new UTXOs from on-chain events. The on-chain program rejectsextraRandomization == 0(ZeroRandomizationForbidden), so every commitment is unlinkable from prior deposits.
Swapper seed binding -
swapperAccountAdditionalSeed = Poseidon(swapperAccountSalt). The on-chain program checks this against the seed used to derive the swap PDA so a relayer cannot retarget a generated proof at a different swapper PDA.
Last updated

