@maci-protocol/website 0.0.0-ci.35d370f → 0.0.0-ci.35e2fb7

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.
Files changed (95) hide show
  1. package/LICENSE +1 -2
  2. package/blog/2024-02-28-maci-v1.2.0.md +2 -2
  3. package/blog/2024-08-10-maci-v2.md +1 -1
  4. package/blog/2025-03-21-roadmap-2025.md +1 -1
  5. package/docusaurus.config.ts +9 -3
  6. package/package.json +13 -12
  7. package/src/pages/roadmap.md +39 -80
  8. package/static/img/circuits/MACI-Circuits.excalidraw +69 -69
  9. package/static/img/circuits/messageValidator.svg +1 -1
  10. package/static/img/circuits/processMessages.svg +1 -1
  11. package/static/img/circuits/processMessagesInputHasher.svg +1 -1
  12. package/static/img/circuits/processMessages_2_0.svg +1 -1
  13. package/static/img/circuits/processOne.svg +1 -1
  14. package/static/img/circuits/processTopup.svg +1 -1
  15. package/static/img/circuits/quinBatchLeavesExists.svg +1 -1
  16. package/static/img/circuits/quinCheckRoot.svg +1 -1
  17. package/static/img/circuits/quinGeneratePathIndices.svg +1 -1
  18. package/static/img/circuits/quinSelector.svg +1 -1
  19. package/static/img/circuits/resultsCommitmentVerifier.svg +1 -1
  20. package/static/img/circuits/splicer.svg +1 -1
  21. package/static/img/circuits/tallyInputHasher.svg +1 -1
  22. package/static/img/circuits/tallyVotes.svg +1 -1
  23. package/versioned_docs/version-v0.x/introduction.md +0 -4
  24. package/versioned_docs/version-v0.x/quadratic-vote-tallying-circuit.md +16 -16
  25. package/versioned_docs/version-v1.2/circuits.md +8 -8
  26. package/versioned_docs/version-v1.2/contributing/contributing.md +4 -4
  27. package/versioned_docs/version-v1.2/deployment.md +1 -1
  28. package/versioned_docs/version-v1.2/integrating.md +1 -1
  29. package/versioned_docs/version-v1.2/key-change.md +1 -1
  30. package/versioned_docs/version-v1.2/poll-types.md +1 -1
  31. package/versioned_docs/version-v1.2/testing-in-detail.md +3 -3
  32. package/versioned_docs/version-v1.2/testing.md +1 -1
  33. package/versioned_docs/version-v1.2/topup.md +1 -1
  34. package/versioned_docs/version-v1.2/typedoc/core/index.md +2 -2
  35. package/versioned_docs/version-v1.2/versioning.md +3 -3
  36. package/versioned_docs/version-v1.2/workflow.md +1 -1
  37. package/versioned_docs/version-v2.x/contributing/contributing.md +4 -4
  38. package/versioned_docs/version-v2.x/core-concepts/key-change.md +1 -1
  39. package/versioned_docs/version-v2.x/core-concepts/merkle-trees.md +1 -1
  40. package/versioned_docs/version-v2.x/core-concepts/poll-types.md +1 -1
  41. package/versioned_docs/version-v2.x/core-concepts/workflow.md +1 -1
  42. package/versioned_docs/version-v2.x/guides/integrating.md +1 -1
  43. package/versioned_docs/version-v2.x/guides/testing/testing-in-detail.md +3 -3
  44. package/versioned_docs/version-v2.x/guides/testing/testing.md +1 -1
  45. package/versioned_docs/version-v2.x/processes/versioning.md +3 -3
  46. package/versioned_docs/version-v2.x/supported-networks/deployed-contracts.md +7 -7
  47. package/versioned_docs/version-v2.x/technical-references/smart-contracts/AccQueue.md +1 -1
  48. package/versioned_docs/version-v2.x/technical-references/smart-contracts/MACI.md +1 -1
  49. package/versioned_docs/version-v2.x/technical-references/smart-contracts/MessageProcessor.md +1 -1
  50. package/versioned_docs/version-v2.x/technical-references/smart-contracts/Params.md +1 -1
  51. package/versioned_docs/version-v2.x/technical-references/smart-contracts/Poll.md +1 -1
  52. package/versioned_docs/version-v2.x/technical-references/smart-contracts/PollFactory.md +1 -1
  53. package/versioned_docs/version-v2.x/technical-references/smart-contracts/Tally.md +1 -1
  54. package/versioned_docs/version-v2.x/technical-references/smart-contracts/VkRegistry.md +1 -1
  55. package/versioned_docs/version-v2.x/technical-references/smart-contracts/VoiceCreditProxy.md +1 -1
  56. package/versioned_docs/version-v2.x/technical-references/zk-snark-circuits/processMessages.md +4 -4
  57. package/versioned_docs/version-v2.x/technical-references/zk-snark-circuits/tallyVotes.md +2 -2
  58. package/versioned_docs/version-v2.x/technical-references/zk-snark-circuits/zk-snark-circuits.md +3 -3
  59. package/versioned_docs/version-v3.x/contributing/contributing.md +4 -4
  60. package/versioned_docs/version-v3.x/core-concepts/key-change.md +14 -14
  61. package/versioned_docs/version-v3.x/core-concepts/maci-keys.md +1 -1
  62. package/versioned_docs/version-v3.x/core-concepts/poll-types.md +33 -9
  63. package/versioned_docs/version-v3.x/core-concepts/polls.md +34 -10
  64. package/versioned_docs/version-v3.x/core-concepts/spec.md +39 -105
  65. package/versioned_docs/version-v3.x/core-concepts/workflow.md +2 -2
  66. package/versioned_docs/version-v3.x/guides/compile-circuits.md +36 -20
  67. package/versioned_docs/version-v3.x/guides/integrating.md +10 -10
  68. package/versioned_docs/version-v3.x/guides/sdk.md +121 -0
  69. package/versioned_docs/version-v3.x/guides/testing/testing-in-detail.md +4 -4
  70. package/versioned_docs/version-v3.x/guides/testing/testing-introduction.md +35 -3
  71. package/versioned_docs/version-v3.x/guides/troubleshooting.md +64 -19
  72. package/versioned_docs/version-v3.x/processes/versioning.md +3 -3
  73. package/versioned_docs/version-v3.x/quick-start.md +29 -21
  74. package/versioned_docs/version-v3.x/resources.md +1 -0
  75. package/versioned_docs/version-v3.x/security/audit.md +2 -2
  76. package/versioned_docs/version-v3.x/security/trusted-setup.md +36 -36
  77. package/versioned_docs/version-v3.x/supported-networks/costs.md +725 -0
  78. package/versioned_docs/version-v3.x/supported-networks/deployed-contracts.md +9 -9
  79. package/versioned_docs/version-v3.x/supported-networks/supported-networks.md +16 -0
  80. package/versioned_docs/version-v3.x/technical-references/smart-contracts/MACI.md +7 -7
  81. package/versioned_docs/version-v3.x/technical-references/smart-contracts/MessageProcessor.md +1 -1
  82. package/versioned_docs/version-v3.x/technical-references/smart-contracts/Params.md +2 -2
  83. package/versioned_docs/version-v3.x/technical-references/smart-contracts/Policies.md +1 -1
  84. package/versioned_docs/version-v3.x/technical-references/smart-contracts/Poll.md +8 -8
  85. package/versioned_docs/version-v3.x/technical-references/smart-contracts/PollFactory.md +1 -1
  86. package/versioned_docs/version-v3.x/technical-references/smart-contracts/Tally.md +4 -4
  87. package/versioned_docs/version-v3.x/technical-references/smart-contracts/VkRegistry.md +8 -8
  88. package/versioned_docs/version-v3.x/technical-references/smart-contracts/VoiceCreditProxy.md +1 -1
  89. package/versioned_docs/version-v3.x/technical-references/technical-references.md +8 -8
  90. package/versioned_docs/version-v3.x/technical-references/zk-snark-circuits/joinPoll.md +2 -2
  91. package/versioned_docs/version-v3.x/technical-references/zk-snark-circuits/processMessages.md +81 -17
  92. package/versioned_docs/version-v3.x/technical-references/zk-snark-circuits/setup.md +3 -3
  93. package/versioned_docs/version-v3.x/technical-references/zk-snark-circuits/tallyVotes.md +6 -6
  94. package/versioned_docs/version-v3.x/technical-references/zk-snark-circuits/utilities.md +9 -9
  95. package/versioned_docs/version-v3.x/technical-references/zk-snark-circuits/zk-snark-circuits.md +3 -3
