@maci-protocol/sdk 0.0.0-ci.00107eb
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/CHANGELOG.md +80 -0
- package/LICENSE +21 -0
- package/README.md +12 -0
- package/build/package.json +65 -0
- package/build/ts/browser/index.d.ts +15 -0
- package/build/ts/browser/index.d.ts.map +1 -0
- package/build/ts/browser/index.js +40 -0
- package/build/ts/browser/index.js.map +1 -0
- package/build/ts/browser/joinPoll.d.ts +10 -0
- package/build/ts/browser/joinPoll.d.ts.map +1 -0
- package/build/ts/browser/joinPoll.js +88 -0
- package/build/ts/browser/joinPoll.js.map +1 -0
- package/build/ts/browser/utils.d.ts +18 -0
- package/build/ts/browser/utils.d.ts.map +1 -0
- package/build/ts/browser/utils.js +37 -0
- package/build/ts/browser/utils.js.map +1 -0
- package/build/ts/deploy/index.d.ts +6 -0
- package/build/ts/deploy/index.d.ts.map +1 -0
- package/build/ts/deploy/index.js +12 -0
- package/build/ts/deploy/index.js.map +1 -0
- package/build/ts/deploy/maci.d.ts +8 -0
- package/build/ts/deploy/maci.d.ts.map +1 -0
- package/build/ts/deploy/maci.js +97 -0
- package/build/ts/deploy/maci.js.map +1 -0
- package/build/ts/deploy/poll.d.ts +8 -0
- package/build/ts/deploy/poll.d.ts.map +1 -0
- package/build/ts/deploy/poll.js +112 -0
- package/build/ts/deploy/poll.js.map +1 -0
- package/build/ts/deploy/types.d.ts +225 -0
- package/build/ts/deploy/types.d.ts.map +1 -0
- package/build/ts/deploy/types.js +3 -0
- package/build/ts/deploy/types.js.map +1 -0
- package/build/ts/deploy/utils.d.ts +11 -0
- package/build/ts/deploy/utils.d.ts.map +1 -0
- package/build/ts/deploy/utils.js +22 -0
- package/build/ts/deploy/utils.js.map +1 -0
- package/build/ts/deploy/verifyingKeysRegistry.d.ts +7 -0
- package/build/ts/deploy/verifyingKeysRegistry.d.ts.map +1 -0
- package/build/ts/deploy/verifyingKeysRegistry.js +14 -0
- package/build/ts/deploy/verifyingKeysRegistry.js.map +1 -0
- package/build/ts/index.d.ts +17 -0
- package/build/ts/index.d.ts.map +1 -0
- package/build/ts/index.js +89 -0
- package/build/ts/index.js.map +1 -0
- package/build/ts/maci/index.d.ts +6 -0
- package/build/ts/maci/index.d.ts.map +1 -0
- package/build/ts/maci/index.js +17 -0
- package/build/ts/maci/index.js.map +1 -0
- package/build/ts/maci/merge.d.ts +9 -0
- package/build/ts/maci/merge.d.ts.map +1 -0
- package/build/ts/maci/merge.js +29 -0
- package/build/ts/maci/merge.js.map +1 -0
- package/build/ts/maci/policy.d.ts +53 -0
- package/build/ts/maci/policy.d.ts.map +1 -0
- package/build/ts/maci/policy.js +166 -0
- package/build/ts/maci/policy.js.map +1 -0
- package/build/ts/maci/state.d.ts +8 -0
- package/build/ts/maci/state.d.ts.map +1 -0
- package/build/ts/maci/state.js +82 -0
- package/build/ts/maci/state.js.map +1 -0
- package/build/ts/maci/types.d.ts +208 -0
- package/build/ts/maci/types.d.ts.map +1 -0
- package/build/ts/maci/types.js +20 -0
- package/build/ts/maci/types.js.map +1 -0
- package/build/ts/maciKeys/__tests__/keypair.test.d.ts +2 -0
- package/build/ts/maciKeys/__tests__/keypair.test.d.ts.map +1 -0
- package/build/ts/maciKeys/__tests__/keypair.test.js +24 -0
- package/build/ts/maciKeys/__tests__/keypair.test.js.map +1 -0
- package/build/ts/maciKeys/__tests__/publicKeys.test.d.ts +2 -0
- package/build/ts/maciKeys/__tests__/publicKeys.test.d.ts.map +1 -0
- package/build/ts/maciKeys/__tests__/publicKeys.test.js +22 -0
- package/build/ts/maciKeys/__tests__/publicKeys.test.js.map +1 -0
- package/build/ts/maciKeys/index.d.ts +4 -0
- package/build/ts/maciKeys/index.d.ts.map +1 -0
- package/build/ts/maciKeys/index.js +8 -0
- package/build/ts/maciKeys/index.js.map +1 -0
- package/build/ts/maciKeys/keypair.d.ts +9 -0
- package/build/ts/maciKeys/keypair.d.ts.map +1 -0
- package/build/ts/maciKeys/keypair.js +21 -0
- package/build/ts/maciKeys/keypair.js.map +1 -0
- package/build/ts/maciKeys/publicKeys.d.ts +8 -0
- package/build/ts/maciKeys/publicKeys.d.ts.map +1 -0
- package/build/ts/maciKeys/publicKeys.js +23 -0
- package/build/ts/maciKeys/publicKeys.js.map +1 -0
- package/build/ts/maciKeys/types.d.ts +28 -0
- package/build/ts/maciKeys/types.d.ts.map +1 -0
- package/build/ts/maciKeys/types.js +3 -0
- package/build/ts/maciKeys/types.js.map +1 -0
- package/build/ts/poll/index.d.ts +4 -0
- package/build/ts/poll/index.d.ts.map +1 -0
- package/build/ts/poll/index.js +9 -0
- package/build/ts/poll/index.js.map +1 -0
- package/build/ts/poll/poll.d.ts +14 -0
- package/build/ts/poll/poll.d.ts.map +1 -0
- package/build/ts/poll/poll.js +62 -0
- package/build/ts/poll/poll.js.map +1 -0
- package/build/ts/poll/types.d.ts +151 -0
- package/build/ts/poll/types.d.ts.map +1 -0
- package/build/ts/poll/types.js +3 -0
- package/build/ts/poll/types.js.map +1 -0
- package/build/ts/poll/utils.d.ts +9 -0
- package/build/ts/poll/utils.d.ts.map +1 -0
- package/build/ts/poll/utils.js +43 -0
- package/build/ts/poll/utils.js.map +1 -0
- package/build/ts/proof/__tests__/download.test.d.ts +2 -0
- package/build/ts/proof/__tests__/download.test.d.ts.map +1 -0
- package/build/ts/proof/__tests__/download.test.js +53 -0
- package/build/ts/proof/__tests__/download.test.js.map +1 -0
- package/build/ts/proof/download.d.ts +9 -0
- package/build/ts/proof/download.d.ts.map +1 -0
- package/build/ts/proof/download.js +47 -0
- package/build/ts/proof/download.js.map +1 -0
- package/build/ts/proof/generate.d.ts +8 -0
- package/build/ts/proof/generate.d.ts.map +1 -0
- package/build/ts/proof/generate.js +133 -0
- package/build/ts/proof/generate.js.map +1 -0
- package/build/ts/proof/index.d.ts +4 -0
- package/build/ts/proof/index.d.ts.map +1 -0
- package/build/ts/proof/index.js +8 -0
- package/build/ts/proof/index.js.map +1 -0
- package/build/ts/proof/prove.d.ts +8 -0
- package/build/ts/proof/prove.d.ts.map +1 -0
- package/build/ts/proof/prove.js +91 -0
- package/build/ts/proof/prove.js.map +1 -0
- package/build/ts/proof/types.d.ts +205 -0
- package/build/ts/proof/types.d.ts.map +1 -0
- package/build/ts/proof/types.js +3 -0
- package/build/ts/proof/types.js.map +1 -0
- package/build/ts/proof/utils.d.ts +10 -0
- package/build/ts/proof/utils.d.ts.map +1 -0
- package/build/ts/proof/utils.js +24 -0
- package/build/ts/proof/utils.js.map +1 -0
- package/build/ts/relayer/__tests__/messages.test.d.ts +2 -0
- package/build/ts/relayer/__tests__/messages.test.d.ts.map +1 -0
- package/build/ts/relayer/__tests__/messages.test.js +76 -0
- package/build/ts/relayer/__tests__/messages.test.js.map +1 -0
- package/build/ts/relayer/__tests__/utils.test.d.ts +2 -0
- package/build/ts/relayer/__tests__/utils.test.d.ts.map +1 -0
- package/build/ts/relayer/__tests__/utils.test.js +73 -0
- package/build/ts/relayer/__tests__/utils.test.js.map +1 -0
- package/build/ts/relayer/index.d.ts +3 -0
- package/build/ts/relayer/index.d.ts.map +1 -0
- package/build/ts/relayer/index.js +8 -0
- package/build/ts/relayer/index.js.map +1 -0
- package/build/ts/relayer/messages.d.ts +23 -0
- package/build/ts/relayer/messages.d.ts.map +1 -0
- package/build/ts/relayer/messages.js +66 -0
- package/build/ts/relayer/messages.js.map +1 -0
- package/build/ts/relayer/types.d.ts +168 -0
- package/build/ts/relayer/types.d.ts.map +1 -0
- package/build/ts/relayer/types.js +3 -0
- package/build/ts/relayer/types.js.map +1 -0
- package/build/ts/relayer/utils.d.ts +12 -0
- package/build/ts/relayer/utils.d.ts.map +1 -0
- package/build/ts/relayer/utils.js +37 -0
- package/build/ts/relayer/utils.js.map +1 -0
- package/build/ts/subgraph/index.d.ts +3 -0
- package/build/ts/subgraph/index.d.ts.map +1 -0
- package/build/ts/subgraph/index.js +18 -0
- package/build/ts/subgraph/index.js.map +1 -0
- package/build/ts/subgraph/maciSubgraph.d.ts +28 -0
- package/build/ts/subgraph/maciSubgraph.d.ts.map +1 -0
- package/build/ts/subgraph/maciSubgraph.js +64 -0
- package/build/ts/subgraph/maciSubgraph.js.map +1 -0
- package/build/ts/subgraph/types.d.ts +20 -0
- package/build/ts/subgraph/types.d.ts.map +1 -0
- package/build/ts/subgraph/types.js +3 -0
- package/build/ts/subgraph/types.js.map +1 -0
- package/build/ts/tally/commitments.d.ts +9 -0
- package/build/ts/tally/commitments.d.ts.map +1 -0
- package/build/ts/tally/commitments.js +43 -0
- package/build/ts/tally/commitments.js.map +1 -0
- package/build/ts/tally/index.d.ts +5 -0
- package/build/ts/tally/index.d.ts.map +1 -0
- package/build/ts/tally/index.js +12 -0
- package/build/ts/tally/index.js.map +1 -0
- package/build/ts/tally/results.d.ts +20 -0
- package/build/ts/tally/results.d.ts.map +1 -0
- package/build/ts/tally/results.js +49 -0
- package/build/ts/tally/results.js.map +1 -0
- package/build/ts/tally/types.d.ts +219 -0
- package/build/ts/tally/types.d.ts.map +1 -0
- package/build/ts/tally/types.js +3 -0
- package/build/ts/tally/types.js.map +1 -0
- package/build/ts/tally/utils.d.ts +24 -0
- package/build/ts/tally/utils.d.ts.map +1 -0
- package/build/ts/tally/utils.js +50 -0
- package/build/ts/tally/utils.js.map +1 -0
- package/build/ts/tally/verification.d.ts +7 -0
- package/build/ts/tally/verification.d.ts.map +1 -0
- package/build/ts/tally/verification.js +62 -0
- package/build/ts/tally/verification.js.map +1 -0
- package/build/ts/trees/index.d.ts +3 -0
- package/build/ts/trees/index.d.ts.map +1 -0
- package/build/ts/trees/index.js +8 -0
- package/build/ts/trees/index.js.map +1 -0
- package/build/ts/trees/stateTree.d.ts +35 -0
- package/build/ts/trees/stateTree.d.ts.map +1 -0
- package/build/ts/trees/stateTree.js +117 -0
- package/build/ts/trees/stateTree.js.map +1 -0
- package/build/ts/trees/types.d.ts +55 -0
- package/build/ts/trees/types.d.ts.map +1 -0
- package/build/ts/trees/types.js +3 -0
- package/build/ts/trees/types.js.map +1 -0
- package/build/ts/user/index.d.ts +5 -0
- package/build/ts/user/index.d.ts.map +1 -0
- package/build/ts/user/index.js +17 -0
- package/build/ts/user/index.js.map +1 -0
- package/build/ts/user/joinPoll.d.ts +8 -0
- package/build/ts/user/joinPoll.d.ts.map +1 -0
- package/build/ts/user/joinPoll.js +84 -0
- package/build/ts/user/joinPoll.js.map +1 -0
- package/build/ts/user/signup.d.ts +20 -0
- package/build/ts/user/signup.d.ts.map +1 -0
- package/build/ts/user/signup.js +84 -0
- package/build/ts/user/signup.js.map +1 -0
- package/build/ts/user/types.d.ts +460 -0
- package/build/ts/user/types.d.ts.map +1 -0
- package/build/ts/user/types.js +3 -0
- package/build/ts/user/types.js.map +1 -0
- package/build/ts/user/utils.d.ts +88 -0
- package/build/ts/user/utils.d.ts.map +1 -0
- package/build/ts/user/utils.js +258 -0
- package/build/ts/user/utils.js.map +1 -0
- package/build/ts/utils/cid.d.ts +23 -0
- package/build/ts/utils/cid.d.ts.map +1 -0
- package/build/ts/utils/cid.js +72 -0
- package/build/ts/utils/cid.js.map +1 -0
- package/build/ts/utils/constants.d.ts +2 -0
- package/build/ts/utils/constants.d.ts.map +1 -0
- package/build/ts/utils/constants.js +5 -0
- package/build/ts/utils/constants.js.map +1 -0
- package/build/ts/utils/contracts.d.ts +15 -0
- package/build/ts/utils/contracts.d.ts.map +1 -0
- package/build/ts/utils/contracts.js +26 -0
- package/build/ts/utils/contracts.js.map +1 -0
- package/build/ts/utils/files.d.ts +9 -0
- package/build/ts/utils/files.d.ts.map +1 -0
- package/build/ts/utils/files.js +20 -0
- package/build/ts/utils/files.js.map +1 -0
- package/build/ts/utils/formatting.d.ts +8 -0
- package/build/ts/utils/formatting.d.ts.map +1 -0
- package/build/ts/utils/formatting.js +11 -0
- package/build/ts/utils/formatting.js.map +1 -0
- package/build/ts/utils/fundWallet.d.ts +7 -0
- package/build/ts/utils/fundWallet.d.ts.map +1 -0
- package/build/ts/utils/fundWallet.js +20 -0
- package/build/ts/utils/fundWallet.js.map +1 -0
- package/build/ts/utils/index.d.ts +12 -0
- package/build/ts/utils/index.d.ts.map +1 -0
- package/build/ts/utils/index.js +29 -0
- package/build/ts/utils/index.js.map +1 -0
- package/build/ts/utils/params.d.ts +7 -0
- package/build/ts/utils/params.d.ts.map +1 -0
- package/build/ts/utils/params.js +19 -0
- package/build/ts/utils/params.js.map +1 -0
- package/build/ts/utils/proofs.d.ts +13 -0
- package/build/ts/utils/proofs.d.ts.map +1 -0
- package/build/ts/utils/proofs.js +41 -0
- package/build/ts/utils/proofs.js.map +1 -0
- package/build/ts/utils/timeTravel.d.ts +7 -0
- package/build/ts/utils/timeTravel.d.ts.map +1 -0
- package/build/ts/utils/timeTravel.js +14 -0
- package/build/ts/utils/timeTravel.js.map +1 -0
- package/build/ts/utils/trees.d.ts +13 -0
- package/build/ts/utils/trees.d.ts.map +1 -0
- package/build/ts/utils/trees.js +30 -0
- package/build/ts/utils/trees.js.map +1 -0
- package/build/ts/utils/types.d.ts +71 -0
- package/build/ts/utils/types.d.ts.map +1 -0
- package/build/ts/utils/types.js +3 -0
- package/build/ts/utils/types.js.map +1 -0
- package/build/ts/utils/utils.d.ts +29 -0
- package/build/ts/utils/utils.d.ts.map +1 -0
- package/build/ts/utils/utils.js +61 -0
- package/build/ts/utils/utils.js.map +1 -0
- package/build/ts/verifyingKeys/checkVerifyingKeys.d.ts +10 -0
- package/build/ts/verifyingKeys/checkVerifyingKeys.d.ts.map +1 -0
- package/build/ts/verifyingKeys/checkVerifyingKeys.js +66 -0
- package/build/ts/verifyingKeys/checkVerifyingKeys.js.map +1 -0
- package/build/ts/verifyingKeys/index.d.ts +5 -0
- package/build/ts/verifyingKeys/index.d.ts.map +1 -0
- package/build/ts/verifyingKeys/index.js +13 -0
- package/build/ts/verifyingKeys/index.js.map +1 -0
- package/build/ts/verifyingKeys/setVerifyingKeys.d.ts +7 -0
- package/build/ts/verifyingKeys/setVerifyingKeys.d.ts.map +1 -0
- package/build/ts/verifyingKeys/setVerifyingKeys.js +108 -0
- package/build/ts/verifyingKeys/setVerifyingKeys.js.map +1 -0
- package/build/ts/verifyingKeys/types.d.ts +239 -0
- package/build/ts/verifyingKeys/types.d.ts.map +1 -0
- package/build/ts/verifyingKeys/types.js +3 -0
- package/build/ts/verifyingKeys/types.js.map +1 -0
- package/build/ts/verifyingKeys/utils.d.ts +29 -0
- package/build/ts/verifyingKeys/utils.d.ts.map +1 -0
- package/build/ts/verifyingKeys/utils.js +118 -0
- package/build/ts/verifyingKeys/utils.js.map +1 -0
- package/build/ts/vote/generate.d.ts +8 -0
- package/build/ts/vote/generate.d.ts.map +1 -0
- package/build/ts/vote/generate.js +46 -0
- package/build/ts/vote/generate.js.map +1 -0
- package/build/ts/vote/index.d.ts +7 -0
- package/build/ts/vote/index.d.ts.map +1 -0
- package/build/ts/vote/index.js +17 -0
- package/build/ts/vote/index.js.map +1 -0
- package/build/ts/vote/invalidate.d.ts +13 -0
- package/build/ts/vote/invalidate.d.ts.map +1 -0
- package/build/ts/vote/invalidate.js +44 -0
- package/build/ts/vote/invalidate.js.map +1 -0
- package/build/ts/vote/publish.d.ts +14 -0
- package/build/ts/vote/publish.d.ts.map +1 -0
- package/build/ts/vote/publish.js +88 -0
- package/build/ts/vote/publish.js.map +1 -0
- package/build/ts/vote/submit.d.ts +13 -0
- package/build/ts/vote/submit.d.ts.map +1 -0
- package/build/ts/vote/submit.js +36 -0
- package/build/ts/vote/submit.js.map +1 -0
- package/build/ts/vote/types.d.ts +238 -0
- package/build/ts/vote/types.d.ts.map +1 -0
- package/build/ts/vote/types.js +3 -0
- package/build/ts/vote/types.js.map +1 -0
- package/build/ts/vote/utils.d.ts +16 -0
- package/build/ts/vote/utils.d.ts.map +1 -0
- package/build/ts/vote/utils.js +26 -0
- package/build/ts/vote/utils.js.map +1 -0
- package/build/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateTallyCommitments = void 0;
|
|
4
|
+
const core_1 = require("@maci-protocol/core");
|
|
5
|
+
const crypto_1 = require("@maci-protocol/crypto");
|
|
6
|
+
/**
|
|
7
|
+
* Generate the tally commitments for this current batch of proving
|
|
8
|
+
* @param tallyData - The tally data
|
|
9
|
+
* @param voteOptionTreeDepth - The vote option tree depth
|
|
10
|
+
* @returns The commitments to the Tally data
|
|
11
|
+
*/
|
|
12
|
+
const generateTallyCommitments = ({ tallyData, voteOptionTreeDepth, }) => {
|
|
13
|
+
// compute newResultsCommitment
|
|
14
|
+
const newResultsCommitment = (0, crypto_1.generateTreeCommitment)(tallyData.results.tally.map((x) => BigInt(x)), BigInt(tallyData.results.salt), voteOptionTreeDepth);
|
|
15
|
+
// compute newSpentVoiceCreditsCommitment
|
|
16
|
+
const newSpentVoiceCreditsCommitment = (0, crypto_1.hash2)([
|
|
17
|
+
BigInt(tallyData.totalSpentVoiceCredits.spent),
|
|
18
|
+
BigInt(tallyData.totalSpentVoiceCredits.salt),
|
|
19
|
+
]);
|
|
20
|
+
let newTallyCommitment;
|
|
21
|
+
let newPerVoteOptionSpentVoiceCreditsCommitment;
|
|
22
|
+
if (tallyData.mode === core_1.EMode.QV) {
|
|
23
|
+
// compute newPerVoteOptionSpentVoiceCreditsCommitment
|
|
24
|
+
newPerVoteOptionSpentVoiceCreditsCommitment = (0, crypto_1.generateTreeCommitment)(tallyData.perVoteOptionSpentVoiceCredits.tally.map((x) => BigInt(x)), BigInt(tallyData.perVoteOptionSpentVoiceCredits.salt), voteOptionTreeDepth);
|
|
25
|
+
// compute newTallyCommitment
|
|
26
|
+
newTallyCommitment = (0, crypto_1.hash3)([
|
|
27
|
+
newResultsCommitment,
|
|
28
|
+
newSpentVoiceCreditsCommitment,
|
|
29
|
+
newPerVoteOptionSpentVoiceCreditsCommitment,
|
|
30
|
+
]);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
newTallyCommitment = (0, crypto_1.hashLeftRight)(newResultsCommitment, newSpentVoiceCreditsCommitment);
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
newTallyCommitment,
|
|
37
|
+
newSpentVoiceCreditsCommitment,
|
|
38
|
+
newPerVoteOptionSpentVoiceCreditsCommitment,
|
|
39
|
+
newResultsCommitment,
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
exports.generateTallyCommitments = generateTallyCommitments;
|
|
43
|
+
//# sourceMappingURL=commitments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commitments.js","sourceRoot":"","sources":["../../../ts/tally/commitments.ts"],"names":[],"mappings":";;;AAAA,8CAA4C;AAC5C,kDAA4F;AAI5F;;;;;GAKG;AACI,MAAM,wBAAwB,GAAG,CAAC,EACvC,SAAS,EACT,mBAAmB,GACW,EAAqB,EAAE;IACrD,+BAA+B;IAC/B,MAAM,oBAAoB,GAAG,IAAA,+BAAsB,EACjD,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAC7C,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAC9B,mBAAmB,CACpB,CAAC;IAEF,yCAAyC;IACzC,MAAM,8BAA8B,GAAG,IAAA,cAAK,EAAC;QAC3C,MAAM,CAAC,SAAS,CAAC,sBAAsB,CAAC,KAAK,CAAC;QAC9C,MAAM,CAAC,SAAS,CAAC,sBAAsB,CAAC,IAAI,CAAC;KAC9C,CAAC,CAAC;IAEH,IAAI,kBAA0B,CAAC;IAC/B,IAAI,2CAA+D,CAAC;IAEpE,IAAI,SAAS,CAAC,IAAI,KAAK,YAAK,CAAC,EAAE,EAAE,CAAC;QAChC,sDAAsD;QACtD,2CAA2C,GAAG,IAAA,+BAAsB,EAClE,SAAS,CAAC,8BAA+B,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EACrE,MAAM,CAAC,SAAS,CAAC,8BAA+B,CAAC,IAAI,CAAC,EACtD,mBAAmB,CACpB,CAAC;QAEF,6BAA6B;QAC7B,kBAAkB,GAAG,IAAA,cAAK,EAAC;YACzB,oBAAoB;YACpB,8BAA8B;YAC9B,2CAA2C;SAC5C,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,kBAAkB,GAAG,IAAA,sBAAa,EAAC,oBAAoB,EAAE,8BAA8B,CAAC,CAAC;IAC3F,CAAC;IAED,OAAO;QACL,kBAAkB;QAClB,8BAA8B;QAC9B,2CAA2C;QAC3C,oBAAoB;KACrB,CAAC;AACJ,CAAC,CAAC;AA5CW,QAAA,wBAAwB,4BA4CnC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { generateTallyCommitments } from "./commitments";
|
|
2
|
+
export { verify } from "./verification";
|
|
3
|
+
export type { ITallyData, IVerifyArgs, IGenerateTallyCommitmentsArgs, ITallyCommitments, IVoteTallyInputs, IGetResultPerOptionArgs, IGetResultsArgs, IResult, } from "./types";
|
|
4
|
+
export { getResultPerOption, getResults, isTallied } from "./results";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../ts/tally/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,YAAY,EACV,UAAU,EACV,WAAW,EACX,6BAA6B,EAC7B,iBAAiB,EACjB,gBAAgB,EAChB,uBAAuB,EACvB,eAAe,EACf,OAAO,GACR,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isTallied = exports.getResults = exports.getResultPerOption = exports.verify = exports.generateTallyCommitments = void 0;
|
|
4
|
+
var commitments_1 = require("./commitments");
|
|
5
|
+
Object.defineProperty(exports, "generateTallyCommitments", { enumerable: true, get: function () { return commitments_1.generateTallyCommitments; } });
|
|
6
|
+
var verification_1 = require("./verification");
|
|
7
|
+
Object.defineProperty(exports, "verify", { enumerable: true, get: function () { return verification_1.verify; } });
|
|
8
|
+
var results_1 = require("./results");
|
|
9
|
+
Object.defineProperty(exports, "getResultPerOption", { enumerable: true, get: function () { return results_1.getResultPerOption; } });
|
|
10
|
+
Object.defineProperty(exports, "getResults", { enumerable: true, get: function () { return results_1.getResults; } });
|
|
11
|
+
Object.defineProperty(exports, "isTallied", { enumerable: true, get: function () { return results_1.isTallied; } });
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ts/tally/index.ts"],"names":[],"mappings":";;;AAAA,6CAAyD;AAAhD,uHAAA,wBAAwB,OAAA;AACjC,+CAAwC;AAA/B,sGAAA,MAAM,OAAA;AAWf,qCAAsE;AAA7D,6GAAA,kBAAkB,OAAA;AAAE,qGAAA,UAAU,OAAA;AAAE,oGAAA,SAAS,OAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IGetResultPerOptionArgs, IGetResultsArgs, IResult } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Get result per option
|
|
4
|
+
* @param {IGetResultPerOptionsArgs} - The arguments to get result per option
|
|
5
|
+
* @returns The result per option
|
|
6
|
+
*/
|
|
7
|
+
export declare const getResultPerOption: ({ maciAddress, pollId, index, signer, }: IGetResultPerOptionArgs) => Promise<IResult>;
|
|
8
|
+
/**
|
|
9
|
+
* Get all results from the Tally contract
|
|
10
|
+
* @param {IGetResultsArgs} - The arguments to get all the results
|
|
11
|
+
* @returns The results array (The final result of vote option n is in index n-1)
|
|
12
|
+
*/
|
|
13
|
+
export declare const getResults: ({ maciAddress, pollId, signer }: IGetResultsArgs) => Promise<IResult[]>;
|
|
14
|
+
/**
|
|
15
|
+
* Check if the poll is tallied
|
|
16
|
+
* @param {IGetResultsArgs} - The arguments to check if the poll is tallied
|
|
17
|
+
* @returns {boolean} - True if the poll is tallied, false otherwise
|
|
18
|
+
*/
|
|
19
|
+
export declare const isTallied: ({ maciAddress, pollId, signer }: IGetResultsArgs) => Promise<boolean>;
|
|
20
|
+
//# sourceMappingURL=results.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"results.d.ts","sourceRoot":"","sources":["../../../ts/tally/results.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAIjF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAU,yCAKtC,uBAAuB,KAAG,OAAO,CAAC,OAAO,CAS3C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAU,iCAAiC,eAAe,KAAG,OAAO,CAAC,OAAO,EAAE,CAkBpG,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS,GAAU,iCAAiC,eAAe,KAAG,OAAO,CAAC,OAAO,CAIjG,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isTallied = exports.getResults = exports.getResultPerOption = void 0;
|
|
4
|
+
const poll_1 = require("../poll");
|
|
5
|
+
/**
|
|
6
|
+
* Get result per option
|
|
7
|
+
* @param {IGetResultPerOptionsArgs} - The arguments to get result per option
|
|
8
|
+
* @returns The result per option
|
|
9
|
+
*/
|
|
10
|
+
const getResultPerOption = async ({ maciAddress, pollId, index, signer, }) => {
|
|
11
|
+
const { tally } = await (0, poll_1.getPollContracts)({ maciAddress, pollId, signer });
|
|
12
|
+
const { value, isSet } = await tally.getTallyResults(index);
|
|
13
|
+
return {
|
|
14
|
+
value,
|
|
15
|
+
isSet,
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
exports.getResultPerOption = getResultPerOption;
|
|
19
|
+
/**
|
|
20
|
+
* Get all results from the Tally contract
|
|
21
|
+
* @param {IGetResultsArgs} - The arguments to get all the results
|
|
22
|
+
* @returns The results array (The final result of vote option n is in index n-1)
|
|
23
|
+
*/
|
|
24
|
+
const getResults = async ({ maciAddress, pollId, signer }) => {
|
|
25
|
+
const { poll, tally } = await (0, poll_1.getPollContracts)({ maciAddress, pollId, signer });
|
|
26
|
+
const numberOfVoteOptions = await poll.voteOptions();
|
|
27
|
+
const results = [];
|
|
28
|
+
for (let i = 0; i < numberOfVoteOptions; i += 1) {
|
|
29
|
+
// eslint-disable-next-line no-await-in-loop
|
|
30
|
+
const { value, isSet } = await tally.getTallyResults(i);
|
|
31
|
+
results.push({
|
|
32
|
+
value,
|
|
33
|
+
isSet,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return results;
|
|
37
|
+
};
|
|
38
|
+
exports.getResults = getResults;
|
|
39
|
+
/**
|
|
40
|
+
* Check if the poll is tallied
|
|
41
|
+
* @param {IGetResultsArgs} - The arguments to check if the poll is tallied
|
|
42
|
+
* @returns {boolean} - True if the poll is tallied, false otherwise
|
|
43
|
+
*/
|
|
44
|
+
const isTallied = async ({ maciAddress, pollId, signer }) => {
|
|
45
|
+
const { tally } = await (0, poll_1.getPollContracts)({ maciAddress, pollId, signer });
|
|
46
|
+
return tally.isTallied();
|
|
47
|
+
};
|
|
48
|
+
exports.isTallied = isTallied;
|
|
49
|
+
//# sourceMappingURL=results.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"results.js","sourceRoot":"","sources":["../../../ts/tally/results.ts"],"names":[],"mapp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mB,EAAoB,EAAE;IACpG,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAA,uBAAgB,EAAC,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAE1E,OAAO,KAAK,CAAC,SAAS,EAAE,CAAC;AAC3B,CAAC,CAAC;AAJW,QAAA,SAAS,aAIpB"}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import type { EMode } from "@maci-protocol/core";
|
|
2
|
+
import type { Signer } from "ethers";
|
|
3
|
+
/**
|
|
4
|
+
* Interface for the tally file data.
|
|
5
|
+
*/
|
|
6
|
+
export interface ITallyData {
|
|
7
|
+
/**
|
|
8
|
+
* The MACI address.
|
|
9
|
+
*/
|
|
10
|
+
maci: string;
|
|
11
|
+
/**
|
|
12
|
+
* The ID of the poll.
|
|
13
|
+
*/
|
|
14
|
+
pollId: string;
|
|
15
|
+
/**
|
|
16
|
+
* The name of the network for which these proofs
|
|
17
|
+
* are valid for
|
|
18
|
+
*/
|
|
19
|
+
network?: string;
|
|
20
|
+
/**
|
|
21
|
+
* The chain ID for which these proofs are valid for
|
|
22
|
+
*/
|
|
23
|
+
chainId?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Voting mode
|
|
26
|
+
*/
|
|
27
|
+
mode: EMode;
|
|
28
|
+
/**
|
|
29
|
+
* The address of the Tally contract.
|
|
30
|
+
*/
|
|
31
|
+
tallyAddress: string;
|
|
32
|
+
/**
|
|
33
|
+
* The new tally commitment.
|
|
34
|
+
*/
|
|
35
|
+
newTallyCommitment: string;
|
|
36
|
+
/**
|
|
37
|
+
* The results of the poll.
|
|
38
|
+
*/
|
|
39
|
+
results: {
|
|
40
|
+
/**
|
|
41
|
+
* The tally of the results.
|
|
42
|
+
*/
|
|
43
|
+
tally: string[];
|
|
44
|
+
/**
|
|
45
|
+
* The salt of the results.
|
|
46
|
+
*/
|
|
47
|
+
salt: string;
|
|
48
|
+
/**
|
|
49
|
+
* The commitment of the results.
|
|
50
|
+
*/
|
|
51
|
+
commitment: string;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* The total spent voice credits.
|
|
55
|
+
*/
|
|
56
|
+
totalSpentVoiceCredits: {
|
|
57
|
+
/**
|
|
58
|
+
* The spent voice credits.
|
|
59
|
+
*/
|
|
60
|
+
spent: string;
|
|
61
|
+
/**
|
|
62
|
+
* The salt of the spent voice credits.
|
|
63
|
+
*/
|
|
64
|
+
salt: string;
|
|
65
|
+
/**
|
|
66
|
+
* The commitment of the spent voice credits.
|
|
67
|
+
*/
|
|
68
|
+
commitment: string;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* The per vote option spent voice credits.
|
|
72
|
+
*/
|
|
73
|
+
perVoteOptionSpentVoiceCredits?: {
|
|
74
|
+
/**
|
|
75
|
+
* The tally of the per vote option spent voice credits.
|
|
76
|
+
*/
|
|
77
|
+
tally: string[];
|
|
78
|
+
/**
|
|
79
|
+
* The salt of the per vote option spent voice credits.
|
|
80
|
+
*/
|
|
81
|
+
salt: string;
|
|
82
|
+
/**
|
|
83
|
+
* The commitment of the per vote option spent voice credits.
|
|
84
|
+
*/
|
|
85
|
+
commitment: string;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Interface for the arguments to the verifyProof command
|
|
90
|
+
*/
|
|
91
|
+
export interface IVerifyArgs {
|
|
92
|
+
/**
|
|
93
|
+
* The id of the poll
|
|
94
|
+
*/
|
|
95
|
+
pollId: bigint;
|
|
96
|
+
/**
|
|
97
|
+
* A signer object
|
|
98
|
+
*/
|
|
99
|
+
signer: Signer;
|
|
100
|
+
/**
|
|
101
|
+
* The tally data
|
|
102
|
+
*/
|
|
103
|
+
tallyData: ITallyData;
|
|
104
|
+
/**
|
|
105
|
+
* The address of the MACI contract
|
|
106
|
+
*/
|
|
107
|
+
maciAddress: string;
|
|
108
|
+
/**
|
|
109
|
+
* The tally commitments
|
|
110
|
+
*/
|
|
111
|
+
tallyCommitments: ITallyCommitments;
|
|
112
|
+
/**
|
|
113
|
+
* The number of vote options
|
|
114
|
+
*/
|
|
115
|
+
totalVoteOptions: number;
|
|
116
|
+
/**
|
|
117
|
+
* The vote option tree depth
|
|
118
|
+
*/
|
|
119
|
+
voteOptionTreeDepth: number;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Arguments for the generateTallyCommitments function
|
|
123
|
+
*/
|
|
124
|
+
export interface IGenerateTallyCommitmentsArgs {
|
|
125
|
+
/**
|
|
126
|
+
* The tally data
|
|
127
|
+
*/
|
|
128
|
+
tallyData: ITallyData;
|
|
129
|
+
/**
|
|
130
|
+
* The vote option tree depth
|
|
131
|
+
*/
|
|
132
|
+
voteOptionTreeDepth: number;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Interface for the tally commitments
|
|
136
|
+
*/
|
|
137
|
+
export interface ITallyCommitments {
|
|
138
|
+
/**
|
|
139
|
+
* The new tally commitment
|
|
140
|
+
*/
|
|
141
|
+
newTallyCommitment: bigint;
|
|
142
|
+
/**
|
|
143
|
+
* The new spent voice credits commitment
|
|
144
|
+
*/
|
|
145
|
+
newSpentVoiceCreditsCommitment: bigint;
|
|
146
|
+
/**
|
|
147
|
+
* The new per vote option spent voice credits commitment
|
|
148
|
+
*/
|
|
149
|
+
newPerVoteOptionSpentVoiceCreditsCommitment?: bigint;
|
|
150
|
+
/**
|
|
151
|
+
* The commitment to the results tree root
|
|
152
|
+
*/
|
|
153
|
+
newResultsCommitment: bigint;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Inputs for circuit VoteTally
|
|
157
|
+
*/
|
|
158
|
+
export interface IVoteTallyInputs {
|
|
159
|
+
stateRoot: bigint;
|
|
160
|
+
ballotRoot: bigint;
|
|
161
|
+
sbSalt: bigint;
|
|
162
|
+
index: bigint;
|
|
163
|
+
totalSignups: bigint;
|
|
164
|
+
sbCommitment: bigint;
|
|
165
|
+
currentTallyCommitment: bigint;
|
|
166
|
+
newTallyCommitment: bigint;
|
|
167
|
+
ballots: bigint[];
|
|
168
|
+
ballotPathElements: bigint[];
|
|
169
|
+
votes: bigint[][];
|
|
170
|
+
currentResults: bigint[];
|
|
171
|
+
currentResultsRootSalt: bigint;
|
|
172
|
+
currentSpentVoiceCreditSubtotal: bigint;
|
|
173
|
+
currentSpentVoiceCreditSubtotalSalt: bigint;
|
|
174
|
+
currentPerVoteOptionSpentVoiceCredits: bigint[];
|
|
175
|
+
currentPerVoteOptionSpentVoiceCreditsRootSalt: bigint;
|
|
176
|
+
newResultsRootSalt: bigint;
|
|
177
|
+
newPerVoteOptionSpentVoiceCreditsRootSalt: bigint;
|
|
178
|
+
newSpentVoiceCreditSubtotalSalt: bigint;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Get results args
|
|
182
|
+
*/
|
|
183
|
+
export interface IGetResultsArgs {
|
|
184
|
+
/**
|
|
185
|
+
* The address of the MACI contract
|
|
186
|
+
*/
|
|
187
|
+
maciAddress: string;
|
|
188
|
+
/**
|
|
189
|
+
* The ID of the poll
|
|
190
|
+
*/
|
|
191
|
+
pollId: string;
|
|
192
|
+
/**
|
|
193
|
+
* The signer
|
|
194
|
+
*/
|
|
195
|
+
signer: Signer;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Get result per option args
|
|
199
|
+
*/
|
|
200
|
+
export interface IGetResultPerOptionArgs extends IGetResultsArgs {
|
|
201
|
+
/**
|
|
202
|
+
* The index of the vote option
|
|
203
|
+
*/
|
|
204
|
+
index: number;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Interface for the result of a voting option
|
|
208
|
+
*/
|
|
209
|
+
export interface IResult {
|
|
210
|
+
/**
|
|
211
|
+
* The result
|
|
212
|
+
*/
|
|
213
|
+
value: bigint;
|
|
214
|
+
/**
|
|
215
|
+
* Whether the result is set or not
|
|
216
|
+
*/
|
|
217
|
+
isSet: boolean;
|
|
218
|
+
}
|
|
219
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../ts/tally/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,IAAI,EAAE,KAAK,CAAC;IAEZ;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,OAAO,EAAE;QACP;;WAEG;QACH,KAAK,EAAE,MAAM,EAAE,CAAC;QAEhB;;WAEG;QACH,IAAI,EAAE,MAAM,CAAC;QAEb;;WAEG;QACH,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IAEF;;OAEG;IACH,sBAAsB,EAAE;QACtB;;WAEG;QACH,KAAK,EAAE,MAAM,CAAC;QAEd;;WAEG;QACH,IAAI,EAAE,MAAM,CAAC;QAEb;;WAEG;QACH,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IAEF;;OAEG;IACH,8BAA8B,CAAC,EAAE;QAC/B;;WAEG;QACH,KAAK,EAAE,MAAM,EAAE,CAAC;QAEhB;;WAEG;QACH,IAAI,EAAE,MAAM,CAAC;QAEb;;WAEG;QACH,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,MAAM,EAAE,M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E,MAAM,CAAC;IAC3B,yCAAyC,EAAE,MAAM,CAAC;IAClD,+BAA+B,EAAE,MAAM,CAAC;CACzC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,eAAe;IAC9D;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;CAChB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../ts/tally/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ITallyData } from "./types";
|
|
2
|
+
import type { Tally } from "@maci-protocol/contracts";
|
|
3
|
+
/**
|
|
4
|
+
* Loop through each per vote option spent voice credits and verify it on-chain
|
|
5
|
+
*
|
|
6
|
+
* @param tallyContract The tally contract
|
|
7
|
+
* @param tallyData The tally.json file data
|
|
8
|
+
* @param voteOptionTreeDepth The vote option tree depth
|
|
9
|
+
* @param newSpentVoiceCreditsCommitment The total spent voice credits commitment
|
|
10
|
+
* @param newResultsCommitment The tally result commitment
|
|
11
|
+
* @returns list of the indexes of the tally result that failed on-chain verification
|
|
12
|
+
*/
|
|
13
|
+
export declare const verifyPerVoteOptionSpentVoiceCredits: (tallyContract: Tally, tallyData: ITallyData, voteOptionTreeDepth: number, newSpentVoiceCreditsCommitment: bigint, newResultsCommitment: bigint) => Promise<number[]>;
|
|
14
|
+
/**
|
|
15
|
+
* Loop through each tally result and verify it on-chain
|
|
16
|
+
* @param tallyContract The tally contract
|
|
17
|
+
* @param tallyData The tally.json file data
|
|
18
|
+
* @param voteOptionTreeDepth The vote option tree depth
|
|
19
|
+
* @param newSpentVoiceCreditsCommitment The total spent voice credits commitment
|
|
20
|
+
* @param newPerVoteOptionSpentVoiceCreditsCommitment The per vote option voice credits commitment
|
|
21
|
+
* @returns list of the indexes of the tally result that failed on-chain verification
|
|
22
|
+
*/
|
|
23
|
+
export declare const verifyTallyResults: (tallyContract: Tally, tallyData: ITallyData, voteOptionTreeDepth: number, newSpentVoiceCreditsCommitment: bigint, newPerVoteOptionSpentVoiceCreditsCommitment?: bigint) => Promise<number[]>;
|
|
24
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../ts/tally/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAEtD;;;;;;;;;GASG;AACH,eAAO,MAAM,oCAAoC,GAC/C,eAAe,KAAK,EACpB,WAAW,UAAU,EACrB,qBAAqB,MAAM,EAC3B,gCAAgC,MAAM,EACtC,sBAAsB,MAAM,KAC3B,OAAO,CAAC,MAAM,EAAE,CA2BlB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,GAC7B,eAAe,KAAK,EACpB,WAAW,UAAU,EACrB,qBAAqB,MAAM,EAC3B,gCAAgC,MAAM,EACtC,8CAA8C,MAAM,KACnD,OAAO,CAAC,MAAM,EAAE,CA2BlB,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verifyTallyResults = exports.verifyPerVoteOptionSpentVoiceCredits = void 0;
|
|
4
|
+
const crypto_1 = require("@maci-protocol/crypto");
|
|
5
|
+
/**
|
|
6
|
+
* Loop through each per vote option spent voice credits and verify it on-chain
|
|
7
|
+
*
|
|
8
|
+
* @param tallyContract The tally contract
|
|
9
|
+
* @param tallyData The tally.json file data
|
|
10
|
+
* @param voteOptionTreeDepth The vote option tree depth
|
|
11
|
+
* @param newSpentVoiceCreditsCommitment The total spent voice credits commitment
|
|
12
|
+
* @param newResultsCommitment The tally result commitment
|
|
13
|
+
* @returns list of the indexes of the tally result that failed on-chain verification
|
|
14
|
+
*/
|
|
15
|
+
const verifyPerVoteOptionSpentVoiceCredits = async (tallyContract, tallyData, voteOptionTreeDepth, newSpentVoiceCreditsCommitment, newResultsCommitment) => {
|
|
16
|
+
const failedIndices = [];
|
|
17
|
+
for (let i = 0; i < tallyData.perVoteOptionSpentVoiceCredits.tally.length; i += 1) {
|
|
18
|
+
const proof = (0, crypto_1.generateTreeProof)(i, tallyData.perVoteOptionSpentVoiceCredits.tally.map((x) => BigInt(x)), voteOptionTreeDepth);
|
|
19
|
+
// eslint-disable-next-line no-await-in-loop
|
|
20
|
+
const isValid = await tallyContract.verifyPerVoteOptionSpentVoiceCredits(i, tallyData.perVoteOptionSpentVoiceCredits.tally[i], proof, tallyData.perVoteOptionSpentVoiceCredits.salt, voteOptionTreeDepth, newSpentVoiceCreditsCommitment, newResultsCommitment);
|
|
21
|
+
if (!isValid) {
|
|
22
|
+
failedIndices.push(i);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return failedIndices;
|
|
26
|
+
};
|
|
27
|
+
exports.verifyPerVoteOptionSpentVoiceCredits = verifyPerVoteOptionSpentVoiceCredits;
|
|
28
|
+
/**
|
|
29
|
+
* Loop through each tally result and verify it on-chain
|
|
30
|
+
* @param tallyContract The tally contract
|
|
31
|
+
* @param tallyData The tally.json file data
|
|
32
|
+
* @param voteOptionTreeDepth The vote option tree depth
|
|
33
|
+
* @param newSpentVoiceCreditsCommitment The total spent voice credits commitment
|
|
34
|
+
* @param newPerVoteOptionSpentVoiceCreditsCommitment The per vote option voice credits commitment
|
|
35
|
+
* @returns list of the indexes of the tally result that failed on-chain verification
|
|
36
|
+
*/
|
|
37
|
+
const verifyTallyResults = async (tallyContract, tallyData, voteOptionTreeDepth, newSpentVoiceCreditsCommitment, newPerVoteOptionSpentVoiceCreditsCommitment) => {
|
|
38
|
+
const failedIndices = [];
|
|
39
|
+
for (let i = 0; i < tallyData.results.tally.length; i += 1) {
|
|
40
|
+
const proof = (0, crypto_1.generateTreeProof)(i, tallyData.results.tally.map((x) => BigInt(x)), voteOptionTreeDepth);
|
|
41
|
+
// eslint-disable-next-line no-await-in-loop
|
|
42
|
+
const isValid = await tallyContract.verifyTallyResult(i, tallyData.results.tally[i], proof, tallyData.results.salt, voteOptionTreeDepth, newSpentVoiceCreditsCommitment, newPerVoteOptionSpentVoiceCreditsCommitment ?? 0n);
|
|
43
|
+
if (!isValid) {
|
|
44
|
+
failedIndices.push(i);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return failedIndices;
|
|
48
|
+
};
|
|
49
|
+
exports.verifyTallyResults = verifyTallyResults;
|
|
50
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../ts/tally/utils.ts"],"names":[],"mappings":";;;AAAA,kDAA0D;AAK1D;;;;;;;;;GASG;AACI,MAAM,oCAAoC,GAAG,KAAK,EACvD,aAAoB,EACpB,SAAqB,EACrB,mBAA2B,EAC3B,8BAAsC,EACtC,oBAA4B,EACT,EAAE;IACrB,MAAM,aAAa,GAAa,EAAE,CAAC;IAEnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,8BAA+B,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACnF,MAAM,KAAK,GAAG,IAAA,0BAAiB,EAC7B,CAAC,EACD,SAAS,CAAC,8BAA+B,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAA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AI,CAAC,OAAO,EAAE,CAAC;YACb,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC;AAjCW,QAAA,kBAAkB,sBAiC7B"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IVerifyArgs } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Verify the results of a poll on-chain
|
|
4
|
+
* @param VerifyArgs - The arguments for the verify command
|
|
5
|
+
*/
|
|
6
|
+
export declare const verify: ({ pollId, tallyData, signer, tallyCommitments, totalVoteOptions, voteOptionTreeDepth, }: IVerifyArgs) => Promise<boolean>;
|
|
7
|
+
//# sourceMappingURL=verification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verification.d.ts","sourceRoot":"","sources":["../../../ts/tally/verification.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAM3C;;;GAGG;AACH,eAAO,MAAM,MAAM,GAAU,yFAO1B,WAAW,KAAG,OAAO,CAAC,OAAO,CAgG/B,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verify = void 0;
|
|
4
|
+
const typechain_types_1 = require("@maci-protocol/contracts/typechain-types");
|
|
5
|
+
const core_1 = require("@maci-protocol/core");
|
|
6
|
+
const contracts_1 = require("../utils/contracts");
|
|
7
|
+
const utils_1 = require("./utils");
|
|
8
|
+
/**
|
|
9
|
+
* Verify the results of a poll on-chain
|
|
10
|
+
* @param VerifyArgs - The arguments for the verify command
|
|
11
|
+
*/
|
|
12
|
+
const verify = async ({ pollId, tallyData, signer, tallyCommitments, totalVoteOptions, voteOptionTreeDepth, }) => {
|
|
13
|
+
const maciContractAddress = tallyData.maci;
|
|
14
|
+
const validContract = await (0, contracts_1.contractExists)(signer.provider, maciContractAddress);
|
|
15
|
+
if (!validContract) {
|
|
16
|
+
throw new Error(`There is no MACI contract deployed at ${maciContractAddress}.`);
|
|
17
|
+
}
|
|
18
|
+
// get the contract objects
|
|
19
|
+
const maciContract = typechain_types_1.MACI__factory.connect(maciContractAddress, signer);
|
|
20
|
+
const pollContracts = await maciContract.polls(pollId);
|
|
21
|
+
const tallyContract = typechain_types_1.Tally__factory.connect(pollContracts.tally, signer);
|
|
22
|
+
// get the on-chain tally commitment\
|
|
23
|
+
const onChainTallyCommitment = BigInt(await tallyContract.tallyCommitment());
|
|
24
|
+
// check the results commitment
|
|
25
|
+
const validResultsCommitment = tallyData.newTallyCommitment.match(/0x[a-fA-F0-9]+/);
|
|
26
|
+
if (!validResultsCommitment) {
|
|
27
|
+
throw new Error("Invalid results commitment format");
|
|
28
|
+
}
|
|
29
|
+
if (tallyData.results.tally.length !== totalVoteOptions) {
|
|
30
|
+
throw new Error("Wrong number of vote options.");
|
|
31
|
+
}
|
|
32
|
+
// destructure the tally commitments
|
|
33
|
+
const { newTallyCommitment, newSpentVoiceCreditsCommitment, newPerVoteOptionSpentVoiceCreditsCommitment, newResultsCommitment, } = tallyCommitments;
|
|
34
|
+
// verify that the results commitment matches the output of generateTreeCommitment()
|
|
35
|
+
if (onChainTallyCommitment !== newTallyCommitment) {
|
|
36
|
+
throw new Error("The on-chain tally commitment does not match.");
|
|
37
|
+
}
|
|
38
|
+
// verify total spent voice credits on-chain
|
|
39
|
+
const verified = await tallyContract.verifySpentVoiceCredits(tallyData.totalSpentVoiceCredits.spent, tallyData.totalSpentVoiceCredits.salt, newResultsCommitment, newPerVoteOptionSpentVoiceCreditsCommitment ?? 0n);
|
|
40
|
+
if (!verified) {
|
|
41
|
+
throw new Error("The on-chain verification of total spent voice credits failed.");
|
|
42
|
+
}
|
|
43
|
+
// verify tally result on-chain for each vote option
|
|
44
|
+
const failedPerVOSpentCredits = await (0, utils_1.verifyTallyResults)(tallyContract, tallyData, voteOptionTreeDepth, newSpentVoiceCreditsCommitment, newPerVoteOptionSpentVoiceCreditsCommitment);
|
|
45
|
+
if (failedPerVOSpentCredits.length > 0) {
|
|
46
|
+
throw new Error(`At least one spent voice credits entry in the tally results failed the on-chain verification. Please check your tally results at these indexes: ${failedPerVOSpentCredits.join(", ")}`);
|
|
47
|
+
}
|
|
48
|
+
if (tallyData.mode !== core_1.EMode.QV) {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
if (tallyData.perVoteOptionSpentVoiceCredits?.tally.length !== totalVoteOptions) {
|
|
52
|
+
throw new Error("Wrong number of vote options.");
|
|
53
|
+
}
|
|
54
|
+
// verify per vote option voice credits on-chain
|
|
55
|
+
const failedSpentCredits = await (0, utils_1.verifyPerVoteOptionSpentVoiceCredits)(tallyContract, tallyData, voteOptionTreeDepth, newSpentVoiceCreditsCommitment, newResultsCommitment);
|
|
56
|
+
if (failedSpentCredits.length > 0) {
|
|
57
|
+
throw new Error(`At least one tally result failed the on-chain verification. Please check your Tally data at these indexes: ${failedSpentCredits.join(", ")}`);
|
|
58
|
+
}
|
|
59
|
+
return true;
|
|
60
|
+
};
|
|
61
|
+
exports.verify = verify;
|
|
62
|
+
//# sourceMappingURL=verification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verification.js","sourceRoot":"","sources":["../../../ts/tally/verification.ts"],"names":[],"mappings":";;;AAAA,8EAAwH;AACxH,8CAA4C;AAI5C,kDAAoD;AAEpD,mCAAmF;AAEnF;;;GAGG;AACI,MAAM,MAAM,GAAG,KAAK,EAAE,EAC3B,MAAM,EACN,SAAS,EACT,MAAM,EACN,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,GACP,EAAoB,EAAE;IAClC,MAAM,mBAAmB,GAAG,SAAS,CAAC,IAAI,CAAC;IAE3C,MAAM,aAAa,GAAG,MAAM,IAAA,0BAAc,EAAC,MAAM,CAAC,QAAS,EAAE,mBAAmB,CAAC,CAAC;IAElF,IAAI,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AAE,mBAAmB,EAAE,iCAAiC,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateSignUpTreeFromKeys = exports.generateSignUpTreeWithEndKey = exports.generateSignUpTree = void 0;
|
|
4
|
+
var stateTree_1 = require("./stateTree");
|
|
5
|
+
Object.defineProperty(exports, "generateSignUpTree", { enumerable: true, get: function () { return stateTree_1.generateSignUpTree; } });
|
|
6
|
+
Object.defineProperty(exports, "generateSignUpTreeWithEndKey", { enumerable: true, get: function () { return stateTree_1.generateSignUpTreeWithEndKey; } });
|
|
7
|
+
Object.defineProperty(exports, "generateSignUpTreeFromKeys", { enumerable: true, get: function () { return stateTree_1.generateSignUpTreeFromKeys; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ts/trees/index.ts"],"names":[],"mappings":";;;AAAA,yCAA2G;AAAlG,+GAAA,kBAAkB,OAAA;AAAE,yHAAA,4BAA4B,OAAA;AAAE,uHAAA,0BAA0B,OAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { PublicKey } from "@maci-protocol/domainobjs";
|
|
2
|
+
import { LeanIMT } from "@zk-kit/lean-imt";
|
|
3
|
+
import type { IGenerateSignUpTreeArgs, IGenerateSignUpTree, IGenerateSignUpTreeWithEndKeyArgs } from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* Generate a State tree object from the events of a MACI smart contracts
|
|
6
|
+
* @param provider - the ethereum provider
|
|
7
|
+
* @param address - the address of the MACI contract
|
|
8
|
+
* @param fromBlock - the block number from which to start fetching events
|
|
9
|
+
* @param blocksPerRequest - the number of blocks to fetch in each request
|
|
10
|
+
* @param endBlock - the block number at which to stop fetching events
|
|
11
|
+
* @param sleepAmount - the amount of time to sleep between each request
|
|
12
|
+
* @returns State tree
|
|
13
|
+
*/
|
|
14
|
+
export declare const generateSignUpTree: ({ provider, address, fromBlock, blocksPerRequest, endBlock, sleepAmount, }: IGenerateSignUpTreeArgs) => Promise<IGenerateSignUpTree>;
|
|
15
|
+
/**
|
|
16
|
+
* Generate a State tree object from the events of a MACI smart contracts
|
|
17
|
+
* @param provider - the ethereum provider
|
|
18
|
+
* @param address - the address of the MACI contract
|
|
19
|
+
* @param fromBlock - the block number from which to start fetching events
|
|
20
|
+
* @param blocksPerRequest - the number of blocks to fetch in each request
|
|
21
|
+
* @param endBlock - the block number at which to stop fetching events
|
|
22
|
+
* @param sleepAmount - the amount of time to sleep between each request
|
|
23
|
+
* @param userPublicKey - the user public key where we end/stop the signUpTree replica.
|
|
24
|
+
* If user public key is 4th then the returned signUpTree will have only 4 leaves
|
|
25
|
+
* (does not matter if MACI' signUpTree has more).
|
|
26
|
+
* @returns State tree
|
|
27
|
+
*/
|
|
28
|
+
export declare const generateSignUpTreeWithEndKey: ({ provider, address, fromBlock, blocksPerRequest, endBlock, sleepAmount, userPublicKey, }: IGenerateSignUpTreeWithEndKeyArgs) => Promise<IGenerateSignUpTree>;
|
|
29
|
+
/**
|
|
30
|
+
* Generate a sign up tree from the public keys
|
|
31
|
+
* @param publicKeys - the public keys to generate the sign up tree from
|
|
32
|
+
* @returns the sign up tree
|
|
33
|
+
*/
|
|
34
|
+
export declare const generateSignUpTreeFromKeys: (publicKeys: PublicKey[]) => LeanIMT;
|
|
35
|
+
//# sourceMappingURL=stateTree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stateTree.d.ts","sourceRoot":"","sources":["../../../ts/trees/stateTree.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,OAAO,EAA4B,MAAM,kBAAkB,CAAC;AAErE,OAAO,KAAK,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,iCAAiC,EAAE,MAAM,SAAS,CAAC;AAI/G;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,GAAU,4EAOtC,uBAAuB,KAAG,OAAO,CAAC,mBAAmB,CAoCvD,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,4BAA4B,GAAU,2FAQhD,iCAAiC,KAAG,OAAO,CAAC,mBAAmB,CA8CjE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,GAAI,YAAY,SAAS,EAAE,KAAG,OAMpE,CAAC"}
|