Go to file
2020-04-13 15:21:34 +03:00
assets update dependencies 2020-03-12 20:43:48 +10:00
components instructions 2020-03-01 01:27:01 +10:00
frontend add frontend and increase timeout for nginx 2020-02-05 23:20:01 -08:00
layouts add loading to authorize page 2020-02-10 00:11:37 +10:00
lib/phase2 providing user entropy 2020-03-11 13:08:01 +03:00
middleware init project 2020-01-29 13:54:03 +03:00
pages real snark tests 2020-04-13 15:21:34 +03:00
plugins instructions 2020-03-01 01:27:01 +10:00
server real snark tests 2020-04-13 15:21:34 +03:00
static providing user entropy 2020-03-11 13:08:01 +03:00
store fix env hashtag 2020-03-02 10:58:11 +03:00
.dockerignore add dockerignore file; readme update 2020-02-08 18:57:49 +03:00
.editorconfig init project 2020-01-29 13:54:03 +03:00
.env.example fix env hashtag 2020-03-02 10:58:11 +03:00
.eslintignore make it work again! 2020-01-29 19:59:37 +03:00
.eslintrc.js updates 2020-01-29 14:30:50 +03:00
.gitignore add dockerignore file; readme update 2020-02-08 18:57:49 +03:00
.prettierignore make it work again! 2020-01-29 19:59:37 +03:00
.prettierrc init project 2020-01-29 13:54:03 +03:00
docker-compose.yml git oauth WIP 2020-02-07 18:21:34 +03:00
Dockerfile fix deploying process 2020-03-02 12:09:41 +03:00
nuxt.config.js upgrade dependencies 2020-04-10 20:18:24 +10:00
package.json upgrade dependencies 2020-04-10 20:18:24 +10:00
README.md real snark tests 2020-04-13 15:21:34 +03:00
yarn.lock upgrade dependencies 2020-04-10 20:18:24 +10:00

Tornado.cash Trusted Setup Ceremony app

zk-SNARKs require a pre-existing setup between the prover and verifier. A set of public parameters define the “rules of the game” for the construction of zk-SNARKs. This app allows everyone to contribute with your source of entropy so that tornado.cash can be trustless.

Environment variables

The app can use .env.development and .env.production. What file will be used depends on NODE_ENV variable. For command yarn dev the .env.development is used. The yarn start uses .env.production.

ENV_VAR Description
DISABLE_S3 Disable contributions uploading to AWS S3. true or false
AWS_ACCESS_KEY_ID AWS access key
AWS_SECRET_ACCESS_KEY AWS secret key
AWS_S3_BUCKET AWS S3 bucket where the contributions will be uploaded
MYSQL_USER Mysql user the app uses. Notice, you don't need mysql db for development. The app will use local sqlite db in dev mode. Local db is stored in db.development.sqlite file.
MYSQL_PASSWORD Mysql password for MYSQL_USER
MYSQL_DATABASE Mysql database
TWITTER_CONSUMER_KEY Twitter consumer API key. Twitter app
TWITTER_CONSUMER_SECRET Twitter consumer API secret
TWITTER_CALLBACK_URL Twitter callback URL. The app handles the /api/oauth_callback/twitter endpoint. Feel free to change domain name and protocol though
GITHUB_CLIEND_ID Github client id. How to create Github OAuth app
GITHUB_CLIENT_SECRET Github client secret
GITHUB_CALLBACK_URL Github callback URL. The app handles the /api/oauth_callback/github endpoint. Feel free to change domain name and protocol though
SESSION_SECRET A random string that will be used by express-session to sign the session ID cookie.

Development setup

$ yarn install

# Edit all necessary environment variables. See the explanation above.
$ cp .env.example .env.development

# serve with hot reload at localhost:3000
$ yarn dev

Production setup

Follow instructions in the Initialize ceremony section to generate current.params ceremony file.

# Edit all necessary environment variables. See the explanation above.
$ cp .env.example .env.production

# Run Nginx + Letsencrypt containers to serve https requests to the app
$ cd frontend 
$ docker-compose up -d
$ cd ..

# Set VIRTUAL_HOST and LETSENCRYPT_HOST variables in the app's docker-compose.yml file
# Run the app and mysql database containers. It will use the MYSQL_USER, MYSQL_PASSWORD and MYSQL_DATABASE vars you specified in .env.production file.
$ docker-compose up -d

Initialize ceremony (current.params file creation):

  1. git clone https://github.com/tornadocash/phase2-bn254 && cd phase2-bn254
  2. git checkout wasm
  3. go to ./powersoftau/src/bn256/mod.rs and change REQUIRED_POWER to 15 (it's going to fit 36k constaints snark)
  4. cd powersoftau
  5. run ./test.sh. After this step you will get many phase1radix* files.
  6. Download withdraw.json for required circuit to ./phase2 folder
  7. cd ../phase2
  8. cp ../powersoftau/phase1radix* .
  9. cargo run --release --bin new withdraw.json current.params
  10. The current.params file is your initial challenge file.
  11. copy current.params, withdraw.json and phase1radix* to ./server/snark_files folder.
  12. mv withdraw.json circuit.json

In case of WASM module changes

  1. go to phase2 folder in phase2-bn254 (ceremony branch for now) and run the following command:
  2. wasm-pack build --release --target web -- --no-default-features --features wasm
  3. it will generate wasm modules in pkg folder, then you need to copy it to this project
  4. cp -r pkg/* <path_to_current_project>/lib/phase2 && cp pkg/phase2_bg.wasm <path_to_current_project>/static/_nuxt/lib/phase2/

Example: wasm-pack build --release --target web -- --no-default-features --features wasm && cp -r pkg/* ../../trusted-setup-nuxt/lib/phase2 && cp pkg/phase2_bg.wasm ../../trusted-setup-nuxt/static/_nuxt/lib/phase2/

Initialize REAL ceremony:

  1. Choose what contribition to use for the ceremony. Also choose what hash of future ethereum block we will use, tweet about it and calculate the VDF.

  2. Make sure your machine has at least 150 GB RAM and 200 GB SSD.

  3. Download the response file of the contribution. You can use aria2c accelerator for it.

  4. git clone https://github.com/tornadocash/phase2-bn254 && cd phase2-bn254

  5. git checkout stable

  6. cd powersoftau

  7. cargo run --release --bin beacon_constrained <challenge_file> last_response 28 256 <VDF output>

  8. cargo run --release --bin prepare_phase2 last_response 28 256 it will generate radix* files. You can abort execution after phase1radix2m15 calculation.

  9. cd ../phase2

  10. wget https://github.com/tornadocash/tornado-core/releases/download/v2.0/withdraw.json

  11. cp ../powersoftau/phase1radix2m15 .

  12. cargo run --release --bin new withdraw.json current.params

  13. The current.params file is your initial challenge file.

  14. copy current.params, withdraw.json and phase1radix* to ./server/snark_files folder.

  15. mv withdraw.json circuit.json

  16. Then the phase2 goes. see Production setup