Circuit Architecture Overview
The Privacy Pools protocol uses three main Circom circuits:
- CommitmentHasher Circuit
- Computes commitment hashes from inputs
- Generates precommitment and nullifier hashes
- Uses Poseidon hash for efficient ZK computation
- LeanIMTInclusionProof Circuit
- Verifies membership in Lean Incremental Merkle Trees
- Computes path from leaf to root
- Validates hashes for each tree level
- Accommodates dynamic tree depth
- Withdrawal Circuit
- Combines commitment and Merkle tree proofs
- Verifies ownership of existing commitment
- Validates new commitment creation
- Checks ASP root inclusion
Commitments
Commitments are cryptographic primitives that allow users to commit to values while keeping them private. In Privacy Pools:
-
Components
- Value: The amount of assets being committed
- Label: Unique identifier from pool scope and nonce
- Nullifier: Secret value preventing double-spending
- Secret: Random value proving ownership
-
Hash Construction
nullifierHash = PoseidonHash(nullifier);
precommitmentHash = PoseidonHash(nullifier, secret);
commitmentHash = PoseidonHash(value, label, precommitmentHash);
Basic Proof Concepts
Privacy Pools uses Groth16 proofs with the following structure:
- Public Inputs
- Values visible on-chain
- Examples: withdrawal amount, roots, context
- Used for on-chain verification
- Private Inputs
- Values kept secret by the prover
- Examples: nullifiers, secrets, siblings
- Used to generate proofs
- Circuit Signals
- Internal values computed during proving
- Enforce mathematical constraints
- Connect public and private inputs
Verification Flow
- Proof Generation
- User provides private and public inputs
- Circuit computes internal signals
- Generates Groth16 proof elements:
- π_A: First elliptic curve point
- π_B: Second elliptic curve point (2x2 matrix)
- π_C: Third elliptic curve point
- On-chain Verification
- Contract receives proof and public signals
- Verifier performs pairing checks
- Validates against verification key
- Returns boolean indicating validity
- Proof Integration
- Proofs linked to protocol operations
- Results determine state transitions
- Failed verifications revert transactions