Mixup is a non-custodial privacy solution based on zkSNARKs. It improves transaction privacy by breaking the on-chain link between the recipient and destination addresses. It uses a smart contract that accepts ONE deposits that can be withdrawn by a different address. Whenever ONE is withdrawn by the new address, there is no way to link the withdrawal to the deposit, ensuring complete privacy.
To make a deposit user generates a secret and sends its hash (called a commitment) along with the deposit amount to the Mixup smart contract. The contract accepts the deposit and adds the commitment to its list of deposits.
Later, the user decides to make a withdrawal. To do that, the user should provide a proof that he or she possesses a secret to an unspent commitment from the smart contract’s list of deposits. zkSnark technology allows that to happen without revealing which exact deposit corresponds to this secret. The smart contract will check the proof and transfer deposited funds to the address specified for withdrawal. An external observer will be unable to determine which deposit this withdrawal came from.
This project takes alot of inspiration from the popular Tornado Cash Mixer
You can read more about it in this Medium article
Run npm i to install. Check out package.json for other commands to compile circuits and contracts.
To deploy on Harmony testnet, run the above command first, create a .secret file with your own private key (Please be careful not to include your private key in any commit!).
node v11.15.0
npm install -g npx
Prepare test environment:
npm run compile:circuits
npm run compile:contracts
npm run deploy:localhost
npm run test
npm run test:full
The project has three main folders:
- hardhat - [circuits, contracts]
- ui
The circuit folder contains all the circuits used in Mixup.
The contracts folder contains all the smart contracts used in Mixup.
The ui folder contains the Mixup frontend.
The following graphic shows the structure of the most important zero knowledge elements of the Mixup project.
├── circuits
│ ├── Merkletree.circom
│ │
│ ├── Withdraw.circom
├── contracts
│ ├── contracts
│ │ ├── Mixup(deposit and withdrawals)
│ │ │ ├── ERC20Mixup.sol
│ │ │ ├── ETHMixup.sol
| | | ├── ETHMixup.sol
│ │ ├── MerkleTree (Merkle tree with history)
│ │ │ ├── MerkleTreeHistory.sol
│ │ ├── Verifier (verifies proof)
│ │ │ ├── verifier.sol
├── ui
│ ├── public
│ │ ├── zkproof
│ │ │ ├── Withdraw.wasm
│ │ │ │── circuit_final.zkey
│ │ │
│ ├── zkproof
│ │ ├── snarkjsZkproof.js
│ │ ├
git clone https://github.com/Darlington02/Mixup.git
To run cicuits, go inside the circuits
folder:
cd circuits
npm run compile:circuits
To run contracts, go inside the contracts
folder:
cd contracts
npm run compile:contracts
To run the frontend, go inside the ui
folder:
cd ui