Protocol
Circuit and public inputs
packages/circuits/circuits/joinsplit.circom, JoinSplit(20): 22,292 non-linear constraints, 12 public inputs, Groth16 over BN254, circom 2.1.9, snarkjs 0.7.4.
What it proves
- Every amount and the fee is below 2^96, and
|extAmount| < 2^96. - One private
tokenIdmatches all four notes. It is not a public input. - The public asset rule:
isNone = (publicAssetId == 0) isNone * extAmount == 0 isNone * fee == 0 (1 - isNone) * (tokenId - publicAssetId) == 0 in0 + in1 + extAmount == out0 + out1 + fee.- Each non-zero input has a valid path to
rootand toaspRoot. nf_i == H(TAG_NULLIFIER, cm_i, leafIndex_i, spendKey_i)andnf_0 ≠ nf_1.outCm_j == H(TAG_COMMITMENT, tokenId, outAmount_j, outOwnerPub_j, outBlinding_j).chainId,poolandextDataHashare bound as public inputs.
Public inputs, in order
| # | Name | Source |
|---|---|---|
| 0 | root |
calldata; must be a known root |
| 1 | aspRoot |
calldata; must be a known root |
| 2–3 | nullifier0, nullifier1 |
calldata; unspent and distinct |
| 4–5 | commitment0, commitment1 |
calldata |
| 6 | extAmount |
signed, field-encoded as `x ≥ 0 ? x : r − |
| 7 | fee |
< 2^96 |
| 8 | publicAssetId |
0 (private) or 1/2 |
| 9 | chainId |
block.chainid, never calldata |
| 10 | pool |
address(this), never calldata |
| 11 | extDataHash |
keccak256(abi.encode(recipient, relayer, enc0, enc1)) mod r |
Every value is checked < r before verification.
By transaction kind
| Kind | publicAssetId | extAmount | fee | recipient | relayer |
|---|---|---|---|---|---|
| Deposit | 1 or 2 | > 0 | 0 | 0 | 0 |
| Transfer / claim | 0 | 0 | 0 | 0 | any |
| Withdrawal | 1 or 2 | < 0 | ≥ 0 | ≠ 0 | ≠ 0 if fee > 0 |
Known gaps
- There is no
in0 + in1 > 0constraint, so a zero-value transfer can be proven without funds. The relayer's limits are the defence (Spec §17). - Ciphertext correctness isn't proven in the circuit. The sender's client checks it (Note encryption).
- An independent circuit review hasn't happened. circomspect has been run.
Source: apps/web/content/docs/circuit.md