@@ -23,14 +23,14 @@ Reverse processing was introduced to prevent a type of attack where a briber wou
23
23
 
24
24
  Let's take as an example the following:
25
25
 
26
- 1. Alice signs up with pub key $pub1$
27
- 2. Bob (Briber) bribes Alice and asks her to submit a key change message to $pub2$ (owned by Bob)
28
- 3. Bob submits a vote with $pub2$
29
- 4. Alice submits a vote with $pub1$
26
+ 1. Alice signs up with public key $public1$
27
+ 2. Bob (Briber) bribes Alice and asks her to submit a key change message to $public2$ (owned by Bob)
28
+ 3. Bob submits a vote with $public2$
29
+ 4. Alice submits a vote with $public1$
30
30
 
31
31
  If messages were processed in the same order as they were submitted, Alice's vote would not be valid, due to it being signed with a private key $priv1$ - which now would not be valid.
32
32
 
33
- On the other hand, due to messages being processed in reverse order, Alice's last message would be counted as valid as the key change would have not been processed yet. Then, Bob's vote would not be counted as valid as the current key for Alice would be $pub1$.
33
+ On the other hand, due to messages being processed in reverse order, Alice's last message would be counted as valid as the key change would have not been processed yet. Then, Bob's vote would not be counted as valid as the current key for Alice would be $public1$.
34
34
 
