Reference
ReferenceCircuit — payment_policy.circom
Signals, constraints, tooling, and the build pipeline for the proof-of-compliance circuit.
payment_policy.circom — Circom 2.2.3, curve bn128 / BN254, depth-4 recipient
Merkle tree.
Public inputs (14, in order)
| # | Signal | Meaning | Encoding |
|---|---|---|---|
| 00 | policyCommitment | Poseidon commitment of the private policy | Fr |
| 01 | recipientRoot | Merkle root of the approved recipients | Fr |
| 02 | recipient | The payee, reduced to a field element | Fr |
| 03 | amount | Payment amount, in stroops | i128 → Fr |
| 04 | invoiceHash | Poseidon hash of the invoice preimage | Fr |
| 05 | nullifier | Single-use replay marker | Fr |
| 06 | agentAddress | The paying agent, reduced to a field element | Fr |
| 07 | assetId | The asset (SAC), reduced to a field element | Fr |
| 08 | contractAddress | The verifier contract, reduced to a field element | Fr |
| 09 | prevEpochId | Epoch the prior counters belong to | u64 → Fr |
| 10 | prevSpent | Spend before this action | i128 → Fr |
| 11 | prevActionCount | Action count before this action | u64 → Fr |
| 12 | newSpent | prevSpent + amount | i128 → Fr |
| 13 | newActionCount | prevActionCount + 1 | u64 → Fr |
Private inputs
privateMaxAmount, privateDailyLimit, policySalt,
pathElements[4], pathIndices[4],
invoicePreimage, nonceConstraints
- Commitment —
Poseidon(privateMaxAmount, privateDailyLimit, recipientRoot, assetId, policySalt) === policyCommitment - Merkle membership —
Poseidon(recipient)underrecipientRoot(depth 4, boolean path indices) - Range —
amount <= privateMaxAmountandprevSpent + amount <= privateDailyLimit(Num2Bits(64)) - State transition —
newSpent === prevSpent + amount,newActionCount === prevActionCount + 1 - Invoice —
Poseidon(invoicePreimage) === invoiceHash - Nullifier —
Poseidon(agentAddress, policyCommitment, contractAddress, nonce) === nullifier
Tooling & build
- circom 2.2.3, snarkjs 0.7.6, Powers-of-Tau
pot14 - circomlib:
poseidon,comparators(LessEqThan),bitify(Num2Bits)
# compile → trusted setup → export verifying key
circom payment_policy.circom --r1cs --wasm --sym -p bn128
snarkjs groth16 setup payment_policy.r1cs pot14.ptau circuit_0000.zkey
snarkjs zkey contribute circuit_0000.zkey payment_policy.zkey
snarkjs zkey export verificationkey payment_policy.zkey vk.jsonThe exported verifying key is transcoded into the contract's vk.rs.