Skip to content

Ubaid-ch/zk_Mixer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mixer Example On-Chain ZK App

zk-Mixer Educational Prototype

A from-scratch zero-knowledge mixer built for learning purposes only. Demonstrates how privacy-preserving protocols can break on-chain links between deposits and withdrawals using ZK proofs.

Important Disclaimer
This project is educational only. It is not secure for real use, has no production hardening, and should never be used with real funds or for actual privacy/anonymity needs. Inspired by classic mixer designs (e.g., Tornado Cash mechanics), but implemented simply to explore ZK concepts.

Features

  • Deposit: User provides a secret + nullifier → computes Poseidon commitment → inserts into on-chain Merkle tree
  • Withdraw: User reveals secret + nullifier + ZK proof → contract verifies:
    • Commitment exists in Merkle tree (via root + proof)
    • Nullifier not previously used (prevents double-spend)
    • Proof is valid → releases funds to specified address without linking back to deposit
  • ZK-friendly Poseidon commitment scheme
  • Merkle tree for scalable commitment storage & inclusion proofs
  • Full zero-knowledge circuit ensuring privacy

Tech Stack

  • ZK Circuit Language: Noir (by Aztec)
  • Hashing: Poseidon (optimized for ZK)
  • Proof System: Barretenberg (via noir.js + bb.js)
  • Frontend/Backend: noir.js for proof generation, TypeScript scripts for witness/proof handling
  • Smart Contracts: Solidity verifier + Mixer contract (using Foundry)
  • Merkle Tree: On-chain Incremental Merkle Tree (IMT) + off-chain reconstruction support
nargo version = 1.0.0-beta.18 |  bb --version= 3.0.0-nightly.20260102

Usage

1. Clone the repo

git clone https://github.com/Ubaid-ch/zk_Mixer.git

2. Install the dependencies

npm install && cd contracts && forge install

3. Running the tests

forge test

4. (optional) re-creating the verifier

This step is needed if you modify the circuit logic at all.

  1. Navigate inside the circuits folder and compile the circuit
nargo compile
  1. Generate the verifiaction key
bb write_vk --oracle_hash keccak -b ./target/circuits.json -o ./target
  1. Generate the verifier
bb write_solidity_verifier -k ./target/vk -o ./target/Verifier.sol
  1. Delete your old Verifier.sol from inside contracts/src and replay with the new one!

Running the front end

Run the front-end

npm run dev

Releases

Packages

Contributors

Languages