@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.
Files changed (326) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/LICENSE +21 -0
  3. package/README.md +12 -0
  4. package/build/package.json +65 -0
  5. package/build/ts/browser/index.d.ts +15 -0
  6. package/build/ts/browser/index.d.ts.map +1 -0
  7. package/build/ts/browser/index.js +40 -0
  8. package/build/ts/browser/index.js.map +1 -0
  9. package/build/ts/browser/joinPoll.d.ts +10 -0
  10. package/build/ts/browser/joinPoll.d.ts.map +1 -0
  11. package/build/ts/browser/joinPoll.js +88 -0
  12. package/build/ts/browser/joinPoll.js.map +1 -0
  13. package/build/ts/browser/utils.d.ts +18 -0
  14. package/build/ts/browser/utils.d.ts.map +1 -0
  15. package/build/ts/browser/utils.js +37 -0
  16. package/build/ts/browser/utils.js.map +1 -0
  17. package/build/ts/deploy/index.d.ts +6 -0
  18. package/build/ts/deploy/index.d.ts.map +1 -0
  19. package/build/ts/deploy/index.js +12 -0
  20. package/build/ts/deploy/index.js.map +1 -0
  21. package/build/ts/deploy/maci.d.ts +8 -0
  22. package/build/ts/deploy/maci.d.ts.map +1 -0
  23. package/build/ts/deploy/maci.js +97 -0
  24. package/build/ts/deploy/maci.js.map +1 -0
  25. package/build/ts/deploy/poll.d.ts +8 -0
  26. package/build/ts/deploy/poll.d.ts.map +1 -0
  27. package/build/ts/deploy/poll.js +112 -0
  28. package/build/ts/deploy/poll.js.map +1 -0
  29. package/build/ts/deploy/types.d.ts +225 -0
  30. package/build/ts/deploy/types.d.ts.map +1 -0
  31. package/build/ts/deploy/types.js +3 -0
  32. package/build/ts/deploy/types.js.map +1 -0
  33. package/build/ts/deploy/utils.d.ts +11 -0
  34. package/build/ts/deploy/utils.d.ts.map +1 -0
  35. package/build/ts/deploy/utils.js +22 -0
  36. package/build/ts/deploy/utils.js.map +1 -0
  37. package/build/ts/deploy/verifyingKeysRegistry.d.ts +7 -0
  38. package/build/ts/deploy/verifyingKeysRegistry.d.ts.map +1 -0
  39. package/build/ts/deploy/verifyingKeysRegistry.js +14 -0
  40. package/build/ts/deploy/verifyingKeysRegistry.js.map +1 -0
  41. package/build/ts/index.d.ts +17 -0
  42. package/build/ts/index.d.ts.map +1 -0
  43. package/build/ts/index.js +89 -0
  44. package/build/ts/index.js.map +1 -0
  45. package/build/ts/maci/index.d.ts +6 -0
  46. package/build/ts/maci/index.d.ts.map +1 -0
  47. package/build/ts/maci/index.js +17 -0
  48. package/build/ts/maci/index.js.map +1 -0
  49. package/build/ts/maci/merge.d.ts +9 -0
  50. package/build/ts/maci/merge.d.ts.map +1 -0
  51. package/build/ts/maci/merge.js +29 -0
  52. package/build/ts/maci/merge.js.map +1 -0
  53. package/build/ts/maci/policy.d.ts +53 -0
  54. package/build/ts/maci/policy.d.ts.map +1 -0
  55. package/build/ts/maci/policy.js +166 -0
  56. package/build/ts/maci/policy.js.map +1 -0
  57. package/build/ts/maci/state.d.ts +8 -0
  58. package/build/ts/maci/state.d.ts.map +1 -0
  59. package/build/ts/maci/state.js +82 -0
  60. package/build/ts/maci/state.js.map +1 -0
  61. package/build/ts/maci/types.d.ts +208 -0
  62. package/build/ts/maci/types.d.ts.map +1 -0
  63. package/build/ts/maci/types.js +20 -0
  64. package/build/ts/maci/types.js.map +1 -0
  65. package/build/ts/maciKeys/__tests__/keypair.test.d.ts +2 -0
  66. package/build/ts/maciKeys/__tests__/keypair.test.d.ts.map +1 -0
  67. package/build/ts/maciKeys/__tests__/keypair.test.js +24 -0
  68. package/build/ts/maciKeys/__tests__/keypair.test.js.map +1 -0
  69. package/build/ts/maciKeys/__tests__/publicKeys.test.d.ts +2 -0
  70. package/build/ts/maciKeys/__tests__/publicKeys.test.d.ts.map +1 -0
  71. package/build/ts/maciKeys/__tests__/publicKeys.test.js +22 -0
  72. package/build/ts/maciKeys/__tests__/publicKeys.test.js.map +1 -0
  73. package/build/ts/maciKeys/index.d.ts +4 -0
  74. package/build/ts/maciKeys/index.d.ts.map +1 -0
  75. package/build/ts/maciKeys/index.js +8 -0
  76. package/build/ts/maciKeys/index.js.map +1 -0
  77. package/build/ts/maciKeys/keypair.d.ts +9 -0
  78. package/build/ts/maciKeys/keypair.d.ts.map +1 -0
  79. package/build/ts/maciKeys/keypair.js +21 -0
  80. package/build/ts/maciKeys/keypair.js.map +1 -0
  81. package/build/ts/maciKeys/publicKeys.d.ts +8 -0
  82. package/build/ts/maciKeys/publicKeys.d.ts.map +1 -0
  83. package/build/ts/maciKeys/publicKeys.js +23 -0
  84. package/build/ts/maciKeys/publicKeys.js.map +1 -0
  85. package/build/ts/maciKeys/types.d.ts +28 -0
  86. package/build/ts/maciKeys/types.d.ts.map +1 -0
  87. package/build/ts/maciKeys/types.js +3 -0
  88. package/build/ts/maciKeys/types.js.map +1 -0
  89. package/build/ts/poll/index.d.ts +4 -0
  90. package/build/ts/poll/index.d.ts.map +1 -0
  91. package/build/ts/poll/index.js +9 -0
  92. package/build/ts/poll/index.js.map +1 -0
  93. package/build/ts/poll/poll.d.ts +14 -0
  94. package/build/ts/poll/poll.d.ts.map +1 -0
  95. package/build/ts/poll/poll.js +62 -0
  96. package/build/ts/poll/poll.js.map +1 -0
  97. package/build/ts/poll/types.d.ts +151 -0
  98. package/build/ts/poll/types.d.ts.map +1 -0
  99. package/build/ts/poll/types.js +3 -0
  100. package/build/ts/poll/types.js.map +1 -0
  101. package/build/ts/poll/utils.d.ts +9 -0
  102. package/build/ts/poll/utils.d.ts.map +1 -0
  103. package/build/ts/poll/utils.js +43 -0
  104. package/build/ts/poll/utils.js.map +1 -0
  105. package/build/ts/proof/__tests__/download.test.d.ts +2 -0
  106. package/build/ts/proof/__tests__/download.test.d.ts.map +1 -0
  107. package/build/ts/proof/__tests__/download.test.js +53 -0
  108. package/build/ts/proof/__tests__/download.test.js.map +1 -0
  109. package/build/ts/proof/download.d.ts +9 -0
  110. package/build/ts/proof/download.d.ts.map +1 -0
  111. package/build/ts/proof/download.js +47 -0
  112. package/build/ts/proof/download.js.map +1 -0
  113. package/build/ts/proof/generate.d.ts +8 -0
  114. package/build/ts/proof/generate.d.ts.map +1 -0
  115. package/build/ts/proof/generate.js +133 -0
  116. package/build/ts/proof/generate.js.map +1 -0
  117. package/build/ts/proof/index.d.ts +4 -0
  118. package/build/ts/proof/index.d.ts.map +1 -0
  119. package/build/ts/proof/index.js +8 -0
  120. package/build/ts/proof/index.js.map +1 -0
  121. package/build/ts/proof/prove.d.ts +8 -0
  122. package/build/ts/proof/prove.d.ts.map +1 -0
  123. package/build/ts/proof/prove.js +91 -0
  124. package/build/ts/proof/prove.js.map +1 -0
  125. package/build/ts/proof/types.d.ts +205 -0
  126. package/build/ts/proof/types.d.ts.map +1 -0
  127. package/build/ts/proof/types.js +3 -0
  128. package/build/ts/proof/types.js.map +1 -0
  129. package/build/ts/proof/utils.d.ts +10 -0
  130. package/build/ts/proof/utils.d.ts.map +1 -0
  131. package/build/ts/proof/utils.js +24 -0
  132. package/build/ts/proof/utils.js.map +1 -0
  133. package/build/ts/relayer/__tests__/messages.test.d.ts +2 -0
  134. package/build/ts/relayer/__tests__/messages.test.d.ts.map +1 -0
  135. package/build/ts/relayer/__tests__/messages.test.js +76 -0
  136. package/build/ts/relayer/__tests__/messages.test.js.map +1 -0
  137. package/build/ts/relayer/__tests__/utils.test.d.ts +2 -0
  138. package/build/ts/relayer/__tests__/utils.test.d.ts.map +1 -0
  139. package/build/ts/relayer/__tests__/utils.test.js +73 -0
  140. package/build/ts/relayer/__tests__/utils.test.js.map +1 -0
  141. package/build/ts/relayer/index.d.ts +3 -0
  142. package/build/ts/relayer/index.d.ts.map +1 -0
  143. package/build/ts/relayer/index.js +8 -0
  144. package/build/ts/relayer/index.js.map +1 -0
  145. package/build/ts/relayer/messages.d.ts +23 -0
  146. package/build/ts/relayer/messages.d.ts.map +1 -0
  147. package/build/ts/relayer/messages.js +66 -0
  148. package/build/ts/relayer/messages.js.map +1 -0
  149. package/build/ts/relayer/types.d.ts +168 -0
  150. package/build/ts/relayer/types.d.ts.map +1 -0
  151. package/build/ts/relayer/types.js +3 -0
  152. package/build/ts/relayer/types.js.map +1 -0
  153. package/build/ts/relayer/utils.d.ts +12 -0
  154. package/build/ts/relayer/utils.d.ts.map +1 -0
  155. package/build/ts/relayer/utils.js +37 -0
  156. package/build/ts/relayer/utils.js.map +1 -0
  157. package/build/ts/subgraph/index.d.ts +3 -0
  158. package/build/ts/subgraph/index.d.ts.map +1 -0
  159. package/build/ts/subgraph/index.js +18 -0
  160. package/build/ts/subgraph/index.js.map +1 -0
  161. package/build/ts/subgraph/maciSubgraph.d.ts +28 -0
  162. package/build/ts/subgraph/maciSubgraph.d.ts.map +1 -0
  163. package/build/ts/subgraph/maciSubgraph.js +64 -0
  164. package/build/ts/subgraph/maciSubgraph.js.map +1 -0
  165. package/build/ts/subgraph/types.d.ts +20 -0
  166. package/build/ts/subgraph/types.d.ts.map +1 -0
  167. package/build/ts/subgraph/types.js +3 -0
  168. package/build/ts/subgraph/types.js.map +1 -0
  169. package/build/ts/tally/commitments.d.ts +9 -0
  170. package/build/ts/tally/commitments.d.ts.map +1 -0
  171. package/build/ts/tally/commitments.js +43 -0
  172. package/build/ts/tally/commitments.js.map +1 -0
  173. package/build/ts/tally/index.d.ts +5 -0
  174. package/build/ts/tally/index.d.ts.map +1 -0
  175. package/build/ts/tally/index.js +12 -0
  176. package/build/ts/tally/index.js.map +1 -0
  177. package/build/ts/tally/results.d.ts +20 -0
  178. package/build/ts/tally/results.d.ts.map +1 -0
  179. package/build/ts/tally/results.js +49 -0
  180. package/build/ts/tally/results.js.map +1 -0
  181. package/build/ts/tally/types.d.ts +219 -0
  182. package/build/ts/tally/types.d.ts.map +1 -0
  183. package/build/ts/tally/types.js +3 -0
  184. package/build/ts/tally/types.js.map +1 -0
  185. package/build/ts/tally/utils.d.ts +24 -0
  186. package/build/ts/tally/utils.d.ts.map +1 -0
  187. package/build/ts/tally/utils.js +50 -0
  188. package/build/ts/tally/utils.js.map +1 -0
  189. package/build/ts/tally/verification.d.ts +7 -0
  190. package/build/ts/tally/verification.d.ts.map +1 -0
  191. package/build/ts/tally/verification.js +62 -0
  192. package/build/ts/tally/verification.js.map +1 -0
  193. package/build/ts/trees/index.d.ts +3 -0
  194. package/build/ts/trees/index.d.ts.map +1 -0
  195. package/build/ts/trees/index.js +8 -0
  196. package/build/ts/trees/index.js.map +1 -0
  197. package/build/ts/trees/stateTree.d.ts +35 -0
  198. package/build/ts/trees/stateTree.d.ts.map +1 -0
  199. package/build/ts/trees/stateTree.js +117 -0
  200. package/build/ts/trees/stateTree.js.map +1 -0
  201. package/build/ts/trees/types.d.ts +55 -0
  202. package/build/ts/trees/types.d.ts.map +1 -0
  203. package/build/ts/trees/types.js +3 -0
  204. package/build/ts/trees/types.js.map +1 -0
  205. package/build/ts/user/index.d.ts +5 -0
  206. package/build/ts/user/index.d.ts.map +1 -0
  207. package/build/ts/user/index.js +17 -0
  208. package/build/ts/user/index.js.map +1 -0
  209. package/build/ts/user/joinPoll.d.ts +8 -0
  210. package/build/ts/user/joinPoll.d.ts.map +1 -0
  211. package/build/ts/user/joinPoll.js +84 -0
  212. package/build/ts/user/joinPoll.js.map +1 -0
  213. package/build/ts/user/signup.d.ts +20 -0
  214. package/build/ts/user/signup.d.ts.map +1 -0
  215. package/build/ts/user/signup.js +84 -0
  216. package/build/ts/user/signup.js.map +1 -0
  217. package/build/ts/user/types.d.ts +460 -0
  218. package/build/ts/user/types.d.ts.map +1 -0
  219. package/build/ts/user/types.js +3 -0
  220. package/build/ts/user/types.js.map +1 -0
  221. package/build/ts/user/utils.d.ts +88 -0
  222. package/build/ts/user/utils.d.ts.map +1 -0
  223. package/build/ts/user/utils.js +258 -0
  224. package/build/ts/user/utils.js.map +1 -0
  225. package/build/ts/utils/cid.d.ts +23 -0
  226. package/build/ts/utils/cid.d.ts.map +1 -0
  227. package/build/ts/utils/cid.js +72 -0
  228. package/build/ts/utils/cid.js.map +1 -0
  229. package/build/ts/utils/constants.d.ts +2 -0
  230. package/build/ts/utils/constants.d.ts.map +1 -0
  231. package/build/ts/utils/constants.js +5 -0
  232. package/build/ts/utils/constants.js.map +1 -0
  233. package/build/ts/utils/contracts.d.ts +15 -0
  234. package/build/ts/utils/contracts.d.ts.map +1 -0
  235. package/build/ts/utils/contracts.js +26 -0
  236. package/build/ts/utils/contracts.js.map +1 -0
  237. package/build/ts/utils/files.d.ts +9 -0
  238. package/build/ts/utils/files.d.ts.map +1 -0
  239. package/build/ts/utils/files.js +20 -0
  240. package/build/ts/utils/files.js.map +1 -0
  241. package/build/ts/utils/formatting.d.ts +8 -0
  242. package/build/ts/utils/formatting.d.ts.map +1 -0
  243. package/build/ts/utils/formatting.js +11 -0
  244. package/build/ts/utils/formatting.js.map +1 -0
  245. package/build/ts/utils/fundWallet.d.ts +7 -0
  246. package/build/ts/utils/fundWallet.d.ts.map +1 -0
  247. package/build/ts/utils/fundWallet.js +20 -0
  248. package/build/ts/utils/fundWallet.js.map +1 -0
  249. package/build/ts/utils/index.d.ts +12 -0
  250. package/build/ts/utils/index.d.ts.map +1 -0
  251. package/build/ts/utils/index.js +29 -0
  252. package/build/ts/utils/index.js.map +1 -0
  253. package/build/ts/utils/params.d.ts +7 -0
  254. package/build/ts/utils/params.d.ts.map +1 -0
  255. package/build/ts/utils/params.js +19 -0
  256. package/build/ts/utils/params.js.map +1 -0
  257. package/build/ts/utils/proofs.d.ts +13 -0
  258. package/build/ts/utils/proofs.d.ts.map +1 -0
  259. package/build/ts/utils/proofs.js +41 -0
  260. package/build/ts/utils/proofs.js.map +1 -0
  261. package/build/ts/utils/timeTravel.d.ts +7 -0
  262. package/build/ts/utils/timeTravel.d.ts.map +1 -0
  263. package/build/ts/utils/timeTravel.js +14 -0
  264. package/build/ts/utils/timeTravel.js.map +1 -0
  265. package/build/ts/utils/trees.d.ts +13 -0
  266. package/build/ts/utils/trees.d.ts.map +1 -0
  267. package/build/ts/utils/trees.js +30 -0
  268. package/build/ts/utils/trees.js.map +1 -0
  269. package/build/ts/utils/types.d.ts +71 -0
  270. package/build/ts/utils/types.d.ts.map +1 -0
  271. package/build/ts/utils/types.js +3 -0
  272. package/build/ts/utils/types.js.map +1 -0
  273. package/build/ts/utils/utils.d.ts +29 -0
  274. package/build/ts/utils/utils.d.ts.map +1 -0
  275. package/build/ts/utils/utils.js +61 -0
  276. package/build/ts/utils/utils.js.map +1 -0
  277. package/build/ts/verifyingKeys/checkVerifyingKeys.d.ts +10 -0
  278. package/build/ts/verifyingKeys/checkVerifyingKeys.d.ts.map +1 -0
  279. package/build/ts/verifyingKeys/checkVerifyingKeys.js +66 -0
  280. package/build/ts/verifyingKeys/checkVerifyingKeys.js.map +1 -0
  281. package/build/ts/verifyingKeys/index.d.ts +5 -0
  282. package/build/ts/verifyingKeys/index.d.ts.map +1 -0
  283. package/build/ts/verifyingKeys/index.js +13 -0
  284. package/build/ts/verifyingKeys/index.js.map +1 -0
  285. package/build/ts/verifyingKeys/setVerifyingKeys.d.ts +7 -0
  286. package/build/ts/verifyingKeys/setVerifyingKeys.d.ts.map +1 -0
  287. package/build/ts/verifyingKeys/setVerifyingKeys.js +108 -0
  288. package/build/ts/verifyingKeys/setVerifyingKeys.js.map +1 -0
  289. package/build/ts/verifyingKeys/types.d.ts +239 -0
  290. package/build/ts/verifyingKeys/types.d.ts.map +1 -0
  291. package/build/ts/verifyingKeys/types.js +3 -0
  292. package/build/ts/verifyingKeys/types.js.map +1 -0
  293. package/build/ts/verifyingKeys/utils.d.ts +29 -0
  294. package/build/ts/verifyingKeys/utils.d.ts.map +1 -0
  295. package/build/ts/verifyingKeys/utils.js +118 -0
  296. package/build/ts/verifyingKeys/utils.js.map +1 -0
  297. package/build/ts/vote/generate.d.ts +8 -0
  298. package/build/ts/vote/generate.d.ts.map +1 -0
  299. package/build/ts/vote/generate.js +46 -0
  300. package/build/ts/vote/generate.js.map +1 -0
  301. package/build/ts/vote/index.d.ts +7 -0
  302. package/build/ts/vote/index.d.ts.map +1 -0
  303. package/build/ts/vote/index.js +17 -0
  304. package/build/ts/vote/index.js.map +1 -0
  305. package/build/ts/vote/invalidate.d.ts +13 -0
  306. package/build/ts/vote/invalidate.d.ts.map +1 -0
  307. package/build/ts/vote/invalidate.js +44 -0
  308. package/build/ts/vote/invalidate.js.map +1 -0
  309. package/build/ts/vote/publish.d.ts +14 -0
  310. package/build/ts/vote/publish.d.ts.map +1 -0
  311. package/build/ts/vote/publish.js +88 -0
  312. package/build/ts/vote/publish.js.map +1 -0
  313. package/build/ts/vote/submit.d.ts +13 -0
  314. package/build/ts/vote/submit.d.ts.map +1 -0
  315. package/build/ts/vote/submit.js +36 -0
  316. package/build/ts/vote/submit.js.map +1 -0
  317. package/build/ts/vote/types.d.ts +238 -0
  318. package/build/ts/vote/types.d.ts.map +1 -0
  319. package/build/ts/vote/types.js +3 -0
  320. package/build/ts/vote/types.js.map +1 -0
  321. package/build/ts/vote/utils.d.ts +16 -0
  322. package/build/ts/vote/utils.d.ts.map +1 -0
  323. package/build/ts/vote/utils.js +26 -0
  324. package/build/ts/vote/utils.js.map +1 -0
  325. package/build/tsconfig.build.tsbuildinfo +1 -0
  326. package/package.json +66 -0
