@maci-protocol/website 0.0.0-ci.9342f07 → 0.0.0-ci.9819a21
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 +2 -2
- package/blog/2024-08-10-maci-v2.md +1 -1
- package/blog/2025-03-21-roadmap-2025.md +1 -1
- package/blog/2025-08-18-maci-aragon-plugin.md +107 -0
- package/docusaurus.config.ts +9 -3
- package/package.json +16 -15
- package/src/pages/roadmap.md +39 -80
- package/static/img/circuits/MACI-Circuits.excalidraw +79 -79
- 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/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/tallyInputHasher.svg +1 -1
- package/static/img/circuits/tallyVotes.svg +1 -1
- package/static/img/circuits/verifySignature.svg +1 -1
- package/versioned_docs/version-v0.x/introduction.md +0 -4
- package/versioned_docs/version-v0.x/quadratic-vote-tallying-circuit.md +16 -16
- package/versioned_docs/version-v1.2/circuits.md +8 -8
- package/versioned_docs/version-v1.2/contributing/contributing.md +4 -4
- package/versioned_docs/version-v1.2/deployment.md +1 -1
- package/versioned_docs/version-v1.2/integrating.md +1 -1
- package/versioned_docs/version-v1.2/key-change.md +1 -1
- package/versioned_docs/version-v1.2/poll-types.md +1 -1
- package/versioned_docs/version-v1.2/testing-in-detail.md +3 -3
- package/versioned_docs/version-v1.2/testing.md +1 -1
- package/versioned_docs/version-v1.2/topup.md +1 -1
- package/versioned_docs/version-v1.2/typedoc/core/index.md +2 -2
- package/versioned_docs/version-v1.2/versioning.md +3 -3
- package/versioned_docs/version-v1.2/workflow.md +1 -1
- package/versioned_docs/version-v2.x/contributing/contributing.md +4 -4
- package/versioned_docs/version-v2.x/core-concepts/key-change.md +1 -1
- package/versioned_docs/version-v2.x/core-concepts/merkle-trees.md +1 -1
- package/versioned_docs/version-v2.x/core-concepts/poll-types.md +1 -1
- package/versioned_docs/version-v2.x/core-concepts/workflow.md +1 -1
- package/versioned_docs/version-v2.x/guides/integrating.md +1 -1
- package/versioned_docs/version-v2.x/guides/testing/testing-in-detail.md +3 -3
- package/versioned_docs/version-v2.x/guides/testing/testing.md +1 -1
- package/versioned_docs/version-v2.x/processes/versioning.md +3 -3
- package/versioned_docs/version-v2.x/supported-networks/deployed-contracts.md +7 -7
- package/versioned_docs/version-v2.x/technical-references/smart-contracts/AccQueue.md +1 -1
- package/versioned_docs/version-v2.x/technical-references/smart-contracts/MACI.md +1 -1
- package/versioned_docs/version-v2.x/technical-references/smart-contracts/MessageProcessor.md +1 -1
- package/versioned_docs/version-v2.x/technical-references/smart-contracts/Params.md +1 -1
- package/versioned_docs/version-v2.x/technical-references/smart-contracts/Poll.md +1 -1
- package/versioned_docs/version-v2.x/technical-references/smart-contracts/PollFactory.md +1 -1
- package/versioned_docs/version-v2.x/technical-references/smart-contracts/Tally.md +1 -1
- package/versioned_docs/version-v2.x/technical-references/smart-contracts/VkRegistry.md +1 -1
- package/versioned_docs/version-v2.x/technical-references/smart-contracts/VoiceCreditProxy.md +1 -1
- package/versioned_docs/version-v2.x/technical-references/zk-snark-circuits/processMessages.md +4 -4
- package/versioned_docs/version-v2.x/technical-references/zk-snark-circuits/tallyVotes.md +2 -2
- package/versioned_docs/version-v2.x/technical-references/zk-snark-circuits/zk-snark-circuits.md +3 -3
- package/versioned_docs/version-v3.x/contributing/contributing.md +11 -5
- package/versioned_docs/version-v3.x/core-concepts/key-change.md +29 -29
- package/versioned_docs/version-v3.x/core-concepts/maci-keys.md +1 -1
- package/versioned_docs/version-v3.x/core-concepts/poll-types.md +33 -9
- package/versioned_docs/version-v3.x/core-concepts/polls.md +34 -10
- package/versioned_docs/version-v3.x/core-concepts/spec.md +40 -106
- package/versioned_docs/version-v3.x/core-concepts/workflow.md +2 -2
- package/versioned_docs/version-v3.x/guides/compile-circuits.md +36 -20
- package/versioned_docs/version-v3.x/guides/integrating.md +10 -10
- package/versioned_docs/version-v3.x/guides/sdk.md +121 -0
- package/versioned_docs/version-v3.x/guides/testing/testing-in-detail.md +4 -4
- package/versioned_docs/version-v3.x/guides/testing/testing-introduction.md +38 -6
- package/versioned_docs/version-v3.x/guides/troubleshooting.md +64 -19
- package/versioned_docs/version-v3.x/processes/versioning.md +3 -3
- package/versioned_docs/version-v3.x/quick-start.md +29 -21
- package/versioned_docs/version-v3.x/resources.md +1 -0
- package/versioned_docs/version-v3.x/security/audit.md +2 -2
- package/versioned_docs/version-v3.x/security/trusted-setup.md +36 -36
- package/versioned_docs/version-v3.x/supported-networks/costs.md +725 -0
- package/versioned_docs/version-v3.x/supported-networks/deployed-contracts.md +9 -9
- package/versioned_docs/version-v3.x/supported-networks/supported-networks.md +16 -0
- package/versioned_docs/version-v3.x/technical-references/smart-contracts/MACI.md +7 -7
- 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/Policies.md +1 -1
- package/versioned_docs/version-v3.x/technical-references/smart-contracts/Poll.md +8 -8
- 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 +4 -4
- package/versioned_docs/version-v3.x/technical-references/smart-contracts/VkRegistry.md +8 -8
- package/versioned_docs/version-v3.x/technical-references/smart-contracts/VoiceCreditProxy.md +1 -1
- package/versioned_docs/version-v3.x/technical-references/technical-references.md +8 -8
- package/versioned_docs/version-v3.x/technical-references/zk-snark-circuits/joinPoll.md +4 -4
- package/versioned_docs/version-v3.x/technical-references/zk-snark-circuits/processMessages.md +81 -17
- package/versioned_docs/version-v3.x/technical-references/zk-snark-circuits/setup.md +3 -3
- package/versioned_docs/version-v3.x/technical-references/zk-snark-circuits/tallyVotes.md +6 -6
- package/versioned_docs/version-v3.x/technical-references/zk-snark-circuits/utilities.md +9 -9
- package/versioned_docs/version-v3.x/technical-references/zk-snark-circuits/zk-snark-circuits.md +3 -3
package/versioned_docs/version-v2.x/technical-references/smart-contracts/MessageProcessor.md
CHANGED
|
@@ -6,7 +6,7 @@ sidebar_position: 4
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
:::info
|
|
9
|
-
Code location: [MessageProcessor.sol](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
9
|
+
Code location: [MessageProcessor.sol](https://github.com/privacy-scaling-explorations/maci/blob/main/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` and ownership assigned to the coordinator.
|
|
@@ -6,7 +6,7 @@ sidebar_position: 9
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
:::info
|
|
9
|
-
Code location: [Params.sol](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
9
|
+
Code location: [Params.sol](https://github.com/privacy-scaling-explorations/maci/blob/main/contracts/contracts/utils/Params.sol)
|
|
10
10
|
:::
|
|
11
11
|
|
|
12
12
|
A contract holding three structs:
|
|
@@ -6,7 +6,7 @@ sidebar_position: 2
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
:::info
|
|
9
|
-
Code location: [Poll.sol](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
9
|
+
Code location: [Poll.sol](https://github.com/privacy-scaling-explorations/maci/blob/main/contracts/contracts/Poll.sol)
|
|
10
10
|
:::
|
|
11
11
|
|
|
12
12
|
This contract allows users to submit their votes.
|
|
@@ -6,7 +6,7 @@ sidebar_position: 3
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
:::info
|
|
9
|
-
Code location: [PollFactory.sol](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
9
|
+
Code location: [PollFactory.sol](https://github.com/privacy-scaling-explorations/maci/blob/main/contracts/contracts/PollFactory.sol)
|
|
10
10
|
:::
|
|
11
11
|
|
|
12
12
|
`PollFactory` is a smart contract that is used to deploy new Polls. This is used by MACI inside the `deployPoll` function.
|
|
@@ -6,7 +6,7 @@ sidebar_position: 5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
:::info
|
|
9
|
-
Code location: [Tally.sol](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
9
|
+
Code location: [Tally.sol](https://github.com/privacy-scaling-explorations/maci/blob/main/contracts/contracts/Tally.sol)
|
|
10
10
|
:::
|
|
11
11
|
|
|
12
12
|
The `Tally` contract is used by the coordinator to submit commitments to the tally results via the `tallyVotes` function. This is done in batches and the final commitment can be used by the users to verify the validity of the results.
|
|
@@ -6,7 +6,7 @@ sidebar_position: 8
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
:::info
|
|
9
|
-
Code location: [VkRegistry.sol](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
9
|
+
Code location: [VkRegistry.sol](https://github.com/privacy-scaling-explorations/maci/blob/main/contracts/contracts/VkRegistry.sol)
|
|
10
10
|
:::
|
|
11
11
|
|
|
12
12
|
The VkRegistry is a contract that holds the verifying keys for the zk-SNARK circuits. It holds two different sets of keys:
|
package/versioned_docs/version-v2.x/technical-references/smart-contracts/VoiceCreditProxy.md
CHANGED
|
@@ -6,7 +6,7 @@ sidebar_position: 7
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
:::info
|
|
9
|
-
Code location: [InitialVoiceCreditProxy](https://github.com/privacy-scaling-explorations/maci/tree/
|
|
9
|
+
Code location: [InitialVoiceCreditProxy](https://github.com/privacy-scaling-explorations/maci/tree/main/contracts/contracts/initialVoiceCreditProxy)
|
|
10
10
|
:::
|
|
11
11
|
|
|
12
12
|
The VoiceCreditProxy contract is used to assign voice credits to users. Whichever implementation should the MACI deployers use, this must implement a view function that returns the balance for a user, such as the one below:
|
package/versioned_docs/version-v2.x/technical-references/zk-snark-circuits/processMessages.md
CHANGED
|
@@ -5,11 +5,11 @@ sidebar_label: Process Messages Circuit
|
|
|
5
5
|
sidebar_position: 3
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
[**Repo link**](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
8
|
+
[**Repo link**](https://github.com/privacy-scaling-explorations/maci/blob/main/circuits/circom/core)
|
|
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 ^ msgBatchDepth 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/
|
|
12
|
+
The [`processMessages`](https://github.com/privacy-scaling-explorations/maci/blob/main/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:
|
|
14
14
|
|
|
15
15
|
- the related Poll has ended
|
|
@@ -21,7 +21,7 @@ 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/
|
|
24
|
+
A version working with non quadratic voting (non-qv) is also [available](https://github.com/privacy-scaling-explorations/maci/blob/main/circuits/circom/core/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
25
|
:::
|
|
26
26
|
|
|
27
27
|
#### Parameters
|
|
@@ -93,7 +93,7 @@ A simplified example using a tree of arity 2:
|
|
|
93
93
|
|
|
94
94
|
To prove that `a...d` are leaves of the tree with root `r`, we prove that the leaves have the subroot `s` with depth 2, and _then_ prove that `s` is a member of `r` at depth 1.
|
|
95
95
|
|
|
96
|
-
The implementation for this is in the `QuinBatchLeavesExists` circuit in `https://github.com/privacy-scaling-explorations/maci/blob/
|
|
96
|
+
The implementation for this is in the `QuinBatchLeavesExists` circuit in `https://github.com/privacy-scaling-explorations/maci/blob/main/circuits/circom/trees/incrementalQuinTree.circom`.
|
|
97
97
|
|
|
98
98
|
This method requires fewer circuit constraints than if we verified a Merkle proof for each leaf.
|
|
99
99
|
|
|
@@ -5,7 +5,7 @@ sidebar_label: Tally Votes Circuit
|
|
|
5
5
|
sidebar_position: 4
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
[**Repo link**](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
8
|
+
[**Repo link**](https://github.com/privacy-scaling-explorations/maci/blob/main/circuits/circom/core)
|
|
9
9
|
|
|
10
10
|
#### Parameters
|
|
11
11
|
|
|
@@ -18,7 +18,7 @@ sidebar_position: 4
|
|
|
18
18
|

|
|
19
19
|
|
|
20
20
|
:::info
|
|
21
|
-
A version working with non quadratic voting (non-qv) is also [available](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
21
|
+
A version working with non quadratic voting (non-qv) is also [available](https://github.com/privacy-scaling-explorations/maci/blob/main/circuits/circom/core/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
|
package/versioned_docs/version-v2.x/technical-references/zk-snark-circuits/zk-snark-circuits.md
CHANGED
|
@@ -5,10 +5,10 @@ sidebar_label: zk-SNARK Circuits
|
|
|
5
5
|
sidebar_position: 1
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
MACI has two main zk-SNARK [circuits](https://github.com/privacy-scaling-explorations/maci/tree/
|
|
8
|
+
MACI has two main zk-SNARK [circuits](https://github.com/privacy-scaling-explorations/maci/tree/main/circuits):
|
|
9
9
|
|
|
10
|
-
1. ProcessMessages.circom, which takes a batch of encrypted messages, decrypts them, and generates a proof that the coordinator's local processing was performed correctly. [QV](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
11
|
-
2. TallyVotes.circom, which counts votes from users' ballots, batch by batch. [QV](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
10
|
+
1. ProcessMessages.circom, which takes a batch of encrypted messages, decrypts them, and generates a proof that the coordinator's local processing was performed correctly. [QV](https://github.com/privacy-scaling-explorations/maci/blob/main/circuits/circom/core/qv/processMessages.circom) and [non-QV](https://github.com/privacy-scaling-explorations/maci/blob/main/circuits/circom/core/non-qv/processMessages.circom) versions are available.
|
|
11
|
+
2. TallyVotes.circom, which counts votes from users' ballots, batch by batch. [QV](https://github.com/privacy-scaling-explorations/maci/blob/main/circuits/circom/core/qv/tallyVotes.circom) and [non-QV](https://github.com/privacy-scaling-explorations/maci/blob/main/circuits/circom/core/non-qv/tallyVotes.circom) versions are available.
|
|
12
12
|
|
|
13
13
|
The rest of the circuits are utilities templates that are required for the main circuits to work correctly. These include utilities such as float math, conversion of private keys, and Poseidon hashing/encryption.
|
|
14
14
|
|
|
@@ -57,15 +57,21 @@ Pull requests are great if you want to add a feature or fix a bug. Here's a quic
|
|
|
57
57
|
|
|
58
58
|
7. Make the test pass.
|
|
59
59
|
|
|
60
|
-
8. Commit your changes. Please make sure your forked `
|
|
60
|
+
8. Commit your changes. Please make sure your forked `main` branch is synced as well feature/fix branch and there are no "temp" commits (like wip, fix typo/lint/types and etc). We recommend to squash the feature/fix branch commits before creating PR. You can use this command for it:
|
|
61
61
|
|
|
62
62
|
```bash
|
|
63
|
-
git
|
|
63
|
+
git checkout main
|
|
64
|
+
git pull
|
|
65
|
+
git checkout your-branch
|
|
66
|
+
git rebase main
|
|
67
|
+
git reset $(git merge-base main $(git rev-parse --abbrev-ref HEAD))
|
|
64
68
|
```
|
|
65
69
|
|
|
66
|
-
9.
|
|
70
|
+
9. Before creating a pull request make sure your work is ready. Do not create WIP pull requests and do not skip pre-commit hooks.
|
|
67
71
|
|
|
68
|
-
10.
|
|
72
|
+
10. Push to your fork and submit a pull request on our `main` branch. Please provide us with some explanation of why you made the changes you made. For new features make sure to explain a standard use case to us. Do not remove our PR template and follow all the steps defined in it.
|
|
73
|
+
|
|
74
|
+
11. Link any issues that the PR is addressing as described in our processes documentation.
|
|
69
75
|
|
|
70
76
|
## CI (Github Actions) Tests
|
|
71
77
|
|
|
@@ -131,7 +137,7 @@ Just as in the subject, use the imperative, present tense: "change" not "changed
|
|
|
131
137
|
|
|
132
138
|
### Branch rules
|
|
133
139
|
|
|
134
|
-
- Branches should generally be created off of the base branch (`
|
|
140
|
+
- Branches should generally be created off of the base branch (`main` )
|
|
135
141
|
- Avoid long descriptive names for long-lived branches
|
|
136
142
|
- Use kebab-case (no CamelCase)
|
|
137
143
|
- Use grouping tokens (words) at the beginning of your branch names (in a similar way to the `type` of commit)
|
|
@@ -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
|
|
27
|
-
2. Bob (Briber) bribes Alice and asks her to submit a key change message to $
|
|
28
|
-
3. Bob submits a vote with $
|
|
29
|
-
4. Alice submits a vote with $
|
|
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 $
|
|
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
|
|
50
|
+
const secondKeypair = new Keypair();
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
- Votes will be
|
|
@@ -77,10 +77,10 @@ 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
|
|
80
|
+
const maciState = new MaciState(STATE_TREE_DEPTH);
|
|
81
81
|
// Sign up
|
|
82
|
-
user1StateIndex = maciState.signUp(user1Keypair.
|
|
83
|
-
user2StateIndex = maciState.signUp(user2Keypair.
|
|
82
|
+
user1StateIndex = maciState.signUp(user1Keypair.publicKey, voiceCreditBalance, BigInt(Math.floor(Date.now() / 1000)));
|
|
83
|
+
user2StateIndex = maciState.signUp(user2Keypair.publicKey, voiceCreditBalance, BigInt(Math.floor(Date.now() / 1000)));
|
|
84
84
|
// deploy a poll
|
|
85
85
|
pollId = maciState.deployPoll(
|
|
86
86
|
duration,
|
|
@@ -95,61 +95,61 @@ pollId = maciState.deployPoll(
|
|
|
95
95
|
|
|
96
96
|
```ts
|
|
97
97
|
const poll = maciState.polls[pollId];
|
|
98
|
-
const command1 = new
|
|
98
|
+
const command1 = new VoteCommand(
|
|
99
99
|
BigInt(user1StateIndex),
|
|
100
|
-
user1Keypair.
|
|
100
|
+
user1Keypair.publicKey,
|
|
101
101
|
user1VoteOptionIndex,
|
|
102
102
|
user1VoteWeight,
|
|
103
103
|
BigInt(1),
|
|
104
104
|
BigInt(pollId),
|
|
105
105
|
);
|
|
106
106
|
|
|
107
|
-
const signature1 = command1.sign(user1Keypair.
|
|
107
|
+
const signature1 = command1.sign(user1Keypair.privateKey);
|
|
108
108
|
|
|
109
109
|
const ecdhKeypair1 = new Keypair();
|
|
110
|
-
const sharedKey1 = Keypair.genEcdhSharedKey(ecdhKeypair1.
|
|
110
|
+
const sharedKey1 = Keypair.genEcdhSharedKey(ecdhKeypair1.privateKey, coordinatorKeypair.publicKey);
|
|
111
111
|
|
|
112
112
|
const message1 = command1.encrypt(signature1, sharedKey1);
|
|
113
|
-
poll.publishMessage(message1, ecdhKeypair1.
|
|
113
|
+
poll.publishMessage(message1, ecdhKeypair1.publicKey);
|
|
114
114
|
|
|
115
|
-
const command2 = new
|
|
115
|
+
const command2 = new VoteCommand(
|
|
116
116
|
BigInt(user2StateIndex),
|
|
117
|
-
user2Keypair.
|
|
117
|
+
user2Keypair.publicKey,
|
|
118
118
|
user2VoteOptionIndex,
|
|
119
119
|
user2VoteWeight,
|
|
120
120
|
BigInt(1),
|
|
121
121
|
BigInt(pollId),
|
|
122
122
|
);
|
|
123
123
|
|
|
124
|
-
const signature2 = command2.sign(user2Keypair.
|
|
124
|
+
const signature2 = command2.sign(user2Keypair.privateKey);
|
|
125
125
|
|
|
126
126
|
const ecdhKeypair2 = new Keypair();
|
|
127
|
-
const sharedKey2 = Keypair.genEcdhSharedKey(ecdhKeypair2.
|
|
127
|
+
const sharedKey2 = Keypair.genEcdhSharedKey(ecdhKeypair2.privateKey, coordinatorKeypair.publicKey);
|
|
128
128
|
|
|
129
129
|
const message2 = command2.encrypt(signature2, sharedKey2);
|
|
130
|
-
poll.publishMessage(message2, ecdhKeypair2.
|
|
130
|
+
poll.publishMessage(message2, ecdhKeypair2.publicKey);
|
|
131
131
|
```
|
|
132
132
|
|
|
133
133
|
- User1 submits a key change message with the new vote
|
|
134
134
|
|
|
135
135
|
```ts
|
|
136
136
|
const poll = maciState.polls[pollId];
|
|
137
|
-
const command = new
|
|
137
|
+
const command = new VoteCommand(
|
|
138
138
|
BigInt(user1StateIndex),
|
|
139
|
-
|
|
139
|
+
secondKeypair.publicKey,
|
|
140
140
|
user1VoteOptionIndex,
|
|
141
141
|
user1NewVoteWeight,
|
|
142
142
|
BigInt(1),
|
|
143
143
|
BigInt(pollId),
|
|
144
144
|
);
|
|
145
145
|
|
|
146
|
-
const signature = command.sign(user1Keypair.
|
|
146
|
+
const signature = command.sign(user1Keypair.privateKey);
|
|
147
147
|
|
|
148
148
|
const ecdhKeypair = new Keypair();
|
|
149
|
-
const sharedKey = Keypair.genEcdhSharedKey(ecdhKeypair.
|
|
149
|
+
const sharedKey = Keypair.genEcdhSharedKey(ecdhKeypair.privateKey, coordinatorKeypair.publicKey);
|
|
150
150
|
|
|
151
151
|
const message = command.encrypt(signature, sharedKey);
|
|
152
|
-
poll.publishMessage(message, ecdhKeypair.
|
|
152
|
+
poll.publishMessage(message, ecdhKeypair.publicKey);
|
|
153
153
|
```
|
|
154
154
|
|
|
155
155
|
- We process the votes and check that the result is as expected (`user1NewVoteWeight` was 5 and `user2VoteWeight` 3)
|
|
@@ -158,8 +158,8 @@ poll.publishMessage(message, ecdhKeypair.pubKey);
|
|
|
158
158
|
const poll = maciState.polls[pollId];
|
|
159
159
|
poll.processMessages(pollId);
|
|
160
160
|
poll.tallyVotes();
|
|
161
|
-
expect(poll.
|
|
162
|
-
expect(poll.
|
|
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
|
|
@@ -168,12 +168,12 @@ expect(poll.perVOSpentVoiceCredits[1].toString()).to.eq((user2VoteWeight * user2
|
|
|
168
168
|
const poll = maciState.polls[pollId];
|
|
169
169
|
const stateLeaf1 = poll.stateLeaves[user1StateIndex];
|
|
170
170
|
const stateLeaf2 = poll.stateLeaves[user2StateIndex];
|
|
171
|
-
expect(stateLeaf1.
|
|
172
|
-
expect(stateLeaf2.
|
|
171
|
+
expect(stateLeaf1.publicKey.equals(user1SecondKeypair.publicKey)).to.eq(true);
|
|
172
|
+
expect(stateLeaf2.publicKey.equals(user2Keypair.publicKey)).to.eq(true);
|
|
173
173
|
```
|
|
174
174
|
|
|
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/
|
|
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
|
|
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/
|
|
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 `
|
|
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
|
-
"
|
|
26
|
-
"
|
|
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 `
|
|
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
|
-
"
|
|
50
|
-
"
|
|
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
|
|
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
|
-
"
|
|
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/
|
|
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 `
|
|
43
|
+
In the deploy-config.json file set the `mode` value to **qv**.
|
|
44
44
|
|
|
45
45
|
```json
|
|
46
46
|
"Poll": {
|
|
47
47
|
[...]
|
|
48
|
-
"
|
|
49
|
-
"
|
|
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 `
|
|
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
|
-
"
|
|
73
|
-
"
|
|
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
|
|