A zero-knowledge mixer protocol inspired by Tornado Cash enabling anonymous on-chain transfers using zk-SNARKs and Poseidon-based commitments.
ZK-ETH-Mixer is a privacy-focused smart contract protocol that allows users to deposit and withdraw cryptocurrency in a completely anonymous way. It uses zero-knowledge proofs to unlink the sender and recipient addresses, making on-chain analysis ineffective.
This implementation uses:
- Poseidon Hash for zk-friendly Merkle commitments.
- Noir for building custom zk-SNARK circuits.
- Hardhat and Ethers.js for Ethereum development and interaction.
- zk-SNARK verifier deployed on-chain to validate anonymous proofs.
- β Anonymous deposits and withdrawals
- π Poseidon hash-based commitments
- π³ Merkle tree structure for anonymity set
- β¨ Zero-knowledge proof verification
- πΈ Fixed denomination ETH transfers
- π§Ύ Nullifier system to prevent double-spending
- User generates a
(secret, nullifier)pair. - Computes
commitment = PoseidonHash(secret, nullifier). - Sends a fixed amount (e.g.,
0.1 ETH) with thecommitmentto the contract. - The contract inserts the commitment into a Merkle tree and stores it on-chain.
- User generates a zk-SNARK proof showing:
- They know a secret pair
(secret, nullifier)that hashes to a commitment in the tree. - The nullifier hasnβt been used before.
- They know a secret pair
- User submits the proof and
nullifierHashto the contract. - If valid, the contract:
- Verifies the proof on-chain
- Transfers ETH to the specified recipient
- Marks the
nullifierHashas spent
| Component | Tech |
|---|---|
| Smart Contracts | Solidity |
| ZK Circuits | Noir + SnarkJS |
| Hashing | Poseidon |
| Testing | Hardhat + Mocha |
| Interaction | Ethers.js |
| Frontend (opt) | React + Tailwind |
- Node.js (v18+)
- Yarn or NPM
- Hardhat
- Noir
- SnarkJS
git clone https://github.com/your-username/ZK-ETH-Mixer.git
cd tornado-clone
# Install dependencies
yarn install
# or
npm installcd circuits/
Noir mixer.nr --r1cs --wasm --sym
cd mixer_js/
node generate_witness.js mixer.wasm input.json witness.wtns
snarkjs groth16 setup mixer.r1cs pot12_final.ptau mixer_0000.zkey
snarkjs zkey contribute mixer_0000.zkey mixer_final.zkey
snarkjs zkey export verificationkey mixer_final.zkey verification_key.jsoncd ..
npx hardhat testβββ contracts/
β βββ ZK-ETH-Mixer.sol # Main mixer contract
β βββ Verifier.sol # zk-SNARK proof verifier
βββ circuits/
β βββ mixer.nr # ZK circuit (Poseidon hash, Merkle inclusion)
βββ scripts/
β βββ deploy.js # Deployment scripts
βββ test/
β βββ mixer.test.js # Unit tests (deposit/withdraw/proof)
βββ frontend/ (optional)
β βββ React UI (connect wallet, deposit, withdraw)
- User generates: secret, nullifier β computes commitment.
- Deposits ETH via
deposit(commitment)function. - Waits for more users (anonymity set grows).
- Generates proof off-chain (using witness data + zk key).
- Calls
withdraw(proof, root, nullifierHash, recipient)on-chain. - Receives ETH privately at recipient address.
- πͺ ERC20 support
- πͺ Relayer integration (for true privacy)
- π§Ύ Better UI/UX with React
- π IPFS or off-chain state syncing
- π Cross-chain mixer (L2, zkSync, Polygon)
Contributions are welcome! Please open issues or pull requests.
# Run linter and tests before submitting PR
npx hardhat test
npm run lintMIT License Β© 2025 YourName
β οΈ For educational and research purposes only. This repository is not intended for production use. Always consult legal experts before deploying any privacy-preserving application to a public blockchain.
- Tornado Cash
- Poseidon Hash
- Noir Docs
- ZK Learning
- ZK Hack YOLO change