@maci-protocol/website 0.0.0-ci.a577366 → 0.0.0-ci.a73cfa9
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/blog/2025-09-05-maci-coordinator-service.md +167 -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/coordinator-service/index.md +15 -1
- package/versioned_docs/version-v3.x/technical-references/coordinator-service/installation.md +5 -33
- package/versioned_docs/version-v3.x/technical-references/coordinator-service/usage.md +64 -0
- package/versioned_docs/version-v3.x/technical-references/smart-contracts/MACI.md +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
|
@@ -86,7 +86,7 @@ while true:
|
|
|
86
86
|
if rand >= min:
|
|
87
87
|
break
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
privateKey = rand % p
|
|
90
90
|
```
|
|
91
91
|
|
|
92
92
|
#### 1.3. Private key formatting
|
|
@@ -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
|
|
554
|
-
|
|
|
555
|
-
| `
|
|
556
|
-
| `
|
|
557
|
-
| `
|
|
558
|
-
| `setVerifyingKeys`
|
|
559
|
-
| `create`
|
|
560
|
-
| `deployPoll`
|
|
561
|
-
| `signup`
|
|
562
|
-
| `publish`
|
|
563
|
-
| `mergeMessages`
|
|
564
|
-
| `mergeSignups`
|
|
565
|
-
| `
|
|
566
|
-
| `proveOnChain`
|
|
567
|
-
|
|
568
|
-
## 5.
|
|
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/
|
|
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
|
-
| `
|
|
657
|
-
| `
|
|
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
|
-
| `
|
|
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
|
-
| `
|
|
670
|
-
| `
|
|
671
|
-
| `
|
|
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
|
-
| `
|
|
608
|
+
| `coordinatorPrivateKey` | The coordinator's private key |
|
|
675
609
|
| `batchEndIndex` | The last batch index |
|
|
676
|
-
| `
|
|
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
|
-
##### `
|
|
638
|
+
##### `messageSubrootPathElements`
|
|
705
639
|
|
|
706
|
-
The index of each message in `
|
|
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 `
|
|
731
|
-
4. That `coordinatorPublicKeyHash` is a hash of public key that is correctly derived from `
|
|
732
|
-
5. That each message in `
|
|
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 (`
|
|
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
|
|
821
|
-
|
|
|
822
|
-
| `stateTreeDepth`
|
|
823
|
-
| `
|
|
824
|
-
| `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` |
|
|
825
759
|
|
|
826
760
|
#### Input signals
|
|
827
761
|
|
|
828
762
|
| Input signal | Description |
|
|
829
763
|
| --------------------------------------- | ---------------------------------------------------------------- |
|
|
830
|
-
| `
|
|
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 `
|
|
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 **
|
|
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/
|
|
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
|
|
|
@@ -77,28 +77,28 @@ 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
|
-
"pubs": ["nullifier", "stateRoot", "
|
|
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
|
-
"
|
|
97
|
-
"file": "./
|
|
98
|
-
"template": "
|
|
96
|
+
"MessageProcessorQv_10-20-2_test": {
|
|
97
|
+
"file": "./coordinator/qv/MessageProcessor",
|
|
98
|
+
"template": "MessageProcessorQv",
|
|
99
99
|
"params": [10, 20, 2],
|
|
100
100
|
"pubs": [
|
|
101
|
-
"
|
|
101
|
+
"totalSignups",
|
|
102
102
|
"index",
|
|
103
103
|
"batchEndIndex",
|
|
104
104
|
"currentSbCommitment",
|
|
@@ -109,12 +109,12 @@ Edit `circuits/circom/circuits` to include the circuits you would like to compil
|
|
|
109
109
|
"voteOptions"
|
|
110
110
|
]
|
|
111
111
|
},
|
|
112
|
-
"
|
|
113
|
-
"file": "./
|
|
114
|
-
"template": "
|
|
112
|
+
"MessageProcessorNonQv_10-20-2_test": {
|
|
113
|
+
"file": "./coordinator/non-qv/MessageProcessor",
|
|
114
|
+
"template": "MessageProcessorNonQv",
|
|
115
115
|
"params": [10, 20, 2],
|
|
116
116
|
"pubs": [
|
|
117
|
-
"
|
|
117
|
+
"totalSignups",
|
|
118
118
|
"index",
|
|
119
119
|
"batchEndIndex",
|
|
120
120
|
"currentSbCommitment",
|
|
@@ -125,17 +125,33 @@ Edit `circuits/circom/circuits` to include the circuits you would like to compil
|
|
|
125
125
|
"voteOptions"
|
|
126
126
|
]
|
|
127
127
|
},
|
|
128
|
-
"
|
|
129
|
-
"file": "./
|
|
130
|
-
"template": "
|
|
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
|
+
},
|
|
144
|
+
"VoteTallyQv_10-1-2_test": {
|
|
145
|
+
"file": "./coordinator/qv/VoteTally",
|
|
146
|
+
"template": "VoteTallyQv",
|
|
131
147
|
"params": [10, 1, 2],
|
|
132
|
-
"pubs": ["index", "
|
|
148
|
+
"pubs": ["index", "totalSignups", "sbCommitment", "currentTallyCommitment", "newTallyCommitment"]
|
|
133
149
|
},
|
|
134
|
-
"
|
|
135
|
-
"file": "./
|
|
136
|
-
"template": "
|
|
150
|
+
"VoteTallyNonQv_10-1-2_test": {
|
|
151
|
+
"file": "./coordinator/non-qv/VoteTally",
|
|
152
|
+
"template": "VoteTallyNonQv",
|
|
137
153
|
"params": [10, 1, 2],
|
|
138
|
-
"pubs": ["index", "
|
|
154
|
+
"pubs": ["index", "totalSignups", "sbCommitment", "currentTallyCommitment", "newTallyCommitment"]
|
|
139
155
|
}
|
|
140
156
|
}
|
|
141
157
|
```
|
|
@@ -17,12 +17,12 @@ As an example, a [contract](https://github.com/ctrlc03/minimalQF/blob/main/contr
|
|
|
17
17
|
|
|
18
18
|
```javascript
|
|
19
19
|
/// @inheritdoc IMACI
|
|
20
|
-
function signUp(
|
|
20
|
+
function signUp(PublicKey memory _publicKey, bytes memory _signUpPolicyData) public virtual {
|
|
21
21
|
// ensure we do not have more signups than what the circuits support
|
|
22
22
|
if (leanIMTData.size >= maxSignups) revert TooManySignups();
|
|
23
23
|
|
|
24
24
|
// ensure that the public key is on the baby jubjub curve
|
|
25
|
-
if (!CurveBabyJubJub.isOnCurve(
|
|
25
|
+
if (!CurveBabyJubJub.isOnCurve(_publicKey.x, _publicKey.y)) {
|
|
26
26
|
revert InvalidPubKey();
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -31,19 +31,19 @@ function signUp(PubKey memory _pubKey, bytes memory _signUpPolicyData) public vi
|
|
|
31
31
|
signUpPolicy.enforce(msg.sender, _signUpPolicyData);
|
|
32
32
|
|
|
33
33
|
// Hash the public key and insert it into the tree.
|
|
34
|
-
uint256 pubKeyHash = hashLeftRight(
|
|
34
|
+
uint256 pubKeyHash = hashLeftRight(_publicKey.x, _publicKey.y);
|
|
35
35
|
uint256 stateRoot = InternalLeanIMT._insert(leanIMTData, pubKeyHash);
|
|
36
36
|
|
|
37
37
|
// Store the current state tree root in the array
|
|
38
38
|
stateRootsOnSignUp.push(stateRoot);
|
|
39
39
|
|
|
40
|
-
emit SignUp(leanIMTData.size - 1, block.timestamp,
|
|
40
|
+
emit SignUp(leanIMTData.size - 1, block.timestamp, _publicKey.x, _publicKey.y);
|
|
41
41
|
}
|
|
42
42
|
```
|
|
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/main/packages/contracts/contracts/interfaces/IInitialVoiceCreditProxy.sol). You can see our [basic example](https://github.com/privacy-scaling-explorations/maci/blob/main/packages/contracts/contracts/initialVoiceCreditProxy/ConstantInitialVoiceCreditProxy.sol) how it's implemented for constant distribution.
|
|
47
47
|
|
|
48
48
|
```ts
|
|
49
49
|
contract ConstantInitialVoiceCreditProxy is InitialVoiceCreditProxy {
|
|
@@ -71,7 +71,7 @@ On the other hand, the Poll contract can be inherited to expand functionality su
|
|
|
71
71
|
```javascript
|
|
72
72
|
function joinPoll(
|
|
73
73
|
uint256 _nullifier,
|
|
74
|
-
|
|
74
|
+
PublicKey calldata _publicKey,
|
|
75
75
|
uint256 _stateRootIndex,
|
|
76
76
|
uint256[8] calldata _proof,
|
|
77
77
|
bytes memory _signUpPolicyData,
|
|
@@ -86,7 +86,7 @@ function joinPoll(
|
|
|
86
86
|
pollNullifiers[_nullifier] = true;
|
|
87
87
|
|
|
88
88
|
// Verify user's proof
|
|
89
|
-
if (!verifyJoiningPollProof(_nullifier, _stateRootIndex,
|
|
89
|
+
if (!verifyJoiningPollProof(_nullifier, _stateRootIndex, _publicKey, _proof)) {
|
|
90
90
|
revert InvalidPollProof();
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -100,7 +100,7 @@ function joinPoll(
|
|
|
100
100
|
);
|
|
101
101
|
|
|
102
102
|
// Store user in the pollStateTree
|
|
103
|
-
uint256 stateLeaf = hashStateLeaf(StateLeaf(
|
|
103
|
+
uint256 stateLeaf = hashStateLeaf(StateLeaf(_publicKey, voiceCreditBalance, block.timestamp));
|
|
104
104
|
|
|
105
105
|
uint256 stateRoot = InternalLazyIMT._insert(pollStateTree, stateLeaf);
|
|
106
106
|
|
|
@@ -108,7 +108,7 @@ function joinPoll(
|
|
|
108
108
|
pollStateRootsOnJoin.push(stateRoot);
|
|
109
109
|
|
|
110
110
|
uint256 pollStateIndex = pollStateTree.numberOfLeaves - 1;
|
|
111
|
-
emit PollJoined(
|
|
111
|
+
emit PollJoined(_publicKey.x, _publicKey.y, voiceCreditBalance, block.timestamp, _nullifier, pollStateIndex);
|
|
112
112
|
}
|
|
113
113
|
```
|
|
114
114
|
|
|
@@ -118,7 +118,7 @@ Given the verification functions being exposed by the Tally contract, quadratic
|
|
|
118
118
|
|
|
119
119
|
## SDK
|
|
120
120
|
|
|
121
|
-
Another important component of MACI is the [SDK](https://github.com/privacy-scaling-explorations/maci/tree/
|
|
121
|
+
Another important component of MACI is the [SDK](https://github.com/privacy-scaling-explorations/maci/tree/main/packages/sdk). This is a TypeScript library that allows you to interact with MACI.
|
|
122
122
|
|
|
123
123
|
You can find the following subdirectories, where functions are organised as follows:
|
|
124
124
|
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: MACI SDK
|
|
3
|
+
description: How to use the MACI SDK
|
|
4
|
+
sidebar_label: MACI SDK
|
|
5
|
+
sidebar_position: 6
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
In this guide we will be looking at how to use the MACI SDK to interact with the MACI protocol.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @maci-protocol/sdk
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Browser compatibility
|
|
17
|
+
|
|
18
|
+
As the SDK imports functions from the `@maci-protocol/contracts` package which uses hardhat, certain functionality is not browser compatible.
|
|
19
|
+
However, all it takes to use browser compatible functions is to import from `@maci-protocol/sdk/browser`.
|
|
20
|
+
|
|
21
|
+
As an example, we can import the `signUp` function from the `@maci-protocol/sdk/browser` package.
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { signUp } from "@maci-protocol/sdk/browser";
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Let's take a look at an example of how to use the `joinPoll` function to register a user to a poll.
|
|
28
|
+
|
|
29
|
+
### JoinPoll
|
|
30
|
+
|
|
31
|
+
This step is required to register a user to a specific poll for which they want to vote. In short, it requires the user to generate a zk-SNARK proof that they know the private key to a public key registered to the MACI contract (proving they passed the initial gatekeeping requirements). This forces them to join with the same MACI key to each poll, greatly increasing the value of the key. Should they have been allowed to join with a throwaway key, they could simply sell their key for polls they do not care about.
|
|
32
|
+
|
|
33
|
+
**How does the flow look like?**
|
|
34
|
+
|
|
35
|
+
1. Reconstruct the MACI state tree by pulling all public keys from the MACI contract (events from RPC or from Subgraph)
|
|
36
|
+
2. Generate a merkle tree inclusion proof for the user's public key
|
|
37
|
+
3. Generate a zk-SNARK proof that the user knows the private key to the public key in the merkle tree inclusion proof
|
|
38
|
+
4. Call the `joinPoll` function on the Poll smart contract
|
|
39
|
+
|
|
40
|
+
**How to use the SDK for this?**
|
|
41
|
+
|
|
42
|
+
> This example is browser specific, as it uses the `@maci-protocol/sdk/browser` package and WASM for witness generation
|
|
43
|
+
|
|
44
|
+
Option 1: Use the `joinPoll` function from the `@maci-protocol/sdk/browser` package.
|
|
45
|
+
|
|
46
|
+
1. Download the `pollJoining` zk artifacts using [downloadPollJoiningArtifactsBrowser](https://github.com/privacy-scaling-explorations/maci/blob/main/packages/sdk/ts/proof/download.ts#L46)
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import { downloadPollJoiningArtifactsBrowser } from "@maci-protocol/sdk/browser";
|
|
50
|
+
|
|
51
|
+
const artifacts = await downloadPollJoiningArtifactsBrowser({
|
|
52
|
+
testing: true,
|
|
53
|
+
stateTreeDepth: 10,
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
2. Use the `joinPoll` function to join the poll
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import { joinPoll } from "@maci-protocol/sdk/browser";
|
|
61
|
+
|
|
62
|
+
const joinedPollData = await joinPoll({
|
|
63
|
+
maciAddress: PUBLIC_MACI_ADDRESS,
|
|
64
|
+
privateKey: maciKeypair.privateKey.serialize(),
|
|
65
|
+
signer,
|
|
66
|
+
pollId,
|
|
67
|
+
inclusionProof,
|
|
68
|
+
pollJoiningZkey: artifacts.zKey as unknown as string,
|
|
69
|
+
pollWasm: artifacts.wasm as unknown as string,
|
|
70
|
+
sgDataArg: DEFAULT_SG_DATA,
|
|
71
|
+
ivcpDataArg: DEFAULT_IVCP_DATA,
|
|
72
|
+
blocksPerBatch: 1000,
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
This is not really efficient, as we are using the user RPC to fetch events, which can be quite slow and prone to errors. A better approach is to use a Subgraph to fetch the events.
|
|
77
|
+
|
|
78
|
+
Option 2: Fetch the MACI keys using a subgraph and reconstruct the state tree locally.
|
|
79
|
+
|
|
80
|
+
1. Deploy the subgraph - instructions [here](/guides/subgraph)
|
|
81
|
+
2. Fetch the MACI keys
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
import { MaciSubgraph } from "@maci-protocol/sdk/browser";
|
|
85
|
+
|
|
86
|
+
const subgraph = new MaciSubgraph("https://api.studio.thegraph.com/query/x/maci/version/latest");
|
|
87
|
+
|
|
88
|
+
const keys = await subgraph.getKeys();
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
3. Generate the merkle tree
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
import { generateSignUpTreeFromKeys } from "@maci-protocol/sdk/browser";
|
|
95
|
+
|
|
96
|
+
const signUpTree = generateSignUpTreeFromKeys(keys);
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
4. Generate the inclusion proof - you will need to know the index of the user's public key in the merkle tree
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
const inclusionProof = signUpTree.generateProof(publicKeyIndex);
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
5. Generate the zk-SNARK proof and join the poll
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
import { joinPoll } from "@maci-protocol/sdk/browser";
|
|
109
|
+
|
|
110
|
+
const joinedPollData = await joinPoll({
|
|
111
|
+
maciAddress: PUBLIC_MACI_ADDRESS,
|
|
112
|
+
privateKey: maciKeypair.privateKey.serialize(),
|
|
113
|
+
signer,
|
|
114
|
+
pollId,
|
|
115
|
+
inclusionProof,
|
|
116
|
+
pollJoiningZkey: artifacts.zKey as unknown as string,
|
|
117
|
+
pollWasm: artifacts.wasm as unknown as string,
|
|
118
|
+
sgDataArg: DEFAULT_SG_DATA,
|
|
119
|
+
ivcpDataArg: DEFAULT_IVCP_DATA,
|
|
120
|
+
});
|
|
121
|
+
```
|
|
@@ -154,7 +154,7 @@ Within the circuits folder, there are a number of tests that are used to verify
|
|
|
154
154
|
|
|
155
155
|
These tests often use mock data from the `core` package. For instance, when testing the `processMessages` circuit, we are required to generate the parameters from the `core` packing, using the `Poll:processMessages` function. The same applies to vote tallying, where we need the `Poll:tally` function to be run first with mock users and vote messages.
|
|
156
156
|
|
|
157
|
-
All of the tests run using test parameters, usually `10, 20, 2`, aside from the tests inside: [`ceremonyParam`](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
157
|
+
All of the tests run using test parameters, usually `10, 20, 2`, aside from the tests inside: [`ceremonyParam`](https://github.com/privacy-scaling-explorations/maci/blob/main/circuits/ts/__tests__/CeremonyParams.test.ts) which use the parameters of the latest MACI ceremony. More details on the trusted setup can be found [here](/docs/security/trusted-setup).
|
|
158
158
|
|
|
159
159
|
### Core
|
|
160
160
|
|
|
@@ -162,7 +162,7 @@ The core package contains a number of tests that are used to verify that the cor
|
|
|
162
162
|
|
|
163
163
|
These tests interact with the crypto and dombinobjs packages, where mock data comes from. Their main goal is to ensure that the core functions work as expected, and that the state is as expected after a series of operations.
|
|
164
164
|
|
|
165
|
-
Currently, there is a blend of e2e and unit tests, where e2e tests are used to verify that the entire MACI local processing works as expected (users signup, publish votes, messages are processed and finally these votes are tallied). Unit tests on the other hand are used to verify that the core functions work as expected, such as `
|
|
165
|
+
Currently, there is a blend of e2e and unit tests, where e2e tests are used to verify that the entire MACI local processing works as expected (users signup, publish votes, messages are processed and finally these votes are tallied). Unit tests on the other hand are used to verify that the core functions work as expected, such as `MessageProcessor` and `VoteTally`. You will find them in separate files, with e2e being [here](https://github.com/privacy-scaling-explorations/maci/blob/main/core/ts/__tests__/e2e.test.ts) and unit tests in the other files.
|
|
166
166
|
|
|
167
167
|
### Domainobjs/Crypto tests
|
|
168
168
|
|
|
@@ -170,13 +170,13 @@ These tests are used to verify that MACI's primitives such as private keys work
|
|
|
170
170
|
|
|
171
171
|
## "Manual" Testing
|
|
172
172
|
|
|
173
|
-
To ensure that the MACI stack works as expected, without having to run the entire test suite (or even just the e2e tests), there is a [bash script](https://github.com/privacy-scaling-explorations/maci/blob/
|
|
173
|
+
To ensure that the MACI stack works as expected, without having to run the entire test suite (or even just the e2e tests), there is a [bash script](https://github.com/privacy-scaling-explorations/maci/blob/main/packages/contracts/testScriptLocalhost.sh) inside the contracts folder which can be used.
|
|
174
174
|
|
|
175
175
|
This script contains a number of actions which touch all of the parts of MACI, and resemble exactly what other e2e tests do.
|
|
176
176
|
|
|
177
177
|
Looking at this in more details we do the following:
|
|
178
178
|
|
|
179
|
-
1. Deploy a `
|
|
179
|
+
1. Deploy a `VerifyingKeysRegistry` contract
|
|
180
180
|
2. Set the verification keys on this smart contract
|
|
181
181
|
3. Deploy a `MACI` contract (and associated utility contracts)
|
|
182
182
|
4. Deploy a Poll from the MACI contract.
|