@maci-protocol/website 0.0.0-ci.26f28d6 → 0.0.0-ci.2d2f5fb
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/LICENSE +1 -2
- package/blog/2024-02-28-maci-v1.2.0.md +1 -1
- package/blog/2024-08-10-maci-v2.md +1 -1
- package/blog/2024-12-01-maci-getting-started.md +1 -1
- package/blog/2025-03-21-roadmap-2025.md +1 -1
- package/package.json +5 -5
- package/src/pages/roadmap.md +39 -80
- package/static/img/circuits/MACI-Circuits.excalidraw +37 -37
- package/static/img/circuits/ecdh.svg +1 -1
- package/static/img/circuits/messageToCommand.svg +1 -1
- package/static/img/circuits/messageValidator.svg +1 -1
- package/static/img/circuits/privToPubkey.svg +1 -1
- package/static/img/circuits/processMessages.svg +1 -1
- package/static/img/circuits/processMessagesInputHasher.svg +1 -1
- package/static/img/circuits/processMessages_2_0.svg +1 -1
- package/static/img/circuits/processOne.svg +1 -1
- package/static/img/circuits/processTopup.svg +1 -1
- package/static/img/circuits/tallyInputHasher.svg +1 -1
- package/static/img/circuits/verifySignature.svg +1 -1
- package/static/img/relayer-diagram.png +0 -0
- package/versioned_docs/version-v3.x/core-concepts/coordinator-service.md +16 -0
- package/versioned_docs/version-v3.x/core-concepts/key-change.md +28 -28
- package/versioned_docs/version-v3.x/core-concepts/maci-keys.md +1 -1
- package/versioned_docs/version-v3.x/core-concepts/offchain-voting.md +14 -0
- package/versioned_docs/version-v3.x/core-concepts/poll-types.md +2 -2
- package/versioned_docs/version-v3.x/core-concepts/polls.md +3 -3
- package/versioned_docs/version-v3.x/core-concepts/spec.md +36 -102
- package/versioned_docs/version-v3.x/core-concepts/state-leaf.md +2 -2
- package/versioned_docs/version-v3.x/core-concepts/workflow.md +7 -1
- package/versioned_docs/version-v3.x/guides/compile-circuits.md +7 -7
- package/versioned_docs/version-v3.x/guides/integrating.md +8 -8
- package/versioned_docs/version-v3.x/guides/testing/testing-in-detail.md +1 -1
- package/versioned_docs/version-v3.x/guides/troubleshooting.md +11 -11
- package/versioned_docs/version-v3.x/quick-start.md +6 -6
- package/versioned_docs/version-v3.x/supported-networks/deployed-contracts.md +2 -2
- package/versioned_docs/version-v3.x/technical-references/coordinator-service/_category_.json +8 -0
- package/versioned_docs/version-v3.x/technical-references/coordinator-service/index.md +10 -0
- package/versioned_docs/version-v3.x/technical-references/coordinator-service/installation.md +43 -0
- package/versioned_docs/version-v3.x/technical-references/offchain-relayer/_category_.json +8 -0
- package/versioned_docs/version-v3.x/technical-references/offchain-relayer/index.md +51 -0
- package/versioned_docs/version-v3.x/technical-references/offchain-relayer/installation.md +109 -0
- package/versioned_docs/version-v3.x/technical-references/smart-contracts/MACI.md +5 -5
- package/versioned_docs/version-v3.x/technical-references/smart-contracts/Poll.md +7 -7
- package/versioned_docs/version-v3.x/technical-references/smart-contracts/Tally.md +2 -2
- package/versioned_docs/version-v3.x/technical-references/smart-contracts/VkRegistry.md +5 -5
- package/versioned_docs/version-v3.x/technical-references/zk-snark-circuits/joinPoll.md +3 -4
- package/versioned_docs/version-v3.x/technical-references/zk-snark-circuits/processMessages.md +12 -12
- 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/utilities.md +1 -1
|
@@ -7,7 +7,7 @@ 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
|
-
- [
|
|
10
|
+
- [VerifyingKeysRegistry](https://github.com/privacy-scaling-explorations/maci/blob/dev/contracts/contracts/VerifyingKeysRegistry.sol)
|
|
11
11
|
- [PoseidonHashers](https://github.com/privacy-scaling-explorations/maci/blob/dev/contracts/contracts/crypto/Hasher.sol)
|
|
12
12
|
- [PollFactory](https://github.com/privacy-scaling-explorations/maci/blob/dev/contracts/contracts/PollFactory.sol)
|
|
13
13
|
- [MessageProcessorFactory](https://github.com/privacy-scaling-explorations/maci/blob/dev/contracts/contracts/MessageProcessorFactory.sol)
|
|
@@ -29,7 +29,7 @@ cd cli && node build/ts/index.js checkVerifyingKeys -q false -vk 0x74569d524a193
|
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
:::info
|
|
32
|
-
You should change the -vk parameter to the
|
|
32
|
+
You should change the -vk parameter to the VerifyingKeysRegistry address for the chain you are deploying to. Also you might need to modify the parameters based on the circuit configuration. Please refer to the [circuits page](/docs/technical-references/zk-snark-circuits/setup) for more information. Also you can add `-uq false` if you want to check non quadratic voting keys.
|
|
33
33
|
:::
|
|
34
34
|
|
|
35
35
|
## Contract Addresses
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"label": "Coordinator Service",
|
|
3
|
+
"position": 1,
|
|
4
|
+
"link": {
|
|
5
|
+
"type": "generated-index",
|
|
6
|
+
"description": "The Coordinator Service is a backend service that aims to automate MACI-related operations, such as contracts deployment, proof generation and poll finalisation."
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Introduction
|
|
3
|
+
description: The Coordinator Service is a service that allows to automate MACI coordinator tasks.
|
|
4
|
+
sidebar_label: Introduction
|
|
5
|
+
sidebar_position: 1
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Coordinator Service
|
|
9
|
+
|
|
10
|
+
Welcome to the Coordinator Service technical reference. Here you will find the technical details of the Coordinator Service, including the API endpoints and code examples.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Installation and setup
|
|
3
|
+
description: Learn how to install and setup the Coordinator Service.
|
|
4
|
+
sidebar_label: Installation
|
|
5
|
+
sidebar_position: 2
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
1. Add `.env` file (see `.env.example`).
|
|
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:
|
|
24
|
+
|
|
25
|
+
```
|
|
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
|
+
|
|
35
|
+
# Subgraph project folder
|
|
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
|
+
```
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Introduction
|
|
3
|
+
description: The Offchain Relayer is a service that allows users to vote on MACI polls free of charge.
|
|
4
|
+
sidebar_label: Introduction
|
|
5
|
+
sidebar_position: 1
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Coordinator Service
|
|
9
|
+
|
|
10
|
+
Welcome to the Offchain Relayer technical reference. Here you will find the technical details of the Offchain Relayer: how to set it up and and how to use it.
|
|
11
|
+
|
|
12
|
+
## Flow Diagram
|
|
13
|
+
|
|
14
|
+
Below is a high-level diagram illustrating the flow of the Relayer Service:
|
|
15
|
+
|
|
16
|
+

|
|
17
|
+
|
|
18
|
+
## High-Level Overview of the Relayer:
|
|
19
|
+
|
|
20
|
+
### Functionality
|
|
21
|
+
|
|
22
|
+
The Relayer serves as an intermediary between users and the MACI system. It performs the following tasks:
|
|
23
|
+
|
|
24
|
+
- Allows users to send messages without having to pay gas fees by processing these messages off-chain.
|
|
25
|
+
- Receives user messages.
|
|
26
|
+
- Prepare messages batches and upload it to IPFS
|
|
27
|
+
- Submits the message hashes to the Poll contract with IPFS hash of the batch.
|
|
28
|
+
|
|
29
|
+
This process ensures that user actions are recorded on-chain without compromising their privacy.
|
|
30
|
+
|
|
31
|
+
### Privacy Preservation
|
|
32
|
+
|
|
33
|
+
By verifying the zero-knowledge proofs, the Relayer ensures that only authorized users can send messages.
|
|
34
|
+
Users must know the pre-image to a state leaf in the poll state tree.
|
|
35
|
+
|
|
36
|
+
### Decentralization and Trust
|
|
37
|
+
|
|
38
|
+
It's recommended that the coordinator only runs this service for now. That is because if the service malfunctions and batch hashes are pushed on chain without the messages actually being stored on ipfs, then polls can't be finalized.
|
|
39
|
+
|
|
40
|
+
### Integration with MACI Components
|
|
41
|
+
|
|
42
|
+
The Relayer interacts with other components of the MACI system, such as the **Coordinator** and the on-chain smart contracts:
|
|
43
|
+
|
|
44
|
+
- The **Coordinator** fetches all the messages stored in IPFS and uses them as regular on-chain messages.
|
|
45
|
+
- This ensures that user messages are properly processed and recorded, contributing to the overall functionality and security of the voting protocol.
|
|
46
|
+
|
|
47
|
+
### Additional Information
|
|
48
|
+
|
|
49
|
+
For more details, you can read the following post on EthResearch:
|
|
50
|
+
|
|
51
|
+
[MACI with Mostly Off-Chain Happy Path](https://ethresear.ch/t/maci-with-mostly-off-chain-happy-path/19527)
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Installation and setup
|
|
3
|
+
description: Learn how to install and setup the Offchain Relayer service.
|
|
4
|
+
sidebar_label: Setup
|
|
5
|
+
sidebar_position: 2
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Prerequisites
|
|
9
|
+
|
|
10
|
+
Make sure you have the following tools installed on your system:
|
|
11
|
+
|
|
12
|
+
- **Docker**: [Install Docker](https://www.docker.com/products/docker-desktop)
|
|
13
|
+
- **Docker Compose**: [Install Docker Compose](https://docs.docker.com/compose/install/)
|
|
14
|
+
|
|
15
|
+
## Getting Started
|
|
16
|
+
|
|
17
|
+
Follow these steps to run the MACI Relayer service using Docker.
|
|
18
|
+
|
|
19
|
+
### 1. Clone the Repository
|
|
20
|
+
|
|
21
|
+
First, clone the repository to your local machine.
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
git clone https://github.com/privacy-scaling-explorations/maci
|
|
25
|
+
cd maci
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## 2. Configure Environment Variables
|
|
29
|
+
|
|
30
|
+
The `.env` file contains sensitive configuration values that will be injected into the Docker containers at runtime. To set them up:
|
|
31
|
+
|
|
32
|
+
1. Copy the `.env.example` file to `.env`.
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
cp .env.example .env
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
2. Edit the `.env` file and configure the variables.
|
|
39
|
+
|
|
40
|
+
## 3. Build and Run the Docker Containers
|
|
41
|
+
|
|
42
|
+
Now that your environment is set up, it's time to build and run the Docker containers.
|
|
43
|
+
|
|
44
|
+
Run the following command from the root directory of your project:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
docker-compose up --build
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
This command does the following:
|
|
51
|
+
|
|
52
|
+
- Builds the Docker images based on the Dockerfile and `docker-compose.yml` files.
|
|
53
|
+
- Starts the service container (the MACI relayer application) and the mongodb container.
|
|
54
|
+
|
|
55
|
+
The MACI Relayer service will be available on port 3000 by default (you can modify this in the `.env` file).
|
|
56
|
+
|
|
57
|
+
## 4. Access the Service
|
|
58
|
+
|
|
59
|
+
Once the containers are up and running, you can access the relayer service at:
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
http://localhost:3000
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Additionally, the Swagger UI documentation for the Relayer service API can be accessed at:
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
http://localhost:3000/api
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
You can interact with the API through the Swagger interface, which provides a convenient way to test endpoints and view the API methods.
|
|
72
|
+
|
|
73
|
+
## 5. Check Logs
|
|
74
|
+
|
|
75
|
+
To view the logs from the containers and troubleshoot any issues, run:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
docker-compose logs
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
This will display logs from both the service (relayer) and mongodb containers.
|
|
82
|
+
|
|
83
|
+
## 6. Stop the Services
|
|
84
|
+
|
|
85
|
+
To stop the containers and remove the containers (but keep the volumes), use the following command:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
docker-compose down
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
This will stop and remove the containers but retain the volumes (like MongoDB data). To also remove the volumes, run:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
docker-compose down --volumes
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## 7. MongoDB Persistence
|
|
98
|
+
|
|
99
|
+
MongoDB data is persisted using Docker volumes (`mongodb-data`). Even if you remove and recreate the MongoDB container, the data will persist.
|
|
100
|
+
|
|
101
|
+
This ensures that any data stored in the MongoDB database is not lost even if the container is restarted or removed.
|
|
102
|
+
|
|
103
|
+
If you'd like to remove the persisted data as well, you can remove the volume by running:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
docker volume rm your-repo_mongodb-data
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
This will delete the volume, along with all the data stored in MongoDB.
|
|
@@ -62,12 +62,12 @@ This function does the following:
|
|
|
62
62
|
- hashes the public key and inserts it into the state tree.
|
|
63
63
|
|
|
64
64
|
```ts
|
|
65
|
-
function signUp(
|
|
65
|
+
function signUp(PublicKey memory _publicKey, bytes memory _signUpPolicyData) public virtual {
|
|
66
66
|
// ensure we do not have more signups than what the circuits support
|
|
67
67
|
if (leanIMTData.size >= maxSignups) revert TooManySignups();
|
|
68
68
|
|
|
69
69
|
// ensure that the public key is on the baby jubjub curve
|
|
70
|
-
if (!CurveBabyJubJub.isOnCurve(
|
|
70
|
+
if (!CurveBabyJubJub.isOnCurve(_publicKey.x, _publicKey.y)) {
|
|
71
71
|
revert InvalidPubKey();
|
|
72
72
|
}
|
|
73
73
|
|
|
@@ -76,13 +76,13 @@ function signUp(PubKey memory _pubKey, bytes memory _signUpPolicyData) public vi
|
|
|
76
76
|
signUpPolicy.register(msg.sender, _signUpPolicyData);
|
|
77
77
|
|
|
78
78
|
// Hash the public key and insert it into the tree.
|
|
79
|
-
uint256 pubKeyHash = hashLeftRight(
|
|
79
|
+
uint256 pubKeyHash = hashLeftRight(_publicKey.x, _publicKey.y);
|
|
80
80
|
uint256 stateRoot = InternalLeanIMT._insert(leanIMTData, pubKeyHash);
|
|
81
81
|
|
|
82
82
|
// Store the current state tree root in the array
|
|
83
83
|
stateRootsOnSignUp.push(stateRoot);
|
|
84
84
|
|
|
85
|
-
emit SignUp(leanIMTData.size - 1, block.timestamp,
|
|
85
|
+
emit SignUp(leanIMTData.size - 1, block.timestamp, _publicKey.x, _publicKey.y);
|
|
86
86
|
}
|
|
87
87
|
```
|
|
88
88
|
|
|
@@ -156,5 +156,5 @@ Polls require the following information:
|
|
|
156
156
|
- `voteOptions`: the number of vote options for the poll
|
|
157
157
|
|
|
158
158
|
:::info
|
|
159
|
-
Please be advised that the number of signups in the MACI contract (number of leaves in the merkle tree holding MACI's state) considers the initial zero leaf as one signup. For this reason, when accounting for the real users signed up to MACI, you should subtract one from the value returned from the `
|
|
159
|
+
Please be advised that the number of signups in the MACI contract (number of leaves in the merkle tree holding MACI's state) considers the initial zero leaf as one signup. For this reason, when accounting for the real users signed up to MACI, you should subtract one from the value returned from the `totalSignups` function.
|
|
160
160
|
:::
|
|
@@ -26,7 +26,7 @@ The `joinPoll` function looks as follows:
|
|
|
26
26
|
/// @inheritdoc IPoll
|
|
27
27
|
function joinPoll(
|
|
28
28
|
uint256 _nullifier,
|
|
29
|
-
|
|
29
|
+
PublicKey calldata _publicKey,
|
|
30
30
|
uint256 _stateRootIndex,
|
|
31
31
|
uint256[8] calldata _proof,
|
|
32
32
|
bytes memory _signUpPolicyData,
|
|
@@ -41,7 +41,7 @@ The `joinPoll` function looks as follows:
|
|
|
41
41
|
pollNullifiers[_nullifier] = true;
|
|
42
42
|
|
|
43
43
|
// Verify user's proof
|
|
44
|
-
if (!verifyJoiningPollProof(_nullifier, _stateRootIndex,
|
|
44
|
+
if (!verifyJoiningPollProof(_nullifier, _stateRootIndex, _publicKey, _proof)) {
|
|
45
45
|
revert InvalidPollProof();
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -55,7 +55,7 @@ The `joinPoll` function looks as follows:
|
|
|
55
55
|
);
|
|
56
56
|
|
|
57
57
|
// Store user in the pollStateTree
|
|
58
|
-
uint256 stateLeaf = hashStateLeaf(StateLeaf(
|
|
58
|
+
uint256 stateLeaf = hashStateLeaf(StateLeaf(_publicKey, voiceCreditBalance, block.timestamp));
|
|
59
59
|
|
|
60
60
|
uint256 stateRoot = InternalLazyIMT._insert(pollStateTree, stateLeaf);
|
|
61
61
|
|
|
@@ -63,7 +63,7 @@ The `joinPoll` function looks as follows:
|
|
|
63
63
|
pollStateRootsOnJoin.push(stateRoot);
|
|
64
64
|
|
|
65
65
|
uint256 pollStateIndex = pollStateTree.numberOfLeaves - 1;
|
|
66
|
-
emit PollJoined(
|
|
66
|
+
emit PollJoined(_publicKey.x, _publicKey.y, voiceCreditBalance, block.timestamp, _nullifier, pollStateIndex);
|
|
67
67
|
}
|
|
68
68
|
```
|
|
69
69
|
|
|
@@ -72,7 +72,7 @@ The `joinPoll` function looks as follows:
|
|
|
72
72
|
The `publishMessage` function looks as follows:
|
|
73
73
|
|
|
74
74
|
```ts
|
|
75
|
-
function publishMessage(Message calldata _message,
|
|
75
|
+
function publishMessage(Message calldata _message, PublicKey calldata _encPubKey) public virtual isOpenForVoting {
|
|
76
76
|
// check if the public key is on the curve
|
|
77
77
|
if (!CurveBabyJubJub.isOnCurve(_encPubKey.x, _encPubKey.y)) {
|
|
78
78
|
revert InvalidPubKey();
|
|
@@ -84,7 +84,7 @@ function publishMessage(Message calldata _message, PubKey calldata _encPubKey) p
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
// compute current message hash
|
|
87
|
-
uint256 messageHash =
|
|
87
|
+
uint256 messageHash = hashMessageAndPublicKey(_message, _encPubKey);
|
|
88
88
|
|
|
89
89
|
// update current message chain hash
|
|
90
90
|
updateChainHash(messageHash);
|
|
@@ -96,7 +96,7 @@ function publishMessage(Message calldata _message, PubKey calldata _encPubKey) p
|
|
|
96
96
|
The `publishMessageBatch` function looks as follows:
|
|
97
97
|
|
|
98
98
|
```ts
|
|
99
|
-
function publishMessageBatch(Message[] calldata _messages,
|
|
99
|
+
function publishMessageBatch(Message[] calldata _messages, PublicKey[] calldata _encPubKeys) public virtual {
|
|
100
100
|
if (_messages.length != _encPubKeys.length) {
|
|
101
101
|
revert InvalidBatchLength();
|
|
102
102
|
}
|
|
@@ -16,14 +16,14 @@ This contract should be deployed alongside a `Poll`, with the the constructor ac
|
|
|
16
16
|
```ts
|
|
17
17
|
constructor(
|
|
18
18
|
address _verifier,
|
|
19
|
-
address
|
|
19
|
+
address _verifyingKeysRegistry,
|
|
20
20
|
address _poll,
|
|
21
21
|
address _mp,
|
|
22
22
|
address _tallyOwner,
|
|
23
23
|
Mode _mode
|
|
24
24
|
) payable {
|
|
25
25
|
verifier = IVerifier(_verifier);
|
|
26
|
-
vkRegistry = IVkRegistry(
|
|
26
|
+
vkRegistry = IVkRegistry(_verifyingKeysRegistry);
|
|
27
27
|
poll = IPoll(_poll);
|
|
28
28
|
messageProcessor = IMessageProcessor(_mp);
|
|
29
29
|
mode = _mode;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
---
|
|
2
|
-
title:
|
|
3
|
-
description:
|
|
4
|
-
sidebar_label:
|
|
2
|
+
title: VerifyingKeysRegistry Smart Contract
|
|
3
|
+
description: VerifyingKeysRegistry smart contract
|
|
4
|
+
sidebar_label: VerifyingKeysRegistry
|
|
5
5
|
sidebar_position: 8
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
:::info
|
|
9
|
-
Code location: [
|
|
9
|
+
Code location: [VerifyingKeysRegistry.sol](https://github.com/privacy-scaling-explorations/maci/blob/dev/contracts/contracts/VerifyingKeysRegistry.sol)
|
|
10
10
|
:::
|
|
11
11
|
|
|
12
|
-
The
|
|
12
|
+
The VerifyingKeysRegistry is a contract that holds the verifying keys for the zk-SNARK circuits. It holds four different sets of keys:
|
|
13
13
|
|
|
14
14
|
- `processVks` - The keys for the processMessages circuit
|
|
15
15
|
- `tallyVks` - The keys for the tallyVotes circuit
|
|
@@ -21,8 +21,8 @@ Users need to provide a valid proof to the Poll smart contract to join a poll, a
|
|
|
21
21
|
|
|
22
22
|
| Input signal | Description |
|
|
23
23
|
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
24
|
-
| `
|
|
25
|
-
| `
|
|
24
|
+
| `privateKey` | The user's private key |
|
|
25
|
+
| `pollPublicKey` | The poll's public key |
|
|
26
26
|
| `siblings` | The siblings for the merkle tree inclusion proof |
|
|
27
27
|
| `indices` | The indices for the merkle tree inclusion proof |
|
|
28
28
|
| `nullifier` | The nullifier |
|
|
@@ -44,9 +44,8 @@ Users will use this circuit to anonymously prove that they joined a poll. This c
|
|
|
44
44
|
|
|
45
45
|
| Input signal | Description |
|
|
46
46
|
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
47
|
-
| `
|
|
47
|
+
| `privateKey` | The user's private key |
|
|
48
48
|
| `voiceCreditsBalance` | The user's initial voice credits balance |
|
|
49
|
-
| `joinTimestamp` | The timestamp of when the user joined the poll |
|
|
50
49
|
| `pathElements` | The path elements for the merkle tree inclusion proof |
|
|
51
50
|
| `pathIndices` | The path indices for the merkle tree inclusion proof |
|
|
52
51
|
| `stateRoot` | The MACI state tree root |
|
package/versioned_docs/version-v3.x/technical-references/zk-snark-circuits/processMessages.md
CHANGED
|
@@ -7,7 +7,7 @@ sidebar_position: 3
|
|
|
7
7
|
|
|
8
8
|
[**Repo link**](https://github.com/privacy-scaling-explorations/maci/blob/dev/circuits/circom/core)
|
|
9
9
|
|
|
10
|
-
This circuit allows the coordinator to prove that they have correctly processed each message in reverse order, in a consecutive batch of 5 ^
|
|
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
12
|
The [`processMessages`](https://github.com/privacy-scaling-explorations/maci/blob/dev/circuits/circom/core/qv/processMessages.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:
|
|
@@ -36,17 +36,17 @@ A version working with non quadratic voting (non-qv) is also [available](https:/
|
|
|
36
36
|
|
|
37
37
|
| Input signal | Description |
|
|
38
38
|
| -------------------------------- | --------------------------------------------------------------------------------------- |
|
|
39
|
-
| `
|
|
39
|
+
| `totalSignups` | Number of users that have completed the sign up |
|
|
40
40
|
| `index` | The batch index of current message batch |
|
|
41
41
|
| `pollEndTimestamp` | The Unix timestamp at which the poll ends |
|
|
42
|
-
| `
|
|
43
|
-
| `
|
|
44
|
-
| `
|
|
42
|
+
| `messageRoot` | The root of the message tree |
|
|
43
|
+
| `messages` | The batch of messages as an array of arrays |
|
|
44
|
+
| `messageSubrootPathElements` | As described below |
|
|
45
45
|
| `coordinatorPublicKeyHash` | $\mathsf{poseidon_2}([cPk_x, cPk_y])$ |
|
|
46
46
|
| `newSbCommitment` | As described below |
|
|
47
|
-
| `
|
|
47
|
+
| `coordinatorPrivateKey` | The coordinator's private key |
|
|
48
48
|
| `batchEndIndex` | The last batch index |
|
|
49
|
-
| `
|
|
49
|
+
| `encryptionPublicKeys` | The public keys used to generate shared ECDH encryption keys to encrypt the messages |
|
|
50
50
|
| `currentStateRoot` | The state root before the commands are applied |
|
|
51
51
|
| `currentStateLeaves` | The state leaves upon which messages are applied |
|
|
52
52
|
| `currentStateLeavesPathElements` | The Merkle path to each incremental state root |
|
|
@@ -74,9 +74,9 @@ The salt used to produce `currentSbCommitment` (see above).
|
|
|
74
74
|
|
|
75
75
|
The salt used to produce `newSbCommitment` (see above).
|
|
76
76
|
|
|
77
|
-
##### `
|
|
77
|
+
##### `messageSubrootPathElements`
|
|
78
78
|
|
|
79
|
-
The index of each message in `
|
|
79
|
+
The index of each message in `messages` is consecutive. As such, in order to prove that each message in `messages` is indeed a leaf of the message tree, we compute the subtree root of `messages`, and then verify that the subtree root is indeed a subroot of `messageRoot`.
|
|
80
80
|
|
|
81
81
|
A simplified example using a tree of arity 2:
|
|
82
82
|
|
|
@@ -100,7 +100,7 @@ This method requires fewer circuit constraints than if we verified a Merkle proo
|
|
|
100
100
|
|
|
101
101
|
1. That the prover knows the preimage to `currentSbCommitment` (that is, the state root, ballot root, and `currentSbSalt`)
|
|
102
102
|
2. That `maxVoteOptions <= (5 ^ voteOptionTreeDepth)`
|
|
103
|
-
3. That `
|
|
104
|
-
4. That `coordinatorPublicKeyHash` is a hash of public key that is correctly derived from `
|
|
105
|
-
5. That each message in `
|
|
103
|
+
3. That `totalSignups <= (2 ^ stateTreeDepth)`
|
|
104
|
+
4. That `coordinatorPublicKeyHash` is a hash of public key that is correctly derived from `coordinatorPrivateKey`
|
|
105
|
+
5. That each message in `messages` exists in the message tree
|
|
106
106
|
6. That after decrypting and applying each message, in reverse order, to the corresponding state and ballot leaves, the new state root, new ballot root, and `newSbSalt` are the preimage to `newSbCommitment`
|
|
@@ -25,7 +25,7 @@ A version working with non quadratic voting (non-qv) is also [available](https:/
|
|
|
25
25
|
|
|
26
26
|
| Input signal | Description |
|
|
27
27
|
| --------------------------------------- | ---------------------------------------------------------------- |
|
|
28
|
-
| `
|
|
28
|
+
| `totalSignups` | The number of users that signup |
|
|
29
29
|
| `index` | Start index of given batch |
|
|
30
30
|
| `sbCommitment` | Described below |
|
|
31
31
|
| `currentTallyCommitment` | Described below |
|
|
@@ -72,7 +72,7 @@ $poseidon_3([tc_r, tc_t, tc_p])$
|
|
|
72
72
|
#### Statements that the circuit proves
|
|
73
73
|
|
|
74
74
|
1. That the coordinator knows the preimage of `sbCommitment`
|
|
75
|
-
2. That `index` is less than or equal to `
|
|
75
|
+
2. That `index` is less than or equal to `totalSignups`
|
|
76
76
|
3. That each ballot in `ballots` is in a member of the ballot tree with the Merkle root `ballotRoot` at indices `batchStartIndex` to `batchStartIndex + (5 ** intStateTreeDepth)`
|
|
77
77
|
4. That each set of votes (`votes[i]`) has the Merkle root $blt_r$ whose value equals `ballots[i][1]`
|
|
78
78
|
5. That the tally is valid, which is:
|