@maci-protocol/sdk 0.0.0-ci.2653bc0
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 +22 -0
- package/README.md +12 -0
- package/build/package.json +56 -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 +43 -0
- package/build/ts/browser/index.js.map +1 -0
- package/build/ts/deploy/index.d.ts +5 -0
- package/build/ts/deploy/index.d.ts.map +1 -0
- package/build/ts/deploy/index.js +10 -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 +87 -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 +107 -0
- package/build/ts/deploy/poll.js.map +1 -0
- package/build/ts/deploy/types.d.ts +204 -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/vkRegistry.d.ts +7 -0
- package/build/ts/deploy/vkRegistry.d.ts.map +1 -0
- package/build/ts/deploy/vkRegistry.js +14 -0
- package/build/ts/deploy/vkRegistry.js.map +1 -0
- package/build/ts/index.d.ts +16 -0
- package/build/ts/index.d.ts.map +1 -0
- package/build/ts/index.js +69 -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 +41 -0
- package/build/ts/maci/policy.d.ts.map +1 -0
- package/build/ts/maci/policy.js +127 -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 +176 -0
- package/build/ts/maci/types.d.ts.map +1 -0
- package/build/ts/maci/types.js +18 -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 +20 -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 +23 -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 +152 -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 +50 -0
- package/build/ts/proof/__tests__/download.test.js.map +1 -0
- package/build/ts/proof/constants.d.ts +17 -0
- package/build/ts/proof/constants.d.ts.map +1 -0
- package/build/ts/proof/constants.js +20 -0
- package/build/ts/proof/constants.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 +49 -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 +127 -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 +81 -0
- package/build/ts/proof/prove.js.map +1 -0
- package/build/ts/proof/types.d.ts +175 -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/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/tally/commitments.d.ts +9 -0
- package/build/ts/tally/commitments.d.ts.map +1 -0
- package/build/ts/tally/commitments.js +42 -0
- package/build/ts/tally/commitments.js.map +1 -0
- package/build/ts/tally/index.d.ts +4 -0
- package/build/ts/tally/index.d.ts.map +1 -0
- package/build/ts/tally/index.js +8 -0
- package/build/ts/tally/index.js.map +1 -0
- package/build/ts/tally/types.d.ts +179 -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 +6 -0
- package/build/ts/trees/index.js.map +1 -0
- package/build/ts/trees/stateTree.d.ts +13 -0
- package/build/ts/trees/stateTree.d.ts.map +1 -0
- package/build/ts/trees/stateTree.js +53 -0
- package/build/ts/trees/stateTree.js.map +1 -0
- package/build/ts/trees/types.d.ts +46 -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 +3 -0
- package/build/ts/user/index.d.ts.map +1 -0
- package/build/ts/user/index.js +11 -0
- package/build/ts/user/index.js.map +1 -0
- package/build/ts/user/types.d.ts +424 -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/user.d.ts +42 -0
- package/build/ts/user/user.d.ts.map +1 -0
- package/build/ts/user/user.js +192 -0
- package/build/ts/user/user.js.map +1 -0
- package/build/ts/user/utils.d.ts +52 -0
- package/build/ts/user/utils.d.ts.map +1 -0
- package/build/ts/user/utils.js +186 -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 +28 -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 +16 -0
- package/build/ts/utils/utils.d.ts.map +1 -0
- package/build/ts/utils/utils.js +36 -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 +67 -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 +73 -0
- package/build/ts/verifyingKeys/setVerifyingKeys.js.map +1 -0
- package/build/ts/verifyingKeys/types.d.ts +231 -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 +102 -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 +6 -0
- package/build/ts/vote/index.d.ts.map +1 -0
- package/build/ts/vote/index.js +15 -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 +57 -0
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import type { EMode } from "@maci-protocol/contracts";
|
|
2
|
+
import type { IVkContractParams, VerifyingKey } from "@maci-protocol/domainobjs";
|
|
3
|
+
import type { Signer } from "ethers";
|
|
4
|
+
/**
|
|
5
|
+
* Arguments for the getAllVks function
|
|
6
|
+
*/
|
|
7
|
+
export interface IGetAllVksArgs {
|
|
8
|
+
/**
|
|
9
|
+
* The address of the VkRegistry contract
|
|
10
|
+
*/
|
|
11
|
+
vkRegistryAddress: string;
|
|
12
|
+
/**
|
|
13
|
+
* The signer to use for the contract calls
|
|
14
|
+
*/
|
|
15
|
+
signer: Signer;
|
|
16
|
+
/**
|
|
17
|
+
* The depth of the state tree
|
|
18
|
+
*/
|
|
19
|
+
stateTreeDepth: number;
|
|
20
|
+
/**
|
|
21
|
+
* The depth of the vote option tree
|
|
22
|
+
*/
|
|
23
|
+
voteOptionTreeDepth: number;
|
|
24
|
+
/**
|
|
25
|
+
* The batch size for the process messages
|
|
26
|
+
*/
|
|
27
|
+
messageBatchSize: number;
|
|
28
|
+
/**
|
|
29
|
+
* The depth of the ballot tree
|
|
30
|
+
*/
|
|
31
|
+
intStateTreeDepth: number;
|
|
32
|
+
/**
|
|
33
|
+
* The mode to use for the contract calls
|
|
34
|
+
*/
|
|
35
|
+
mode: EMode;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* MACI's verifying keys
|
|
39
|
+
*/
|
|
40
|
+
export interface IMaciVerifyingKeys {
|
|
41
|
+
/**
|
|
42
|
+
* The verifying key for the poll joining circuit
|
|
43
|
+
*/
|
|
44
|
+
pollJoiningVkOnChain: IVkContractParams;
|
|
45
|
+
/**
|
|
46
|
+
* The verifying key for the poll joined circuit
|
|
47
|
+
*/
|
|
48
|
+
pollJoinedVkOnChain: IVkContractParams;
|
|
49
|
+
/**
|
|
50
|
+
* The verifying key for the process messages circuit
|
|
51
|
+
*/
|
|
52
|
+
processVkOnChain: IVkContractParams;
|
|
53
|
+
/**
|
|
54
|
+
* The verifying key for the tally votes circuit
|
|
55
|
+
*/
|
|
56
|
+
tallyVkOnChain: IVkContractParams;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Arguments for the extractAllVks function
|
|
60
|
+
*/
|
|
61
|
+
export interface IExtractAllVksArgs {
|
|
62
|
+
/**
|
|
63
|
+
* The path to the poll joining zkey
|
|
64
|
+
*/
|
|
65
|
+
pollJoiningZkeyPath?: string;
|
|
66
|
+
/**
|
|
67
|
+
* The path to the poll joined zkey
|
|
68
|
+
*/
|
|
69
|
+
pollJoinedZkeyPath?: string;
|
|
70
|
+
/**
|
|
71
|
+
* The path to the process messages zkey
|
|
72
|
+
*/
|
|
73
|
+
processMessagesZkeyPath?: string;
|
|
74
|
+
/**
|
|
75
|
+
* The path to the tally votes zkey
|
|
76
|
+
*/
|
|
77
|
+
tallyVotesZkeyPath?: string;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Maci verifying keys
|
|
81
|
+
*/
|
|
82
|
+
export interface IMaciVks {
|
|
83
|
+
/**
|
|
84
|
+
* The poll joining verifying key
|
|
85
|
+
*/
|
|
86
|
+
pollJoiningVk?: VerifyingKey;
|
|
87
|
+
/**
|
|
88
|
+
* The poll joined verifying key
|
|
89
|
+
*/
|
|
90
|
+
pollJoinedVk?: VerifyingKey;
|
|
91
|
+
/**
|
|
92
|
+
* The message processing verifying key
|
|
93
|
+
*/
|
|
94
|
+
processVk?: VerifyingKey;
|
|
95
|
+
/**
|
|
96
|
+
* The tally verifying key
|
|
97
|
+
*/
|
|
98
|
+
tallyVk?: VerifyingKey;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The arguments for the setVerifyingKeys function
|
|
102
|
+
*/
|
|
103
|
+
export interface ISetVerifyingKeysArgs {
|
|
104
|
+
/**
|
|
105
|
+
* The polll joining Vk object
|
|
106
|
+
*/
|
|
107
|
+
pollJoiningVk: VerifyingKey;
|
|
108
|
+
/**
|
|
109
|
+
* The poll joined Vk object
|
|
110
|
+
*/
|
|
111
|
+
pollJoinedVk: VerifyingKey;
|
|
112
|
+
/**
|
|
113
|
+
* The process messages Vk object
|
|
114
|
+
*/
|
|
115
|
+
processMessagesVk: VerifyingKey;
|
|
116
|
+
/**
|
|
117
|
+
* The tally votes Vk object
|
|
118
|
+
*/
|
|
119
|
+
tallyVotesVk: VerifyingKey;
|
|
120
|
+
/**
|
|
121
|
+
* The state tree depth
|
|
122
|
+
*/
|
|
123
|
+
stateTreeDepth: number;
|
|
124
|
+
/**
|
|
125
|
+
* The intermediate state tree depth (ballot tree)
|
|
126
|
+
*/
|
|
127
|
+
intStateTreeDepth: number;
|
|
128
|
+
/**
|
|
129
|
+
* The vote option tree depth
|
|
130
|
+
*/
|
|
131
|
+
voteOptionTreeDepth: number;
|
|
132
|
+
/**
|
|
133
|
+
* The message batch size
|
|
134
|
+
*/
|
|
135
|
+
messageBatchSize: number;
|
|
136
|
+
/**
|
|
137
|
+
* The VkRegistry contract address
|
|
138
|
+
*/
|
|
139
|
+
vkRegistryAddress: string;
|
|
140
|
+
/**
|
|
141
|
+
* The signer
|
|
142
|
+
*/
|
|
143
|
+
signer: Signer;
|
|
144
|
+
/**
|
|
145
|
+
* QV or NON_QV
|
|
146
|
+
*/
|
|
147
|
+
mode: EMode;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Interface for the arguments to the checkVerifyingKeys command
|
|
151
|
+
*/
|
|
152
|
+
export interface ICheckVerifyingKeysArgs {
|
|
153
|
+
/**
|
|
154
|
+
* The depth of the state tree
|
|
155
|
+
*/
|
|
156
|
+
stateTreeDepth: number;
|
|
157
|
+
/**
|
|
158
|
+
* The depth of the state subtree
|
|
159
|
+
*/
|
|
160
|
+
intStateTreeDepth: number;
|
|
161
|
+
/**
|
|
162
|
+
* The depth of the vote option tree
|
|
163
|
+
*/
|
|
164
|
+
voteOptionTreeDepth: number;
|
|
165
|
+
/**
|
|
166
|
+
* The size of the message batch
|
|
167
|
+
*/
|
|
168
|
+
messageBatchSize: number;
|
|
169
|
+
/**
|
|
170
|
+
* The path to the poll joining zkey
|
|
171
|
+
*/
|
|
172
|
+
pollJoiningZkeyPath: string;
|
|
173
|
+
/**
|
|
174
|
+
* The path to the poll joined zkey
|
|
175
|
+
*/
|
|
176
|
+
pollJoinedZkeyPath: string;
|
|
177
|
+
/**
|
|
178
|
+
* The path to the process messages zkey
|
|
179
|
+
*/
|
|
180
|
+
processMessagesZkeyPath: string;
|
|
181
|
+
/**
|
|
182
|
+
* The path to the tally votes zkey
|
|
183
|
+
*/
|
|
184
|
+
tallyVotesZkeyPath: string;
|
|
185
|
+
/**
|
|
186
|
+
* A signer object
|
|
187
|
+
*/
|
|
188
|
+
signer: Signer;
|
|
189
|
+
/**
|
|
190
|
+
* The address of the VkRegistry contract
|
|
191
|
+
*/
|
|
192
|
+
vkRegistry: string;
|
|
193
|
+
/**
|
|
194
|
+
* Whether to use quadratic voting or not
|
|
195
|
+
*/
|
|
196
|
+
useQuadraticVoting?: boolean;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Interface for the arguments to the extractVkToFile command
|
|
200
|
+
*/
|
|
201
|
+
export interface IExtractVkToFileArgs {
|
|
202
|
+
/**
|
|
203
|
+
* File path for poll joining zkey
|
|
204
|
+
*/
|
|
205
|
+
pollJoiningZkeyPath: string;
|
|
206
|
+
/**
|
|
207
|
+
* File path for poll joined zkey
|
|
208
|
+
*/
|
|
209
|
+
pollJoinedZkeyPath: string;
|
|
210
|
+
/**
|
|
211
|
+
* File path for processMessagesQv zkey
|
|
212
|
+
*/
|
|
213
|
+
processMessagesZkeyPathQv: string;
|
|
214
|
+
/**
|
|
215
|
+
* File path for tallyVotesQv zkey
|
|
216
|
+
*/
|
|
217
|
+
tallyVotesZkeyPathQv: string;
|
|
218
|
+
/**
|
|
219
|
+
* File path for processMessagesNonQv zkey
|
|
220
|
+
*/
|
|
221
|
+
processMessagesZkeyPathNonQv: string;
|
|
222
|
+
/**
|
|
223
|
+
* File path for tallyVotes zkey
|
|
224
|
+
*/
|
|
225
|
+
tallyVotesZkeyPathNonQv: string;
|
|
226
|
+
/**
|
|
227
|
+
* Output file path of extracted vkeys
|
|
228
|
+
*/
|
|
229
|
+
outputFilePath: string;
|
|
230
|
+
}
|
|
231
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../ts/verifyingKeys/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACjF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,IAAI,EAAE,KAAK,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,oB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AEG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,uBAAuB,EAAE,MAAM,CAAC;IAEhC;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,yBAAyB,EAAE,MAAM,CAAC;IAElC;;OAEG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,4BAA4B,EAAE,MAAM,CAAC;IAErC;;OAEG;IACH,uBAAuB,EAAE,MAAM,CAAC;IAEhC;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../ts/verifyingKeys/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { IVkContractParams, VerifyingKey } from "@maci-protocol/domainobjs";
|
|
2
|
+
import type { IGetAllVksArgs, IExtractAllVksArgs, IMaciVks, IMaciVerifyingKeys, IExtractVkToFileArgs } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Get all the verifying keys from the contract
|
|
5
|
+
* @param args - The arguments for the getAllVks function
|
|
6
|
+
* @returns The verifying keys
|
|
7
|
+
*/
|
|
8
|
+
export declare const getAllOnChainVks: ({ vkRegistryAddress, signer, stateTreeDepth, voteOptionTreeDepth, messageBatchSize, intStateTreeDepth, mode, }: IGetAllVksArgs) => Promise<IMaciVerifyingKeys>;
|
|
9
|
+
/**
|
|
10
|
+
* Compare two verifying keys
|
|
11
|
+
* @param vkOnChain - the verifying key on chain
|
|
12
|
+
* @param vk - the local verifying key
|
|
13
|
+
* @returns whether they are equal or not
|
|
14
|
+
*/
|
|
15
|
+
export declare const compareVks: (vkOnChain: VerifyingKey | IVkContractParams, vk?: VerifyingKey | IVkContractParams) => boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Extract all the verifying keys
|
|
18
|
+
* @param args - The arguments for the extractAllVks function
|
|
19
|
+
* @returns The verifying keys
|
|
20
|
+
*/
|
|
21
|
+
export declare const extractAllVks: ({ pollJoiningZkeyPath, pollJoinedZkeyPath, processMessagesZkeyPath, tallyVotesZkeyPath, }: IExtractAllVksArgs) => Promise<IMaciVks>;
|
|
22
|
+
/**
|
|
23
|
+
* Command to confirm that the verifying keys in the contract match the local ones
|
|
24
|
+
* @note see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing
|
|
25
|
+
* @param args The arguments for the checkVerifyingKeys command
|
|
26
|
+
* @returns Whether the verifying keys match or not
|
|
27
|
+
*/
|
|
28
|
+
export declare const extractVkToFile: ({ processMessagesZkeyPathQv, tallyVotesZkeyPathQv, processMessagesZkeyPathNonQv, pollJoinedZkeyPath, pollJoiningZkeyPath, tallyVotesZkeyPathNonQv, outputFilePath, }: IExtractVkToFileArgs) => Promise<void>;
|
|
29
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../ts/verifyingKeys/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAI5E,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,QAAQ,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEtH;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAU,gHAQpC,cAAc,KAAG,OAAO,CAAC,kBAAkB,CAgB7C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GACrB,WAAW,YAAY,GAAG,iBAAiB,EAC3C,KAAK,YAAY,GAAG,iBAAiB,KACpC,OA2BF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAU,2FAKjC,kBAAkB,KAAG,OAAO,CAAC,QAAQ,CAgBvC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAU,sKAQnC,oBAAoB,KAAG,OAAO,CAAC,IAAI,CAcrC,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.extractVkToFile = exports.extractAllVks = exports.compareVks = exports.getAllOnChainVks = void 0;
|
|
7
|
+
const contracts_1 = require("@maci-protocol/contracts");
|
|
8
|
+
const domainobjs_1 = require("@maci-protocol/domainobjs");
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
/**
|
|
11
|
+
* Get all the verifying keys from the contract
|
|
12
|
+
* @param args - The arguments for the getAllVks function
|
|
13
|
+
* @returns The verifying keys
|
|
14
|
+
*/
|
|
15
|
+
const getAllOnChainVks = async ({ vkRegistryAddress, signer, stateTreeDepth, voteOptionTreeDepth, messageBatchSize, intStateTreeDepth, mode, }) => {
|
|
16
|
+
const vkRegistryContractInstance = contracts_1.VkRegistry__factory.connect(vkRegistryAddress, signer);
|
|
17
|
+
const [pollJoiningVkOnChain, pollJoinedVkOnChain, processVkOnChain, tallyVkOnChain] = await Promise.all([
|
|
18
|
+
vkRegistryContractInstance.getPollJoiningVk(stateTreeDepth),
|
|
19
|
+
vkRegistryContractInstance.getPollJoinedVk(stateTreeDepth),
|
|
20
|
+
vkRegistryContractInstance.getProcessVk(stateTreeDepth, voteOptionTreeDepth, messageBatchSize, mode),
|
|
21
|
+
vkRegistryContractInstance.getTallyVk(stateTreeDepth, intStateTreeDepth, voteOptionTreeDepth, mode),
|
|
22
|
+
]);
|
|
23
|
+
return {
|
|
24
|
+
pollJoiningVkOnChain,
|
|
25
|
+
pollJoinedVkOnChain,
|
|
26
|
+
processVkOnChain,
|
|
27
|
+
tallyVkOnChain,
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
exports.getAllOnChainVks = getAllOnChainVks;
|
|
31
|
+
/**
|
|
32
|
+
* Compare two verifying keys
|
|
33
|
+
* @param vkOnChain - the verifying key on chain
|
|
34
|
+
* @param vk - the local verifying key
|
|
35
|
+
* @returns whether they are equal or not
|
|
36
|
+
*/
|
|
37
|
+
const compareVks = (vkOnChain, vk) => {
|
|
38
|
+
if (!vk) {
|
|
39
|
+
throw new Error("Verifying key is not provided");
|
|
40
|
+
}
|
|
41
|
+
let isEqual = vk.ic.length === vkOnChain.ic.length;
|
|
42
|
+
for (let i = 0; i < vk.ic.length; i += 1) {
|
|
43
|
+
isEqual = isEqual && vk.ic[i].x.toString() === vkOnChain.ic[i].x.toString();
|
|
44
|
+
isEqual = isEqual && vk.ic[i].y.toString() === vkOnChain.ic[i].y.toString();
|
|
45
|
+
}
|
|
46
|
+
isEqual = isEqual && vk.alpha1.x.toString() === vkOnChain.alpha1.x.toString();
|
|
47
|
+
isEqual = isEqual && vk.alpha1.y.toString() === vkOnChain.alpha1.y.toString();
|
|
48
|
+
isEqual = isEqual && vk.beta2.x[0].toString() === vkOnChain.beta2.x[0].toString();
|
|
49
|
+
isEqual = isEqual && vk.beta2.x[1].toString() === vkOnChain.beta2.x[1].toString();
|
|
50
|
+
isEqual = isEqual && vk.beta2.y[0].toString() === vkOnChain.beta2.y[0].toString();
|
|
51
|
+
isEqual = isEqual && vk.beta2.y[1].toString() === vkOnChain.beta2.y[1].toString();
|
|
52
|
+
isEqual = isEqual && vk.delta2.x[0].toString() === vkOnChain.delta2.x[0].toString();
|
|
53
|
+
isEqual = isEqual && vk.delta2.x[1].toString() === vkOnChain.delta2.x[1].toString();
|
|
54
|
+
isEqual = isEqual && vk.delta2.y[0].toString() === vkOnChain.delta2.y[0].toString();
|
|
55
|
+
isEqual = isEqual && vk.delta2.y[1].toString() === vkOnChain.delta2.y[1].toString();
|
|
56
|
+
isEqual = isEqual && vk.gamma2.x[0].toString() === vkOnChain.gamma2.x[0].toString();
|
|
57
|
+
isEqual = isEqual && vk.gamma2.x[1].toString() === vkOnChain.gamma2.x[1].toString();
|
|
58
|
+
isEqual = isEqual && vk.gamma2.y[0].toString() === vkOnChain.gamma2.y[0].toString();
|
|
59
|
+
isEqual = isEqual && vk.gamma2.y[1].toString() === vkOnChain.gamma2.y[1].toString();
|
|
60
|
+
return isEqual;
|
|
61
|
+
};
|
|
62
|
+
exports.compareVks = compareVks;
|
|
63
|
+
/**
|
|
64
|
+
* Extract all the verifying keys
|
|
65
|
+
* @param args - The arguments for the extractAllVks function
|
|
66
|
+
* @returns The verifying keys
|
|
67
|
+
*/
|
|
68
|
+
const extractAllVks = async ({ pollJoiningZkeyPath, pollJoinedZkeyPath, processMessagesZkeyPath, tallyVotesZkeyPath, }) => {
|
|
69
|
+
// extract the vks
|
|
70
|
+
const pollJoiningVk = pollJoiningZkeyPath ? domainobjs_1.VerifyingKey.fromObj(await (0, contracts_1.extractVk)(pollJoiningZkeyPath)) : undefined;
|
|
71
|
+
const pollJoinedVk = pollJoinedZkeyPath ? domainobjs_1.VerifyingKey.fromObj(await (0, contracts_1.extractVk)(pollJoinedZkeyPath)) : undefined;
|
|
72
|
+
const processVk = processMessagesZkeyPath
|
|
73
|
+
? domainobjs_1.VerifyingKey.fromObj(await (0, contracts_1.extractVk)(processMessagesZkeyPath))
|
|
74
|
+
: undefined;
|
|
75
|
+
const tallyVk = tallyVotesZkeyPath ? domainobjs_1.VerifyingKey.fromObj(await (0, contracts_1.extractVk)(tallyVotesZkeyPath)) : undefined;
|
|
76
|
+
return {
|
|
77
|
+
pollJoiningVk,
|
|
78
|
+
pollJoinedVk,
|
|
79
|
+
processVk,
|
|
80
|
+
tallyVk,
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
exports.extractAllVks = extractAllVks;
|
|
84
|
+
/**
|
|
85
|
+
* Command to confirm that the verifying keys in the contract match the local ones
|
|
86
|
+
* @note see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing
|
|
87
|
+
* @param args The arguments for the checkVerifyingKeys command
|
|
88
|
+
* @returns Whether the verifying keys match or not
|
|
89
|
+
*/
|
|
90
|
+
const extractVkToFile = async ({ processMessagesZkeyPathQv, tallyVotesZkeyPathQv, processMessagesZkeyPathNonQv, pollJoinedZkeyPath, pollJoiningZkeyPath, tallyVotesZkeyPathNonQv, outputFilePath, }) => {
|
|
91
|
+
const [processVkQv, tallyVkQv, processVkNonQv, tallyVkNonQv, pollJoiningVk, pollJoinedVk] = await Promise.all([
|
|
92
|
+
(0, contracts_1.extractVk)(processMessagesZkeyPathQv),
|
|
93
|
+
(0, contracts_1.extractVk)(tallyVotesZkeyPathQv),
|
|
94
|
+
(0, contracts_1.extractVk)(processMessagesZkeyPathNonQv),
|
|
95
|
+
(0, contracts_1.extractVk)(tallyVotesZkeyPathNonQv),
|
|
96
|
+
(0, contracts_1.extractVk)(pollJoiningZkeyPath),
|
|
97
|
+
(0, contracts_1.extractVk)(pollJoinedZkeyPath),
|
|
98
|
+
]);
|
|
99
|
+
await fs_1.default.promises.writeFile(outputFilePath, JSON.stringify({ processVkQv, tallyVkQv, processVkNonQv, tallyVkNonQv, pollJoiningVk, pollJoinedVk }));
|
|
100
|
+
};
|
|
101
|
+
exports.extractVkToFile = extractVkToFile;
|
|
102
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../ts/verifyingKeys/utils.ts"],"names":[],"mappings":";;;;;;AAAA,wDAA+F;AAC/F,0DAA4E;AAE5E,4CAAoB;AAIpB;;;;GAIG;AACI,MAAM,gBAAgB,GAAG,KAAK,EAAE,EACrC,iBAAiB,EACjB,MAAM,EACN,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,IAAI,GACW,EAA+B,EAAE;IAChD,MAAM,0BAA0B,GAAG,+BAAiB,CAAC,OAAO,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;IAExF,MAAM,CAAC,oBAAoB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,cAAc,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACtG,0BAA0B,CAAC,gBAAgB,CAAC,cAAc,CAAC;QAC3D,0BAA0B,CAAC,eAAe,CAAC,cAAc,CAAC;QAC1D,0BAA0B,CAAC,YAAY,CAAC,cAAc,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,IAAI,CAAC;QACpG,0BAA0B,CAAC,UAAU,CAAC,cAAc,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,IAAI,CAAC;KACpG,CAAC,CAAC;IAEH,OAAO;QACL,oBAAoB;QACpB,mBAAmB;QACnB,gBAAgB;QAChB,cAAc;KACf,CAAC;AACJ,CAAC,CAAC;AAxBW,QAAA,gBAAgB,oBAwB3B;AAEF;;;;;GAKG;AACI,MAAM,UAAU,GAAG,CACxB,SAA2C,EAC3C,EAAqC,EAC5B,EAAE;IACX,IAAI,CAAC,EAAE,EAAE,CAAC;QACR,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC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AAkB,CAAC,CAAC,CAAC,yBAAY,CAAC,OAAO,CAAC,MAAM,IAAA,qBAAS,EAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAE3G,OAAO;QACL,aAAa;QACb,YAAY;QACZ,SAAS;QACT,OAAO;KACR,CAAC;AACJ,CAAC,CAAC;AArBW,QAAA,aAAa,iBAqBxB;AAEF;;;;;GAKG;AACI,MAAM,eAAe,GAAG,KAAK,EAAE,EACpC,yBAAyB,EACzB,oBAAoB,EACpB,4BAA4B,EAC5B,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,GACO,EAAiB,EAAE;IACxC,MAAM,CAAC,WAAW,EAAE,SAAS,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAC5G,IAAA,qBAAS,EAAC,yBAAyB,CAAC;QACpC,IAAA,qBAAS,EAAC,oBAAoB,CAAC;QAC/B,IAAA,qBAAS,EAAC,4BAA4B,CAAC;QACvC,IAAA,qBAAS,EAAC,uBAAuB,CAAC;QAClC,IAAA,qBAAS,EAAC,mBAAmB,CAAC;QAC9B,IAAA,qBAAS,EAAC,kBAAkB,CAAC;KAC9B,CAAC,CAAC;IAEH,MAAM,YAAE,CAAC,QAAQ,CAAC,SAAS,CACzB,cAAc,EACd,IAAI,CAAC,SAAS,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC,CACtG,CAAC;AACJ,CAAC,CAAC;AAtBW,QAAA,eAAe,mBAsB1B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IGenerateVoteArgs, IVote } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Generate a vote
|
|
4
|
+
* @param args - The arguments for the vote
|
|
5
|
+
* @returns The vote object
|
|
6
|
+
*/
|
|
7
|
+
export declare const generateVote: ({ pollId, voteOptionIndex, salt, nonce, privateKey, stateIndex, voteWeight, coordinatorPubKey, maxVoteOption, ephemeralKeypair, newPubKey, }: IGenerateVoteArgs) => IVote;
|
|
8
|
+
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../ts/vote/generate.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAIxD;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,8IAY1B,iBAAiB,KAAG,KAmDtB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateVote = void 0;
|
|
4
|
+
const crypto_1 = require("@maci-protocol/crypto");
|
|
5
|
+
const domainobjs_1 = require("@maci-protocol/domainobjs");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
/**
|
|
8
|
+
* Generate a vote
|
|
9
|
+
* @param args - The arguments for the vote
|
|
10
|
+
* @returns The vote object
|
|
11
|
+
*/
|
|
12
|
+
const generateVote = ({ pollId, voteOptionIndex, salt, nonce, privateKey, stateIndex, voteWeight, coordinatorPubKey, maxVoteOption, ephemeralKeypair, newPubKey, }) => {
|
|
13
|
+
const keypair = new domainobjs_1.Keypair(privateKey);
|
|
14
|
+
// validate args
|
|
15
|
+
if (voteOptionIndex < 0 || voteOptionIndex > maxVoteOption) {
|
|
16
|
+
throw new Error("Invalid vote option index");
|
|
17
|
+
}
|
|
18
|
+
// check < 1 cause index zero is a blank state leaf
|
|
19
|
+
if (stateIndex < 1) {
|
|
20
|
+
throw new Error("Invalid state index");
|
|
21
|
+
}
|
|
22
|
+
if (nonce < 0) {
|
|
23
|
+
throw new Error("Invalid nonce");
|
|
24
|
+
}
|
|
25
|
+
if (salt && !(0, utils_1.validateSalt)(salt)) {
|
|
26
|
+
throw new Error("Invalid salt");
|
|
27
|
+
}
|
|
28
|
+
const userSalt = salt ? BigInt(salt) : (0, crypto_1.genRandomSalt)();
|
|
29
|
+
if (pollId < 0) {
|
|
30
|
+
throw new Error("Invalid poll id");
|
|
31
|
+
}
|
|
32
|
+
// if no ephemeral keypair is provided, generate a new one
|
|
33
|
+
const encKeypair = ephemeralKeypair ?? new domainobjs_1.Keypair();
|
|
34
|
+
// create the command object
|
|
35
|
+
const command = new domainobjs_1.PCommand(stateIndex, newPubKey ?? keypair.pubKey, voteOptionIndex, voteWeight, nonce, pollId, userSalt);
|
|
36
|
+
// sign the command with the poll private key
|
|
37
|
+
const signature = command.sign(privateKey);
|
|
38
|
+
// encrypt the command using a shared key between the user and the coordinator
|
|
39
|
+
const message = command.encrypt(signature, domainobjs_1.Keypair.genEcdhSharedKey(encKeypair.privKey, coordinatorPubKey));
|
|
40
|
+
return {
|
|
41
|
+
message,
|
|
42
|
+
ephemeralKeypair: encKeypair,
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
exports.generateVote = generateVote;
|
|
46
|
+
//# sourceMappingURL=generate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../ts/vote/generate.ts"],"names":[],"mappings":";;;AAAA,kDAAsD;AACtD,0DAA8D;AAI9D,mCAAuC;AAEvC;;;;GAIG;AACI,MAAM,YAAY,GAAG,CAAC,EAC3B,MAAM,EACN,eAAe,EACf,IAAI,EACJ,KAAK,EACL,UAAU,EACV,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,SAAS,GACS,EAAS,EAAE;IAC7B,MAAM,OAAO,GAAG,IAAI,oBAAO,CAAC,UAAU,CAAC,CAAC;IAExC,gBAAgB;IAChB,IAAI,eAAe,GAAG,CAAC,IAAI,eAAe,GAAG,aAAa,EAAE,CAAC;QAC3D,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC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Vote, IGenerateVoteArgs, IPublishArgs, IPublishBatchArgs, IPublishBatchData, IPublishData, IPublishMessage, ISubmitVoteArgs, ISubmitVoteBatchArgs, } from "./types";
|
|
2
|
+
export { generateVote } from "./generate";
|
|
3
|
+
export { publish, publishBatch } from "./publish";
|
|
4
|
+
export { submitVote, submitVoteBatch } from "./submit";
|
|
5
|
+
export { getCoordinatorPubKey, validateSalt } from "./utils";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../ts/vote/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,KAAK,EACL,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,eAAe,EACf,oBAAoB,GACrB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateSalt = exports.getCoordinatorPubKey = exports.submitVoteBatch = exports.submitVote = exports.publishBatch = exports.publish = exports.generateVote = void 0;
|
|
4
|
+
var generate_1 = require("./generate");
|
|
5
|
+
Object.defineProperty(exports, "generateVote", { enumerable: true, get: function () { return generate_1.generateVote; } });
|
|
6
|
+
var publish_1 = require("./publish");
|
|
7
|
+
Object.defineProperty(exports, "publish", { enumerable: true, get: function () { return publish_1.publish; } });
|
|
8
|
+
Object.defineProperty(exports, "publishBatch", { enumerable: true, get: function () { return publish_1.publishBatch; } });
|
|
9
|
+
var submit_1 = require("./submit");
|
|
10
|
+
Object.defineProperty(exports, "submitVote", { enumerable: true, get: function () { return submit_1.submitVote; } });
|
|
11
|
+
Object.defineProperty(exports, "submitVoteBatch", { enumerable: true, get: function () { return submit_1.submitVoteBatch; } });
|
|
12
|
+
var utils_1 = require("./utils");
|
|
13
|
+
Object.defineProperty(exports, "getCoordinatorPubKey", { enumerable: true, get: function () { return utils_1.getCoordinatorPubKey; } });
|
|
14
|
+
Object.defineProperty(exports, "validateSalt", { enumerable: true, get: function () { return utils_1.validateSalt; } });
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ts/vote/index.ts"],"names":[],"mappings":";;;AAWA,uCAA0C;AAAjC,wGAAA,YAAY,OAAA;AACrB,qCAAkD;AAAzC,kGAAA,OAAO,OAAA;AAAE,uGAAA,YAAY,OAAA;AAC9B,mCAAuD;AAA9C,oGAAA,UAAU,OAAA;AAAE,yGAAA,eAAe,OAAA;AACpC,iCAA6D;AAApD,6GAAA,oBAAoB,OAAA;AAAE,qGAAA,YAAY,OAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IInvalidateVotesArgs } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Invalidate votes
|
|
4
|
+
* @dev This function is used to invalidate votes for a given poll
|
|
5
|
+
* by sending a key change command with a new random key
|
|
6
|
+
* Given messages are processed in reverse order, this will be processed before
|
|
7
|
+
* previous votes and would require previous votes to have been casted with this
|
|
8
|
+
* new key, which is impossible.
|
|
9
|
+
* @param args invalidate votes args
|
|
10
|
+
* @returns transaction hash
|
|
11
|
+
*/
|
|
12
|
+
export declare const invalidateVotes: ({ maciAddress, pollId, signer, maciPrivateKey, stateIndex, }: IInvalidateVotesArgs) => Promise<string | undefined>;
|
|
13
|
+
//# sourceMappingURL=invalidate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invalidate.d.ts","sourceRoot":"","sources":["../../../ts/vote/invalidate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAQpD;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,GAAU,8DAMnC,oBAAoB,KAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CA2BnD,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.invalidateVotes = void 0;
|
|
4
|
+
const domainobjs_1 = require("@maci-protocol/domainobjs");
|
|
5
|
+
const poll_1 = require("../poll");
|
|
6
|
+
const generate_1 = require("./generate");
|
|
7
|
+
const submit_1 = require("./submit");
|
|
8
|
+
const utils_1 = require("./utils");
|
|
9
|
+
/**
|
|
10
|
+
* Invalidate votes
|
|
11
|
+
* @dev This function is used to invalidate votes for a given poll
|
|
12
|
+
* by sending a key change command with a new random key
|
|
13
|
+
* Given messages are processed in reverse order, this will be processed before
|
|
14
|
+
* previous votes and would require previous votes to have been casted with this
|
|
15
|
+
* new key, which is impossible.
|
|
16
|
+
* @param args invalidate votes args
|
|
17
|
+
* @returns transaction hash
|
|
18
|
+
*/
|
|
19
|
+
const invalidateVotes = async ({ maciAddress, pollId, signer, maciPrivateKey, stateIndex, }) => {
|
|
20
|
+
const { poll: pollContract } = await (0, poll_1.getPollContracts)({ maciAddress, pollId, signer });
|
|
21
|
+
const [maxVoteOption, pollAddress] = await Promise.all([pollContract.voteOptions(), pollContract.getAddress()]);
|
|
22
|
+
const coordinatorPubKey = await (0, utils_1.getCoordinatorPubKey)(pollAddress, signer);
|
|
23
|
+
// generate the key change message
|
|
24
|
+
const message = (0, generate_1.generateVote)({
|
|
25
|
+
pollId,
|
|
26
|
+
voteOptionIndex: 0n,
|
|
27
|
+
nonce: 0n,
|
|
28
|
+
privateKey: maciPrivateKey,
|
|
29
|
+
stateIndex,
|
|
30
|
+
// use a random key to invalidate the previous votes
|
|
31
|
+
newPubKey: new domainobjs_1.Keypair().pubKey,
|
|
32
|
+
voteWeight: 0n,
|
|
33
|
+
coordinatorPubKey,
|
|
34
|
+
maxVoteOption,
|
|
35
|
+
});
|
|
36
|
+
const receipt = await (0, submit_1.submitVote)({
|
|
37
|
+
pollAddress,
|
|
38
|
+
vote: message,
|
|
39
|
+
signer,
|
|
40
|
+
});
|
|
41
|
+
return receipt;
|
|
42
|
+
};
|
|
43
|
+
exports.invalidateVotes = invalidateVotes;
|
|
44
|
+
//# sourceMappingURL=invalidate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invalidate.js","sourceRoot":"","sources":["../../../ts/vote/invalidate.ts"],"names":[],"mappings":";;;AAAA,0DAAoD;AAIpD,kCAA2C;AAE3C,yCAA0C;AAC1C,qCAAsC;AACtC,mCAA+C;AAE/C;;;;;;;;;GASG;AACI,MAAM,eAAe,GAAG,KAAK,EAAE,EACpC,WAAW,EACX,MAAM,EACN,MAAM,EACN,cAAc,EACd,UAAU,GACW,EAA+B,EAAE;IACtD,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,MAAM,IAAA,uBAAgB,EAAC,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAEvF,MAAM,CAAC,aAAa,EAAE,WAAW,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,YAAY,CAAC,WAAW,EAAE,EAAE,YAAY,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IAChH,MAAM,iBAAiB,GAAG,MAAM,IAAA,4BAAoB,EAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAE1E,kCAAkC;IAClC,MAAM,OAAO,GAAG,IAAA,uBAAY,EAAC;QAC3B,MAAM;QACN,eAAe,EAAE,EAAE;QACnB,KAAK,EAAE,EAAE;QACT,UAAU,EAAE,cAAc;QAC1B,UAAU;QACV,oDAAoD;QACpD,SAAS,EAAE,IAAI,oBAAO,EAAE,CAAC,MAAM;QAC/B,UAAU,EAAE,EAAE;QACd,iBAAiB;QACjB,aAAa;KACd,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,IAAA,mBAAU,EAAC;QAC/B,WAAW;QACX,IAAI,EAAE,OAAO;QACb,MAAM;KACP,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAjCW,QAAA,eAAe,mBAiC1B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IPublishBatchArgs, IPublishBatchData, IPublishArgs, IPublishData } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Publish a new message to a MACI Poll contract
|
|
4
|
+
* @param {IPublishArgs} args - The arguments for the publish command
|
|
5
|
+
* @returns {IPublishData} The ephemeral private key used to encrypt the message, transaction hash
|
|
6
|
+
*/
|
|
7
|
+
export declare const publish: ({ pubkey, stateIndex, voteOptionIndex, nonce, pollId, newVoteWeight, maciAddress, salt, privateKey, signer, }: IPublishArgs) => Promise<IPublishData>;
|
|
8
|
+
/**
|
|
9
|
+
* Batch publish new messages to a MACI Poll contract
|
|
10
|
+
* @param {IPublishBatchArgs} args - The arguments for the publish command
|
|
11
|
+
* @returns {IPublishBatchData} The ephemeral private key used to encrypt the message, transaction hash
|
|
12
|
+
*/
|
|
13
|
+
export declare const publishBatch: ({ messages, pollId, maciAddress, publicKey, privateKey, signer, }: IPublishBatchArgs) => Promise<IPublishBatchData>;
|
|
14
|
+
//# sourceMappingURL=publish.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../../ts/vote/publish.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAQhG;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAU,+GAW3B,YAAY,KAAG,OAAO,CAAC,YAAY,CAqCrC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAU,mEAOhC,iBAAiB,KAAG,OAAO,CAAC,iBAAiB,CA4C/C,CAAC"}
|