@maci-protocol/website 0.0.0-ci.d0dddbc → 0.0.0-ci.d231815
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/blog/2024-02-28-maci-v1.2.0.md +1 -1
- package/blog/2025-03-21-roadmap-2025.md +1 -1
- package/blog/2025-08-18-maci-aragon-plugin.md +107 -0
- package/blog/2025-09-05-maci-coordinator-service.md +167 -0
- package/docusaurus.config.ts +7 -1
- package/package.json +11 -10
- package/versioned_docs/version-v0.x/contract.md +1 -1
- package/versioned_docs/version-v0.x/introduction.md +0 -4
- package/versioned_docs/version-v0.x/quadratic-vote-tallying-circuit.md +1 -1
- package/versioned_docs/version-v1.2/circuits.md +8 -8
- package/versioned_docs/version-v1.2/contributing/contributing.md +4 -4
- package/versioned_docs/version-v1.2/deployment.md +1 -1
- package/versioned_docs/version-v1.2/integrating.md +1 -1
- package/versioned_docs/version-v1.2/key-change.md +1 -1
- package/versioned_docs/version-v1.2/poll-types.md +1 -1
- package/versioned_docs/version-v1.2/testing-in-detail.md +3 -3
- package/versioned_docs/version-v1.2/testing.md +1 -1
- package/versioned_docs/version-v1.2/topup.md +1 -1
- package/versioned_docs/version-v1.2/typedoc/core/index.md +2 -2
- package/versioned_docs/version-v1.2/versioning.md +3 -3
- package/versioned_docs/version-v1.2/workflow.md +1 -1
- package/versioned_docs/version-v2.x/contributing/contributing.md +4 -4
- package/versioned_docs/version-v2.x/core-concepts/key-change.md +1 -1
- package/versioned_docs/version-v2.x/core-concepts/merkle-trees.md +1 -1
- package/versioned_docs/version-v2.x/core-concepts/poll-types.md +1 -1
- package/versioned_docs/version-v2.x/core-concepts/workflow.md +1 -1
- package/versioned_docs/version-v2.x/guides/integrating.md +1 -1
- package/versioned_docs/version-v2.x/guides/testing/testing-in-detail.md +3 -3
- package/versioned_docs/version-v2.x/guides/testing/testing.md +1 -1
- package/versioned_docs/version-v2.x/processes/versioning.md +3 -3
- package/versioned_docs/version-v2.x/supported-networks/deployed-contracts.md +7 -7
- package/versioned_docs/version-v2.x/technical-references/smart-contracts/AccQueue.md +1 -1
- package/versioned_docs/version-v2.x/technical-references/smart-contracts/MACI.md +1 -1
- package/versioned_docs/version-v2.x/technical-references/smart-contracts/MessageProcessor.md +1 -1
- package/versioned_docs/version-v2.x/technical-references/smart-contracts/Params.md +1 -1
- package/versioned_docs/version-v2.x/technical-references/smart-contracts/Poll.md +1 -1
- package/versioned_docs/version-v2.x/technical-references/smart-contracts/PollFactory.md +1 -1
- package/versioned_docs/version-v2.x/technical-references/smart-contracts/Tally.md +1 -1
- package/versioned_docs/version-v2.x/technical-references/smart-contracts/VkRegistry.md +1 -1
- package/versioned_docs/version-v2.x/technical-references/smart-contracts/VoiceCreditProxy.md +1 -1
- package/versioned_docs/version-v2.x/technical-references/zk-snark-circuits/processMessages.md +4 -4
- package/versioned_docs/version-v2.x/technical-references/zk-snark-circuits/tallyVotes.md +2 -2
- package/versioned_docs/version-v2.x/technical-references/zk-snark-circuits/zk-snark-circuits.md +3 -3
- package/versioned_docs/version-v3.x/contributing/contributing.md +11 -5
- package/versioned_docs/version-v3.x/core-concepts/key-change.md +1 -1
- package/versioned_docs/version-v3.x/core-concepts/poll-types.md +1 -1
- package/versioned_docs/version-v3.x/core-concepts/polls.md +1 -1
- package/versioned_docs/version-v3.x/core-concepts/workflow.md +1 -1
- package/versioned_docs/version-v3.x/guides/integrating.md +2 -2
- package/versioned_docs/version-v3.x/guides/sdk.md +3 -3
- package/versioned_docs/version-v3.x/guides/testing/testing-in-detail.md +3 -3
- package/versioned_docs/version-v3.x/guides/testing/testing-introduction.md +4 -4
- package/versioned_docs/version-v3.x/guides/troubleshooting.md +2 -2
- package/versioned_docs/version-v3.x/processes/versioning.md +3 -3
- package/versioned_docs/version-v3.x/security/trusted-setup.md +1 -1
- package/versioned_docs/version-v3.x/supported-networks/deployed-contracts.md +7 -7
- package/versioned_docs/version-v3.x/technical-references/coordinator-service/index.md +15 -1
- package/versioned_docs/version-v3.x/technical-references/coordinator-service/installation.md +5 -33
- package/versioned_docs/version-v3.x/technical-references/coordinator-service/usage.md +64 -0
- package/versioned_docs/version-v3.x/technical-references/smart-contracts/MACI.md +1 -1
- package/versioned_docs/version-v3.x/technical-references/smart-contracts/MessageProcessor.md +1 -1
- package/versioned_docs/version-v3.x/technical-references/smart-contracts/Params.md +1 -1
- package/versioned_docs/version-v3.x/technical-references/smart-contracts/Policies.md +1 -1
- package/versioned_docs/version-v3.x/technical-references/smart-contracts/Poll.md +1 -1
- package/versioned_docs/version-v3.x/technical-references/smart-contracts/PollFactory.md +1 -1
- package/versioned_docs/version-v3.x/technical-references/smart-contracts/Tally.md +1 -1
- package/versioned_docs/version-v3.x/technical-references/smart-contracts/VkRegistry.md +1 -1
- package/versioned_docs/version-v3.x/technical-references/smart-contracts/VoiceCreditProxy.md +1 -1
- package/versioned_docs/version-v3.x/technical-references/zk-snark-circuits/joinPoll.md +1 -1
- package/versioned_docs/version-v3.x/technical-references/zk-snark-circuits/processMessages.md +66 -6
- package/versioned_docs/version-v3.x/technical-references/zk-snark-circuits/tallyVotes.md +2 -2
- package/versioned_docs/version-v3.x/technical-references/zk-snark-circuits/zk-snark-circuits.md +3 -3
|
@@ -17,7 +17,7 @@ to manage a large amount of value, and if their users accept that the risk of
|
|
|
17
17
|
coordinator misbehaviour is insufficient to justify doing the work of a
|
|
18
18
|
trusted setup. After all, MACI's security model presumes a trusted coordinator.
|
|
19
19
|
|
|
20
|
-
The [PSE team](https://pse.
|
|
20
|
+
The [PSE team](https://pse.main/) is making available a trusted set of zKeys for MACI's circuits,
|
|
21
21
|
which are available and accessible on
|
|
22
22
|
[p0tion's website](https://ceremony.pse.dev/).
|
|
23
23
|
For more info on trusted setup ceremonies please refer to p0tion's [docs](https://p0tion.super.site/).
|
|
@@ -7,14 +7,14 @@ sidebar_position: 2
|
|
|
7
7
|
|
|
8
8
|
There are a number of MACI's smart contracts which can be re-used by different deployments. These are the following:
|
|
9
9
|
|
|
10
|
-
- [VerifyingKeysRegistry](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
11
|
-
- [PoseidonHashers](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
12
|
-
- [PollFactory](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
13
|
-
- [MessageProcessorFactory](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
14
|
-
- [TallyFactory](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
15
|
-
- [Verifier](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
10
|
+
- [VerifyingKeysRegistry](https://github.com/privacy-scaling-explorations/maci/blob/main/packages/contracts/contracts/VerifyingKeysRegistry.sol)
|
|
11
|
+
- [PoseidonHashers](https://github.com/privacy-scaling-explorations/maci/blob/main/packages/contracts/contracts/crypto/Hasher.sol)
|
|
12
|
+
- [PollFactory](https://github.com/privacy-scaling-explorations/maci/blob/main/packages/contracts/contracts/PollFactory.sol)
|
|
13
|
+
- [MessageProcessorFactory](https://github.com/privacy-scaling-explorations/maci/blob/main/packages/contracts/contracts/MessageProcessorFactory.sol)
|
|
14
|
+
- [TallyFactory](https://github.com/privacy-scaling-explorations/maci/blob/main/packages/contracts/contracts/TallyFactory.sol)
|
|
15
|
+
- [Verifier](https://github.com/privacy-scaling-explorations/maci/blob/main/packages/contracts/contracts/crypto/Verifier.sol)
|
|
16
16
|
- [FreeForAllPolicy](https://github.com/privacy-scaling-explorations/excubiae/tree/main/packages/contracts/contracts/extensions/freeForAll)
|
|
17
|
-
- [ConstantInitialVoiceCreditProxy](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
17
|
+
- [ConstantInitialVoiceCreditProxy](https://github.com/privacy-scaling-explorations/maci/blob/main/packages/contracts/contracts/initialVoiceCreditProxy/ConstantInitialVoiceCreditProxy.sol) - if you are happy to work with a fixed amount of credits
|
|
18
18
|
|
|
19
19
|
VkRegistries can be re-used by different protocols to share the same set of verifying keys. Please be advised that you should be verifying that those verifying keys are the ones that have undergone a trusted setup ceremony.
|
|
20
20
|
|
|
@@ -7,4 +7,18 @@ sidebar_position: 1
|
|
|
7
7
|
|
|
8
8
|
# Coordinator Service
|
|
9
9
|
|
|
10
|
-
Welcome to the Coordinator Service technical reference.
|
|
10
|
+
Welcome to the Coordinator Service technical reference. This guide describes how the Coordinator Service works, its workflow, and how to interact with it. For more technical code documentation regarding API endpoints and data transfer objects, please refer to the [API documentation](https://coordinator.maci.vote/api).
|
|
11
|
+
|
|
12
|
+
## Responsibilities
|
|
13
|
+
|
|
14
|
+
A MACI coordinator is responsible for running voting processes. In quadratic funding rounds or authority election rounds, the coordinator is the entity that defines who can vote, which projects or candidates are eligible for funding, and the duration of the voting round.
|
|
15
|
+
|
|
16
|
+
First of all, the coordinator needs to deploy the MACI smart contracts with the desired configuration: gatekeeper policy, which defines who can sign up as a voter; the state Merkle tree depth which defines the maximum number of voters; and the voting mode which defines how votes will be counted (more info in [Poll types](https://maci.pse.dev/docs/core-concepts/poll-types#quadratic-voting)).
|
|
17
|
+
|
|
18
|
+
After deploying the MACI contracts, the coordinator can deploy a poll (which represents a voting process). To deploy the poll, the coordinator needs to specify: the gatekeeper policy, which defines who can join the poll as a voter; the start and end dates of the poll; the number of options to vote for; the maximum number of votes per voter; and the voting mode.
|
|
19
|
+
|
|
20
|
+
The coordinator will then wait until the poll ends, after which they will need to finalize the poll. This involves processing all published messages, extracting the votes, tallying them, and submitting the results on-chain.
|
|
21
|
+
|
|
22
|
+
## Conclusion
|
|
23
|
+
|
|
24
|
+
In the following documents, we will go through the details of setting up the Coordinator Service and how to interact with it to perform the tasks described above.
|
package/versioned_docs/version-v3.x/technical-references/coordinator-service/installation.md
CHANGED
|
@@ -5,39 +5,11 @@ sidebar_label: Installation
|
|
|
5
5
|
sidebar_position: 2
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
2. Generate RSA key pair with `pnpm run generate-keypair`.
|
|
10
|
-
3. Download zkey files using `pnpm run download-zkeys:{type}` (only test type is available for now).
|
|
11
|
-
4. Make sure you copied RSA public key to your application. This will be needed for encrypting `Authorization` header and coordinator private key for proof generation. Also it can be accessed through API method `GET v1/proof/publicKey`.
|
|
12
|
-
5. Run `pnpm run start` to run the service.
|
|
13
|
-
6. All API calls must be called with `Authorization` header, where the value is encrypted with RSA public key you generated before. Header value contains message signature and message digest created by `COORDINATOR_ADDRESSES`. The format is `publicEncrypt({signature}:{digest})`.
|
|
14
|
-
Make sure you set `COORDINATOR_ADDRESSES` env variable and sign any message with the addresses from your application (see [AccountSignatureGuard](./ts/auth/AccountSignatureGuard.service.ts)).
|
|
15
|
-
7. Proofs can be generated with `POST v1/proof/generate` API method or with Websockets (see [dto spec](./ts/proof/dto.ts), [controller](./ts/app.controller.ts) and [wsgateway](./ts/events/events.gateway.ts)).
|
|
16
|
-
|
|
17
|
-
## Subgraph deployment
|
|
18
|
-
|
|
19
|
-
It is possible to deploy subgraph using coordinator service.
|
|
20
|
-
|
|
21
|
-
First, you need to setup subgraph and create a project. [Subgraph dashboard](https://thegraph.com/studio/).
|
|
22
|
-
|
|
23
|
-
Then, set env variables:
|
|
8
|
+
There are two ways to run the coordinator service: building it from source or using Docker. Both methods require you to clone the MACI repository and move to the project root directory.
|
|
24
9
|
|
|
10
|
+
```bash
|
|
11
|
+
git clone https://github.com/privacy-scaling-explorations/maci
|
|
12
|
+
cd maci
|
|
25
13
|
```
|
|
26
|
-
# Subgraph name
|
|
27
|
-
SUBGRAPH_NAME="maci-subgraph"
|
|
28
|
-
|
|
29
|
-
# Subgraph provider url
|
|
30
|
-
SUBGRAPH_PROVIDER_URL=https://api.studio.thegraph.com/deploy/
|
|
31
|
-
|
|
32
|
-
# Subgraph deploy key
|
|
33
|
-
SUBGRAPH_DEPLOY_KEY=*******
|
|
34
14
|
|
|
35
|
-
|
|
36
|
-
SUBGRAPH_FOLDER=../subgraph
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
After deployment, subgraph url will be available in studio dashboard and you can use this type of url to get latest deployed version in your application:
|
|
40
|
-
|
|
41
|
-
```
|
|
42
|
-
https://api.studio.thegraph.com/.../{SUBGRAPH_NAME}/version/latest
|
|
43
|
-
```
|
|
15
|
+
You need to check the latest [README.md](https://github.com/privacy-ethereum/maci/tree/main/apps/coordinator) instructions in the coordinator service app for detailed information about requirements and steps to install, build, and run the service.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Usage
|
|
3
|
+
description: Learn how to interact with a running MACI coordinator service instance.
|
|
4
|
+
sidebar_label: Usage
|
|
5
|
+
sidebar_position: 3
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
After setting up and running the MACI coordinator service, you can interact with it through its RESTful API. The service provides various endpoints for deployment and finalization of polls. Please refer to the API documentation at [https://coordinator.maci.vote/api](https://coordinator.maci.vote/api) for the exact request format and required parameters for all endpoint calls described below.
|
|
9
|
+
|
|
10
|
+
# Authentication
|
|
11
|
+
|
|
12
|
+
The coordinator service uses a custom signature authentication mechanism to guard the deploy endpoints. To interact with these endpoints, you need to:
|
|
13
|
+
|
|
14
|
+
1. Make sure you have run the command to set up and generate the RSA keypair, as described in the instructions section.
|
|
15
|
+
|
|
16
|
+
2. Ensure that your Ethereum public key is set in the `.env` file under the `COORDINATOR_ADDRESSES` variable.
|
|
17
|
+
|
|
18
|
+
3. Get the RSA public key from the coordinator service with [https://coordinator.maci.vote/v1/proof/publicKey](https://coordinator.maci.vote/v1/proof/publicKey).
|
|
19
|
+
|
|
20
|
+
4. Sign a message such as "authenticate-me" using the coordinator's Ethereum private key.
|
|
21
|
+
|
|
22
|
+
5. Encrypt both the message (also called digest) and its signature using the RSA public key. For example, you can use RSA public-key encryption in the format:
|
|
23
|
+
|
|
24
|
+
```javascript
|
|
25
|
+
const payload: string = "signature:digest";
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Then encrypt this payload using the coordinator’s RSA public key.
|
|
29
|
+
|
|
30
|
+
# Deploy MACI
|
|
31
|
+
|
|
32
|
+
To deploy the set of MACI smart contracts, you need to call the endpoint [https://coordinator.maci.vote/v1/deploy/maci](https://coordinator.maci.vote/v1/deploy/maci) with a POST request. The request body should include the necessary parameters for the deployment, such as the gatekeeper policy, state tree depth, and voting mode.
|
|
33
|
+
|
|
34
|
+
# Deploy Poll
|
|
35
|
+
|
|
36
|
+
To deploy a new poll to an existing MACI instance, you need to call the endpoint [https://coordinator.maci.vote/v1/deploy/poll](https://coordinator.maci.vote/v1/deploy/poll) with a POST request. The request body should include the necessary parameters for the poll deployment, such as the gatekeeper policy, start and end dates, number of options, and voting mode.
|
|
37
|
+
|
|
38
|
+
# Deploy Subgraph
|
|
39
|
+
|
|
40
|
+
To deploy a subgraph for a MACI instance and its corresponding polls, you need to call the endpoint [https://coordinator.maci.vote/v1/subgraph/deploy](https://coordinator.maci.vote/v1/subgraph/deploy) with a POST request. The request body should include the necessary parameters for the subgraph deployment, such as the MACI contract address and the subgraph name.
|
|
41
|
+
|
|
42
|
+
# Finalize Poll
|
|
43
|
+
|
|
44
|
+
To finalize a poll, you need to follow a series of steps that involve processing messages, merging state trees, generating proofs, and submitting the final tally on-chain. The Coordinator Service provides endpoints for each of these steps.
|
|
45
|
+
|
|
46
|
+
## Merge
|
|
47
|
+
|
|
48
|
+
To merge the published messages and create the required state tree, you need to call the endpoint [https://coordinator.maci.vote/v1/proof/merge](https://coordinator.maci.vote/v1/proof/merge) with a POST request. The request body should include the necessary parameters for the merge operation, such as the MACI contract address and the poll ID.
|
|
49
|
+
|
|
50
|
+
## Generate
|
|
51
|
+
|
|
52
|
+
Once the Merkle trees are ready, you can generate the zk-SNARK proof for the final tally by calling the endpoint [https://coordinator.maci.vote/v1/proof/generate](https://coordinator.maci.vote/v1/proof/generate) with a POST request. The request body should include the necessary parameters for the proof generation, such as the MACI contract address and the poll ID.
|
|
53
|
+
|
|
54
|
+
## Submit
|
|
55
|
+
|
|
56
|
+
After generating the proof, you can submit the final tally on-chain by calling the endpoint [https://coordinator.maci.vote/v1/proof/submit](https://coordinator.maci.vote/v1/proof/submit) with a POST request. The request body should include the necessary parameters for the submission, such as the MACI contract address, poll ID, and the generated proof.
|
|
57
|
+
|
|
58
|
+
# Schedule Poll
|
|
59
|
+
|
|
60
|
+
After deploying a poll, you can schedule it to be finalized automatically after it ends. Make sure to set the MACI coordinator private key in the `.env` file. To do so, you need to call the endpoint [https://coordinator.maci.vote/v1/schedule/poll](https://coordinator.maci.vote/v1/schedule/poll) with a POST request. The request body should include the necessary parameters for scheduling the poll, such as the MACI contract address and the poll ID.
|
|
61
|
+
|
|
62
|
+
# Health
|
|
63
|
+
|
|
64
|
+
To check that the env variables are set correctly and the service is running, you can call the health endpoint [https://coordinator.maci.vote/v1/health](https://coordinator.maci.vote/v1/health) with a GET request. This endpoint will return a status message indicating the rapidsnark access, redis database connection, zkeys access, and the MACI coordinator address with its funds in each MACI-compatible network.
|
|
@@ -6,7 +6,7 @@ sidebar_position: 1
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
:::info
|
|
9
|
-
Code location: [MACI.sol](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
9
|
+
Code location: [MACI.sol](https://github.com/privacy-scaling-explorations/maci/blob/main/packages/contracts/contracts/MACI.sol)
|
|
10
10
|
:::
|
|
11
11
|
|
|
12
12
|
`MACI.sol` is the core contract of the project, as it provides the base layer for user signups and Polls to be created.
|
package/versioned_docs/version-v3.x/technical-references/smart-contracts/MessageProcessor.md
CHANGED
|
@@ -6,7 +6,7 @@ sidebar_position: 4
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
:::info
|
|
9
|
-
Code location: [MessageProcessor.sol](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
9
|
+
Code location: [MessageProcessor.sol](https://github.com/privacy-scaling-explorations/maci/blob/main/packages/contracts/contracts/MessageProcessor.sol)
|
|
10
10
|
:::
|
|
11
11
|
|
|
12
12
|
This contract is used to prepare parameters for the zk-SNARK circuits as well as for verifying proofs. It should be deployed alongside a `Poll`.
|
|
@@ -6,7 +6,7 @@ sidebar_position: 9
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
:::info
|
|
9
|
-
Code location: [Params.sol](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
9
|
+
Code location: [Params.sol](https://github.com/privacy-scaling-explorations/maci/blob/main/packages/contracts/contracts/utilities/Params.sol)
|
|
10
10
|
:::
|
|
11
11
|
|
|
12
12
|
A contract holding three structs:
|
|
@@ -21,7 +21,7 @@ The MACI repository comes with several out-of-the-box options:
|
|
|
21
21
|
- `HatsPolicy` - This allows gatekeeping signups to only users who have a specific [Hat](https://www.hatsprotocol.xyz/).
|
|
22
22
|
- `GitcoinPassportPolicy` - This allows gatekeeping signups to only users who have a specific [Gitcoin Passport](https://passport.gitcoin.co/) score.
|
|
23
23
|
- `ZupassPolicy` - This allows gatekeeping signups only to users who have a valid [Zupass PCD ticket](https://github.com/proofcarryingdata/zupass).
|
|
24
|
-
- `SemaphorePolicy` - This allows gatekeeping signups only to users who can prove they are part of a [Semaphore](https://semaphore.pse.
|
|
24
|
+
- `SemaphorePolicy` - This allows gatekeeping signups only to users who can prove they are part of a [Semaphore](https://semaphore.pse.main/) group.
|
|
25
25
|
|
|
26
26
|
You can find all of the latest policy contracts here:
|
|
27
27
|
https://github.com/privacy-scaling-explorations/excubiae/tree/main/packages/contracts/contracts/extensions
|
|
@@ -6,7 +6,7 @@ sidebar_position: 2
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
:::info
|
|
9
|
-
Code location: [Poll.sol](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
9
|
+
Code location: [Poll.sol](https://github.com/privacy-scaling-explorations/maci/blob/main/packages/contracts/contracts/Poll.sol)
|
|
10
10
|
:::
|
|
11
11
|
|
|
12
12
|
This contract allows users to submit their votes.
|
|
@@ -6,7 +6,7 @@ sidebar_position: 3
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
:::info
|
|
9
|
-
Code location: [PollFactory.sol](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
9
|
+
Code location: [PollFactory.sol](https://github.com/privacy-scaling-explorations/maci/blob/main/packages/contracts/contracts/PollFactory.sol)
|
|
10
10
|
:::
|
|
11
11
|
|
|
12
12
|
`PollFactory` is a smart contract that is used to deploy new Polls. This is used by MACI inside the `deployPoll` function.
|
|
@@ -6,7 +6,7 @@ sidebar_position: 5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
:::info
|
|
9
|
-
Code location: [Tally.sol](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
9
|
+
Code location: [Tally.sol](https://github.com/privacy-scaling-explorations/maci/blob/main/packages/contracts/contracts/Tally.sol)
|
|
10
10
|
:::
|
|
11
11
|
|
|
12
12
|
The `Tally` contract is used by the coordinator to submit commitments to the tally results via the `tallyVotes` function. This is done in batches and the final commitment can be used by the users to verify the validity of the results.
|
|
@@ -6,7 +6,7 @@ sidebar_position: 8
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
:::info
|
|
9
|
-
Code location: [VerifyingKeysRegistry.sol](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
9
|
+
Code location: [VerifyingKeysRegistry.sol](https://github.com/privacy-scaling-explorations/maci/blob/main/packages/contracts/contracts/VerifyingKeysRegistry.sol)
|
|
10
10
|
:::
|
|
11
11
|
|
|
12
12
|
The VerifyingKeysRegistry is a contract that holds the verifying keys for the zk-SNARK circuits. It holds four different sets of keys:
|
package/versioned_docs/version-v3.x/technical-references/smart-contracts/VoiceCreditProxy.md
CHANGED
|
@@ -6,7 +6,7 @@ sidebar_position: 7
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
:::info
|
|
9
|
-
Code location: [InitialVoiceCreditProxy](https://github.com/privacy-scaling-explorations/maci/tree/
|
|
9
|
+
Code location: [InitialVoiceCreditProxy](https://github.com/privacy-scaling-explorations/maci/tree/main/contracts/contracts/initialVoiceCreditProxy)
|
|
10
10
|
:::
|
|
11
11
|
|
|
12
12
|
The VoiceCreditProxy contract is used to assign voice credits to users. Whichever implementation should the MACI deployers use, this must implement a view function that returns the balance for a user, such as the one below:
|
|
@@ -5,7 +5,7 @@ sidebar_label: Join Poll Circuit
|
|
|
5
5
|
sidebar_position: 6
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
[**Repo link**](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
8
|
+
[**Repo link**](https://github.com/privacy-scaling-explorations/maci/blob/main/circuits/circom/voter)
|
|
9
9
|
|
|
10
10
|
## PollJoining
|
|
11
11
|
|
package/versioned_docs/version-v3.x/technical-references/zk-snark-circuits/processMessages.md
CHANGED
|
@@ -5,11 +5,11 @@ sidebar_label: Process Messages Circuit
|
|
|
5
5
|
sidebar_position: 3
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
[**Repo link**](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
8
|
+
[**Repo link**](https://github.com/privacy-scaling-explorations/maci/blob/main/circuits/circom/coordinator)
|
|
9
9
|
|
|
10
10
|
This circuit allows the coordinator to prove that they have correctly processed each message in reverse order, in a consecutive batch of 5 ^ messageBatchDepth messages to the respective state leaf within the state tree. Coordinators would use this circuit to prove correct execution at the end of each Poll.
|
|
11
11
|
|
|
12
|
-
The [`MessageProcessorQv`](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
12
|
+
The [`MessageProcessorQv`](https://github.com/privacy-scaling-explorations/maci/blob/main/circuits/circom/coordinator/qv/MessageProcessor.circom) circuit will try to decrypt the messages, and based on the content of the message, update within itself the trees, to generate a proof that the coordinator's off-chain processing was done correctly. In other words, the circuit takes a final state, an initial state, and the leaves (messages and user signups) - it processes these messages via the different state transitions to finally check that the expected state is correct.
|
|
13
13
|
The pre-requisites for this circuit are:
|
|
14
14
|
|
|
15
15
|
- the related Poll has ended
|
|
@@ -18,14 +18,74 @@ The pre-requisites for this circuit are:
|
|
|
18
18
|
|
|
19
19
|
This circuit requires the coordinator's private key, hence a proof for this circuit can only be generated by the coordinator. The private key is needed in order to generate the ECDH shared key used to decrypt the messages.
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
```mermaid
|
|
22
|
+
flowchart LR
|
|
23
|
+
parameters(["MessageProcessorQv - Parameters"])
|
|
24
|
+
parameters --> stateTreeDepth["stateTreeDepth"]
|
|
25
|
+
parameters --> batchSize["batchSize"]
|
|
26
|
+
parameters --> voteOptionTreeDepth["voteOptionTreeDepth"]
|
|
27
|
+
|
|
28
|
+
stateTreeDepth & batchSize & voteOptionTreeDepth --> publicInputs["Public inputs"]
|
|
29
|
+
|
|
30
|
+
subgraph publicInputs
|
|
31
|
+
direction LR
|
|
32
|
+
totalSignups ~~~ index
|
|
33
|
+
batchEndIndex ~~~ currentSbCommitment
|
|
34
|
+
newSbCommitment ~~~ outputBatchHash
|
|
35
|
+
actualStateTreeDepth ~~~ coordinatorPublicKeyHash
|
|
36
|
+
voteOptions
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
publicInputs --> privateInputs
|
|
40
|
+
|
|
41
|
+
subgraph privateInputs
|
|
42
|
+
direction LR
|
|
43
|
+
inputBatchHash ~~~ messages
|
|
44
|
+
coordinatorPrivateKey ~~~ encryptionPublicKeys
|
|
45
|
+
currentStateRoot ~~~ currentStateLeaves
|
|
46
|
+
currentStateLeavesPathElements ~~~ currentSbSalt
|
|
47
|
+
newSbSalt ~~~ currentBallotRoot
|
|
48
|
+
currentBallots ~~~ currentBallotsPathElements
|
|
49
|
+
currentVoteWeights ~~~ currentVoteWeightsPathElements
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
privateInputs --> step1["1 - Verify currentSbCommitment"]
|
|
53
|
+
step1 --> step1B["hash(currentStateRoot, currentBallotRoot, currentSbSalt)"]
|
|
54
|
+
|
|
55
|
+
privateInputs --> step2["2 – Check voteOptions upper-bound"]
|
|
56
|
+
step2 --> step2B["voteOptions <= 5 ** voteOptionTreeDepth"]
|
|
57
|
+
|
|
58
|
+
privateInputs --> step3["3 – Ensure totalSignups within capacity"]
|
|
59
|
+
step3 --> step3B["totalSignups <= 2 ** stateTreeDepth"]
|
|
60
|
+
|
|
61
|
+
privateInputs --> step4["4 – Hash each message + pub-key"]
|
|
62
|
+
step4 --> step4B["MessageHasher template loop"]
|
|
63
|
+
|
|
64
|
+
privateInputs --> step5["5 – Build and verify chainHash"]
|
|
65
|
+
step5 --> step5B["PoseidonHasher template loop + Mux1"]
|
|
66
|
+
|
|
67
|
+
privateInputs --> step6["6 – Derive & verify coordinator pubKey"]
|
|
68
|
+
step6 --> step6B["PrivateToPublicKey -> derivedPublicKeyHash == coordinatorPublicKeyHash"]
|
|
69
|
+
|
|
70
|
+
privateInputs --> step7["7 – Decrypt each message to a command using MessageToCommand"]
|
|
71
|
+
step7 --> step7B["MessageToCommand template loop"]
|
|
72
|
+
|
|
73
|
+
privateInputs --> step8["8 – Process messages in reverse order"]
|
|
74
|
+
step8 --> step8B["SingleMessageProcessorQv template loop"]
|
|
75
|
+
|
|
76
|
+
privateInputs --> step9["9 – Compute newSbCommitment"]
|
|
77
|
+
step9 --> step9B["hash(stateRoot, ballotRoot, newSbSalt)"]
|
|
78
|
+
|
|
79
|
+
privateInputs --> step10["10 – Verify provided newSbCommitment"]
|
|
80
|
+
step10 --> step10B["equality with computed commitment"]
|
|
81
|
+
```
|
|
22
82
|
|
|
23
83
|
:::info
|
|
24
|
-
A version working with non quadratic voting (non-qv) is also [available](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
84
|
+
A version working with non quadratic voting (non-qv) is also [available](https://github.com/privacy-scaling-explorations/maci/blob/main/circuits/circom/coordinator/non-qv/MessageProcessor.circom). This version is called `MessageProcessorNonQV` and is to be used when the Poll is not using the quadratic voting feature. Note that by default MACI works with quadratic voting.
|
|
25
85
|
:::
|
|
26
86
|
|
|
27
87
|
:::info
|
|
28
|
-
A version working with full credits voting (full) is also [available](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
88
|
+
A version working with full credits voting (full) is also [available](https://github.com/privacy-scaling-explorations/maci/blob/main/circuits/circom/coordinator/full/MessageProcessor.circom). This version is called `MessageProcessorFull` and is to be used when the Poll is not using the quadratic or non quadratic voting features. Note that by default MACI works with quadratic voting.
|
|
29
89
|
:::
|
|
30
90
|
|
|
31
91
|
#### Parameters
|
|
@@ -96,7 +156,7 @@ A simplified example using a tree of arity 2:
|
|
|
96
156
|
|
|
97
157
|
To prove that `a...d` are leaves of the tree with root `r`, we prove that the leaves have the subroot `s` with depth 2, and _then_ prove that `s` is a member of `r` at depth 1.
|
|
98
158
|
|
|
99
|
-
The implementation for this is in the `QuinBatchLeavesExists` circuit in `https://github.com/privacy-scaling-explorations/maci/blob/
|
|
159
|
+
The implementation for this is in the `QuinBatchLeavesExists` circuit in `https://github.com/privacy-scaling-explorations/maci/blob/main/circuits/circom/trees/incrementalQuinTree.circom`.
|
|
100
160
|
|
|
101
161
|
This method requires fewer circuit constraints than if we verified a Merkle proof for each leaf.
|
|
102
162
|
|
|
@@ -5,7 +5,7 @@ sidebar_label: Tally Votes Circuit
|
|
|
5
5
|
sidebar_position: 4
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
[**Repo link**](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
8
|
+
[**Repo link**](https://github.com/privacy-scaling-explorations/maci/blob/main/circuits/circom/core)
|
|
9
9
|
|
|
10
10
|
#### Parameters
|
|
11
11
|
|
|
@@ -18,7 +18,7 @@ sidebar_position: 4
|
|
|
18
18
|

|
|
19
19
|
|
|
20
20
|
:::info
|
|
21
|
-
A version working with non quadratic and full credits voting (non-qv, full) is also [available](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
21
|
+
A version working with non quadratic and full credits voting (non-qv, full) is also [available](https://github.com/privacy-scaling-explorations/maci/blob/main/circuits/circom/coordinator/non-qv/VoteTally.circom). This version is called `tallyVotes` and is to be used when the Poll is not using the quadratic voting feature. Note that by default MACI works with quadratic voting.
|
|
22
22
|
:::
|
|
23
23
|
|
|
24
24
|
#### Input signals
|
package/versioned_docs/version-v3.x/technical-references/zk-snark-circuits/zk-snark-circuits.md
CHANGED
|
@@ -5,10 +5,10 @@ sidebar_label: zk-SNARK Circuits
|
|
|
5
5
|
sidebar_position: 1
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
MACI has three main zk-SNARK [circuits](https://github.com/privacy-scaling-explorations/maci/tree/
|
|
8
|
+
MACI has three main zk-SNARK [circuits](https://github.com/privacy-scaling-explorations/maci/tree/main/packages/circuits):
|
|
9
9
|
|
|
10
|
-
1. ProcessMessages.circom, which takes a batch of encrypted messages, decrypts them, and generates a proof that the coordinator's local processing was performed correctly. [QV](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
11
|
-
2. TallyVotes.circom, which counts votes from users' ballots, batch by batch. [QV](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
10
|
+
1. ProcessMessages.circom, which takes a batch of encrypted messages, decrypts them, and generates a proof that the coordinator's local processing was performed correctly. [QV](https://github.com/privacy-scaling-explorations/maci/blob/main/circuits/circom/coordinator/qv/MessageProcessor.circom), [non-QV](https://github.com/privacy-scaling-explorations/maci/blob/main/circuits/circom/coordinator/non-qv/MessageProcessor.circom), [Full](https://github.com/privacy-scaling-explorations/maci/blob/main/circuits/circom/coordinator/full/MessageProcessor.circom) versions are available.
|
|
11
|
+
2. TallyVotes.circom, which counts votes from users' ballots, batch by batch. [QV](https://github.com/privacy-scaling-explorations/maci/blob/main/circuits/circom/coordinator/qv/VoteTally.circom) and [non-QV](https://github.com/privacy-scaling-explorations/maci/blob/main/circuits/circom/coordinator/non-qv/VoteTally.circom) versions are available.
|
|
12
12
|
3. PollJoining.circom, which allows users to prove they know a private key for a public key signed up to the MACI smart contract, and to register to a specific poll.
|
|
13
13
|
|
|
14
14
|
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.
|