Skip to content

Commit

Permalink
Merge pull request #918 from privacy-scaling-explorations/feat/ceremo…
Browse files Browse the repository at this point in the history
…ny-params

test(ceremony): test ceremony artifacts and params
  • Loading branch information
ctrlc03 authored Dec 30, 2023
2 parents 7da86bc + 58611db commit ae1142a
Show file tree
Hide file tree
Showing 10 changed files with 451 additions and 6 deletions.
71 changes: 71 additions & 0 deletions .github/scripts/ceremony-param-tests-c-witness.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/bash

set -e

cd "$(dirname "$0")"
cd ../../cli

HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js deployVkRegistry -q true
HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js setVerifyingKeys \
--state-tree-depth 6 \
--int-state-tree-depth 2 \
--msg-tree-depth 8 \
--vote-option-tree-depth 3 \
--msg-batch-depth 2 \
--process-messages-zkey ./zkeys/processMessages_6-8-2-3.zkey \
--tally-votes-zkey ./zkeys/tallyVotes_6-2-3.zkey \
-q true
HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js create -s 6 -q true
HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js deployPoll \
-pk macipk.c974f4f168b79727ac98bfd53a65ea0b4e45dc2552fe73df9f8b51ebb0930330 \
--duration 30 \
--max-messages 390625 \
--max-vote-options 125 \
--int-state-tree-depth 2 \
--msg-tree-depth 8 \
--msg-batch-depth 2 \
--vote-option-tree-depth 3 \
-q true
HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js signup \
--pubkey macipk.3e7bb2d7f0a1b7e980f1b6f363d1e3b7a12b9ae354c2cd60a9cfa9fd12917391 \
-q true
HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js publish \
--pubkey macipk.3e7bb2d7f0a1b7e980f1b6f363d1e3b7a12b9ae354c2cd60a9cfa9fd12917391 \
--privkey macisk.fd7aa614ec4a82716ffc219c24fd7e7b52a2b63b5afb17e81c22fe21515539c \
--state-index 1 \
--vote-option-index 0 \
--new-vote-weight 9 \
--nonce 1 \
--poll-id 0 \
-q true
HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js publish \
--pubkey macipk.d5788ea6ccf1ec295df99aaef859031fe7bd359e7e03acb80eb6e8a192f2ce19 \
--privkey macisk.fd7aa614ec4a82716ffc219c24fd7e7b52a2b63b5afb17e81c22fe21515539c \
--state-index 1 \
--vote-option-index 1 \
--new-vote-weight 9 \
--nonce 2 \
--poll-id 0 \
-q true
HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js timeTravel -s 100 -q true
HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js mergeSignups --poll-id 0 -q true
HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js mergeMessages --poll-id 0 -q true
HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js genProofs \
--privkey macisk.49953af3585856f539d194b46c82f4ed54ec508fb9b882940cbe68bbc57e59e \
--poll-id 0 \
--rapidsnark ~/rapidsnark/build/prover \
--process-zkey ./zkeys/processMessages_6-8-2-3.zkey \
--tally-zkey ./zkeys/tallyVotes_6-2-3.zkey \
--tally-file tally.json \
--output proofs/ \
--tally-witnessgen ./zkeys/tallyVotes_6-2-3 \
--process-witnessgen ./zkeys/processMessages_6-8-2-3 \
-q true
HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js proveOnChain \
--poll-id 0 \
--proof-dir proofs/ \
-q true
HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js verify \
--poll-id 0 \
--tally-file tally.json \
-q true
15 changes: 15 additions & 0 deletions .github/scripts/download-ceremony-artifacts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -e

cd "$(dirname "$0")"
cd ..
mkdir -p ../cli/zkeys

URL=https://maci-develop-fra.s3.eu-central-1.amazonaws.com/v1.2.0/maci-ceremony-artifacts-v1.2.0.tar.gz
DIR_NAME="maci_keys.tar.gz"
OUT_DIR=../cli/

echo "downloading $URL"
curl $URL -o "$OUT_DIR/$DIR_NAME"
tar -xvf "$OUT_DIR/$DIR_NAME" -C "$OUT_DIR"
56 changes: 56 additions & 0 deletions .github/workflows/nightly-ceremony.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Nightly Ceremony

on:
schedule:
- cron: 0 0 * * *

jobs:
test-with-ceremony-keys:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4
with:
ref: dev

- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install --yes \
build-essential \
libgmp-dev \
libsodium-dev \
nasm \
nlohmann-json3-dev
- name: Initialize Project
run: |
npm install
npm run bootstrap
npm run build
- name: Compile contracts with ceremony params and run hardhat fork
run: |
cd contracts
npm run compileSol 6
npm run hardhat &
- name: Download rapidsnark (1c137)
run: |
mkdir -p ~/rapidsnark/build
wget -qO ~/rapidsnark/build/prover https://maci-devops-zkeys.s3.ap-northeast-2.amazonaws.com/rapidsnark-linux-amd64-1c137
chmod +x ~/rapidsnark/build/prover
- name: Download ceremony artifacts
run: ./.github/scripts/download-ceremony-artifacts.sh

- name: Run e2e tests
run: ./.github/scripts/ceremony-param-tests-c-witness.sh

- name: Stop Hardhat
run: kill $(lsof -t -i:8545)
10 changes: 10 additions & 0 deletions circuits/circom/test/ceremonyParams/processMessages_test.circom
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pragma circom 2.0.0;
include "../../processMessages.circom";
/*
stateTreeDepth,
msgTreeDepth,
msgSubTreeDepth
voteOptionTreeDepth,
*/

component main {public [inputHash]} = ProcessMessages(6, 8, 2, 3);
7 changes: 7 additions & 0 deletions circuits/circom/test/ceremonyParams/tallyVotes_test.circom
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pragma circom 2.0.0;
include "../../tallyVotes.circom";

component main {public [inputHash]} = TallyVotes(6, 2, 3);
/*stateTreeDepth,*/
/*intStateTreeDepth,*/
/*voteOptionTreeDepth*/
3 changes: 2 additions & 1 deletion circuits/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"test-privToPubKey": "ts-mocha --exit ts/__tests__/PrivToPubKey.test.ts",
"test-calculateTotal": "ts-mocha --exit ts/__tests__/CalculateTotal.test.ts",
"test-processMessages": "NODE_OPTIONS=--max-old-space-size=4096 ts-mocha --exit ts/__tests__/ProcessMessages.test.ts",
"test-tallyVotes": "NODE_OPTIONS=--max-old-space-size=4096 ts-mocha --exit ts/__tests__/TallyVotes.test.ts"
"test-tallyVotes": "NODE_OPTIONS=--max-old-space-size=4096 ts-mocha --exit ts/__tests__/TallyVotes.test.ts",
"test-ceremonyParams": "ts-mocha --exit ts/__tests__/CeremonyParams.test.ts"
},
"dependencies": {
"circomlib": "https://github.com/weijiekoh/circomlib#ac85e82c1914d47789e2032fb11ceb2cfdd38a2b",
Expand Down
Loading

0 comments on commit ae1142a

Please sign in to comment.