Skip to content

exfinen/snarkjs-mpc

Repository files navigation

Snarkjs-based Trusted Setup Phase 2 MPC

Setting up environment

Node.js

  1. Install Node.js version 14
    $ nvm install 14

Firebase

  1. Install firebase tools

    $ npm i -g firebase-tools
  2. Save the Firebase configuration obtained from Firebase console as config/firebaseConfig.js. The content should look something like:

    // For Firebase JS SDK v7.20.0 and later, measurementId is optional
    const firebaseConfig = {
      apiKey: "...",
      authDomain: "...",
      databaseURL: "...",
      projectId: "...",
      storageBucket: "...",
      messagingSenderId: "...",
      appId: "...",
      measurementId: "...",
    }
  3. Similarly save the Firebase private key file from Firebase console as config/serviceAccountPrvkey.json. The content should look something like:

    {
       "type": "service_account",
       "project_id": "zkcream",
       "private_key_id": "...",
       "private_key": "...",
       "client_email": "...",
       "client_id": "...",
       "auth_uri": "...",
       "token_uri": "...",
       "auth_provider_x509_cert_url": "...",
       "client_x509_cert_url": "..."
    }
  4. In repository root directory, run:

    $ ./deploy-firebase-config.sh
  5. Create OAuth application in GitHub and using the id and secret, set up Firebase GitHub authentication.

  6. Login to firebase (if haven't logged in yet)

    $ firebase login

CORS

  1. Install gstool (https://cloud.google.com/storage/docs/gsutil_install?hl=ja#deb)

  2. Set up CORS for the default bucket e.g.

    $ gsutil cors set cors.json gs://zkcream.appspot.com

Setting up ceremony

Refer to admin package

Setting up application

  1. Install dependencies

    $ npx lerna bootstrap
  2. Update ceremony config file packages/client/config/default.ts

  3. build client and deploy

    $ cd packages/client
    $ npm run build
    $ npm run deploy

Opening application

Open https://[project id].web.app in browser

Snarkjs included in this repository

A slightly modified version of Snarkjs 0.4.6 that can run zkey functions on web browsers is included