@maci-protocol/website 0.0.0-ci.fd5247e → 0.0.0-ci.ffabe48
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/docusaurus.config.ts +2 -2
- package/package.json +4 -4
- package/static/img/circuits/MACI-Circuits.excalidraw +44 -44
- package/static/img/circuits/processMessages.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/quinBatchLeavesExists.svg +1 -1
- package/static/img/circuits/quinCheckRoot.svg +1 -1
- package/static/img/circuits/quinGeneratePathIndices.svg +1 -1
- package/static/img/circuits/quinSelector.svg +1 -1
- package/static/img/circuits/resultsCommitmentVerifier.svg +1 -1
- package/static/img/circuits/splicer.svg +1 -1
- package/static/img/circuits/tallyVotes.svg +1 -1
- package/versioned_docs/version-v0.x/quadratic-vote-tallying-circuit.md +16 -16
- package/versioned_docs/version-v3.x/core-concepts/poll-types.md +31 -7
- package/versioned_docs/version-v3.x/core-concepts/polls.md +31 -7
- package/versioned_docs/version-v3.x/core-concepts/spec.md +6 -6
- package/versioned_docs/version-v3.x/guides/compile-circuits.md +23 -7
- package/versioned_docs/version-v3.x/guides/integrating.md +1 -1
- package/versioned_docs/version-v3.x/guides/testing/testing-introduction.md +7 -1
- package/versioned_docs/version-v3.x/quick-start.md +23 -15
- package/versioned_docs/version-v3.x/security/audit.md +2 -2
- package/versioned_docs/version-v3.x/supported-networks/deployed-contracts.md +7 -7
- package/versioned_docs/version-v3.x/technical-references/smart-contracts/MACI.md +2 -2
- 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 +2 -2
- 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 +2 -2
- package/versioned_docs/version-v3.x/technical-references/smart-contracts/VkRegistry.md +2 -2
- package/versioned_docs/version-v3.x/technical-references/zk-snark-circuits/processMessages.md +7 -3
- package/versioned_docs/version-v3.x/technical-references/zk-snark-circuits/setup.md +1 -1
- 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 +6 -6
- package/versioned_docs/version-v3.x/technical-references/zk-snark-circuits/zk-snark-circuits.md +3 -3
|
@@ -5,25 +5,25 @@ sidebar_label: Poll types
|
|
|
5
5
|
sidebar_position: 9
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
MACI allows to conduct polls in both a quadratic voting and non quadratic voting fashion. One should be aware that the only distinction between the two happens when messages are processed and votes tallied. On top of that, the Tally smart contract has been split into two different ones, with the non quadratic voting version one being slightly smaller, due to the need of one less function.
|
|
8
|
+
MACI allows to conduct polls in both a quadratic voting and non quadratic voting fashion. One should be aware that the only distinction between the two happens when messages are processed and votes tallied. On top of that, the Tally smart contract has been split into two different ones, with the non quadratic voting version one being slightly smaller, due to the need of one less function. Additionally, there is a variation of non quadratic voting that allows participants to cast their entire voice credit balance for a single option only.
|
|
9
9
|
|
|
10
10
|
This document will explain how to use each of these options. Hardhat tasks are the currently recommended way to deploy contracts and run polls but you can also use the MACI cli.
|
|
11
11
|
|
|
12
12
|
## Quadratic Voting
|
|
13
13
|
|
|
14
|
-
MACI has always worked with quadratic voting. Users signing up to MACI are assigned a number of voice credits based on certain conditions (enforced by the [initial voice credit proxy contract](https://github.com/privacy-scaling-explorations/maci/blob/dev/contracts/contracts/initialVoiceCreditProxy/
|
|
14
|
+
MACI has always worked with quadratic voting. Users signing up to MACI are assigned a number of voice credits based on certain conditions (enforced by the [initial voice credit proxy contract](https://github.com/privacy-scaling-explorations/maci/blob/dev/packages/contracts/contracts/initialVoiceCreditProxy/ConstantInitialVoiceCreditProxy.sol)), and after each vote, the number of voice credits is reduced by the square of the weight of the vote casted. For instance, if the vote weight is 5, a user must have at least 25 voice credits to cast the vote.
|
|
15
15
|
|
|
16
16
|
To run a poll with quadratic voting, the coordinator must deploy the Poll with the mode set to quadratic voting.
|
|
17
17
|
|
|
18
18
|
### Using Hardhat tasks
|
|
19
19
|
|
|
20
|
-
In the deploy-config.json file set the `
|
|
20
|
+
In the deploy-config.json file set the `mode` value to **qv**.
|
|
21
21
|
|
|
22
22
|
```json
|
|
23
23
|
"Poll": {
|
|
24
24
|
"pollDuration": 604800,
|
|
25
25
|
"coordinatorPublicKey": "macipk",
|
|
26
|
-
"
|
|
26
|
+
"mode": "qv"
|
|
27
27
|
}
|
|
28
28
|
```
|
|
29
29
|
|
|
@@ -37,17 +37,41 @@ pnpm deploy-poll:NETWORK
|
|
|
37
37
|
|
|
38
38
|
The non quadratic voting option is a new feature that has been added to MACI with the v1.2 release. It allows to conduct polls without the quadratic voting mechanism. This means that the number of voice credits is not reduced by the square of the weight of the vote casted. This option is useful for polls where the quadratic voting mechanism is not necessary, and it is also slightly cheaper for coordinators to tally votes, as there are less checks required in the Tally smart contract.
|
|
39
39
|
|
|
40
|
-
To run a poll with non quadratic voting, the coordinator must set the `
|
|
40
|
+
To run a poll with non quadratic voting, the coordinator must set the `mode` parameter to `non-qv` when creating the MACI instance. This will make the MACI instance use the `TallyNonQv` smart contract, which is a smaller version of the `Tally` smart contract, as it does not require the checks for the quadratic voting mechanism.
|
|
41
41
|
|
|
42
42
|
### Using Hardhat tasks
|
|
43
43
|
|
|
44
|
-
In the deploy-config.json file set the `
|
|
44
|
+
In the deploy-config.json file set the `mode` value to **non-qv**.
|
|
45
45
|
|
|
46
46
|
```json
|
|
47
47
|
"Poll": {
|
|
48
48
|
"pollDuration": 604800,
|
|
49
49
|
"coordinatorPublicKey": "macipk",
|
|
50
|
-
"
|
|
50
|
+
"mode": "non-qv"
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Then run the task to create a poll:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pnpm deploy-poll:NETWORK
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Full Credits Voting
|
|
61
|
+
|
|
62
|
+
Full Credits Voting is a new feature introduced in MACI v3. This voting mode disables the quadratic voting mechanism and requires participants to allocate their entire voice credit balance to a single option. Unlike quadratic voting, where the cost of votes increases quadratically with the number of votes cast, Full Credits Voting uses a linear model: participants spend all their available voice credits on one chosen option. No splitting across multiple options is allowed. This option is useful for polls where the quadratic voting mechanism is not necessary and where it's important to ensure voters fully commit to a single choice—eliminating fragmented or spread-out voting behavior. It also offers a slight cost advantage for coordinators, as tallying is more efficient with fewer checks required in the Tally smart contract.
|
|
63
|
+
|
|
64
|
+
To run a poll full credits voting, the coordinator must set the `mode` parameter to `full` when creating the MACI instance. This will make the MACI instance use the `TallyNonQv` smart contract, which is a smaller version of the `Tally` smart contract, as it does not require the checks for the quadratic voting mechanism.
|
|
65
|
+
|
|
66
|
+
### Using Hardhat tasks
|
|
67
|
+
|
|
68
|
+
In the deploy-config.json file set the `mode` value to **full**.
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
"Poll": {
|
|
72
|
+
"pollDuration": 604800,
|
|
73
|
+
"coordinatorPublicKey": "macipk",
|
|
74
|
+
"mode": "full"
|
|
51
75
|
}
|
|
52
76
|
```
|
|
53
77
|
|
|
@@ -11,7 +11,7 @@ Currently, you can configure the following parameters for a poll:
|
|
|
11
11
|
|
|
12
12
|
- Poll duration, in the form of a unix timestamp for start and end times. This allows polls to be scheduled to start at a certain time, and run for a certain amount of time.
|
|
13
13
|
- Vote option - how many vote options are allowed for a poll.
|
|
14
|
-
- Vote mode - quadratic
|
|
14
|
+
- Vote mode - quadratic, non quadratic, full credits voting. One should be aware that the only distinction between them happens when messages are processed and votes tallied.
|
|
15
15
|
- Policy - the Excubiae policy that will be used to gate access to the poll.
|
|
16
16
|
- Initial voice credit proxy - the initial voice credit proxy that will be used to assign voice credits to voters.
|
|
17
17
|
- Relayer - the list of addresses that will be able to relay messages on behalf of other users (for now this is recommended to be the coordinator only)
|
|
@@ -34,19 +34,19 @@ The full configuration for a poll looks like this:
|
|
|
34
34
|
|
|
35
35
|
## Quadratic Voting
|
|
36
36
|
|
|
37
|
-
MACI has always worked with quadratic voting. Users joining a Poll are assigned a number of voice credits based on certain conditions (enforced by the [initial voice credit proxy contract](https://github.com/privacy-scaling-explorations/maci/blob/dev/contracts/contracts/initialVoiceCreditProxy/
|
|
37
|
+
MACI has always worked with quadratic voting. Users joining a Poll are assigned a number of voice credits based on certain conditions (enforced by the [initial voice credit proxy contract](https://github.com/privacy-scaling-explorations/maci/blob/dev/packages/contracts/contracts/initialVoiceCreditProxy/ConstantInitialVoiceCreditProxy.sol)), and after each vote, the number of voice credits is reduced by the square of the weight of the vote casted. For instance, if the vote weight is 5, a user must have at least 25 voice credits to cast the vote.
|
|
38
38
|
|
|
39
39
|
To run a poll with quadratic voting, the coordinator must deploy the Poll with the mode set to quadratic voting.
|
|
40
40
|
|
|
41
41
|
### Using Hardhat tasks
|
|
42
42
|
|
|
43
|
-
In the deploy-config.json file set the `
|
|
43
|
+
In the deploy-config.json file set the `mode` value to **qv**.
|
|
44
44
|
|
|
45
45
|
```json
|
|
46
46
|
"Poll": {
|
|
47
47
|
[...]
|
|
48
48
|
"coordinatorPublicKey": "macipk",
|
|
49
|
-
"
|
|
49
|
+
"mode": "qv"
|
|
50
50
|
}
|
|
51
51
|
```
|
|
52
52
|
|
|
@@ -60,17 +60,41 @@ pnpm deploy-poll:NETWORK
|
|
|
60
60
|
|
|
61
61
|
The non quadratic voting option is a new feature that has been added to MACI with the v1.2 release. It allows to conduct polls without the quadratic voting mechanism. This means that the number of voice credits is not reduced by the square of the weight of the vote casted. This option is useful for polls where the quadratic voting mechanism is not necessary, and it is also slightly cheaper for coordinators to tally votes, as there are less checks required in the Tally smart contract.
|
|
62
62
|
|
|
63
|
-
To run a poll with non quadratic voting, the coordinator must set the `
|
|
63
|
+
To run a poll with non quadratic voting, the coordinator must set the `mode` parameter to `non-qv` when creating the MACI instance.
|
|
64
64
|
|
|
65
65
|
### Using Hardhat tasks
|
|
66
66
|
|
|
67
|
-
In the deploy-config.json file set the `
|
|
67
|
+
In the deploy-config.json file set the `mode` value to **non-qv**.
|
|
68
68
|
|
|
69
69
|
```json
|
|
70
70
|
"Poll": {
|
|
71
71
|
[...]
|
|
72
72
|
"coordinatorPublicKey": "macipk",
|
|
73
|
-
"
|
|
73
|
+
"mode": "non-qv"
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Then run the task to create a poll:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
pnpm deploy-poll:NETWORK
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Full Credits Voting
|
|
84
|
+
|
|
85
|
+
Full Credits Voting is a new feature introduced in MACI v3. This voting mode disables the quadratic voting mechanism and requires participants to allocate their entire voice credit balance to a single option. Unlike quadratic voting, where the cost of votes increases quadratically with the number of votes cast, Full Credits Voting uses a linear model: participants spend all their available voice credits on one chosen option. No splitting across multiple options is allowed. This option is useful for polls where the quadratic voting mechanism is not necessary and where it's important to ensure voters fully commit to a single choice—eliminating fragmented or spread-out voting behavior. It also offers a slight cost advantage for coordinators, as tallying is more efficient with fewer checks required in the Tally smart contract.
|
|
86
|
+
|
|
87
|
+
To run a poll with full credits voting, the coordinator must set the `mode` parameter to `full` when creating the MACI instance.
|
|
88
|
+
|
|
89
|
+
### Using Hardhat tasks
|
|
90
|
+
|
|
91
|
+
In the deploy-config.json file set the `mode` value to **full**.
|
|
92
|
+
|
|
93
|
+
```json
|
|
94
|
+
"Poll": {
|
|
95
|
+
[...]
|
|
96
|
+
"coordinatorPublicKey": "macipk",
|
|
97
|
+
"mode": "full"
|
|
74
98
|
}
|
|
75
99
|
```
|
|
76
100
|
|
|
@@ -751,11 +751,11 @@ The coordinator uses the ballot tallying circuit (`tallyVotes.circom`) to genera
|
|
|
751
751
|
|
|
752
752
|
#### Parameters
|
|
753
753
|
|
|
754
|
-
| Parameter
|
|
755
|
-
|
|
|
756
|
-
| `stateTreeDepth`
|
|
757
|
-
| `
|
|
758
|
-
| `voteOptionTreeDepth`
|
|
754
|
+
| Parameter | Description |
|
|
755
|
+
| ------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
|
|
756
|
+
| `stateTreeDepth` | Depth of the state tree, this value must be equal to `10` |
|
|
757
|
+
| `tallyProcessingStateTreeDepth` | Depth of the intermediate state tree, `5 ** tallyProcessingStateTreeDepth` is the batch size |
|
|
758
|
+
| `voteOptionTreeDepth` | Depth of the vote option tree, this must be the same value passed to the `deployPoll()` contract function of `MACI.sol` |
|
|
759
759
|
|
|
760
760
|
#### Input signals
|
|
761
761
|
|
|
@@ -809,7 +809,7 @@ $\mathsf{poseidon_3}([tc_r, tc_t, tc_p])$
|
|
|
809
809
|
|
|
810
810
|
1. That the coordinator knows the preimage of `sbCommitment` (see above)
|
|
811
811
|
2. That `index` is less than or equal to `totalSignups`
|
|
812
|
-
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 **
|
|
812
|
+
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 ** tallyProcessingStateTreeDepth)`
|
|
813
813
|
4. That each set of votes (`votes[i]`) has the Merkle root $blt_r$ whose value equals `ballots[i][1]`
|
|
814
814
|
5. That the tally is valid, which is:
|
|
815
815
|
- That the sum of votes per vote option is correct
|
|
@@ -77,24 +77,24 @@ Remember that if on a ARM64 chip, you will not be able to compile the c++ witnes
|
|
|
77
77
|
|
|
78
78
|
### Configure circomkit
|
|
79
79
|
|
|
80
|
-
Edit `circuits/circom/circuits` to include the circuits you would like to compile. This comes already configured with the
|
|
80
|
+
Edit `circuits/circom/circuits` to include the circuits you would like to compile. This comes already configured with the main coordinator circuits, in qv, non qv and full credits variants, as well as the client side circuit. The parameters are designed to support testing use cases:
|
|
81
81
|
|
|
82
82
|
```json
|
|
83
83
|
{
|
|
84
84
|
"PollJoining_10_test": {
|
|
85
|
-
"file": "./
|
|
85
|
+
"file": "./voter/PollJoining",
|
|
86
86
|
"template": "PollJoining",
|
|
87
87
|
"params": [10],
|
|
88
88
|
"pubs": ["nullifier", "stateRoot", "pollPublicKey", "pollId"]
|
|
89
89
|
},
|
|
90
90
|
"PollJoined_10_test": {
|
|
91
|
-
"file": "./
|
|
91
|
+
"file": "./voter/PollJoined",
|
|
92
92
|
"template": "PollJoined",
|
|
93
93
|
"params": [10],
|
|
94
94
|
"pubs": ["stateRoot"]
|
|
95
95
|
},
|
|
96
96
|
"ProcessMessages_10-20-2_test": {
|
|
97
|
-
"file": "./
|
|
97
|
+
"file": "./coordinator/qv/processMessages",
|
|
98
98
|
"template": "ProcessMessages",
|
|
99
99
|
"params": [10, 20, 2],
|
|
100
100
|
"pubs": [
|
|
@@ -110,7 +110,7 @@ Edit `circuits/circom/circuits` to include the circuits you would like to compil
|
|
|
110
110
|
]
|
|
111
111
|
},
|
|
112
112
|
"ProcessMessagesNonQv_10-20-2_test": {
|
|
113
|
-
"file": "./
|
|
113
|
+
"file": "./coordinator/non-qv/processMessages",
|
|
114
114
|
"template": "ProcessMessagesNonQv",
|
|
115
115
|
"params": [10, 20, 2],
|
|
116
116
|
"pubs": [
|
|
@@ -125,14 +125,30 @@ Edit `circuits/circom/circuits` to include the circuits you would like to compil
|
|
|
125
125
|
"voteOptions"
|
|
126
126
|
]
|
|
127
127
|
},
|
|
128
|
+
"ProcessMessagesFull_10-20-2_test": {
|
|
129
|
+
"file": "./coordinator/non-qv/MessageProcessor",
|
|
130
|
+
"template": "MessageProcessorFull",
|
|
131
|
+
"params": [10, 20, 2],
|
|
132
|
+
"pubs": [
|
|
133
|
+
"totalSignups",
|
|
134
|
+
"index",
|
|
135
|
+
"batchEndIndex",
|
|
136
|
+
"currentSbCommitment",
|
|
137
|
+
"newSbCommitment",
|
|
138
|
+
"outputBatchHash",
|
|
139
|
+
"actualStateTreeDepth",
|
|
140
|
+
"coordinatorPublicKeyHash",
|
|
141
|
+
"voteOptions"
|
|
142
|
+
]
|
|
143
|
+
},
|
|
128
144
|
"TallyVotes_10-1-2_test": {
|
|
129
|
-
"file": "./
|
|
145
|
+
"file": "./coordinator/qv/tallyVotes",
|
|
130
146
|
"template": "TallyVotes",
|
|
131
147
|
"params": [10, 1, 2],
|
|
132
148
|
"pubs": ["index", "totalSignups", "sbCommitment", "currentTallyCommitment", "newTallyCommitment"]
|
|
133
149
|
},
|
|
134
150
|
"TallyVotesNonQv_10-1-2_test": {
|
|
135
|
-
"file": "./
|
|
151
|
+
"file": "./coordinator/non-qv/tallyVotes",
|
|
136
152
|
"template": "TallyVotesNonQv",
|
|
137
153
|
"params": [10, 1, 2],
|
|
138
154
|
"pubs": ["index", "totalSignups", "sbCommitment", "currentTallyCommitment", "newTallyCommitment"]
|
|
@@ -43,7 +43,7 @@ function signUp(PublicKey memory _publicKey, bytes memory _signUpPolicyData) pub
|
|
|
43
43
|
|
|
44
44
|
## InitialVoiceCreditProxy
|
|
45
45
|
|
|
46
|
-
If you'd like to extend the functionality of how votes are distributed among users, you need to
|
|
46
|
+
If you'd like to extend the functionality of how votes are distributed among users, you'll need to build you own initial voice credit proxy contract by following the [IInitialVoiceCreditProxy interface](https://github.com/privacy-scaling-explorations/maci/blob/dev/packages/contracts/contracts/interfaces/IInitialVoiceCreditProxy.sol). You can see our [basic example](https://github.com/privacy-scaling-explorations/maci/blob/dev/packages/contracts/contracts/initialVoiceCreditProxy/ConstantInitialVoiceCreditProxy.sol) how it's implemented for constant distribution.
|
|
47
47
|
|
|
48
48
|
```ts
|
|
49
49
|
contract ConstantInitialVoiceCreditProxy is InitialVoiceCreditProxy {
|
|
@@ -74,7 +74,7 @@ or download them. Please remember to not use these testing `.zkey` files in prod
|
|
|
74
74
|
MACI has two main zk-SNARK circuits, `processMessages` and `tallyVotes`.
|
|
75
75
|
|
|
76
76
|
:::info
|
|
77
|
-
The `processMessages` and `tallyVotes` circuits are also provided in a non-quadratic voting (non-QV)
|
|
77
|
+
The `processMessages` and `tallyVotes` circuits are also provided in a non-quadratic voting (non-QV) and in a full credits voting (full) versions. Currently these new versions have not undergone a trusted setup ceremony.
|
|
78
78
|
:::
|
|
79
79
|
|
|
80
80
|
Each circuit is parameterised and there should be one
|
|
@@ -151,6 +151,12 @@ To run e2e tests with normal voting (not quadratic voting):
|
|
|
151
151
|
pnpm run test:e2e-non-qv
|
|
152
152
|
```
|
|
153
153
|
|
|
154
|
+
To run e2e tests with full credits voting (full):
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
pnpm run test:e2e-full
|
|
158
|
+
```
|
|
159
|
+
|
|
154
160
|
To run integration tests:
|
|
155
161
|
|
|
156
162
|
```bash
|
|
@@ -135,16 +135,16 @@ For testing we suggest using the **FreeForAlPolicy** as it allows anyone to sign
|
|
|
135
135
|
|
|
136
136
|
The VerifyingKeysRegistry hold the verifying keys used to verify the proofs, on the zkeys field we define the path to the zero knowledge artifacts we downloaded in the previous steps.
|
|
137
137
|
|
|
138
|
-
| Property
|
|
139
|
-
|
|
|
140
|
-
| **stateTreeDepth**
|
|
141
|
-
| **
|
|
142
|
-
| **messageTreeDepth**
|
|
143
|
-
| **voteOptionTreeDepth**
|
|
144
|
-
| **messageBatchDepth**
|
|
145
|
-
| **zkeys**
|
|
146
|
-
| **pollJoiningZkey**
|
|
147
|
-
| **pollJoinedZkey**
|
|
138
|
+
| Property | Description |
|
|
139
|
+
| --------------------------------- | ------------------------------------------------------------------------------------ |
|
|
140
|
+
| **stateTreeDepth** | Defines how many users the system supports. |
|
|
141
|
+
| **tallyProcessingStateTreeDepth** | Defines how many ballots can be processed per batch when tallying the results. |
|
|
142
|
+
| **messageTreeDepth** | Defines how many messages (votes) the system supports. |
|
|
143
|
+
| **voteOptionTreeDepth** | Defines how many vote options the system supports. |
|
|
144
|
+
| **messageBatchDepth** | Defines how many messages in a batch can the circuit process. |
|
|
145
|
+
| **zkeys** | Defines the path to the zkey files for QV, Non QV and Full Credits keys. |
|
|
146
|
+
| **pollJoiningZkey** | Defines the zkey to the poll joining circuit which allows to join polls for voting. |
|
|
147
|
+
| **pollJoinedZkey** | Defines the zkey to the poll joined circuit which allows to prove you joined a poll. |
|
|
148
148
|
|
|
149
149
|
:::important
|
|
150
150
|
The recommended values for test keys are: **10-1-2-2-1**. For ceremony keys: **14-5-9-3-2**.
|
|
@@ -203,6 +203,10 @@ As a coordinator, first you need to merge signups and messages (votes). This opt
|
|
|
203
203
|
pnpm merge:[network] --poll [poll-id]
|
|
204
204
|
```
|
|
205
205
|
|
|
206
|
+
:::info
|
|
207
|
+
`poll-id` starts at 0 and increments for each deployed poll
|
|
208
|
+
:::
|
|
209
|
+
|
|
206
210
|
Then you need to generate the proofs for the message processing, and tally calculations. This allows to publish the poll results on-chain and then everyone can verify the results:
|
|
207
211
|
|
|
208
212
|
```bash
|
|
@@ -210,12 +214,16 @@ pnpm run prove:[network] --poll [poll-id] \
|
|
|
210
214
|
--coordinator-private-key [coordinator-maci-private-key] \
|
|
211
215
|
--tally-file ../results/tally.json \
|
|
212
216
|
--output-dir ../results/proofs/ \
|
|
213
|
-
--start-block [block-number]
|
|
217
|
+
--start-block [block-number] \
|
|
214
218
|
--blocks-per-batch [number-of-blocks]
|
|
215
219
|
```
|
|
216
220
|
|
|
217
|
-
:::
|
|
218
|
-
|
|
221
|
+
:::info
|
|
222
|
+
The `--coordinator-private-key` is the one you generated earlier with `pnpm run generateMaciKeyPair`.
|
|
223
|
+
|
|
224
|
+
`--start-block` is the block number from which to start looking for events from. You can use the block that you deployed the contracts in.
|
|
225
|
+
|
|
226
|
+
You can reduce the time of the proving by including more blocks per batch with `--blocks-per-batch`, you can try with 500.
|
|
219
227
|
:::
|
|
220
228
|
|
|
221
229
|
#### Submit On-chain
|
|
@@ -224,8 +232,8 @@ Now it's time to submit the poll results on-chain so that everyone can verify th
|
|
|
224
232
|
|
|
225
233
|
```bash
|
|
226
234
|
pnpm submitOnChain:[network] --poll [poll-id] \
|
|
227
|
-
--output-dir proofs/ \
|
|
228
|
-
--tally-file
|
|
235
|
+
--output-dir ../results/proofs/ \
|
|
236
|
+
--tally-file ../results/tally.json
|
|
229
237
|
```
|
|
230
238
|
|
|
231
239
|
### Tally
|
|
@@ -38,7 +38,7 @@ We would like to thank the Veridise team for their effort in keeping open source
|
|
|
38
38
|
|
|
39
39
|
**Description**
|
|
40
40
|
|
|
41
|
-
In the template `
|
|
41
|
+
In the template `QuinarySelector`, if you want to confirm the input signal index is a valid integer less than 2\*\*3, you should add Num2bits(3) to check it.
|
|
42
42
|
|
|
43
43
|
**Code Location**
|
|
44
44
|
|
|
@@ -119,7 +119,7 @@ greaterThan[i].in[1] <== index;
|
|
|
119
119
|
|
|
120
120
|
**Description**
|
|
121
121
|
|
|
122
|
-
In the template `
|
|
122
|
+
In the template `QuinaryGeneratePathIndices`, the constraints of the `signal n[levels + 1]` don't perform well for division and modulo counting.
|
|
123
123
|
|
|
124
124
|
**Code Location**
|
|
125
125
|
|
|
@@ -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/dev/contracts/contracts/VerifyingKeysRegistry.sol)
|
|
11
|
-
- [PoseidonHashers](https://github.com/privacy-scaling-explorations/maci/blob/dev/contracts/contracts/crypto/Hasher.sol)
|
|
12
|
-
- [PollFactory](https://github.com/privacy-scaling-explorations/maci/blob/dev/contracts/contracts/PollFactory.sol)
|
|
13
|
-
- [MessageProcessorFactory](https://github.com/privacy-scaling-explorations/maci/blob/dev/contracts/contracts/MessageProcessorFactory.sol)
|
|
14
|
-
- [TallyFactory](https://github.com/privacy-scaling-explorations/maci/blob/dev/contracts/contracts/TallyFactory.sol)
|
|
15
|
-
- [Verifier](https://github.com/privacy-scaling-explorations/maci/blob/dev/contracts/contracts/crypto/Verifier.sol)
|
|
10
|
+
- [VerifyingKeysRegistry](https://github.com/privacy-scaling-explorations/maci/blob/dev/packages/contracts/contracts/VerifyingKeysRegistry.sol)
|
|
11
|
+
- [PoseidonHashers](https://github.com/privacy-scaling-explorations/maci/blob/dev/packages/contracts/contracts/crypto/Hasher.sol)
|
|
12
|
+
- [PollFactory](https://github.com/privacy-scaling-explorations/maci/blob/dev/packages/contracts/contracts/PollFactory.sol)
|
|
13
|
+
- [MessageProcessorFactory](https://github.com/privacy-scaling-explorations/maci/blob/dev/packages/contracts/contracts/MessageProcessorFactory.sol)
|
|
14
|
+
- [TallyFactory](https://github.com/privacy-scaling-explorations/maci/blob/dev/packages/contracts/contracts/TallyFactory.sol)
|
|
15
|
+
- [Verifier](https://github.com/privacy-scaling-explorations/maci/blob/dev/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/dev/contracts/contracts/initialVoiceCreditProxy/ConstantInitialVoiceCreditProxy.sol) - if you are happy to work with a fixed amount of credits
|
|
17
|
+
- [ConstantInitialVoiceCreditProxy](https://github.com/privacy-scaling-explorations/maci/blob/dev/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
|
|
|
@@ -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/dev/contracts/contracts/MACI.sol)
|
|
9
|
+
Code location: [MACI.sol](https://github.com/privacy-scaling-explorations/maci/blob/dev/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.
|
|
@@ -149,7 +149,7 @@ Polls require the following information:
|
|
|
149
149
|
- `coordinatorPubKey`: the public key of the poll's coordinator
|
|
150
150
|
- `verifier`: the address of the zk-SNARK verifier contract
|
|
151
151
|
- `vkRegistry`: the address of the vk registry contract
|
|
152
|
-
- `mode`: the mode of the poll, to set whether it supports quadratic voting
|
|
152
|
+
- `mode`: the mode of the poll, to set whether it supports quadratic voting, non quadratic voting, full credits voting
|
|
153
153
|
- `signUpPolicy`: the address of the sign up policy contract
|
|
154
154
|
- `initialVoiceCreditProxy`: the address of the initial voice credit proxy contract
|
|
155
155
|
- `relayers`: the addresses of the relayers for the poll (if offchain voting is enabled)
|
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/dev/contracts/contracts/MessageProcessor.sol)
|
|
9
|
+
Code location: [MessageProcessor.sol](https://github.com/privacy-scaling-explorations/maci/blob/dev/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/dev/contracts/contracts/
|
|
9
|
+
Code location: [Params.sol](https://github.com/privacy-scaling-explorations/maci/blob/dev/packages/contracts/contracts/utilities/Params.sol)
|
|
10
10
|
:::
|
|
11
11
|
|
|
12
12
|
A contract holding three structs:
|
|
@@ -14,7 +14,7 @@ A contract holding three structs:
|
|
|
14
14
|
```ts
|
|
15
15
|
/// @notice A struct holding the depths of the merkle trees
|
|
16
16
|
struct TreeDepths {
|
|
17
|
-
uint8
|
|
17
|
+
uint8 tallyProcessingStateTreeDepth;
|
|
18
18
|
uint8 voteOptionTreeDepth;
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -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/dev/contracts/contracts/Poll.sol)
|
|
9
|
+
Code location: [Poll.sol](https://github.com/privacy-scaling-explorations/maci/blob/dev/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/dev/contracts/contracts/PollFactory.sol)
|
|
9
|
+
Code location: [PollFactory.sol](https://github.com/privacy-scaling-explorations/maci/blob/dev/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/dev/contracts/contracts/Tally.sol)
|
|
9
|
+
Code location: [Tally.sol](https://github.com/privacy-scaling-explorations/maci/blob/dev/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.
|
|
@@ -34,7 +34,7 @@ This contract should be deployed alongside a `Poll`, with the the constructor ac
|
|
|
34
34
|
- `vkRegistry` - The address of the vkRegistry contract
|
|
35
35
|
- `poll` - The address of the poll contract
|
|
36
36
|
- `messageProcessor` - The address of the messageProcessor contract
|
|
37
|
-
- `mode` - The mode of the tally contract - depending on this, the commitments will be processed differently, and it must equal the Poll mode (quadratic vs non quadratic voting)
|
|
37
|
+
- `mode` - The mode of the tally contract - depending on this, the commitments will be processed differently, and it must equal the Poll mode (quadratic vs non quadratic vs full credits voting)
|
|
38
38
|
|
|
39
39
|
Users can use the verification functions to verify the Tally results. These are as follows:
|
|
40
40
|
|
|
@@ -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/dev/contracts/contracts/VerifyingKeysRegistry.sol)
|
|
9
|
+
Code location: [VerifyingKeysRegistry.sol](https://github.com/privacy-scaling-explorations/maci/blob/dev/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:
|
|
@@ -18,7 +18,7 @@ The VerifyingKeysRegistry is a contract that holds the verifying keys for the zk
|
|
|
18
18
|
|
|
19
19
|
Each circuit will have a signature which is its compile-time constants represented as a uint256.
|
|
20
20
|
|
|
21
|
-
Please note that each Verifying Key should be set with the corresponding mode. Available modes are quadratic
|
|
21
|
+
Please note that each Verifying Key should be set with the corresponding mode. Available modes are quadratic, non quadratic and full credits voting.
|
|
22
22
|
|
|
23
23
|
The contract owner can set them using the `setVerifyingKeysBatch` function:
|
|
24
24
|
|
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/dev/circuits/circom/
|
|
8
|
+
[**Repo link**](https://github.com/privacy-scaling-explorations/maci/blob/dev/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 [`processMessages`](https://github.com/privacy-scaling-explorations/maci/blob/dev/circuits/circom/
|
|
12
|
+
The [`processMessages`](https://github.com/privacy-scaling-explorations/maci/blob/dev/circuits/circom/coordinator/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:
|
|
14
14
|
|
|
15
15
|
- the related Poll has ended
|
|
@@ -21,7 +21,11 @@ This circuit requires the coordinator's private key, hence a proof for this circ
|
|
|
21
21
|

|
|
22
22
|
|
|
23
23
|
:::info
|
|
24
|
-
A version working with non quadratic voting (non-qv) is also [available](https://github.com/privacy-scaling-explorations/maci/blob/dev/circuits/circom/
|
|
24
|
+
A version working with non quadratic voting (non-qv) is also [available](https://github.com/privacy-scaling-explorations/maci/blob/dev/circuits/circom/coordinator/non-qv/processMessages.circom). This version is called `processMessagesNonQV` 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
|
+
:::
|
|
26
|
+
|
|
27
|
+
:::info
|
|
28
|
+
A version working with full credits voting (full) is also [available](https://github.com/privacy-scaling-explorations/maci/blob/dev/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.
|
|
25
29
|
:::
|
|
26
30
|
|
|
27
31
|
#### Parameters
|
|
@@ -37,7 +37,7 @@ MACI's circuits are parameterized, and thus can be configured to support differe
|
|
|
37
37
|
- **STATE_TREE_DEPTH** = how many users the system supports
|
|
38
38
|
- **VOTE_OPTIONS_TREE_DEPTH** = how many vote options the system supports
|
|
39
39
|
- **MESSAGE_BATCH_SIZE** = how many messages in a batch the circuit should process
|
|
40
|
-
- **
|
|
40
|
+
- **TALLY_PROCESSING_STATE_TREE_DEPTH** = how many ballots can be processed per batch when tallying the results (`5 ** TALLY_PROCESSING_STATE_TREE_DEPTH` ballots)
|
|
41
41
|
|
|
42
42
|
Please refer to the individual circuit documentation for more details on the inner working of each circuit and where parameters fit.
|
|
43
43
|
|
|
@@ -18,7 +18,7 @@ sidebar_position: 4
|
|
|
18
18
|

|
|
19
19
|
|
|
20
20
|
:::info
|
|
21
|
-
A version working with non quadratic voting (non-qv) is also [available](https://github.com/privacy-scaling-explorations/maci/blob/dev/circuits/circom/
|
|
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/dev/circuits/circom/coordinator/non-qv/tallyVotes.circom). This version is called `tallyVotesNonQv` 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
|
|
@@ -73,7 +73,7 @@ $poseidon_3([tc_r, tc_t, tc_p])$
|
|
|
73
73
|
|
|
74
74
|
1. That the coordinator knows the preimage of `sbCommitment`
|
|
75
75
|
2. That `index` is less than or equal to `totalSignups`
|
|
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 **
|
|
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 ** tallyProcessingStateTreeDepth)`
|
|
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:
|
|
79
79
|
- That the sum of votes per vote option is correct
|
|
@@ -39,11 +39,11 @@ A utility circuit used by the main `tallyVotes` circuit to verify that the resul
|
|
|
39
39
|
|
|
40
40
|

|
|
41
41
|
|
|
42
|
-
####
|
|
42
|
+
#### QuinaryCheckRoot
|
|
43
43
|
|
|
44
44
|
Utility circuit that given a quin Merkle root and a list of leaves, check if the root is the correct result of inserting all the leaves into the tree in the given order.
|
|
45
45
|
|
|
46
|
-

|
|
47
47
|
|
|
48
48
|
#### CalculateTotal
|
|
49
49
|
|
|
@@ -100,11 +100,11 @@ Utility circuit used to unpack an input element.
|
|
|
100
100
|
|
|
101
101
|

|
|
102
102
|
|
|
103
|
-
####
|
|
103
|
+
#### QuinarySelector
|
|
104
104
|
|
|
105
105
|
Utility circuit used to select one element from an array of n elements at a given index.
|
|
106
106
|
|
|
107
|
-

|
|
108
108
|
|
|
109
109
|
#### Splicer
|
|
110
110
|
|
|
@@ -118,11 +118,11 @@ Utility circuit used to check if a batch of leaves exists in a quinary tree.
|
|
|
118
118
|
|
|
119
119
|

|
|
120
120
|
|
|
121
|
-
####
|
|
121
|
+
#### QuinaryGeneratePathIndices
|
|
122
122
|
|
|
123
123
|
Utility circuit used to generate the indices needed to traverse the tree until we find the leaf we are looking for.
|
|
124
124
|
|
|
125
|
-

|
|
126
126
|
|
|
127
127
|
#### ProcessOne
|
|
128
128
|
|