Tornado Cash as a foundry project, using latest versions of tools such as Circom, snarkJS, etc.
Find a file
2024-12-02 14:08:15 +05:30
circuits working flow 2024-10-30 18:06:45 +05:30
forge-ffi-scripts Update comment 2024-12-02 14:08:15 +05:30
lib forge install: forge-std 2024-10-28 14:10:20 +05:30
src remove dummy log 2024-11-21 10:53:16 +05:30
test Use generated verifier 2024-12-02 09:26:54 +05:30
.gitignore works: compile + generate verifier contract without creating witness 2024-10-29 10:15:35 +05:30
.gitmodules forge install: forge-std 2024-10-28 14:10:20 +05:30
foundry.toml working flow 2024-10-30 18:06:45 +05:30
makefile working flow 2024-10-30 18:06:45 +05:30
package.json update packages 2024-10-30 18:24:02 +05:30
README.md update readme 2024-10-30 18:49:37 +05:30
yarn.lock update packages 2024-10-30 18:24:02 +05:30

Tornado Cash [Re-built]

Tornado Cash is a non-custodial Ethereum and ERC20 privacy solution based on zkSNARKs.

This repository re-builds Tornado Cash for educational purposes as a Foundry project, and uses the latest versions of Circom (circomlib and circomlibjs) and snarkJS to generate proofs.

The original-repository is built with older versions of tools, and it is difficult to use it as educational reference material to understand the latest Solidity <-> Circom workflow for writing smart contracts with ZK-SNARK capabilities.

Installation

Clone this repository

git clone https://github.com/nkrishang/tornado-cash-rebuilt.git

Install dependencies:

forge install
yarn

Usage

Compiling circom circuits

The main workflow of this repo is:

  1. Compile circuits to generate circuit artifacts
  2. Perform a powers of tau ceremony
  3. Generate zkey and verifier Solidity smart contract

These three steps are written as bash commands in the makefile. Run the following to perform these steps:

make all

This will create a /circuit_artifacts folder that contains everything needed to run tests.

Running tests

There is a single forge test file /test/ETHTornado.t.sol and scripts used in this test /forge-ffi-scripts. The test and script files are annotated.

Run the following command to run tests (after you have generated circuit artifacts):

forge test

Credits

For a comprehensive understanding of ZK-SNARKs, see the Rareskills ZK Book and their article on how Tornado Cash works.