@@ -0,0 +1,239 @@
1
+ import type { EMode } from "@maci-protocol/contracts";
2
+ import type { IVerifyingKeyContractParams, VerifyingKey } from "@maci-protocol/domainobjs";
3
+ import type { Signer } from "ethers";
4
+ /**
5
+ * Arguments for the getAllVerifyingKeys function
6
+ */
7
+ export interface IGetAllVerifyingKeysArgs {
8
+ /**
9
+ * The address of the VerifyingKeysRegistry contract
10
+ */
11
+ verifyingKeysRegistryAddress: 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
+ tallyProcessingStateTreeDepth: 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 IMaciVerifyingKeysOnchain {
41
+ /**
42
+ * The verifying key for the poll joining circuit
43
+ */
44
+ pollJoiningVerifyingKeyOnChain: IVerifyingKeyContractParams;
45
+ /**
46
+ * The verifying key for the poll joined circuit
47
+ */
48
+ pollJoinedVerifyingKeyOnChain: IVerifyingKeyContractParams;
49
+ /**
50
+ * The verifying key for the process messages circuit
51
+ */
52
+ processVerifyingKeyOnChain: IVerifyingKeyContractParams;
53
+ /**
54
+ * The verifying key for the tally votes circuit
55
+ */
56
+ tallyVerifyingKeyOnChain: IVerifyingKeyContractParams;
57
+ }
58
+ /**
59
+ * Arguments for the extractAllVerifyingKeys function
60
+ */
61
+ export interface IExtractAllVerifyingKeysArgs {
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
+ messageProcessorZkeyPath?: string;
74
+ /**
75
+ * The path to the tally votes zkey
76
+ */
77
+ voteTallyZkeyPath?: string;
78
+ }
79
+ /**
80
+ * Maci verifying keys
81
+ */
82
+ export interface IMaciVerifyingKeys {
83
+ /**
84
+ * The poll joining verifying key
85
+ */
86
+ pollJoiningVerifyingKey?: VerifyingKey;
87
+ /**
88
+ * The poll joined verifying key
89
+ */
90
+ pollJoinedVerifyingKey?: VerifyingKey;
91
+ /**
92
+ * The message processing verifying key
93
+ */
94
+ processVerifyingKey?: VerifyingKey;
95
+ /**
96
+ * The tally verifying key
97
+ */
98
+ tallyVerifyingKey?: VerifyingKey;
99
+ }
100
+ /**
101
+ * The arguments for the setVerifyingKeys function
102
+ */
103
+ export interface ISetVerifyingKeysArgs {
104
+ /**
105
+ * The polll joining verifying key object
106
+ */
107
+ pollJoiningVerifyingKey: VerifyingKey;
108
+ /**
109
+ * The poll joined verifying key object
110
+ */
111
+ pollJoinedVerifyingKey: VerifyingKey;
112
+ /**
113
+ * The process messages verifying keys array
114
+ */
115
+ processMessagesVerifyingKeys: VerifyingKey[];
116
+ /**
117
+ * The tally votes verifying keys array
118
+ */
119
+ tallyVotesVerifyingKeys: VerifyingKey[];
120
+ /**
121
+ * The state tree depth
122
+ */
123
+ stateTreeDepth: number;
124
+ /**
125
+ * The poll state tree depth
126
+ */
127
+ pollStateTreeDepth: number;
128
+ /**
129
+ * The intermediate state tree depth (ballot tree)
130
+ */
131
+ tallyProcessingStateTreeDepth: number;
132
+ /**
133
+ * The vote option tree depth
134
+ */
135
+ voteOptionTreeDepth: number;
136
+ /**
137
+ * The message batch size
138
+ */
139
+ messageBatchSize: number;
140
+ /**
141
+ * The VerifyingKeysRegistry contract address
142
+ */
143
+ verifyingKeysRegistryAddress: string;
144
+ /**
145
+ * The signer
146
+ */
147
+ signer: Signer;
148
+ /**
149
+ * QV, NON_QV or FULL
150
+ */
151
+ modes: EMode[];
152
+ }
153
+ /**
154
+ * Interface for the arguments to the checkVerifyingKeys command
155
+ */
156
+ export interface ICheckVerifyingKeysArgs {
157
+ /**
158
+ * The depth of the state tree
159
+ */
160
+ stateTreeDepth: number;
161
+ /**
162
+ * The depth of the state subtree
163
+ */
164
+ tallyProcessingStateTreeDepth: number;
165
+ /**
166
+ * The depth of the vote option tree
167
+ */
168
+ voteOptionTreeDepth: number;
169
+ /**
170
+ * The size of the message batch
171
+ */
172
+ messageBatchSize: number;
173
+ /**
174
+ * The path to the poll joining zkey
175
+ */
176
+ pollJoiningZkeyPath: string;
177
+ /**
178
+ * The path to the poll joined zkey
179
+ */
180
+ pollJoinedZkeyPath: string;
181
+ /**
182
+ * The path to the process messages zkey
183
+ */
184
+ messageProcessorZkeyPath: string;
185
+ /**
186
+ * The path to the tally votes zkey
187
+ */
188
+ voteTallyZkeyPath: string;
189
+ /**
190
+ * A signer object
191
+ */
192
+ signer: Signer;
193
+ /**
194
+ * The address of the VerifyingKeysRegistry contract
195
+ */
196
+ verifyingKeysRegistry: string;
197
+ /**
198
+ * Voting mode
199
+ */
200
+ mode?: EMode;
201
+ }
202
+ /**
203
+ * Interface for the arguments to the extractVerifyingKeyToFile command
204
+ */
205
+ export interface IExtractVerifyingKeyToFileArgs {
206
+ /**
207
+ * File path for poll joining zkey
208
+ */
209
+ pollJoiningZkeyPath: string;
210
+ /**
211
+ * File path for poll joined zkey
212
+ */
213
+ pollJoinedZkeyPath: string;
214
+ /**
215
+ * File path for processMessagesQv zkey
216
+ */
217
+ messageProcessorZkeyPathQv: string;
218
+ /**
219
+ * File path for tallyVotesQv zkey
220
+ */
221
+ voteTallyZkeyPathQv: string;
222
+ /**
223
+ * File path for processMessagesNonQv zkey
224
+ */
225
+ messageProcessorZkeyPathNonQv: string;
226
+ /**
227
+ * File path for MessageProcessor zkey
228
+ */
229
+ messageProcessorZkeyPathFull: string;
230
+ /**
231
+ * File path for VoteTally zkey
232
+ */
233
+ voteTallyZkeyPathNonQv: string;
234
+ /**
235
+ * Output file path of extracted verifying keys
236
+ */
237
+ outputFilePath: string;
238
+ }
239
+ //# 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,2BAA2B,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC3F,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,4BAA4B,EAAE,MAAM,CAAC;IAErC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf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IACH,cAAc,EAAE,MAAM,CAAC;CACxB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../ts/verifyingKeys/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,29 @@
1
+ import { type IVerifyingKeyContractParams, VerifyingKey } from "@maci-protocol/domainobjs";
2
+ import type { IGetAllVerifyingKeysArgs, IExtractAllVerifyingKeysArgs, IMaciVerifyingKeys, IMaciVerifyingKeysOnchain, IExtractVerifyingKeyToFileArgs } from "./types";
3
+ /**
4
+ * Get all the verifying keys from the contract
5
+ * @param args - The arguments for the getAllVerifyingKeys function
6
+ * @returns The verifying keys
7
+ */
8
+ export declare const getAllOnChainVerifyingKeys: ({ verifyingKeysRegistryAddress, signer, stateTreeDepth, voteOptionTreeDepth, messageBatchSize, tallyProcessingStateTreeDepth, mode, }: IGetAllVerifyingKeysArgs) => Promise<IMaciVerifyingKeysOnchain>;
9
+ /**
10
+ * Compare two verifying keys
11
+ * @param verifyingKeyOnChain - the verifying key on chain
12
+ * @param verifyingKey - the local verifying key
13
+ * @returns whether they are equal or not
14
+ */
15
+ export declare const compareVerifyingKeys: (verifyingKeyOnChain: VerifyingKey | IVerifyingKeyContractParams, verifyingKey?: VerifyingKey | IVerifyingKeyContractParams) => boolean;
16
+ /**
17
+ * Extract all the verifying keys
18
+ * @param args - The arguments for the extractAllVerifyingKeys function
19
+ * @returns The verifying keys
20
+ */
21
+ export declare const extractAllVerifyingKeys: ({ pollJoiningZkeyPath, pollJoinedZkeyPath, messageProcessorZkeyPath, voteTallyZkeyPath, }: IExtractAllVerifyingKeysArgs) => Promise<IMaciVerifyingKeys>;
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 extractVerifyingKeyToFile: ({ messageProcessorZkeyPathQv, voteTallyZkeyPathQv, messageProcessorZkeyPathNonQv, messageProcessorZkeyPathFull, pollJoinedZkeyPath, pollJoiningZkeyPath, voteTallyZkeyPathNonQv, outputFilePath, }: IExtractVerifyingKeyToFileArgs) => 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":"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"}
@@ -0,0 +1,118 @@
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.extractVerifyingKeyToFile = exports.extractAllVerifyingKeys = exports.compareVerifyingKeys = exports.getAllOnChainVerifyingKeys = void 0;
7
+ const contracts_1 = require("@maci-protocol/contracts");
8
+ const typechain_types_1 = require("@maci-protocol/contracts/typechain-types");
9
+ const domainobjs_1 = require("@maci-protocol/domainobjs");
10
+ const fs_1 = __importDefault(require("fs"));
11
+ /**
12
+ * Get all the verifying keys from the contract
13
+ * @param args - The arguments for the getAllVerifyingKeys function
14
+ * @returns The verifying keys
15
+ */
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
+ ]);
24
+ return {
25
+ pollJoiningVerifyingKeyOnChain,
26
+ pollJoinedVerifyingKeyOnChain,
27
+ processVerifyingKeyOnChain,
28
+ tallyVerifyingKeyOnChain,
29
+ };
30
+ };
31
+ exports.getAllOnChainVerifyingKeys = getAllOnChainVerifyingKeys;
32
+ /**
33
+ * Compare two verifying keys
34
+ * @param verifyingKeyOnChain - the verifying key on chain
35
+ * @param verifyingKey - the local verifying key
36
+ * @returns whether they are equal or not
37
+ */
38
+ const compareVerifyingKeys = (verifyingKeyOnChain, verifyingKey) => {
39
+ if (!verifyingKey) {
40
+ throw new Error("Verifying key is not provided");
41
+ }
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
+ }
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
+ return isEqual;
62
+ };
63
+ exports.compareVerifyingKeys = compareVerifyingKeys;
64
+ /**
65
+ * Extract all the verifying keys
66
+ * @param args - The arguments for the extractAllVerifyingKeys function
67
+ * @returns The verifying keys
68
+ */
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))
82
+ : undefined;
83
+ return {
84
+ pollJoiningVerifyingKey,
85
+ pollJoinedVerifyingKey,
86
+ processVerifyingKey,
87
+ tallyVerifyingKey,
88
+ };
89
+ };
90
+ exports.extractAllVerifyingKeys = extractAllVerifyingKeys;
91
+ /**
92
+ * Command to confirm that the verifying keys in the contract match the local ones
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
94
+ * @param args The arguments for the checkVerifyingKeys command
95
+ * @returns Whether the verifying keys match or not
96
+ */
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),
106
+ ]);
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
+ }));
116
+ };
117
+ exports.extractVerifyingKeyToFile = extractVerifyingKeyToFile;
118
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../ts/verifyingKeys/utils.ts"],"names":[],"mappings":";;;;;;AAAA,wDAA+D;AAC/D,8EAA0H;AAC1H,0DAA2F;AAE3F,4CAAoB;AAUpB;;;;GAIG;AACI,MAAM,0BAA0B,GAAG,KAAK,EAAE,EAC/C,4BAA4B,EAC5B,MAAM,EACN,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,6BAA6B,EAC7B,IAAI,GACqB,EAAsC,EAAE;IACjE,MAAM,QAAQ,GAAG,gDAA4B,CAAC,OAAO,CAAC,4BAA4B,EAAE,MAAM,CAAC,CAAC;IAE5F,MAAM,CACJ,8BAA8B,EAC9B,6BAA6B,EAC7B,0BAA0B,EAC1B,wBAAwB,EACzB,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACpB,QAAQ,CA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B,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"}
@@ -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, coordinatorPublicKey, maxVoteOption, ephemeralKeypair, newPublicKey, }: 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,oJAY1B,iBAAiB,KAAG,KAsDtB,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, coordinatorPublicKey, maxVoteOption, ephemeralKeypair, newPublicKey, }) => {
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.generateRandomSalt)();
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.VoteCommand(stateIndex, newPublicKey ?? keypair.publicKey, 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.generateEcdhSharedKey(encKeypair.privateKey, coordinatorPublicKey));
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,kDAA2D;AAC3D,0DAAiE;AAIjE,mCAAuC;AAEvC;;;;GAIG;AACI,MAAM,YAAY,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AAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAE3C,8EAA8E;IAC9E,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAC7B,SAAS,EACT,oBAAO,CAAC,qBAAqB,CAAC,UAAU,CAAC,UAAU,EAAE,oBAAoB,CAAC,CAC3E,CAAC;IAEF,OAAO;QACL,OAAO;QACP,gBAAgB,EAAE,UAAU;KAC7B,CAAC;AACJ,CAAC,CAAC;AAlEW,QAAA,YAAY,gBAkEvB"}
@@ -0,0 +1,7 @@
1
+ export type { IVote, IGenerateVoteArgs, IPublishArgs, IPublishBatchArgs, IPublishBatchData, IPublishData, IPublishMessage, ISubmitVoteArgs, ISubmitVoteBatchArgs, } from "./types";
2
+ export { generateVote } from "./generate";
3
+ export { invalidateVotes } from "./invalidate";
4
+ export { publish, publishBatch } from "./publish";
5
+ export { submitVote, submitVoteBatch } from "./submit";
6
+ export { getCoordinatorPublicKey, validateSalt } from "./utils";
7
+ //# 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,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"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateSalt = exports.getCoordinatorPublicKey = exports.submitVoteBatch = exports.submitVote = exports.publishBatch = exports.publish = exports.invalidateVotes = 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 invalidate_1 = require("./invalidate");
7
+ Object.defineProperty(exports, "invalidateVotes", { enumerable: true, get: function () { return invalidate_1.invalidateVotes; } });
8
+ var publish_1 = require("./publish");
9
+ Object.defineProperty(exports, "publish", { enumerable: true, get: function () { return publish_1.publish; } });
10
+ Object.defineProperty(exports, "publishBatch", { enumerable: true, get: function () { return publish_1.publishBatch; } });
11
+ var submit_1 = require("./submit");
12
+ Object.defineProperty(exports, "submitVote", { enumerable: true, get: function () { return submit_1.submitVote; } });
13
+ Object.defineProperty(exports, "submitVoteBatch", { enumerable: true, get: function () { return submit_1.submitVoteBatch; } });
14
+ var utils_1 = require("./utils");
15
+ Object.defineProperty(exports, "getCoordinatorPublicKey", { enumerable: true, get: function () { return utils_1.getCoordinatorPublicKey; } });
16
+ Object.defineProperty(exports, "validateSalt", { enumerable: true, get: function () { return utils_1.validateSalt; } });
17
+ //# 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,2CAA+C;AAAtC,6GAAA,eAAe,OAAA;AACxB,qCAAkD;AAAzC,kGAAA,OAAO,OAAA;AAAE,uGAAA,YAAY,OAAA;AAC9B,mCAAuD;AAA9C,oGAAA,UAAU,OAAA;AAAE,yGAAA,eAAe,OAAA;AACpC,iCAAgE;AAAvD,gHAAA,uBAAuB,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 coordinatorPublicKey = await (0, utils_1.getCoordinatorPublicKey)(pollAddress, signer);
23
+ // generate the key change message
24
+ const message = (0, generate_1.generateVote)({
25
+ pollId,
26
+ voteOptionIndex: 0n,
27
+ nonce: 1n,
28
+ privateKey: maciPrivateKey,
29
+ stateIndex,
30
+ // use a random key to invalidate the previous votes
31
+ newPublicKey: new domainobjs_1.Keypair().publicKey,
32
+ voteWeight: 0n,
33
+ coordinatorPublicKey,
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,mCAAkD;AAElD;;;;;;;;;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,oBAAoB,GAAG,MAAM,IAAA,+BAAuB,EAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAEhF,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,YAAY,EAAE,IAAI,oBAAO,EAAE,CAAC,SAAS;QACrC,UAAU,EAAE,EAAE;QACd,oBAAoB;QACpB,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: ({ stateIndex, voteOptionIndex, nonce, pollId, newVoteWeight, maciAddress, salt, publicKey: serializedPublicKey, privateKey: serializedPrivateKey, 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,6JAW3B,YAAY,KAAG,OAAO,CAAC,YAAY,CAqCrC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAU,mEAOhC,iBAAiB,KAAG,OAAO,CAAC,iBAAiB,CA4C/C,CAAC"}