Please refer to the implementation spec for technical details, and the original ethresear.ch post for a high-level view.
We welcome contributions to this project. Please join our Telegram group to discuss.
You should have Node 11.14.0 installed. Use
nvm
to install it.
TODO: Test this with Node 12 LTS.
You also need Solidity 0.5.16 installed in your PATH
.
Clone this repository, install dependencies, and build the source code:
git clone git@github.com:barryWhiteHat/maci.git && \
npm i && \
npm run bootstrap && \
npm run build
This repository is organised as Lerna submodules. Each submodule contains its own unit tests.
config
: project-wide configuration files. Includes config files for both testing and production.crypto
: low-level cryptographic operations.circuits
: zk-SNARK circuits.contracts
: Solidity contracts and deployment code.domainobjs
: Classes which represent high-level domain objects particular to this project.core
: Business logic functions for message processing and vote tallying.
Subdirectories which are not Lerna submodules are:
docker
: Docker files for testing and deployment.
For development purposes, you can generate the proving and verifying keys for the zk-SNARK circuits, along with their Solidity verifier contracts as such:
cd circuits
npm run buildBatchUpdateStateTreeSnark
npm run buildQuadVoteTallySnark
Alternatively, you can save time by downloading the files from Dropbox:
cd circuits
npm run downloadAllSnarks
The following submodules contain unit tests: crypto
, circuits
, contracts
, and domainobjs
.
Except for the contracts
submodule, run unit tests as such (the following
example is for crypto
):
cd crypto
npm run test
For the contracts
unit tests, run the tests one by one. This prevents
incorrect nonce errors.
First, start a Ganache instance in a separate terminal:
cd contracts
npm run ganache
In another terminal, run the tests individually:
cd contracts
npm run test-hasher
npm run test-maci
npm run ...
Assuming that you have a Ganache node set up and listening to the path
configured in config/test.yaml
:
cd contracts
npm run deploy
The addresses which the contracts have been deployed to will be saved in
contracts/deployedAddresses.json
.
TODO: when we develop the CLI, this command should also copy the deployed addresses to the CLI submodule.
First, set the private key you need to deploy the contracts. The account
associated with the key should already have some ETH in it. Create this file in
your home directory (e.g. /home/user/kovanPrivKey.json
) and replace the value
between the quote marks with the private key.
["0x................................................................"]
There is an existing kovan.yml
file in the config
submodule. We will use it
as an example of deploying to the Kovan testnet.
cd contracts
NODE_ENV=kovan npm run deploy
If the deployment fails because of an error from the Ethereum node, change it in kovan.yml
:
chain:
url: "https://kovan.infura.io/v3/<your infura key>"