35
35
  > Note that a key change message should have the nonce set to 1 in order for it to be valid. We'll see a code example in the next sections.
36
36
 
@@ -47,7 +47,7 @@ Let's take a look into a code example:
47
47
  ```ts
48
48
  const user1Keypair = new Keypair();
49
49
  const user2Keypair = new Keypair();
50
- const secondKeyPair = new Keypair();
50
+ const secondKeypair = new Keypair();
51
51
  ```
52
52
 
53
53
  - Votes will be
@@ -77,7 +77,7 @@ As seen above, we expect the first vote weight 9 to not be counted, but instead
77
77
  - Deploy a MaciState locally and sign up
78
78
 
79
79
  ```ts
80
- const maciState: MaciState = new MaciState(STATE_TREE_DEPTH);
80
+ const maciState = new MaciState(STATE_TREE_DEPTH);
81
81
  // Sign up
82
82
  user1StateIndex = maciState.signUp(user1Keypair.publicKey, voiceCreditBalance, BigInt(Math.floor(Date.now() / 1000)));
83
83
  user2StateIndex = maciState.signUp(user2Keypair.publicKey, voiceCreditBalance, BigInt(Math.floor(Date.now() / 1000)));
@@ -95,7 +95,7 @@ pollId = maciState.deployPoll(
95
95
 
96
96
  ```ts
97
97
  const poll = maciState.polls[pollId];
