Skip to content

Commit

Permalink
docs: update README with build guide for MACI circuits
Browse files Browse the repository at this point in the history
  • Loading branch information
baumstern committed May 30, 2023
1 parent e99e47e commit 77fdb63
Showing 1 changed file with 33 additions and 6 deletions.
39 changes: 33 additions & 6 deletions circuits/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,49 @@ The main circuits are:

* `processMessages.circom`
* `tallyVotes.circom`
* `subsidy.circom`
* (optional) `subsidy.circom`

The rest of the circuits are utilities templates that are required for the main circuits to work correctly. These include utilities such as Float math, conversion of private keys, and Poseidon hashing/encryption.
The rest of the circuits are utilities templates that are required for the main circuits to work correctly. These include utilities such as float math, conversion of private keys, and Poseidon hashing/encryption.

Please refer to the [documentation](https://privacy-scaling-explorations.github.io/maci/circuits.html) for a more in depth explanation.

## Build

### Prerequisites

Before building the project, make sure you have the following dependencies installed:

- [circom](https://docs.circom.io/downloads/downloads/)

### Building MACI circuits

To build the two main circuits of MACI, run the following commands:

```
circom --r1cs --sym --wasm --output ./build circom/test/processMessages_test.circom
circom --r1cs --sym --wasm --output ./build circom/test/tallyVotes_test.circom
```

Please note that the circuit is configured with testing purpose parameters, which means it can only handle a limited amount of messages (up to 25 messages). For more information on the parameters and how to configure them, refer to [this page](https://privacy-scaling-explorations.github.io/maci/circuits.html#compile-circuits).

### Generating and Validating ZK Proofs

To generate and validate ZK proofs from the artifacts produced by `circom`, you will need [`snarkjs`](https://github.com/iden3/snarkjs#groth16-1).




## Testing

In order to test the circuits package follow the instructions below:
To test the circuits package, please follow the instructions below:

1. Configure `circomHelperConfig.json` with the correct path to the circom binary. If installed via `cargo` it will likely be in `~/.cargo/bin/circom`
2. run `npm run circom-helper` and wait for it to compile all test circuits and expose the JSON API. Please note that this can take around 10 to 15 minutes, depending on the specs of your machine. Once ready, the following will appear on screen:
1. Configure `circomHelperConfig.json` with the correct path to the circom binary. If you installed it via `cargo`, the binary is likely located at `~/.cargo/bin/circom`.
2. Run the command `npm run build-test-circuits` and wait for it to compile all the test circuits. This process may take approximately 10 to 15 minutes.
3. Run the command `npm run circom-helper` and wait for it to expose the JSON-RPC endpoint. Once it is ready, you will see the following message on the screen:
```
Launched JSON-RPC server at port 9001
```
3. run `npm run test` to run all tests or add `-$CIRCUIT_NAME` to test individually (e.g. `npm run test-processMessages`)
4. To run all tests, use the command `npm run test`. If you want to test a specific circuit individually, you can append `-$CIRCUIT_NAME` to the command (e.g., `npm run test-processMessages`).
[circuits-npm-badge]: https://img.shields.io/npm/v/maci-circuits.svg
Expand Down

0 comments on commit 77fdb63

Please sign in to comment.