@maci-protocol/sdk 0.0.0-ci.9342f07 → 0.0.0-ci.9819a21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -2
- package/build/package.json +16 -8
- package/build/ts/browser/index.d.ts +4 -2
- package/build/ts/browser/index.d.ts.map +1 -1
- package/build/ts/browser/index.js +7 -1
- package/build/ts/browser/index.js.map +1 -1
- package/build/ts/browser/joinPoll.d.ts +4 -2
- package/build/ts/browser/joinPoll.d.ts.map +1 -1
- package/build/ts/browser/joinPoll.js +21 -17
- package/build/ts/browser/joinPoll.js.map +1 -1
- package/build/ts/browser/utils.d.ts +2 -2
- package/build/ts/browser/utils.d.ts.map +1 -1
- package/build/ts/browser/utils.js +3 -3
- package/build/ts/browser/utils.js.map +1 -1
- package/build/ts/deploy/index.d.ts +2 -2
- package/build/ts/deploy/index.d.ts.map +1 -1
- package/build/ts/deploy/index.js +3 -3
- package/build/ts/deploy/index.js.map +1 -1
- package/build/ts/deploy/maci.js +1 -1
- package/build/ts/deploy/maci.js.map +1 -1
- package/build/ts/deploy/poll.d.ts +1 -1
- package/build/ts/deploy/poll.d.ts.map +1 -1
- package/build/ts/deploy/poll.js +13 -9
- package/build/ts/deploy/poll.js.map +1 -1
- package/build/ts/deploy/types.d.ts +19 -10
- package/build/ts/deploy/types.d.ts.map +1 -1
- package/build/ts/deploy/utils.js +1 -1
- package/build/ts/deploy/utils.js.map +1 -1
- 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 +3 -2
- package/build/ts/index.d.ts.map +1 -1
- package/build/ts/index.js +16 -9
- package/build/ts/index.js.map +1 -1
- package/build/ts/maci/state.d.ts +1 -1
- package/build/ts/maci/state.js +8 -8
- package/build/ts/maci/state.js.map +1 -1
- package/build/ts/maci/types.d.ts +1 -1
- package/build/ts/maciKeys/__tests__/keypair.test.js +7 -7
- package/build/ts/maciKeys/__tests__/keypair.test.js.map +1 -1
- package/build/ts/maciKeys/__tests__/publicKeys.test.js +7 -7
- package/build/ts/maciKeys/__tests__/publicKeys.test.js.map +1 -1
- package/build/ts/maciKeys/keypair.d.ts.map +1 -1
- package/build/ts/maciKeys/keypair.js +4 -3
- package/build/ts/maciKeys/keypair.js.map +1 -1
- package/build/ts/maciKeys/publicKeys.d.ts +2 -2
- package/build/ts/maciKeys/publicKeys.d.ts.map +1 -1
- package/build/ts/maciKeys/publicKeys.js +6 -6
- package/build/ts/maciKeys/publicKeys.js.map +1 -1
- package/build/ts/maciKeys/types.d.ts +5 -0
- package/build/ts/maciKeys/types.d.ts.map +1 -1
- package/build/ts/poll/poll.d.ts.map +1 -1
- package/build/ts/poll/poll.js +9 -9
- package/build/ts/poll/poll.js.map +1 -1
- package/build/ts/poll/types.d.ts +6 -6
- package/build/ts/poll/types.d.ts.map +1 -1
- package/build/ts/proof/__tests__/download.test.js +8 -5
- package/build/ts/proof/__tests__/download.test.js.map +1 -1
- package/build/ts/proof/download.d.ts +3 -3
- package/build/ts/proof/download.d.ts.map +1 -1
- package/build/ts/proof/download.js +5 -7
- package/build/ts/proof/download.js.map +1 -1
- package/build/ts/proof/generate.d.ts +2 -2
- package/build/ts/proof/generate.d.ts.map +1 -1
- package/build/ts/proof/generate.js +29 -23
- package/build/ts/proof/generate.js.map +1 -1
- package/build/ts/proof/prove.js +13 -13
- package/build/ts/proof/prove.js.map +1 -1
- package/build/ts/proof/types.d.ts +40 -14
- package/build/ts/proof/types.d.ts.map +1 -1
- 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.js +1 -1
- package/build/ts/relayer/__tests__/messages.test.js.map +1 -1
- package/build/ts/relayer/__tests__/utils.test.js +3 -3
- package/build/ts/relayer/__tests__/utils.test.js.map +1 -1
- package/build/ts/relayer/messages.js +1 -1
- package/build/ts/relayer/utils.js +1 -1
- package/build/ts/relayer/utils.js.map +1 -1
- 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.map +1 -1
- package/build/ts/tally/commitments.js +8 -7
- package/build/ts/tally/commitments.js.map +1 -1
- package/build/ts/tally/index.d.ts +2 -1
- package/build/ts/tally/index.d.ts.map +1 -1
- package/build/ts/tally/index.js +5 -1
- package/build/ts/tally/index.js.map +1 -1
- 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 +55 -15
- package/build/ts/tally/types.d.ts.map +1 -1
- package/build/ts/tally/utils.d.ts +3 -3
- package/build/ts/tally/utils.d.ts.map +1 -1
- package/build/ts/tally/utils.js +10 -10
- package/build/ts/tally/utils.js.map +1 -1
- package/build/ts/tally/verification.d.ts +1 -1
- package/build/ts/tally/verification.d.ts.map +1 -1
- package/build/ts/tally/verification.js +10 -10
- package/build/ts/tally/verification.js.map +1 -1
- package/build/ts/trees/index.d.ts +2 -2
- package/build/ts/trees/index.d.ts.map +1 -1
- package/build/ts/trees/index.js +3 -1
- package/build/ts/trees/index.js.map +1 -1
- package/build/ts/trees/stateTree.d.ts +23 -1
- package/build/ts/trees/stateTree.d.ts.map +1 -1
- package/build/ts/trees/stateTree.js +74 -13
- package/build/ts/trees/stateTree.js.map +1 -1
- package/build/ts/trees/types.d.ts +11 -2
- package/build/ts/trees/types.d.ts.map +1 -1
- package/build/ts/user/index.d.ts +2 -2
- package/build/ts/user/index.d.ts.map +1 -1
- package/build/ts/user/index.js +5 -1
- package/build/ts/user/index.js.map +1 -1
- package/build/ts/user/joinPoll.d.ts +1 -1
- package/build/ts/user/joinPoll.d.ts.map +1 -1
- package/build/ts/user/joinPoll.js +11 -11
- package/build/ts/user/joinPoll.js.map +1 -1
- package/build/ts/user/signup.d.ts +3 -3
- package/build/ts/user/signup.d.ts.map +1 -1
- package/build/ts/user/signup.js +26 -21
- package/build/ts/user/signup.js.map +1 -1
- package/build/ts/user/types.d.ts +63 -19
- package/build/ts/user/types.d.ts.map +1 -1
- package/build/ts/user/utils.d.ts +34 -14
- package/build/ts/user/utils.d.ts.map +1 -1
- package/build/ts/user/utils.js +91 -57
- package/build/ts/user/utils.js.map +1 -1
- package/build/ts/utils/index.d.ts +1 -1
- package/build/ts/utils/index.d.ts.map +1 -1
- package/build/ts/utils/index.js +2 -1
- package/build/ts/utils/index.js.map +1 -1
- package/build/ts/utils/params.d.ts +1 -1
- package/build/ts/utils/params.d.ts.map +1 -1
- package/build/ts/utils/params.js +3 -3
- package/build/ts/utils/params.js.map +1 -1
- package/build/ts/utils/proofs.d.ts +2 -2
- package/build/ts/utils/proofs.d.ts.map +1 -1
- package/build/ts/utils/proofs.js +4 -4
- package/build/ts/utils/proofs.js.map +1 -1
- package/build/ts/utils/types.d.ts +2 -2
- package/build/ts/utils/types.d.ts.map +1 -1
- package/build/ts/utils/utils.d.ts +5 -0
- package/build/ts/utils/utils.d.ts.map +1 -1
- package/build/ts/utils/utils.js +13 -1
- package/build/ts/utils/utils.js.map +1 -1
- package/build/ts/verifyingKeys/checkVerifyingKeys.d.ts +1 -1
- package/build/ts/verifyingKeys/checkVerifyingKeys.d.ts.map +1 -1
- package/build/ts/verifyingKeys/checkVerifyingKeys.js +18 -19
- package/build/ts/verifyingKeys/checkVerifyingKeys.js.map +1 -1
- package/build/ts/verifyingKeys/index.d.ts +2 -2
- package/build/ts/verifyingKeys/index.d.ts.map +1 -1
- package/build/ts/verifyingKeys/index.js +5 -5
- package/build/ts/verifyingKeys/index.js.map +1 -1
- package/build/ts/verifyingKeys/setVerifyingKeys.d.ts +1 -1
- package/build/ts/verifyingKeys/setVerifyingKeys.d.ts.map +1 -1
- package/build/ts/verifyingKeys/setVerifyingKeys.js +75 -41
- package/build/ts/verifyingKeys/setVerifyingKeys.js.map +1 -1
- package/build/ts/verifyingKeys/types.d.ts +56 -48
- package/build/ts/verifyingKeys/types.d.ts.map +1 -1
- package/build/ts/verifyingKeys/utils.d.ts +10 -10
- package/build/ts/verifyingKeys/utils.d.ts.map +1 -1
- package/build/ts/verifyingKeys/utils.js +75 -60
- package/build/ts/verifyingKeys/utils.js.map +1 -1
- package/build/ts/vote/generate.d.ts +1 -1
- package/build/ts/vote/generate.d.ts.map +1 -1
- package/build/ts/vote/generate.js +4 -4
- package/build/ts/vote/generate.js.map +1 -1
- package/build/ts/vote/index.d.ts +2 -1
- package/build/ts/vote/index.d.ts.map +1 -1
- package/build/ts/vote/index.js +4 -2
- package/build/ts/vote/index.js.map +1 -1
- package/build/ts/vote/invalidate.js +4 -4
- package/build/ts/vote/invalidate.js.map +1 -1
- package/build/ts/vote/publish.d.ts +1 -1
- package/build/ts/vote/publish.d.ts.map +1 -1
- package/build/ts/vote/publish.js +19 -19
- package/build/ts/vote/publish.js.map +1 -1
- package/build/ts/vote/submit.js +2 -2
- package/build/ts/vote/submit.js.map +1 -1
- package/build/ts/vote/types.d.ts +6 -6
- package/build/ts/vote/types.d.ts.map +1 -1
- package/build/ts/vote/utils.d.ts +2 -2
- package/build/ts/vote/utils.d.ts.map +1 -1
- package/build/ts/vote/utils.js +5 -5
- package/build/ts/vote/utils.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +22 -14
- package/build/ts/deploy/vkRegistry.d.ts +0 -7
- package/build/ts/deploy/vkRegistry.d.ts.map +0 -1
- package/build/ts/deploy/vkRegistry.js +0 -14
- package/build/ts/deploy/vkRegistry.js.map +0 -1
- package/build/ts/proof/constants.d.ts +0 -17
- package/build/ts/proof/constants.d.ts.map +0 -1
- package/build/ts/proof/constants.js +0 -20
- package/build/ts/proof/constants.js.map +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { EMode } from "@maci-protocol/contracts";
|
|
2
|
-
import type {
|
|
2
|
+
import type { IVerifyingKeyContractParams, VerifyingKey } from "@maci-protocol/domainobjs";
|
|
3
3
|
import type { Signer } from "ethers";
|
|
4
4
|
/**
|
|
5
|
-
* Arguments for the
|
|
5
|
+
* Arguments for the getAllVerifyingKeys function
|
|
6
6
|
*/
|
|
7
|
-
export interface
|
|
7
|
+
export interface IGetAllVerifyingKeysArgs {
|
|
8
8
|
/**
|
|
9
|
-
* The address of the
|
|
9
|
+
* The address of the VerifyingKeysRegistry contract
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
verifyingKeysRegistryAddress: string;
|
|
12
12
|
/**
|
|
13
13
|
* The signer to use for the contract calls
|
|
14
14
|
*/
|
|
@@ -28,7 +28,7 @@ export interface IGetAllVksArgs {
|
|
|
28
28
|
/**
|
|
29
29
|
* The depth of the ballot tree
|
|
30
30
|
*/
|
|
31
|
-
|
|
31
|
+
tallyProcessingStateTreeDepth: number;
|
|
32
32
|
/**
|
|
33
33
|
* The mode to use for the contract calls
|
|
34
34
|
*/
|
|
@@ -37,28 +37,28 @@ export interface IGetAllVksArgs {
|
|
|
37
37
|
/**
|
|
38
38
|
* MACI's verifying keys
|
|
39
39
|
*/
|
|
40
|
-
export interface
|
|
40
|
+
export interface IMaciVerifyingKeysOnchain {
|
|
41
41
|
/**
|
|
42
42
|
* The verifying key for the poll joining circuit
|
|
43
43
|
*/
|
|
44
|
-
|
|
44
|
+
pollJoiningVerifyingKeyOnChain: IVerifyingKeyContractParams;
|
|
45
45
|
/**
|
|
46
46
|
* The verifying key for the poll joined circuit
|
|
47
47
|
*/
|
|
48
|
-
|
|
48
|
+
pollJoinedVerifyingKeyOnChain: IVerifyingKeyContractParams;
|
|
49
49
|
/**
|
|
50
50
|
* The verifying key for the process messages circuit
|
|
51
51
|
*/
|
|
52
|
-
|
|
52
|
+
processVerifyingKeyOnChain: IVerifyingKeyContractParams;
|
|
53
53
|
/**
|
|
54
54
|
* The verifying key for the tally votes circuit
|
|
55
55
|
*/
|
|
56
|
-
|
|
56
|
+
tallyVerifyingKeyOnChain: IVerifyingKeyContractParams;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
|
-
* Arguments for the
|
|
59
|
+
* Arguments for the extractAllVerifyingKeys function
|
|
60
60
|
*/
|
|
61
|
-
export interface
|
|
61
|
+
export interface IExtractAllVerifyingKeysArgs {
|
|
62
62
|
/**
|
|
63
63
|
* The path to the poll joining zkey
|
|
64
64
|
*/
|
|
@@ -70,61 +70,65 @@ export interface IExtractAllVksArgs {
|
|
|
70
70
|
/**
|
|
71
71
|
* The path to the process messages zkey
|
|
72
72
|
*/
|
|
73
|
-
|
|
73
|
+
messageProcessorZkeyPath?: string;
|
|
74
74
|
/**
|
|
75
75
|
* The path to the tally votes zkey
|
|
76
76
|
*/
|
|
77
|
-
|
|
77
|
+
voteTallyZkeyPath?: string;
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
80
|
* Maci verifying keys
|
|
81
81
|
*/
|
|
82
|
-
export interface
|
|
82
|
+
export interface IMaciVerifyingKeys {
|
|
83
83
|
/**
|
|
84
84
|
* The poll joining verifying key
|
|
85
85
|
*/
|
|
86
|
-
|
|
86
|
+
pollJoiningVerifyingKey?: VerifyingKey;
|
|
87
87
|
/**
|
|
88
88
|
* The poll joined verifying key
|
|
89
89
|
*/
|
|
90
|
-
|
|
90
|
+
pollJoinedVerifyingKey?: VerifyingKey;
|
|
91
91
|
/**
|
|
92
92
|
* The message processing verifying key
|
|
93
93
|
*/
|
|
94
|
-
|
|
94
|
+
processVerifyingKey?: VerifyingKey;
|
|
95
95
|
/**
|
|
96
96
|
* The tally verifying key
|
|
97
97
|
*/
|
|
98
|
-
|
|
98
|
+
tallyVerifyingKey?: VerifyingKey;
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
101
101
|
* The arguments for the setVerifyingKeys function
|
|
102
102
|
*/
|
|
103
103
|
export interface ISetVerifyingKeysArgs {
|
|
104
104
|
/**
|
|
105
|
-
* The polll joining
|
|
105
|
+
* The polll joining verifying key object
|
|
106
106
|
*/
|
|
107
|
-
|
|
107
|
+
pollJoiningVerifyingKey: VerifyingKey;
|
|
108
108
|
/**
|
|
109
|
-
* The poll joined
|
|
109
|
+
* The poll joined verifying key object
|
|
110
110
|
*/
|
|
111
|
-
|
|
111
|
+
pollJoinedVerifyingKey: VerifyingKey;
|
|
112
112
|
/**
|
|
113
|
-
* The process messages
|
|
113
|
+
* The process messages verifying keys array
|
|
114
114
|
*/
|
|
115
|
-
|
|
115
|
+
processMessagesVerifyingKeys: VerifyingKey[];
|
|
116
116
|
/**
|
|
117
|
-
* The tally votes
|
|
117
|
+
* The tally votes verifying keys array
|
|
118
118
|
*/
|
|
119
|
-
|
|
119
|
+
tallyVotesVerifyingKeys: VerifyingKey[];
|
|
120
120
|
/**
|
|
121
121
|
* The state tree depth
|
|
122
122
|
*/
|
|
123
123
|
stateTreeDepth: number;
|
|
124
|
+
/**
|
|
125
|
+
* The poll state tree depth
|
|
126
|
+
*/
|
|
127
|
+
pollStateTreeDepth: number;
|
|
124
128
|
/**
|
|
125
129
|
* The intermediate state tree depth (ballot tree)
|
|
126
130
|
*/
|
|
127
|
-
|
|
131
|
+
tallyProcessingStateTreeDepth: number;
|
|
128
132
|
/**
|
|
129
133
|
* The vote option tree depth
|
|
130
134
|
*/
|
|
@@ -134,17 +138,17 @@ export interface ISetVerifyingKeysArgs {
|
|
|
134
138
|
*/
|
|
135
139
|
messageBatchSize: number;
|
|
136
140
|
/**
|
|
137
|
-
* The
|
|
141
|
+
* The VerifyingKeysRegistry contract address
|
|
138
142
|
*/
|
|
139
|
-
|
|
143
|
+
verifyingKeysRegistryAddress: string;
|
|
140
144
|
/**
|
|
141
145
|
* The signer
|
|
142
146
|
*/
|
|
143
147
|
signer: Signer;
|
|
144
148
|
/**
|
|
145
|
-
* QV or
|
|
149
|
+
* QV, NON_QV or FULL
|
|
146
150
|
*/
|
|
147
|
-
|
|
151
|
+
modes: EMode[];
|
|
148
152
|
}
|
|
149
153
|
/**
|
|
150
154
|
* Interface for the arguments to the checkVerifyingKeys command
|
|
@@ -157,7 +161,7 @@ export interface ICheckVerifyingKeysArgs {
|
|
|
157
161
|
/**
|
|
158
162
|
* The depth of the state subtree
|
|
159
163
|
*/
|
|
160
|
-
|
|
164
|
+
tallyProcessingStateTreeDepth: number;
|
|
161
165
|
/**
|
|
162
166
|
* The depth of the vote option tree
|
|
163
167
|
*/
|
|
@@ -177,28 +181,28 @@ export interface ICheckVerifyingKeysArgs {
|
|
|
177
181
|
/**
|
|
178
182
|
* The path to the process messages zkey
|
|
179
183
|
*/
|
|
180
|
-
|
|
184
|
+
messageProcessorZkeyPath: string;
|
|
181
185
|
/**
|
|
182
186
|
* The path to the tally votes zkey
|
|
183
187
|
*/
|
|
184
|
-
|
|
188
|
+
voteTallyZkeyPath: string;
|
|
185
189
|
/**
|
|
186
190
|
* A signer object
|
|
187
191
|
*/
|
|
188
192
|
signer: Signer;
|
|
189
193
|
/**
|
|
190
|
-
* The address of the
|
|
194
|
+
* The address of the VerifyingKeysRegistry contract
|
|
191
195
|
*/
|
|
192
|
-
|
|
196
|
+
verifyingKeysRegistry: string;
|
|
193
197
|
/**
|
|
194
|
-
*
|
|
198
|
+
* Voting mode
|
|
195
199
|
*/
|
|
196
|
-
|
|
200
|
+
mode?: EMode;
|
|
197
201
|
}
|
|
198
202
|
/**
|
|
199
|
-
* Interface for the arguments to the
|
|
203
|
+
* Interface for the arguments to the extractVerifyingKeyToFile command
|
|
200
204
|
*/
|
|
201
|
-
export interface
|
|
205
|
+
export interface IExtractVerifyingKeyToFileArgs {
|
|
202
206
|
/**
|
|
203
207
|
* File path for poll joining zkey
|
|
204
208
|
*/
|
|
@@ -210,21 +214,25 @@ export interface IExtractVkToFileArgs {
|
|
|
210
214
|
/**
|
|
211
215
|
* File path for processMessagesQv zkey
|
|
212
216
|
*/
|
|
213
|
-
|
|
217
|
+
messageProcessorZkeyPathQv: string;
|
|
214
218
|
/**
|
|
215
219
|
* File path for tallyVotesQv zkey
|
|
216
220
|
*/
|
|
217
|
-
|
|
221
|
+
voteTallyZkeyPathQv: string;
|
|
218
222
|
/**
|
|
219
223
|
* File path for processMessagesNonQv zkey
|
|
220
224
|
*/
|
|
221
|
-
|
|
225
|
+
messageProcessorZkeyPathNonQv: string;
|
|
226
|
+
/**
|
|
227
|
+
* File path for MessageProcessor zkey
|
|
228
|
+
*/
|
|
229
|
+
messageProcessorZkeyPathFull: string;
|
|
222
230
|
/**
|
|
223
|
-
* File path for
|
|
231
|
+
* File path for VoteTally zkey
|
|
224
232
|
*/
|
|
225
|
-
|
|
233
|
+
voteTallyZkeyPathNonQv: string;
|
|
226
234
|
/**
|
|
227
|
-
* Output file path of extracted
|
|
235
|
+
* Output file path of extracted verifying keys
|
|
228
236
|
*/
|
|
229
237
|
outputFilePath: string;
|
|
230
238
|
}
|
|
@@ -1 +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,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../ts/verifyingKeys/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA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AAC;IAE5B;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,0BAA0B,EAAE,MAAM,CAAC;IAEnC;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,6BAA6B,EAAE,MAAM,CAAC;IAEtC;;OAEG;IACH,4BAA4B,EAAE,MAAM,CAAC;IAErC;;OAEG;IACH,sBAAsB,EAAE,MAAM,CAAC;IAE/B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;CACxB"}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import type {
|
|
1
|
+
import { type IVerifyingKeyContractParams, VerifyingKey } from "@maci-protocol/domainobjs";
|
|
2
|
+
import type { IGetAllVerifyingKeysArgs, IExtractAllVerifyingKeysArgs, IMaciVerifyingKeys, IMaciVerifyingKeysOnchain, IExtractVerifyingKeyToFileArgs } from "./types";
|
|
3
3
|
/**
|
|
4
4
|
* Get all the verifying keys from the contract
|
|
5
|
-
* @param args - The arguments for the
|
|
5
|
+
* @param args - The arguments for the getAllVerifyingKeys function
|
|
6
6
|
* @returns The verifying keys
|
|
7
7
|
*/
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const getAllOnChainVerifyingKeys: ({ verifyingKeysRegistryAddress, signer, stateTreeDepth, voteOptionTreeDepth, messageBatchSize, tallyProcessingStateTreeDepth, mode, }: IGetAllVerifyingKeysArgs) => Promise<IMaciVerifyingKeysOnchain>;
|
|
9
9
|
/**
|
|
10
10
|
* Compare two verifying keys
|
|
11
|
-
* @param
|
|
12
|
-
* @param
|
|
11
|
+
* @param verifyingKeyOnChain - the verifying key on chain
|
|
12
|
+
* @param verifyingKey - the local verifying key
|
|
13
13
|
* @returns whether they are equal or not
|
|
14
14
|
*/
|
|
15
|
-
export declare const
|
|
15
|
+
export declare const compareVerifyingKeys: (verifyingKeyOnChain: VerifyingKey | IVerifyingKeyContractParams, verifyingKey?: VerifyingKey | IVerifyingKeyContractParams) => boolean;
|
|
16
16
|
/**
|
|
17
17
|
* Extract all the verifying keys
|
|
18
|
-
* @param args - The arguments for the
|
|
18
|
+
* @param args - The arguments for the extractAllVerifyingKeys function
|
|
19
19
|
* @returns The verifying keys
|
|
20
20
|
*/
|
|
21
|
-
export declare const
|
|
21
|
+
export declare const extractAllVerifyingKeys: ({ pollJoiningZkeyPath, pollJoinedZkeyPath, messageProcessorZkeyPath, voteTallyZkeyPath, }: IExtractAllVerifyingKeysArgs) => Promise<IMaciVerifyingKeys>;
|
|
22
22
|
/**
|
|
23
23
|
* Command to confirm that the verifying keys in the contract match the local ones
|
|
24
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
25
|
* @param args The arguments for the checkVerifyingKeys command
|
|
26
26
|
* @returns Whether the verifying keys match or not
|
|
27
27
|
*/
|
|
28
|
-
export declare const
|
|
28
|
+
export declare const extractVerifyingKeyToFile: ({ messageProcessorZkeyPathQv, voteTallyZkeyPathQv, messageProcessorZkeyPathNonQv, messageProcessorZkeyPathFull, pollJoinedZkeyPath, pollJoiningZkeyPath, voteTallyZkeyPathNonQv, outputFilePath, }: IExtractVerifyingKeyToFileArgs) => Promise<void>;
|
|
29
29
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../ts/verifyingKeys/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../ts/verifyingKeys/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,2BAA2B,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAI3F,OAAO,KAAK,EACV,wBAAwB,EACxB,4BAA4B,EAC5B,kBAAkB,EAClB,yBAAyB,EACzB,8BAA8B,EAC/B,MAAM,SAAS,CAAC;AAEjB;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,GAAU,uIAQ9C,wBAAwB,KAAG,OAAO,CAAC,yBAAyB,CAqB9D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAC/B,qBAAqB,YAAY,GAAG,2BAA2B,EAC/D,eAAe,YAAY,GAAG,2BAA2B,KACxD,OA2BF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,GAAU,2FAK3C,4BAA4B,KAAG,OAAO,CAAC,kBAAkB,CAsB3D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,GAAU,oMAS7C,8BAA8B,KAAG,OAAO,CAAC,IAAI,CA+B/C,CAAC"}
|
|
@@ -3,101 +3,116 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.extractVerifyingKeyToFile = exports.extractAllVerifyingKeys = exports.compareVerifyingKeys = exports.getAllOnChainVerifyingKeys = void 0;
|
|
7
7
|
const contracts_1 = require("@maci-protocol/contracts");
|
|
8
8
|
const typechain_types_1 = require("@maci-protocol/contracts/typechain-types");
|
|
9
9
|
const domainobjs_1 = require("@maci-protocol/domainobjs");
|
|
10
10
|
const fs_1 = __importDefault(require("fs"));
|
|
11
11
|
/**
|
|
12
12
|
* Get all the verifying keys from the contract
|
|
13
|
-
* @param args - The arguments for the
|
|
13
|
+
* @param args - The arguments for the getAllVerifyingKeys function
|
|
14
14
|
* @returns The verifying keys
|
|
15
15
|
*/
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const [
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
const getAllOnChainVerifyingKeys = async ({ verifyingKeysRegistryAddress, signer, stateTreeDepth, voteOptionTreeDepth, messageBatchSize, tallyProcessingStateTreeDepth, mode, }) => {
|
|
17
|
+
const contract = typechain_types_1.VerifyingKeysRegistry__factory.connect(verifyingKeysRegistryAddress, signer);
|
|
18
|
+
const [pollJoiningVerifyingKeyOnChain, pollJoinedVerifyingKeyOnChain, processVerifyingKeyOnChain, tallyVerifyingKeyOnChain,] = await Promise.all([
|
|
19
|
+
contract.getPollJoiningVerifyingKey(stateTreeDepth),
|
|
20
|
+
contract.getPollJoinedVerifyingKey(stateTreeDepth),
|
|
21
|
+
contract.getProcessVerifyingKey(stateTreeDepth, voteOptionTreeDepth, messageBatchSize, mode),
|
|
22
|
+
contract.getTallyVerifyingKey(stateTreeDepth, tallyProcessingStateTreeDepth, voteOptionTreeDepth, mode),
|
|
23
23
|
]);
|
|
24
24
|
return {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
pollJoiningVerifyingKeyOnChain,
|
|
26
|
+
pollJoinedVerifyingKeyOnChain,
|
|
27
|
+
processVerifyingKeyOnChain,
|
|
28
|
+
tallyVerifyingKeyOnChain,
|
|
29
29
|
};
|
|
30
30
|
};
|
|
31
|
-
exports.
|
|
31
|
+
exports.getAllOnChainVerifyingKeys = getAllOnChainVerifyingKeys;
|
|
32
32
|
/**
|
|
33
33
|
* Compare two verifying keys
|
|
34
|
-
* @param
|
|
35
|
-
* @param
|
|
34
|
+
* @param verifyingKeyOnChain - the verifying key on chain
|
|
35
|
+
* @param verifyingKey - the local verifying key
|
|
36
36
|
* @returns whether they are equal or not
|
|
37
37
|
*/
|
|
38
|
-
const
|
|
39
|
-
if (!
|
|
38
|
+
const compareVerifyingKeys = (verifyingKeyOnChain, verifyingKey) => {
|
|
39
|
+
if (!verifyingKey) {
|
|
40
40
|
throw new Error("Verifying key is not provided");
|
|
41
41
|
}
|
|
42
|
-
let isEqual =
|
|
43
|
-
for (let i = 0; i <
|
|
44
|
-
isEqual = isEqual &&
|
|
45
|
-
isEqual = isEqual &&
|
|
42
|
+
let isEqual = verifyingKey.ic.length === verifyingKeyOnChain.ic.length;
|
|
43
|
+
for (let i = 0; i < verifyingKey.ic.length; i += 1) {
|
|
44
|
+
isEqual = isEqual && verifyingKey.ic[i].x.toString() === verifyingKeyOnChain.ic[i].x.toString();
|
|
45
|
+
isEqual = isEqual && verifyingKey.ic[i].y.toString() === verifyingKeyOnChain.ic[i].y.toString();
|
|
46
46
|
}
|
|
47
|
-
isEqual = isEqual &&
|
|
48
|
-
isEqual = isEqual &&
|
|
49
|
-
isEqual = isEqual &&
|
|
50
|
-
isEqual = isEqual &&
|
|
51
|
-
isEqual = isEqual &&
|
|
52
|
-
isEqual = isEqual &&
|
|
53
|
-
isEqual = isEqual &&
|
|
54
|
-
isEqual = isEqual &&
|
|
55
|
-
isEqual = isEqual &&
|
|
56
|
-
isEqual = isEqual &&
|
|
57
|
-
isEqual = isEqual &&
|
|
58
|
-
isEqual = isEqual &&
|
|
59
|
-
isEqual = isEqual &&
|
|
60
|
-
isEqual = isEqual &&
|
|
47
|
+
isEqual = isEqual && verifyingKey.alpha1.x.toString() === verifyingKeyOnChain.alpha1.x.toString();
|
|
48
|
+
isEqual = isEqual && verifyingKey.alpha1.y.toString() === verifyingKeyOnChain.alpha1.y.toString();
|
|
49
|
+
isEqual = isEqual && verifyingKey.beta2.x[0].toString() === verifyingKeyOnChain.beta2.x[0].toString();
|
|
50
|
+
isEqual = isEqual && verifyingKey.beta2.x[1].toString() === verifyingKeyOnChain.beta2.x[1].toString();
|
|
51
|
+
isEqual = isEqual && verifyingKey.beta2.y[0].toString() === verifyingKeyOnChain.beta2.y[0].toString();
|
|
52
|
+
isEqual = isEqual && verifyingKey.beta2.y[1].toString() === verifyingKeyOnChain.beta2.y[1].toString();
|
|
53
|
+
isEqual = isEqual && verifyingKey.delta2.x[0].toString() === verifyingKeyOnChain.delta2.x[0].toString();
|
|
54
|
+
isEqual = isEqual && verifyingKey.delta2.x[1].toString() === verifyingKeyOnChain.delta2.x[1].toString();
|
|
55
|
+
isEqual = isEqual && verifyingKey.delta2.y[0].toString() === verifyingKeyOnChain.delta2.y[0].toString();
|
|
56
|
+
isEqual = isEqual && verifyingKey.delta2.y[1].toString() === verifyingKeyOnChain.delta2.y[1].toString();
|
|
57
|
+
isEqual = isEqual && verifyingKey.gamma2.x[0].toString() === verifyingKeyOnChain.gamma2.x[0].toString();
|
|
58
|
+
isEqual = isEqual && verifyingKey.gamma2.x[1].toString() === verifyingKeyOnChain.gamma2.x[1].toString();
|
|
59
|
+
isEqual = isEqual && verifyingKey.gamma2.y[0].toString() === verifyingKeyOnChain.gamma2.y[0].toString();
|
|
60
|
+
isEqual = isEqual && verifyingKey.gamma2.y[1].toString() === verifyingKeyOnChain.gamma2.y[1].toString();
|
|
61
61
|
return isEqual;
|
|
62
62
|
};
|
|
63
|
-
exports.
|
|
63
|
+
exports.compareVerifyingKeys = compareVerifyingKeys;
|
|
64
64
|
/**
|
|
65
65
|
* Extract all the verifying keys
|
|
66
|
-
* @param args - The arguments for the
|
|
66
|
+
* @param args - The arguments for the extractAllVerifyingKeys function
|
|
67
67
|
* @returns The verifying keys
|
|
68
68
|
*/
|
|
69
|
-
const
|
|
70
|
-
// extract the
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
const extractAllVerifyingKeys = async ({ pollJoiningZkeyPath, pollJoinedZkeyPath, messageProcessorZkeyPath, voteTallyZkeyPath, }) => {
|
|
70
|
+
// extract the verifying keys
|
|
71
|
+
const pollJoiningVerifyingKey = pollJoiningZkeyPath
|
|
72
|
+
? domainobjs_1.VerifyingKey.fromObj(await (0, contracts_1.extractVerifyingKey)(pollJoiningZkeyPath))
|
|
73
|
+
: undefined;
|
|
74
|
+
const pollJoinedVerifyingKey = pollJoinedZkeyPath
|
|
75
|
+
? domainobjs_1.VerifyingKey.fromObj(await (0, contracts_1.extractVerifyingKey)(pollJoinedZkeyPath))
|
|
76
|
+
: undefined;
|
|
77
|
+
const processVerifyingKey = messageProcessorZkeyPath
|
|
78
|
+
? domainobjs_1.VerifyingKey.fromObj(await (0, contracts_1.extractVerifyingKey)(messageProcessorZkeyPath))
|
|
79
|
+
: undefined;
|
|
80
|
+
const tallyVerifyingKey = voteTallyZkeyPath
|
|
81
|
+
? domainobjs_1.VerifyingKey.fromObj(await (0, contracts_1.extractVerifyingKey)(voteTallyZkeyPath))
|
|
75
82
|
: undefined;
|
|
76
|
-
const tallyVk = tallyVotesZkeyPath ? domainobjs_1.VerifyingKey.fromObj(await (0, contracts_1.extractVk)(tallyVotesZkeyPath)) : undefined;
|
|
77
83
|
return {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
84
|
+
pollJoiningVerifyingKey,
|
|
85
|
+
pollJoinedVerifyingKey,
|
|
86
|
+
processVerifyingKey,
|
|
87
|
+
tallyVerifyingKey,
|
|
82
88
|
};
|
|
83
89
|
};
|
|
84
|
-
exports.
|
|
90
|
+
exports.extractAllVerifyingKeys = extractAllVerifyingKeys;
|
|
85
91
|
/**
|
|
86
92
|
* Command to confirm that the verifying keys in the contract match the local ones
|
|
87
93
|
* @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
|
|
88
94
|
* @param args The arguments for the checkVerifyingKeys command
|
|
89
95
|
* @returns Whether the verifying keys match or not
|
|
90
96
|
*/
|
|
91
|
-
const
|
|
92
|
-
const [
|
|
93
|
-
(0, contracts_1.
|
|
94
|
-
(0, contracts_1.
|
|
95
|
-
(0, contracts_1.
|
|
96
|
-
(0, contracts_1.
|
|
97
|
-
(0, contracts_1.
|
|
98
|
-
(0, contracts_1.
|
|
97
|
+
const extractVerifyingKeyToFile = async ({ messageProcessorZkeyPathQv, voteTallyZkeyPathQv, messageProcessorZkeyPathNonQv, messageProcessorZkeyPathFull, pollJoinedZkeyPath, pollJoiningZkeyPath, voteTallyZkeyPathNonQv, outputFilePath, }) => {
|
|
98
|
+
const [processVerifyingKeyQv, tallyVerifyingKeyQv, processVerifyingKeyNonQv, tallyVerifyingKeyNonQv, pollJoiningVerifyingKey, pollJoinedVerifyingKey, processVerifyingKeyFull,] = await Promise.all([
|
|
99
|
+
(0, contracts_1.extractVerifyingKey)(messageProcessorZkeyPathQv),
|
|
100
|
+
(0, contracts_1.extractVerifyingKey)(voteTallyZkeyPathQv),
|
|
101
|
+
(0, contracts_1.extractVerifyingKey)(messageProcessorZkeyPathNonQv),
|
|
102
|
+
(0, contracts_1.extractVerifyingKey)(voteTallyZkeyPathNonQv),
|
|
103
|
+
(0, contracts_1.extractVerifyingKey)(pollJoiningZkeyPath),
|
|
104
|
+
(0, contracts_1.extractVerifyingKey)(pollJoinedZkeyPath),
|
|
105
|
+
(0, contracts_1.extractVerifyingKey)(messageProcessorZkeyPathFull),
|
|
99
106
|
]);
|
|
100
|
-
await fs_1.default.promises.writeFile(outputFilePath, JSON.stringify({
|
|
107
|
+
await fs_1.default.promises.writeFile(outputFilePath, JSON.stringify({
|
|
108
|
+
processVerifyingKeyQv,
|
|
109
|
+
tallyVerifyingKeyQv,
|
|
110
|
+
processVerifyingKeyNonQv,
|
|
111
|
+
tallyVerifyingKeyNonQv,
|
|
112
|
+
pollJoiningVerifyingKey,
|
|
113
|
+
pollJoinedVerifyingKey,
|
|
114
|
+
processVerifyingKeyFull,
|
|
115
|
+
}));
|
|
101
116
|
};
|
|
102
|
-
exports.
|
|
117
|
+
exports.extractVerifyingKeyToFile = extractVerifyingKeyToFile;
|
|
103
118
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../ts/verifyingKeys/utils.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../ts/verifyingKeys/utils.ts"],"names":[],"mappings":";;;;;;AAAA,wDAA+D;AAC/D,8EAA0H;AAC1H,0DAA2F;AAE3F,4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AAC,CAAC;AA3BW,QAAA,uBAAuB,2BA2BlC;AAEF;;;;;GAKG;AACI,MAAM,yBAAyB,GAAG,KAAK,EAAE,EAC9C,0BAA0B,EAC1B,mBAAmB,EACnB,6BAA6B,EAC7B,4BAA4B,EAC5B,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,cAAc,GACiB,EAAiB,EAAE;IAClD,MAAM,CACJ,qBAAqB,EACrB,mBAAmB,EACnB,wBAAwB,EACxB,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACxB,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACpB,IAAA,+BAAmB,EAAC,0BAA0B,CAAC;QAC/C,IAAA,+BAAmB,EAAC,mBAAmB,CAAC;QACxC,IAAA,+BAAmB,EAAC,6BAA6B,CAAC;QAClD,IAAA,+BAAmB,EAAC,sBAAsB,CAAC;QAC3C,IAAA,+BAAmB,EAAC,mBAAmB,CAAC;QACxC,IAAA,+BAAmB,EAAC,kBAAkB,CAAC;QACvC,IAAA,+BAAmB,EAAC,4BAA4B,CAAC;KAClD,CAAC,CAAC;IAEH,MAAM,YAAE,CAAC,QAAQ,CAAC,SAAS,CACzB,cAAc,EACd,IAAI,CAAC,SAAS,CAAC;QACb,qBAAqB;QACrB,mBAAmB;QACnB,wBAAwB;QACxB,sBAAsB;QACtB,uBAAuB;QACvB,sBAAsB;QACtB,uBAAuB;KACxB,CAAC,CACH,CAAC;AACJ,CAAC,CAAC;AAxCW,QAAA,yBAAyB,6BAwCpC"}
|
|
@@ -4,5 +4,5 @@ import type { IGenerateVoteArgs, IVote } from "./types";
|
|
|
4
4
|
* @param args - The arguments for the vote
|
|
5
5
|
* @returns The vote object
|
|
6
6
|
*/
|
|
7
|
-
export declare const generateVote: ({ pollId, voteOptionIndex, salt, nonce, privateKey, stateIndex, voteWeight,
|
|
7
|
+
export declare const generateVote: ({ pollId, voteOptionIndex, salt, nonce, privateKey, stateIndex, voteWeight, coordinatorPublicKey, maxVoteOption, ephemeralKeypair, newPublicKey, }: IGenerateVoteArgs) => IVote;
|
|
8
8
|
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -1 +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,
|
|
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,oJAY1B,iBAAiB,KAAG,KAsDtB,CAAC"}
|
|
@@ -9,7 +9,7 @@ const utils_1 = require("./utils");
|
|
|
9
9
|
* @param args - The arguments for the vote
|
|
10
10
|
* @returns The vote object
|
|
11
11
|
*/
|
|
12
|
-
const generateVote = ({ pollId, voteOptionIndex, salt, nonce, privateKey, stateIndex, voteWeight,
|
|
12
|
+
const generateVote = ({ pollId, voteOptionIndex, salt, nonce, privateKey, stateIndex, voteWeight, coordinatorPublicKey, maxVoteOption, ephemeralKeypair, newPublicKey, }) => {
|
|
13
13
|
const keypair = new domainobjs_1.Keypair(privateKey);
|
|
14
14
|
// validate args
|
|
15
15
|
if (voteOptionIndex < 0 || voteOptionIndex > maxVoteOption) {
|
|
@@ -25,18 +25,18 @@ const generateVote = ({ pollId, voteOptionIndex, salt, nonce, privateKey, stateI
|
|
|
25
25
|
if (salt && !(0, utils_1.validateSalt)(salt)) {
|
|
26
26
|
throw new Error("Invalid salt");
|
|
27
27
|
}
|
|
28
|
-
const userSalt = salt ? BigInt(salt) : (0, crypto_1.
|
|
28
|
+
const userSalt = salt ? BigInt(salt) : (0, crypto_1.generateRandomSalt)();
|
|
29
29
|
if (pollId < 0) {
|
|
30
30
|
throw new Error("Invalid poll id");
|
|
31
31
|
}
|
|
32
32
|
// if no ephemeral keypair is provided, generate a new one
|
|
33
33
|
const encKeypair = ephemeralKeypair ?? new domainobjs_1.Keypair();
|
|
34
34
|
// create the command object
|
|
35
|
-
const command = new domainobjs_1.
|
|
35
|
+
const command = new domainobjs_1.VoteCommand(stateIndex, newPublicKey ?? keypair.publicKey, voteOptionIndex, voteWeight, nonce, pollId, userSalt);
|
|
36
36
|
// sign the command with the poll private key
|
|
37
37
|
const signature = command.sign(privateKey);
|
|
38
38
|
// encrypt the command using a shared key between the user and the coordinator
|
|
39
|
-
const message = command.encrypt(signature, domainobjs_1.Keypair.
|
|
39
|
+
const message = command.encrypt(signature, domainobjs_1.Keypair.generateEcdhSharedKey(encKeypair.privateKey, coordinatorPublicKey));
|
|
40
40
|
return {
|
|
41
41
|
message,
|
|
42
42
|
ephemeralKeypair: encKeypair,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../ts/vote/generate.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../ts/vote/generate.ts"],"names":[],"mappings":";;;AAAA,kDAA2D;AAC3D,0DAAiE;AAIjE,mCAAuC;AAEvC;;;;GAIG;AACI,MAAM,YAAY,GAAG,CAAC,EAC3B,MAAM,EACN,eAAe,EACf,IAAI,EACJ,KAAK,EACL,UAAU,EACV,UAAU,EACV,UAAU,EACV,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,YAAY,GACM,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,CAAC;IAC/C,CAAC;IAED,mDAA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IGenerateVoteArgs, IPublishArgs, IPublishBatchArgs, IPublishBatchData, IPublishData, IPublishMessage, ISubmitVoteArgs, ISubmitVoteBatchArgs, } from "./types";
|
|
2
2
|
export { generateVote } from "./generate";
|
|
3
|
+
export { invalidateVotes } from "./invalidate";
|
|
3
4
|
export { publish, publishBatch } from "./publish";
|
|
4
5
|
export { submitVote, submitVoteBatch } from "./submit";
|
|
5
|
-
export {
|
|
6
|
+
export { getCoordinatorPublicKey, validateSalt } from "./utils";
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +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,
|
|
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,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC"}
|
package/build/ts/vote/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateSalt = exports.
|
|
3
|
+
exports.validateSalt = exports.getCoordinatorPublicKey = exports.submitVoteBatch = exports.submitVote = exports.publishBatch = exports.publish = exports.invalidateVotes = exports.generateVote = void 0;
|
|
4
4
|
var generate_1 = require("./generate");
|
|
5
5
|
Object.defineProperty(exports, "generateVote", { enumerable: true, get: function () { return generate_1.generateVote; } });
|
|
6
|
+
var invalidate_1 = require("./invalidate");
|
|
7
|
+
Object.defineProperty(exports, "invalidateVotes", { enumerable: true, get: function () { return invalidate_1.invalidateVotes; } });
|
|
6
8
|
var publish_1 = require("./publish");
|
|
7
9
|
Object.defineProperty(exports, "publish", { enumerable: true, get: function () { return publish_1.publish; } });
|
|
8
10
|
Object.defineProperty(exports, "publishBatch", { enumerable: true, get: function () { return publish_1.publishBatch; } });
|
|
@@ -10,6 +12,6 @@ var submit_1 = require("./submit");
|
|
|
10
12
|
Object.defineProperty(exports, "submitVote", { enumerable: true, get: function () { return submit_1.submitVote; } });
|
|
11
13
|
Object.defineProperty(exports, "submitVoteBatch", { enumerable: true, get: function () { return submit_1.submitVoteBatch; } });
|
|
12
14
|
var utils_1 = require("./utils");
|
|
13
|
-
Object.defineProperty(exports, "
|
|
15
|
+
Object.defineProperty(exports, "getCoordinatorPublicKey", { enumerable: true, get: function () { return utils_1.getCoordinatorPublicKey; } });
|
|
14
16
|
Object.defineProperty(exports, "validateSalt", { enumerable: true, get: function () { return utils_1.validateSalt; } });
|
|
15
17
|
//# sourceMappingURL=index.js.map
|