98
- const command1 = new PCommand(
98
+ const command1 = new VoteCommand(
99
99
  BigInt(user1StateIndex),
100
100
  user1Keypair.publicKey,
101
101
  user1VoteOptionIndex,
@@ -112,7 +112,7 @@ const sharedKey1 = Keypair.genEcdhSharedKey(ecdhKeypair1.privateKey, coordinator
112
112
  const message1 = command1.encrypt(signature1, sharedKey1);
113
113
  poll.publishMessage(message1, ecdhKeypair1.publicKey);
114
114
 
115
- const command2 = new PCommand(
115
+ const command2 = new VoteCommand(
116
116
  BigInt(user2StateIndex),
117
117
  user2Keypair.publicKey,
118
118
  user2VoteOptionIndex,
@@ -134,9 +134,9 @@ poll.publishMessage(message2, ecdhKeypair2.publicKey);
134
134
 
135
135
  ```ts
136
136
  const poll = maciState.polls[pollId];
137
- const command = new PCommand(
137
+ const command = new VoteCommand(
138
138
  BigInt(user1StateIndex),
139
- secondKeyPair.publicKey,
139
+ secondKeypair.publicKey,
140
140
  user1VoteOptionIndex,
141
141
  user1NewVoteWeight,
142
142
  BigInt(1),
@@ -158,8 +158,8 @@ poll.publishMessage(message, ecdhKeypair.publicKey);
158
158
  const poll = maciState.polls[pollId];
159
159
  poll.processMessages(pollId);
160
160
  poll.tallyVotes();
161
- expect(poll.perVOSpentVoiceCredits[0].toString()).to.eq((user1NewVoteWeight * user1NewVoteWeight).toString());
162
- expect(poll.perVOSpentVoiceCredits[1].toString()).to.eq((user2VoteWeight * user2VoteWeight).toString());
161
+ expect(poll.perVoteOptionSpentVoiceCredits[0].toString()).to.eq((user1NewVoteWeight * user1NewVoteWeight).toString());
162
+ expect(poll.perVoteOptionSpentVoiceCredits[1].toString()).to.eq((user2VoteWeight * user2VoteWeight).toString());
163
163
  ```
164
164
 
165
165
  - Finally confirm that the keypair was changed for the user1
@@ -175,5 +175,5 @@ expect(stateLeaf2.publicKey.equals(user2Keypair.publicKey)).to.eq(true);
175
175
  We see that is important that we set the final message (the one with the new vote) with nonce 1, as this vote would be counted as the first vote.
176
176
 
177
177
  :::info
178
- Tests related to key changes have been added to the [core package](https://github.com/privacy-scaling-explorations/maci/blob/dev/core/ts/__tests__/) and to the [cli package](https://github.com/privacy-scaling-explorations/maci/blob/dev/cli/tests/).
178
+ Tests related to key changes have been added to the [core package](https://github.com/privacy-scaling-explorations/maci/blob/main/core/ts/__tests__/) and to the [cli package](https://github.com/privacy-scaling-explorations/maci/blob/main/cli/tests/).
179
179
  :::
@@ -78,7 +78,7 @@ Serialized, these will look like **macipk.0e5194a54562ea4d440ac6a0049a41d4b600e3
78
78
  After successfully [installing](/docs/quick-start#installation) MACI, you can easily generate your MACI key pair by running:
79
79
 
80
80
  ```bash
81
- pnpm run genMaciKeyPair
81
+ pnpm run generate-maci-keypair
82
82
  ```
83
83
 
84
84
  This command will create the necessary public and private keys required for running various MACI operations.
@@ -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/InitialVoiceCreditProxy.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.
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/main/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 `useQuadraticVoting` value to **true**.
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
- "coordinatorPubkey": "macipk",
26
- "useQuadraticVoting": true
25
+ "coordinatorPublicKey": "macipk",
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 `useQuadraticVoting` parameter to `false` 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.
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 `useQuadraticVoting` value to **false**.
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
- "coordinatorPubkey": "macipk",
50
- "useQuadraticVoting": false
49
+ "coordinatorPublicKey": "macipk",
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 or non quadratic voting. One should be aware that the only distinction between the two happens when messages are processed and votes tallied.
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)
@@ -23,7 +23,7 @@ The full configuration for a poll looks like this:
23
23
  "Poll": {
24
24
  "pollStartDate": 3600,
25
25
  "pollEndDate": 3600,
26
- "coordinatorPubkey": "macipk.9a59264310d95cfd8eb7083aebeba221b5c26e77427f12b7c0f50bc1cc35e621",
26
+ "coordinatorPublicKey": "macipk.9a59264310d95cfd8eb7083aebeba221b5c26e77427f12b7c0f50bc1cc35e621",
27
27
  "useQuadraticVoting": false,
28
28
  "policy": "FreeForAllPolicy",
29
29
  "relayers": "0x0000000000000000000000000000000000000000",
@@ -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/InitialVoiceCreditProxy.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.
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/main/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 `useQuadraticVoting` value to **true**.
43
+ In the deploy-config.json file set the `mode` value to **qv**.
44
44
 
45
45
  ```json
46
46
  "Poll": {
47
47
  [...]
48
- "coordinatorPubkey": "macipk",
49
- "useQuadraticVoting": true
48
+ "coordinatorPublicKey": "macipk",
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 `useQuadraticVoting` parameter to `false` when creating the MACI instance.
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 `useQuadraticVoting` value to **false**.
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
- "coordinatorPubkey": "macipk",
73
- "useQuadraticVoting": false
72
+ "coordinatorPublicKey": "macipk",
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
 
@@ -550,88 +550,22 @@ To make these processes easy to use, we provide command-line interface tools.
550
550
 
551
551
  The integration tests and shell scripts in the `cli` directory provide examples of the order in which to execute them.
552
552
 
553
- | Command | Description | Notes |
554
- | ------------------ | -------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
555
- | `genMaciPubkey` | Generate a MACI public key from a private key | Only the coordinator needs to run this, as users should generate their keys in the browser and should be automated by the client application |
556
- | `genMaciKeypair` | Generates a MACI private key and public key | Only the coordinator needs to run this, as users should generate their keys in the browser and should be automated by the client application |
557
- | `deployVkRegistry` | Deploy the `VkRegistry` contract | Executed only the coordinator |
558
- | `setVerifyingKeys` | Set verifying keys to the `VkRegistry` | Executed only the coordinator |
559
- | `create` | Deploy a new instance of MACI | Executed only the coordinator |
560
- | `deployPoll` | Deploy a new poll on a MACI instance | Executed only the coordinator |
561
- | `signup` | Sign up a user | Mainly for testing; as users are more likely to use the client application instead of the CLI |
562
- | `publish` | Submit a message to a poll | Mainly for testing; as users are more likely to use the client application instead of the CLI |
563
- | `mergeMessages` | Must be executed before generating proofs | Executed only the coordinator |
564
- | `mergeSignups` | Must be executed before generating proofs | Executed only the coordinator |
565
- | `genProofs` | Generate all message processing and vote tallying proofs | Executed only the coordinator |
566
- | `proveOnChain` | Submit proofs to the `PollProcessorAndTallyer` contract | Executed only the coordinator |
567
-
568
- ## 5. Ethereum contracts
569
-
570
- ### 5.1. MACI
571
-
572
- | Function | Permissions | Notes |
573
- | ---------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
574
- | `init(VkRegistry _vkRegistry, MessageAqFactory _messageAqFactory)` | Coordinator only | Initialise factory, helper and registry contracts that share equal ownership |
575
- | `signUp(PubKey memory _pubKey, bytes memory _signUpPolicyData, bytes memory _initialVoiceCreditProxyData)` | Executable only during the sign-up period and after initialisation | Participant registration and voice credit assignment |
576
- | `mergeStateAqSubRoots(uint256 _numSrQueueOps, uint256 _pollId)` | Executable only by poll contract `_pollId` and after initialisation | Merge queued state leaves to form the state tree subroots |
577
- | `mergeStateAq(uint256 _pollId)` | Executable only by poll contract `_pollId` and after initialisation | Merge the state subroots to form the state root |
578
- | `getStateTreeRoot()` | Non-applicable | Query the state root |
579
- | `deployPoll(uint256 _duration, TreeDepths memory _treeDepths, PubKey memory _coordinatorPubKey)` | Executable only after initialisation | Create a new poll |
580
- | `getPoll(uint256 _pollId)` | Non-applicable | Query a poll address |
581
-
582
- ### 5.2. Poll
583
-
584
- | Function | Permissions | Notes |
585
- | ---------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
586
- | `getDeployTimeAndDuration()` | Non-applicable | Query the deployment timestamp and duration |
587
- | `numSignUpsAndMessages()` | Non-applicable | Query the number of participants and messages cast |
588
- | `currentSbAndTallyCommitments()` | Non-applicable | Query the current state-ballot and tally commitments hashes |
589
- | `publishMessage(Message memory _message, PubKey memory _encPubKey)` | Executable only during the voting period and if the message limit has not been not met | Submit a message (whether valid or not) to the message queue |
590
- | `hashMessageAndEncPubKey(Message memory _message, PubKey memory _encPubKey)` | Non-applicable | Query a hash of a message and public key coordinates |
591
- | `mergeMaciStateAqSubRoots( uint256 _numSrQueueOps, uint256 _pollId)` | Executable only by the coordinator and after the voting period | Merge queued state leaves to form the state subroots |
592
- | `mergeMaciStateAq(uint256 _pollId)` | Executable only by the coordinator and after the voting period | Merge the state subroots to form the state root and initialise the state-ballot commitment hash |
593
- | `mergeMessageAqSubRoots(uint256 _numSrQueueOps)` | Executable only by the coordinator and after the voting period | Merge the queued message leaves to form the message tree subroots |
594
- | `mergeMessageAq()` | Executable only by the coordinator and after the voting period | Merge the message tree subroots to form the message tree root |
595
- | `batchEnqueueMessage(uint256 _messageSubRoot)` | Executable only by the coordinator and after the voting period | Submit a batch of messages to the queue |
596
-
597
- ### 5.3. PollFactory
598
-
599
- | Function | Permissions | Notes |
600
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------- | --------------------------------------- |
601
- | `setMessageAqFactory(MessageAqFactory _messageAqFactory)` | Coordinator only | Initialise the message factory contract |
602
- | `deploy(uint256 _duration, TreeDepths memory _treeDepths, BatchSizes memory _batchSizes, PubKey memory _coordinatorPubKey, VkRegistry _vkRegistry, IMACI _maci, address _pollOwner)` | Coordinator only | Create a new poll |
603
-
604
- ### 5.4. VkRegistry
605
-
606
- | Function | Permissions | Notes |
607
- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
608
- | `isProcessVkSet(uint256 _sig)` | Non-applicable | Query whether a signature is valid for message processing |
609
- | `isTallyVkSet(uint256 _sig)` | Non-applicable | Query whether a signature valid for tallying votes |
610
- | `genProcessVkSig(uint256 _stateTreeDepth, uint256 _messageTreeDepth, uint256 _voteOptionTreeDepth, uint256 _messageBatchSize)` | Non-applicable | Generate a signature (used for verifying key mapping lookups) for message processing by compressing parameters into a singular value |
611
- | `genTallyVkSig(uint256 _stateTreeDepth, uint256 _intStateTreeDepth, uint256 _voteOptionTreeDepth)` | Non-applicable | Generate a signature (used for verifying key mapping lookups) for vote tallying by compressing parameters into a singular value |
612
- | `setVerifyingKeys( uint256 _stateTreeDepth, uint256 _intStateTreeDepth, uint256 _messageTreeDepth, uint256 _voteOptionTreeDepth, uint256 _messageBatchSize, VerifyingKey memory _processVk, VerifyingKey memory _tallyVk)` | Coordinator only | Initialise verifying keys for processing and tallying to the contract alongside specifying each tree depth |
613
- | `hasProcessVk(uint256 _stateTreeDepth, uint256 _messageTreeDepth, uint256 _voteOptionTreeDepth, uint256 _messageBatchSize)` | Non-applicable | Query whether the signature of the parameters is valid for message processing |
614
- | `getProcessVkBySig(uint256 _sig)` | Non-applicable | Query a processing verifying key by providing a valid signature |
615
- | `getProcessVk(uint256 _stateTreeDepth, uint256 _messageTreeDepth, uint256 _voteOptionTreeDepth, uint256 _messageBatchSize)` | Non-applicable | Query a processing verifying key by providing parameters to generate a valid signature |
616
- | `hasTallyVk(uint256 _stateTreeDepth, uint256 _intStateTreeDepth, uint256 _voteOptionTreeDepth)` | Non-applicable | Query whether the signature of the parameters is valid for vote tallying |
617
- | `getTallyVkBySig(uint256 _sig)` | Non-applicable | Query a tallying verifying key by providing a valid signature |
618
- | `getTallyVk(uint256 _stateTreeDepth, uint256 _intStateTreeDepth, uint256 _voteOptionTreeDepth)` | Non-applicable | Query a tallying verifying key by providing parameters to generate a valid signature |
619
-
620
- ### 5.5. PollProcessorAndTallyer
621
-
622
- | Function | Permissions | Notes |
623
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
624
- | `sha256Hash(uint256[] memory array)` | Non-applicable | Hash an array of values (using SHA256) moduluo the snark field size |
625
- | `processMessages(Poll _poll, uint256 _newSbCommitment, uint256[8] memory _proof)` | Executable only by the coordinator and after the voting period | Process state messages relative to a new state-ballot commitment given that the proof is valid |
626
- | `verifyProcessProof(Poll _poll, uint256 _currentMessageBatchIndex, uint256 _messageRoot, uint256 _currentSbCommitment, uint256 _newSbCommitment, uint256[8] memory _proof)` | Non-applicable | Query whether a message processing proof is valid |
627
- | `genProcessMessagesPublicInputHash(Poll _poll, uint256 _currentMessageBatchIndex, uint256 _messageRoot, uint256 _numSignUps, uint256 _currentSbCommitment, uint256 _newSbCommitment)` | Non-applicable | Hash of the coordinators public key, `packedVals`, current state-ballot commitment and message root |
628
- | `genProcessMessagesPackedVals( Poll _poll, uint256 _currentMessageBatchIndex, uint256 _numSignUps)` | Non-applicable | Generate a packed 250-bit value `packedVals` for message processing |
629
- | `genTallyVotesPackedVals( uint256 _numSignUps, uint256 _batchStartIndex, uint256 _tallyBatchSize)` | Non-applicable | Generate a packed 100-bit value `packedVals` for vote tallying |
630
- | `genTallyVotesPublicInputHash( uint256 _numSignUps, uint256 _batchStartIndex, uint256 _tallyBatchSize, uint256 _newTallyCommitment )` | Non-applicable | Hash of the current tally commitment, the new tally commitment, `packedVals` and the state-ballot commitment |
631
- | `tallyVotes(Poll _poll, uint256 _newTallyCommitment, uint256[8] memory _proof)` | Executable only by the coordinator and after the voting period | Tally votes relative to a new tally commitment given that the proof is valid |
632
- | `verifyTallyProof(Poll _poll, uint256[8] memory _proof, uint256 _numSignUps, uint256 _batchStartIndex, uint256 _tallyBatchSize, uint256 _newTallyCommitment)` | Non-applicable | Query whether a vote tallying proof is valid |
633
-
634
- ## 6. zk-SNARKs
553
+ | Command | Description | Notes |
554
+ | ----------------------------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
555
+ | `generateMaciPublicKey` | Generate a MACI public key from a private key | Only the coordinator needs to run this, as users should generate their keys in the browser and should be automated by the client application |
556
+ | `generateMaciKeypair` | Generates a MACI private key and public key | Only the coordinator needs to run this, as users should generate their keys in the browser and should be automated by the client application |
557
+ | `deployVerifyingKeysRegistry` | Deploy the `deployVerifyingKeysRegistry` contract | Executed only the coordinator |
558
+ | `setVerifyingKeys` | Set verifying keys to the `deployVerifyingKeysRegistry` | Executed only the coordinator |
559
+ | `create` | Deploy a new instance of MACI | Executed only the coordinator |
560
+ | `deployPoll` | Deploy a new poll on a MACI instance | Executed only the coordinator |
561
+ | `signup` | Sign up a user | Mainly for testing; as users are more likely to use the client application instead of the CLI |
562
+ | `publish` | Submit a message to a poll | Mainly for testing; as users are more likely to use the client application instead of the CLI |
563
+ | `mergeMessages` | Must be executed before generating proofs | Executed only the coordinator |
564
+ | `mergeSignups` | Must be executed before generating proofs | Executed only the coordinator |
565
+ | `generateProofs` | Generate all message processing and vote tallying proofs | Executed only the coordinator |
566
+ | `proveOnChain` | Submit proofs to the `MessageProcessor` and `Tally` contracts | Executed only the coordinator |
567
+
568
+ ## 5. zk-SNARKs
635
569
 
636
570
  The zk-SNARK circuits in MACI are written in the [circom](https://github.com/iden3/circom) language. Proofs are [Groth16](https://eprint.iacr.org/2016/260.pdf) and are generated using the [`rapidsnark`](https://github.com/iden3/rapidsnark) prover.
637
571
 
@@ -646,15 +580,15 @@ Please note that MACI requires the coordinator to generate proofs on an x86 mach
646
580
 
647
581
  ### 6.1. Message processing circuit
648
582
 
649
- The message processing circuit, defined in `circuits/circom/processMessages.circom`, allows the coordinator to prove that they have correctly applied each message in reverse order, in a consecutive batch of `5 ^ msgBatchDepth` messages to the respective state leaf within the state tree.
583
+ The message processing circuit, defined in `circuits/circom/coordinator/qv/MessageProcessor.circom`, allows the coordinator to prove that they have correctly applied each message in reverse order, in a consecutive batch of `5 ^ messageBatchDepth` messages to the respective state leaf within the state tree.
650
584
 
651
585
  #### Parameters
652
586
 
653
587
  | Parameter | Description |
654
588
  | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
655
589
  | `stateTreeDepth` | Depth of the state tree, this value must be equal to `10` |
656
- | `msgTreeDepth` | Depth of the message tree, this must be the same value passed to the `deployPoll()` contract function of `MACI.sol` |
657
- | `msgBatchDepth` | Depth of a tree that exactly fits the number of messages in a batch, this must be the same value passed to the `deployPoll()` contract function of `MACI.sol` |
590
+ | `messageTreeDepth` | Depth of the message tree, this must be the same value passed to the `deployPoll()` contract function of `MACI.sol` |
591
+ | `messageBatchDepth` | Depth of a tree that exactly fits the number of messages in a batch, this must be the same value passed to the `deployPoll()` contract function of `MACI.sol` |
658
592
  | `voteOptionTreeDepth` | Depth of the vote option tree, this must be the same value passed to the `deployPoll()` contract function of `MACI.sol` |
659
593
 
660
594
  The state tree, message tree, and vote option trees all have an arity of 5. As such, it is possible to calculate the maximum number of signups, messages per poll, and vote options per poll.
@@ -663,17 +597,17 @@ The state tree, message tree, and vote option trees all have an arity of 5. As s
663
597
 
664
598
  | Input signal | Description |
665
599
  | -------------------------------- | --------------------------------------------------------------------------------------- |
666
- | `numSignUps` | Number of users that have completed the sign up |
600
+ | `totalSignups` | Number of users that have completed the sign up |
667
601
  | `index` | The batch index of current message batch |
668
602
  | `pollEndTimestamp` | The Unix timestamp at which the poll ends |
669
- | `msgRoot` | The root of the message tree |
670
- | `msgs` | The batch of messages as an array of arrays |
671
- | `msgSubrootPathElements` | As described below |
603
+ | `messageRoot` | The root of the message tree |
604
+ | `messages` | The batch of messages as an array of arrays |
605
+ | `messageSubrootPathElements` | As described below |
672
606
  | `coordinatorPublicKeyHash` | $\mathsf{poseidon_2}([cPk_x, cPk_y])$ |
673
607
  | `newSbCommitment` | As described below |
674
- | `coordPrivKey` | The coordinator's private key |
608
+ | `coordinatorPrivateKey` | The coordinator's private key |
675
609
  | `batchEndIndex` | The last batch index |
676
- | `encPubKeys` | The public keys used to generate shared ECDH encryption keys to encrypt the messages |
610
+ | `encryptionPublicKeys` | The public keys used to generate shared ECDH encryption keys to encrypt the messages |
677
611
  | `currentStateRoot` | The state root before the commands are applied |
678
612
  | `currentStateLeaves` | The state leaves upon which messages are applied |
679
613
  | `currentStateLeavesPathElements` | The Merkle path to each incremental state root |
@@ -701,9 +635,9 @@ The salt used to produce `currentSbCommitment` (see above).
701
635
 
702
636
  The salt used to produce `newSbCommitment` (see above).
703
637
 
704
- ##### `msgSubrootPathElements`
638
+ ##### `messageSubrootPathElements`
705
639
 
706
- The index of each message in `msgs` is consecutive. As such, in order to prove that each message in `msgs` is indeed a leaf of the message tree, we compute the subtree root of `msgs`, and then verify that the subtree root is indeed a subroot of `msgRoot`.
640
+ 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`.
707
641
 
708
642
  A simplified example using a tree of arity 2:
709
643
 
@@ -727,9 +661,9 @@ This method requires fewer circuit constraints than if we verified a Merkle proo
727
661
 
728
662
  1. That the prover knows the preimage to `currentSbCommitment` (that is, the state root, ballot root, and `currentSbSalt`)
729
663
  2. That `maxVoteOptions <= (5 ^ voteOptionTreeDepth)`
730
- 3. That `numSignUps <== (5 ^ stateTreeDepth)`
731
- 4. That `coordinatorPublicKeyHash` is a hash of public key that is correctly derived from `coordPrivKey`
732
- 5. That each message in `msgs` exists in the message tree
664
+ 3. That `totalSignups <== (5 ^ stateTreeDepth)`
665
+ 4. That `coordinatorPublicKeyHash` is a hash of public key that is correctly derived from `coordinatorPrivateKey`
666
+ 5. That each message in `messages` exists in the message tree
733
667
  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`
734
668
 
735
669
  #### How messages are decrypted and applied
@@ -813,21 +747,21 @@ The final tally should be:
813
747
  2. Total voice credits per vote option: `[3, 9, 19, 33, 26]`
814
748
  3. Total spent voice credits: `66`
815
749
 
816
- The coordinator uses the ballot tallying circuit (`tallyVotes.circom`) to generate proofs that they have correctly computed the tally. As there are many ballots to tally, each proof only computes the tally for a batch of ballots. Each proof is chained to the previous one such that each proof is also a proof of knowledge of the preimage of the previous tally commitment.
750
+ The coordinator uses the ballot tallying circuit (`VoteTally.circom`) to generate proofs that they have correctly computed the tally. As there are many ballots to tally, each proof only computes the tally for a batch of ballots. Each proof is chained to the previous one such that each proof is also a proof of knowledge of the preimage of the previous tally commitment.
817
751
 
818
752
  #### Parameters
819
753
 
820
- | Parameter | Description |
821
- | --------------------- | ----------------------------------------------------------------------------------------------------------------------- |
822
- | `stateTreeDepth` | Depth of the state tree, this value must be equal to `10` |
823
- | `intStateTreeDepth` | Depth of the intermediate state tree, `5 ** intStateTreeDepth` is the batch size |
824
- | `voteOptionTreeDepth` | Depth of the vote option tree, this must be the same value passed to the `deployPoll()` contract function of `MACI.sol` |
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` |
825
759
 
826
760
  #### Input signals
827
761
 
828
762
  | Input signal | Description |
829
763
  | --------------------------------------- | ---------------------------------------------------------------- |
830
- | `numSignUps` | The number of users that signup |
764
+ | `totalSignups` | The number of users that signup |
831
765
  | `index` | Start index of given batch |
832
766
  | `sbCommitment` | As described below |
833
767
  | `currentTallyCommitment` | As described below |
@@ -874,8 +808,8 @@ $\mathsf{poseidon_3}([tc_r, tc_t, tc_p])$
874
808
  #### Statements that the circuit proves
875
809
 
876
810
  1. That the coordinator knows the preimage of `sbCommitment` (see above)
877
- 2. That `index` is less than or equal to `numSignUps`
878
- 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)`
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 ** tallyProcessingStateTreeDepth)`
879
813
  4. That each set of votes (`votes[i]`) has the Merkle root $blt_r$ whose value equals `ballots[i][1]`
880
814
  5. That the tally is valid, which is:
881
815
  - That the sum of votes per vote option is correct
@@ -66,7 +66,7 @@ Therefore, even if a coordinator is corrupt, they are unable to change a user’
66
66
 
67
67
  To explain the MACI workflow, let's give a quick overview of the key smart contracts.
68
68
 
69
- See our [smart contract docs](/docs/category/smart-contracts) or our [contract source code](https://github.com/privacy-scaling-explorations/maci/tree/dev/contracts/contracts) for a more in-depth explanation of all smart contracts.
69
+ See our [smart contract docs](/docs/category/smart-contracts) or our [contract source code](https://github.com/privacy-scaling-explorations/maci/tree/main/contracts/contracts) for a more in-depth explanation of all smart contracts.
70
70
 
71
71
  ### MACI.sol
72
72
 
@@ -133,7 +133,7 @@ The `MessageProcessor` contract will send the proof to a separate verifier contr
133
133
 
134
134
  #### Tally Results
135
135
 
136
- Finally, once all messages have been processed, the coordinator tallies the votes of the valid messages (off-chain). The coordinator creates a zk-SNARK proving that the valid messages in the state tree (proved in Process Messages step) contain votes that sum to the given tally result. Then, they call [`Tally.tallyVotes()`](/docs/technical-references/smart-contracts/solidity-docs/Tally#tallyvotes) with a hash of the correct tally results and the zk-SNARK proof. Similarly to the processMessages function, the `tallyVotes` function will send the proof to a verifier contract to ensure that it is valid.
136
+ Finally, once all messages have been processed, the coordinator tallies the votes of the valid messages (off-chain). The coordinator creates a zk-SNARK proving that the valid messages in the state tree (proved in Process Messages step) contain votes that sum to the given tally result. Then, they call [`Tally.tallyVotes()`](/docs/technical-references/smart-contracts/solidity-docs/Tally#tallyvotes) with a hash of the correct tally results and the zk-SNARK proof. Similarly to the `processMessages` function, the `tallyVotes` function will send the proof to a verifier contract to ensure that it is valid.
137
137
 
138
138
  <!-- "hash of the correct tally results" - so are the final results actually put on chain? or just a hash?? -->
139
139