This app allows users to deposit assets and later withdraw them without linking the withdrawal to the deposit. It allows withdrawers to prove ownership of a deposit without revealing which deposit belongs to the withdrawer.
## How it works
- Merkle tree for anonymity set:
- Each deposit has its own unique commitment: hash of a secret plus public identifier
- These commitmentsw are stored in a merkle tree (on-chain?)
- The root of this Merkle tree is updated whenever a new deposit is made
- ZK proofs for withdrawals:
- The withdrawer proves (using Noir) that they know a valid preimage for a commitment in the Merkle tree (without revealing which commitment they know)
- The proof should also confirm that the commitment is part of a valid tree root without revealing which specific leaf they control.
- To prevent double-spending, include a nullifier (a hash of the secret that gets recorded on-chain when withdrawn).
Zero Knowledge Proofs (ZKPs) allow a prover to convince a verifier that a specific computation was correctly executed without requiring the verifier to rerun it. The proof ensures correctness without revealing the inputs used in the computation. The ‘zero-knowledge’ property means that the proof can be structured in a way that leaks no additional information beyond the validity of the computation itself.
- We have removed paymasters to simplify the code. This means the receiving wallet will need to pay the gas fees therefore, hold native tokens
## Usage
git clone https://github.com/Cyfrin/zk-mixer-cu.git
### 2. Install the dependencies
npm install && cd contracts && forge install
forge test
This step is needed if you modify the circuit logic at all.
- Navigate inside the circuits folder and compile the circuit
nargo compile
- Generate the verifiaction key
bb write_vk --oracle_hash keccak -b ./target/circuits.json -o ./target
- Generate the verifier
bb write_solidity_verifier -k ./target/vk -o ./target/Verifier.sol
- Delete your old
Verifier.sol
from insidecontracts/src
and replay with the new one!