Coordinator

Coordinator manual

Coordinate using MACI CLI

Clone the MACI repo and switch to version v0.9.4:
1
git clone https://github.com/appliedzkp/maci.git
2
cd maci/
3
git checkout v0.9.4
Copied!
Follow instructions in README.md to install necessary dependencies.

Medium Circuits

Download zkSNARK parameters for 'medium' circuits into circuits/params/ directory and rebuild the keys:
1
cd circuits
2
./scripts/buildSnarksMedium.sh
Copied!

x32 Circuits

Download zkSNARK parameters for 'x32' circuits into circuits/params/ directory and rebuild the keys:
1
cd circuits
2
./scripts/buildSnarks32.sh
Copied!
Recompile the contracts:
1
cd ../contracts
2
npm run compileSol
Copied!

Generate coordinator key

1
cd ../cli
2
node build/index.js genMaciKeypair
Copied!
A single key can be used to coordinate multiple rounds.

Tally votes

Decrypt messages and tally the votes:
1
cd ../cli
2
node build/index.js genProofs \
3
--eth-provider <json-rpc-api-url> \
4
--contract <maci-address> \
5
--privkey <coordinator-private-key> \
6
--output proofs.json \
7
--tally-file tally.json
Copied!
Coordinator private key must be in MACI key format (starts with macisk). Ethereum private key can be any private key that controls the necessary amount of ETH to pay for gas.
The genProofs command will create two files: proofs.json and tally.json. The proofs.json file will be needed to run the next command which submits proofs to MACI contract:
1
node build/index.js proveOnChain \
2
--eth-provider <json-rpc-api-url> \
3
--contract <maci-address> \
4
--privkey <coordinator-private-key> \
5
--eth-privkey <eth-private-key> \
6
--proof-file proofs.json
Copied!
The process may take several hours. Results can be found in tally.json file, which must then be published via IPFS.
Finally, the CID of tally file must be submitted to FundingRound contract:
1
await fundingRound.publishTallyHash('<CID>')
Copied!

Coordinate using clrfund scripts

Generate coordinator key

1
cd contracts/
2
yarn ts-node scripts/generate-key.ts
Copied!
A single key can be used to coordinate multiple rounds.

Tally votes

Install zkutil (see instructions in MACI readme).
Switch to contracts directory:
1
cd contracts/
Copied!
Download zkSNARK parameters for 'medium' circuits to snark-params directory. Example:
1
ipfs get --output snark-params QmRzp3vkFPNHPpXiu7iKpPqVnZB97wq7gyih2mp6pa5bmD
Copied!
Set the path to downloaded parameter files and also the path to zkutil binary (if needed):
1
export NODE_CONFIG='{"snarkParamsPath": "../../../contracts/snark-params/", "zkutil_bin": "/usr/bin/zkutil"}'
Copied!
Decrypt messages and tally the votes:
1
COORDINATOR_PK=<coordinator-private-key> COORDINATOR_ETH_PK=<eth-private-key> ROUND_ADDRESS=<funding-round-address> yarn hardhat run --network xdai scripts/tally.ts
Copied!
Result will be saved to tally.json file, which must then be published via IPFS.