@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.
Files changed (298) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/LICENSE +22 -0
  3. package/README.md +12 -0
  4. package/build/package.json +56 -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 +43 -0
  8. package/build/ts/browser/index.js.map +1 -0
  9. package/build/ts/deploy/index.d.ts +5 -0
  10. package/build/ts/deploy/index.d.ts.map +1 -0
  11. package/build/ts/deploy/index.js +10 -0
  12. package/build/ts/deploy/index.js.map +1 -0
  13. package/build/ts/deploy/maci.d.ts +8 -0
  14. package/build/ts/deploy/maci.d.ts.map +1 -0
  15. package/build/ts/deploy/maci.js +87 -0
  16. package/build/ts/deploy/maci.js.map +1 -0
  17. package/build/ts/deploy/poll.d.ts +8 -0
  18. package/build/ts/deploy/poll.d.ts.map +1 -0
  19. package/build/ts/deploy/poll.js +107 -0
  20. package/build/ts/deploy/poll.js.map +1 -0
  21. package/build/ts/deploy/types.d.ts +204 -0
  22. package/build/ts/deploy/types.d.ts.map +1 -0
  23. package/build/ts/deploy/types.js +3 -0
  24. package/build/ts/deploy/types.js.map +1 -0
  25. package/build/ts/deploy/utils.d.ts +11 -0
  26. package/build/ts/deploy/utils.d.ts.map +1 -0
  27. package/build/ts/deploy/utils.js +22 -0
  28. package/build/ts/deploy/utils.js.map +1 -0
  29. package/build/ts/deploy/vkRegistry.d.ts +7 -0
  30. package/build/ts/deploy/vkRegistry.d.ts.map +1 -0
  31. package/build/ts/deploy/vkRegistry.js +14 -0
  32. package/build/ts/deploy/vkRegistry.js.map +1 -0
  33. package/build/ts/index.d.ts +16 -0
  34. package/build/ts/index.d.ts.map +1 -0
  35. package/build/ts/index.js +69 -0
  36. package/build/ts/index.js.map +1 -0
  37. package/build/ts/maci/index.d.ts +6 -0
  38. package/build/ts/maci/index.d.ts.map +1 -0
  39. package/build/ts/maci/index.js +17 -0
  40. package/build/ts/maci/index.js.map +1 -0
  41. package/build/ts/maci/merge.d.ts +9 -0
  42. package/build/ts/maci/merge.d.ts.map +1 -0
  43. package/build/ts/maci/merge.js +29 -0
  44. package/build/ts/maci/merge.js.map +1 -0
  45. package/build/ts/maci/policy.d.ts +41 -0
  46. package/build/ts/maci/policy.d.ts.map +1 -0
  47. package/build/ts/maci/policy.js +127 -0
  48. package/build/ts/maci/policy.js.map +1 -0
  49. package/build/ts/maci/state.d.ts +8 -0
  50. package/build/ts/maci/state.d.ts.map +1 -0
  51. package/build/ts/maci/state.js +82 -0
  52. package/build/ts/maci/state.js.map +1 -0
  53. package/build/ts/maci/types.d.ts +176 -0
  54. package/build/ts/maci/types.d.ts.map +1 -0
  55. package/build/ts/maci/types.js +18 -0
  56. package/build/ts/maci/types.js.map +1 -0
  57. package/build/ts/maciKeys/__tests__/keypair.test.d.ts +2 -0
  58. package/build/ts/maciKeys/__tests__/keypair.test.d.ts.map +1 -0
  59. package/build/ts/maciKeys/__tests__/keypair.test.js +24 -0
  60. package/build/ts/maciKeys/__tests__/keypair.test.js.map +1 -0
  61. package/build/ts/maciKeys/__tests__/publicKeys.test.d.ts +2 -0
  62. package/build/ts/maciKeys/__tests__/publicKeys.test.d.ts.map +1 -0
  63. package/build/ts/maciKeys/__tests__/publicKeys.test.js +22 -0
  64. package/build/ts/maciKeys/__tests__/publicKeys.test.js.map +1 -0
  65. package/build/ts/maciKeys/index.d.ts +4 -0
  66. package/build/ts/maciKeys/index.d.ts.map +1 -0
  67. package/build/ts/maciKeys/index.js +8 -0
  68. package/build/ts/maciKeys/index.js.map +1 -0
  69. package/build/ts/maciKeys/keypair.d.ts +9 -0
  70. package/build/ts/maciKeys/keypair.d.ts.map +1 -0
  71. package/build/ts/maciKeys/keypair.js +20 -0
  72. package/build/ts/maciKeys/keypair.js.map +1 -0
  73. package/build/ts/maciKeys/publicKeys.d.ts +8 -0
  74. package/build/ts/maciKeys/publicKeys.d.ts.map +1 -0
  75. package/build/ts/maciKeys/publicKeys.js +23 -0
  76. package/build/ts/maciKeys/publicKeys.js.map +1 -0
  77. package/build/ts/maciKeys/types.d.ts +23 -0
  78. package/build/ts/maciKeys/types.d.ts.map +1 -0
  79. package/build/ts/maciKeys/types.js +3 -0
  80. package/build/ts/maciKeys/types.js.map +1 -0
  81. package/build/ts/poll/index.d.ts +4 -0
  82. package/build/ts/poll/index.d.ts.map +1 -0
  83. package/build/ts/poll/index.js +9 -0
  84. package/build/ts/poll/index.js.map +1 -0
  85. package/build/ts/poll/poll.d.ts +14 -0
  86. package/build/ts/poll/poll.d.ts.map +1 -0
  87. package/build/ts/poll/poll.js +62 -0
  88. package/build/ts/poll/poll.js.map +1 -0
  89. package/build/ts/poll/types.d.ts +152 -0
  90. package/build/ts/poll/types.d.ts.map +1 -0
  91. package/build/ts/poll/types.js +3 -0
  92. package/build/ts/poll/types.js.map +1 -0
  93. package/build/ts/poll/utils.d.ts +9 -0
  94. package/build/ts/poll/utils.d.ts.map +1 -0
  95. package/build/ts/poll/utils.js +43 -0
  96. package/build/ts/poll/utils.js.map +1 -0
  97. package/build/ts/proof/__tests__/download.test.d.ts +2 -0
  98. package/build/ts/proof/__tests__/download.test.d.ts.map +1 -0
  99. package/build/ts/proof/__tests__/download.test.js +50 -0
  100. package/build/ts/proof/__tests__/download.test.js.map +1 -0
  101. package/build/ts/proof/constants.d.ts +17 -0
  102. package/build/ts/proof/constants.d.ts.map +1 -0
  103. package/build/ts/proof/constants.js +20 -0
  104. package/build/ts/proof/constants.js.map +1 -0
  105. package/build/ts/proof/download.d.ts +9 -0
  106. package/build/ts/proof/download.d.ts.map +1 -0
  107. package/build/ts/proof/download.js +49 -0
  108. package/build/ts/proof/download.js.map +1 -0
  109. package/build/ts/proof/generate.d.ts +8 -0
  110. package/build/ts/proof/generate.d.ts.map +1 -0
  111. package/build/ts/proof/generate.js +127 -0
  112. package/build/ts/proof/generate.js.map +1 -0
  113. package/build/ts/proof/index.d.ts +4 -0
  114. package/build/ts/proof/index.d.ts.map +1 -0
  115. package/build/ts/proof/index.js +8 -0
  116. package/build/ts/proof/index.js.map +1 -0
  117. package/build/ts/proof/prove.d.ts +8 -0
  118. package/build/ts/proof/prove.d.ts.map +1 -0
  119. package/build/ts/proof/prove.js +81 -0
  120. package/build/ts/proof/prove.js.map +1 -0
  121. package/build/ts/proof/types.d.ts +175 -0
  122. package/build/ts/proof/types.d.ts.map +1 -0
  123. package/build/ts/proof/types.js +3 -0
  124. package/build/ts/proof/types.js.map +1 -0
  125. package/build/ts/relayer/__tests__/messages.test.d.ts +2 -0
  126. package/build/ts/relayer/__tests__/messages.test.d.ts.map +1 -0
  127. package/build/ts/relayer/__tests__/messages.test.js +76 -0
  128. package/build/ts/relayer/__tests__/messages.test.js.map +1 -0
  129. package/build/ts/relayer/__tests__/utils.test.d.ts +2 -0
  130. package/build/ts/relayer/__tests__/utils.test.d.ts.map +1 -0
  131. package/build/ts/relayer/__tests__/utils.test.js +73 -0
  132. package/build/ts/relayer/__tests__/utils.test.js.map +1 -0
  133. package/build/ts/relayer/index.d.ts +3 -0
  134. package/build/ts/relayer/index.d.ts.map +1 -0
  135. package/build/ts/relayer/index.js +8 -0
  136. package/build/ts/relayer/index.js.map +1 -0
  137. package/build/ts/relayer/messages.d.ts +23 -0
  138. package/build/ts/relayer/messages.d.ts.map +1 -0
  139. package/build/ts/relayer/messages.js +66 -0
  140. package/build/ts/relayer/messages.js.map +1 -0
  141. package/build/ts/relayer/types.d.ts +168 -0
  142. package/build/ts/relayer/types.d.ts.map +1 -0
  143. package/build/ts/relayer/types.js +3 -0
  144. package/build/ts/relayer/types.js.map +1 -0
  145. package/build/ts/relayer/utils.d.ts +12 -0
  146. package/build/ts/relayer/utils.d.ts.map +1 -0
  147. package/build/ts/relayer/utils.js +37 -0
  148. package/build/ts/relayer/utils.js.map +1 -0
  149. package/build/ts/tally/commitments.d.ts +9 -0
  150. package/build/ts/tally/commitments.d.ts.map +1 -0
  151. package/build/ts/tally/commitments.js +42 -0
  152. package/build/ts/tally/commitments.js.map +1 -0
  153. package/build/ts/tally/index.d.ts +4 -0
  154. package/build/ts/tally/index.d.ts.map +1 -0
  155. package/build/ts/tally/index.js +8 -0
  156. package/build/ts/tally/index.js.map +1 -0
  157. package/build/ts/tally/types.d.ts +179 -0
  158. package/build/ts/tally/types.d.ts.map +1 -0
  159. package/build/ts/tally/types.js +3 -0
  160. package/build/ts/tally/types.js.map +1 -0
  161. package/build/ts/tally/utils.d.ts +24 -0
  162. package/build/ts/tally/utils.d.ts.map +1 -0
  163. package/build/ts/tally/utils.js +50 -0
  164. package/build/ts/tally/utils.js.map +1 -0
  165. package/build/ts/tally/verification.d.ts +7 -0
  166. package/build/ts/tally/verification.d.ts.map +1 -0
  167. package/build/ts/tally/verification.js +62 -0
  168. package/build/ts/tally/verification.js.map +1 -0
  169. package/build/ts/trees/index.d.ts +3 -0
  170. package/build/ts/trees/index.d.ts.map +1 -0
  171. package/build/ts/trees/index.js +6 -0
  172. package/build/ts/trees/index.js.map +1 -0
  173. package/build/ts/trees/stateTree.d.ts +13 -0
  174. package/build/ts/trees/stateTree.d.ts.map +1 -0
  175. package/build/ts/trees/stateTree.js +53 -0
  176. package/build/ts/trees/stateTree.js.map +1 -0
  177. package/build/ts/trees/types.d.ts +46 -0
  178. package/build/ts/trees/types.d.ts.map +1 -0
  179. package/build/ts/trees/types.js +3 -0
  180. package/build/ts/trees/types.js.map +1 -0
  181. package/build/ts/user/index.d.ts +3 -0
  182. package/build/ts/user/index.d.ts.map +1 -0
  183. package/build/ts/user/index.js +11 -0
  184. package/build/ts/user/index.js.map +1 -0
  185. package/build/ts/user/types.d.ts +424 -0
  186. package/build/ts/user/types.d.ts.map +1 -0
  187. package/build/ts/user/types.js +3 -0
  188. package/build/ts/user/types.js.map +1 -0
  189. package/build/ts/user/user.d.ts +42 -0
  190. package/build/ts/user/user.d.ts.map +1 -0
  191. package/build/ts/user/user.js +192 -0
  192. package/build/ts/user/user.js.map +1 -0
  193. package/build/ts/user/utils.d.ts +52 -0
  194. package/build/ts/user/utils.d.ts.map +1 -0
  195. package/build/ts/user/utils.js +186 -0
  196. package/build/ts/user/utils.js.map +1 -0
  197. package/build/ts/utils/cid.d.ts +23 -0
  198. package/build/ts/utils/cid.d.ts.map +1 -0
  199. package/build/ts/utils/cid.js +72 -0
  200. package/build/ts/utils/cid.js.map +1 -0
  201. package/build/ts/utils/constants.d.ts +2 -0
  202. package/build/ts/utils/constants.d.ts.map +1 -0
  203. package/build/ts/utils/constants.js +5 -0
  204. package/build/ts/utils/constants.js.map +1 -0
  205. package/build/ts/utils/contracts.d.ts +15 -0
  206. package/build/ts/utils/contracts.d.ts.map +1 -0
  207. package/build/ts/utils/contracts.js +26 -0
  208. package/build/ts/utils/contracts.js.map +1 -0
  209. package/build/ts/utils/files.d.ts +9 -0
  210. package/build/ts/utils/files.d.ts.map +1 -0
  211. package/build/ts/utils/files.js +20 -0
  212. package/build/ts/utils/files.js.map +1 -0
  213. package/build/ts/utils/formatting.d.ts +8 -0
  214. package/build/ts/utils/formatting.d.ts.map +1 -0
  215. package/build/ts/utils/formatting.js +11 -0
  216. package/build/ts/utils/formatting.js.map +1 -0
  217. package/build/ts/utils/fundWallet.d.ts +7 -0
  218. package/build/ts/utils/fundWallet.d.ts.map +1 -0
  219. package/build/ts/utils/fundWallet.js +20 -0
  220. package/build/ts/utils/fundWallet.js.map +1 -0
  221. package/build/ts/utils/index.d.ts +12 -0
  222. package/build/ts/utils/index.d.ts.map +1 -0
  223. package/build/ts/utils/index.js +28 -0
  224. package/build/ts/utils/index.js.map +1 -0
  225. package/build/ts/utils/params.d.ts +7 -0
  226. package/build/ts/utils/params.d.ts.map +1 -0
  227. package/build/ts/utils/params.js +19 -0
  228. package/build/ts/utils/params.js.map +1 -0
  229. package/build/ts/utils/proofs.d.ts +13 -0
  230. package/build/ts/utils/proofs.d.ts.map +1 -0
  231. package/build/ts/utils/proofs.js +41 -0
  232. package/build/ts/utils/proofs.js.map +1 -0
  233. package/build/ts/utils/timeTravel.d.ts +7 -0
  234. package/build/ts/utils/timeTravel.d.ts.map +1 -0
  235. package/build/ts/utils/timeTravel.js +14 -0
  236. package/build/ts/utils/timeTravel.js.map +1 -0
  237. package/build/ts/utils/trees.d.ts +13 -0
  238. package/build/ts/utils/trees.d.ts.map +1 -0
  239. package/build/ts/utils/trees.js +30 -0
  240. package/build/ts/utils/trees.js.map +1 -0
  241. package/build/ts/utils/types.d.ts +71 -0
  242. package/build/ts/utils/types.d.ts.map +1 -0
  243. package/build/ts/utils/types.js +3 -0
  244. package/build/ts/utils/types.js.map +1 -0
  245. package/build/ts/utils/utils.d.ts +16 -0
  246. package/build/ts/utils/utils.d.ts.map +1 -0
  247. package/build/ts/utils/utils.js +36 -0
  248. package/build/ts/utils/utils.js.map +1 -0
  249. package/build/ts/verifyingKeys/checkVerifyingKeys.d.ts +10 -0
  250. package/build/ts/verifyingKeys/checkVerifyingKeys.d.ts.map +1 -0
  251. package/build/ts/verifyingKeys/checkVerifyingKeys.js +67 -0
  252. package/build/ts/verifyingKeys/checkVerifyingKeys.js.map +1 -0
  253. package/build/ts/verifyingKeys/index.d.ts +5 -0
  254. package/build/ts/verifyingKeys/index.d.ts.map +1 -0
  255. package/build/ts/verifyingKeys/index.js +13 -0
  256. package/build/ts/verifyingKeys/index.js.map +1 -0
  257. package/build/ts/verifyingKeys/setVerifyingKeys.d.ts +7 -0
  258. package/build/ts/verifyingKeys/setVerifyingKeys.d.ts.map +1 -0
  259. package/build/ts/verifyingKeys/setVerifyingKeys.js +73 -0
  260. package/build/ts/verifyingKeys/setVerifyingKeys.js.map +1 -0
  261. package/build/ts/verifyingKeys/types.d.ts +231 -0
  262. package/build/ts/verifyingKeys/types.d.ts.map +1 -0
  263. package/build/ts/verifyingKeys/types.js +3 -0
  264. package/build/ts/verifyingKeys/types.js.map +1 -0
  265. package/build/ts/verifyingKeys/utils.d.ts +29 -0
  266. package/build/ts/verifyingKeys/utils.d.ts.map +1 -0
  267. package/build/ts/verifyingKeys/utils.js +102 -0
  268. package/build/ts/verifyingKeys/utils.js.map +1 -0
  269. package/build/ts/vote/generate.d.ts +8 -0
  270. package/build/ts/vote/generate.d.ts.map +1 -0
  271. package/build/ts/vote/generate.js +46 -0
  272. package/build/ts/vote/generate.js.map +1 -0
  273. package/build/ts/vote/index.d.ts +6 -0
  274. package/build/ts/vote/index.d.ts.map +1 -0
  275. package/build/ts/vote/index.js +15 -0
  276. package/build/ts/vote/index.js.map +1 -0
  277. package/build/ts/vote/invalidate.d.ts +13 -0
  278. package/build/ts/vote/invalidate.d.ts.map +1 -0
  279. package/build/ts/vote/invalidate.js +44 -0
  280. package/build/ts/vote/invalidate.js.map +1 -0
  281. package/build/ts/vote/publish.d.ts +14 -0
  282. package/build/ts/vote/publish.d.ts.map +1 -0
  283. package/build/ts/vote/publish.js +88 -0
  284. package/build/ts/vote/publish.js.map +1 -0
  285. package/build/ts/vote/submit.d.ts +13 -0
  286. package/build/ts/vote/submit.d.ts.map +1 -0
  287. package/build/ts/vote/submit.js +36 -0
  288. package/build/ts/vote/submit.js.map +1 -0
  289. package/build/ts/vote/types.d.ts +238 -0
  290. package/build/ts/vote/types.d.ts.map +1 -0
  291. package/build/ts/vote/types.js +3 -0
  292. package/build/ts/vote/types.js.map +1 -0
  293. package/build/ts/vote/utils.d.ts +16 -0
  294. package/build/ts/vote/utils.d.ts.map +1 -0
  295. package/build/ts/vote/utils.js +26 -0
  296. package/build/ts/vote/utils.js.map +1 -0
  297. package/build/tsconfig.build.tsbuildinfo +1 -0
  298. package/package.json +57 -0
@@ -0,0 +1,13 @@
1
+ import type { CircuitInputs } from "./types";
2
+ /**
3
+ * Generate and verify poll proof
4
+ * @param inputs - the inputs to the circuit
5
+ * @param zkeyPath - the path to the zkey
6
+ * @param useWasm - whether we want to use the wasm witness or not
7
+ * @param rapidsnarkExePath - the path to the rapidnsark binary
8
+ * @param witnessExePath - the path to the compiled witness binary
9
+ * @param wasmPath - the path to the wasm witness
10
+ * @returns proof - an array of strings
11
+ */
12
+ export declare const generateAndVerifyProof: (inputs: CircuitInputs, zkeyPath: string, useWasm: boolean | undefined, rapidsnarkExePath: string | undefined, witnessExePath: string | undefined, wasmPath: string | undefined) => Promise<string[]>;
13
+ //# sourceMappingURL=proofs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proofs.d.ts","sourceRoot":"","sources":["../../../ts/utils/proofs.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB,GACjC,QAAQ,aAAa,EACrB,UAAU,MAAM,EAChB,SAAS,OAAO,GAAG,SAAS,EAC5B,mBAAmB,MAAM,GAAG,SAAS,EACrC,gBAAgB,MAAM,GAAG,SAAS,EAClC,UAAU,MAAM,GAAG,SAAS,KAC3B,OAAO,CAAC,MAAM,EAAE,CA4BlB,CAAC"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateAndVerifyProof = void 0;
4
+ const contracts_1 = require("@maci-protocol/contracts");
5
+ /**
6
+ * Generate and verify poll proof
7
+ * @param inputs - the inputs to the circuit
8
+ * @param zkeyPath - the path to the zkey
9
+ * @param useWasm - whether we want to use the wasm witness or not
10
+ * @param rapidsnarkExePath - the path to the rapidnsark binary
11
+ * @param witnessExePath - the path to the compiled witness binary
12
+ * @param wasmPath - the path to the wasm witness
13
+ * @returns proof - an array of strings
14
+ */
15
+ const generateAndVerifyProof = async (inputs, zkeyPath, useWasm, rapidsnarkExePath, witnessExePath, wasmPath) => {
16
+ let r;
17
+ const vk = await (0, contracts_1.extractVk)(zkeyPath);
18
+ if (useWasm === true || useWasm === undefined) {
19
+ r = await (0, contracts_1.genProofSnarkjs)({
20
+ inputs,
21
+ zkeyPath,
22
+ wasmPath,
23
+ });
24
+ }
25
+ else {
26
+ r = await (0, contracts_1.genProofRapidSnark)({
27
+ inputs,
28
+ zkeyPath,
29
+ rapidsnarkExePath,
30
+ witnessExePath,
31
+ });
32
+ }
33
+ // verify it
34
+ const isValid = await (0, contracts_1.verifyProof)(r.publicSignals, r.proof, vk);
35
+ if (!isValid) {
36
+ throw new Error("Generated an invalid proof");
37
+ }
38
+ return (0, contracts_1.formatProofForVerifierContract)(r.proof);
39
+ };
40
+ exports.generateAndVerifyProof = generateAndVerifyProof;
41
+ //# sourceMappingURL=proofs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proofs.js","sourceRoot":"","sources":["../../../ts/utils/proofs.ts"],"names":[],"mappings":";;;AAAA,wDAOkC;AAIlC;;;;;;;;;GASG;AACI,MAAM,sBAAsB,GAAG,KAAK,EACzC,MAAqB,EACrB,QAAgB,EAChB,OAA4B,EAC5B,iBAAqC,EACrC,cAAkC,EAClC,QAA4B,EACT,EAAE;IACrB,IAAI,CAAkB,CAAC;IAEvB,MAAM,EAAE,GAAG,MAAM,IAAA,qBAAS,EAAC,QAAQ,CAAC,CAAC;IAErC,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC9C,CAAC,GAAG,MAAM,IAAA,2BAAe,EAAC;YACxB,MAAM;YACN,QAAQ;YACR,QAAQ;SACT,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,CAAC,GAAG,MAAM,IAAA,8BAAkB,EAAC;YAC3B,MAAM;YACN,QAAQ;YACR,iBAAiB;YACjB,cAAc;SACf,CAAC,CAAC;IACL,CAAC;IAED,YAAY;IACZ,MAAM,OAAO,GAAG,MAAM,IAAA,uBAAW,EAAC,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAEhE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAChD,CAAC;IAED,OAAO,IAAA,0CAA8B,EAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AACjD,CAAC,CAAC;AAnCW,QAAA,sBAAsB,0BAmCjC"}
@@ -0,0 +1,7 @@
1
+ import type { ITimeTravelArgs } from "./types";
2
+ /**
3
+ * Utility to travel in time when using a local blockchain
4
+ * @param args time travel args
5
+ */
6
+ export declare const timeTravel: ({ seconds, signer }: ITimeTravelArgs) => Promise<void>;
7
+ //# sourceMappingURL=timeTravel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeTravel.d.ts","sourceRoot":"","sources":["../../../ts/utils/timeTravel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG/C;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAU,qBAAqB,eAAe,KAAG,OAAO,CAAC,IAAI,CAInF,CAAC"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.timeTravel = void 0;
4
+ /**
5
+ * Utility to travel in time when using a local blockchain
6
+ * @param args time travel args
7
+ */
8
+ const timeTravel = async ({ seconds, signer }) => {
9
+ // send the instructions to the provider
10
+ await signer.provider.send("evm_increaseTime", [Number(seconds)]);
11
+ await signer.provider.send("evm_mine", []);
12
+ };
13
+ exports.timeTravel = timeTravel;
14
+ //# sourceMappingURL=timeTravel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeTravel.js","sourceRoot":"","sources":["../../../ts/utils/timeTravel.ts"],"names":[],"mappings":";;;AAGA;;;GAGG;AACI,MAAM,UAAU,GAAG,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAmB,EAAiB,EAAE;IACtF,wCAAwC;IACxC,MAAO,MAAM,CAAC,QAA4B,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACvF,MAAO,MAAM,CAAC,QAA4B,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;AAClE,CAAC,CAAC;AAJW,QAAA,UAAU,cAIrB"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Utility to calculate the depth of a binary tree
3
+ * @param maxLeaves - the number of leaves in the tree
4
+ * @returns the depth of the tree
5
+ */
6
+ export declare const calculateBinaryTreeDepthFromMaxLeaves: (maxLeaves: number) => number;
7
+ /**
8
+ * Utility to calculate the depth of a quin tree
9
+ * @param maxLeaves the number of leaves in the tree
10
+ * @returns the depth of the tree
11
+ */
12
+ export declare const calculateQuinTreeDepthFromMaxLeaves: (maxLeaves: number) => number;
13
+ //# sourceMappingURL=trees.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trees.d.ts","sourceRoot":"","sources":["../../../ts/utils/trees.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,qCAAqC,GAAI,WAAW,MAAM,KAAG,MAQzE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mCAAmC,GAAI,WAAW,MAAM,KAAG,MAQvE,CAAC"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calculateQuinTreeDepthFromMaxLeaves = exports.calculateBinaryTreeDepthFromMaxLeaves = void 0;
4
+ /**
5
+ * Utility to calculate the depth of a binary tree
6
+ * @param maxLeaves - the number of leaves in the tree
7
+ * @returns the depth of the tree
8
+ */
9
+ const calculateBinaryTreeDepthFromMaxLeaves = (maxLeaves) => {
10
+ let result = 0;
11
+ while (2 ** result < maxLeaves) {
12
+ result += 1;
13
+ }
14
+ return result;
15
+ };
16
+ exports.calculateBinaryTreeDepthFromMaxLeaves = calculateBinaryTreeDepthFromMaxLeaves;
17
+ /**
18
+ * Utility to calculate the depth of a quin tree
19
+ * @param maxLeaves the number of leaves in the tree
20
+ * @returns the depth of the tree
21
+ */
22
+ const calculateQuinTreeDepthFromMaxLeaves = (maxLeaves) => {
23
+ let result = 0;
24
+ while (5 ** result < maxLeaves) {
25
+ result += 1;
26
+ }
27
+ return result;
28
+ };
29
+ exports.calculateQuinTreeDepthFromMaxLeaves = calculateQuinTreeDepthFromMaxLeaves;
30
+ //# sourceMappingURL=trees.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trees.js","sourceRoot":"","sources":["../../../ts/utils/trees.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACI,MAAM,qCAAqC,GAAG,CAAC,SAAiB,EAAU,EAAE;IACjF,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,OAAO,CAAC,IAAI,MAAM,GAAG,SAAS,EAAE,CAAC;QAC/B,MAAM,IAAI,CAAC,CAAC;IACd,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AARW,QAAA,qCAAqC,yCAQhD;AAEF;;;;GAIG;AACI,MAAM,mCAAmC,GAAG,CAAC,SAAiB,EAAU,EAAE;IAC/E,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,OAAO,CAAC,IAAI,MAAM,GAAG,SAAS,EAAE,CAAC;QAC/B,MAAM,IAAI,CAAC,CAAC;IACd,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AARW,QAAA,mCAAmC,uCAQ9C"}
@@ -0,0 +1,71 @@
1
+ import type { BigNumberish, Signer } from "ethers";
2
+ /**
3
+ * A circuit inputs for the circom circuit
4
+ */
5
+ export type CircuitInputs = Record<string, string | bigint | bigint[] | bigint[][] | string[] | bigint[][][]>;
6
+ /**
7
+ * Circuit parameters
8
+ */
9
+ export interface ICircuitParams {
10
+ /**
11
+ * The state tree depth
12
+ */
13
+ stateTreeDepth: number;
14
+ /**
15
+ * The intermediate state tree depth (ballot tree)
16
+ */
17
+ intStateTreeDepth: number;
18
+ /**
19
+ * The vote option tree depth
20
+ */
21
+ voteOptionTreeDepth: number;
22
+ /**
23
+ * The message batch size
24
+ */
25
+ messageBatchSize: number;
26
+ }
27
+ /**
28
+ * Interface that represents Verification key
29
+ */
30
+ export interface ISnarkJSVerificationKey {
31
+ protocol: BigNumberish;
32
+ curve: BigNumberish;
33
+ nPublic: BigNumberish;
34
+ vk_alpha_1: BigNumberish[];
35
+ vk_beta_2: BigNumberish[][];
36
+ vk_gamma_2: BigNumberish[][];
37
+ vk_delta_2: BigNumberish[][];
38
+ vk_alphabeta_12: BigNumberish[][][];
39
+ IC: BigNumberish[][];
40
+ }
41
+ /**
42
+ * Interface for the arguments to the TimeTravel command
43
+ */
44
+ export interface ITimeTravelArgs {
45
+ /**
46
+ * The number of seconds to time travel
47
+ */
48
+ seconds: number;
49
+ /**
50
+ * A signer object
51
+ */
52
+ signer: Signer;
53
+ }
54
+ /**
55
+ * Interface for the arguments to the FundWallet command
56
+ */
57
+ export interface IFundWalletArgs {
58
+ /**
59
+ * The amount to fund
60
+ */
61
+ amount: number;
62
+ /**
63
+ * The address of the wallet to fund
64
+ */
65
+ address: string;
66
+ /**
67
+ * A signer object
68
+ */
69
+ signer: Signer;
70
+ }
71
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../ts/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEnD;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;AAE9G;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,YAAY,CAAC;IACvB,KAAK,EAAE,YAAY,CAAC;IACpB,OAAO,EAAE,YAAY,CAAC;IACtB,UAAU,EAAE,YAAY,EAAE,CAAC;IAC3B,SAAS,EAAE,YAAY,EAAE,EAAE,CAAC;IAC5B,UAAU,EAAE,YAAY,EAAE,EAAE,CAAC;IAC7B,UAAU,EAAE,YAAY,EAAE,EAAE,CAAC;IAC7B,eAAe,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;IACpC,EAAE,EAAE,YAAY,EAAE,EAAE,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB"}
@@ -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/utils/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Check if we are running on an arm chip
3
+ * @returns whether we are running on an arm chip
4
+ */
5
+ export declare const isArm: () => boolean;
6
+ /**
7
+ * Remove a file
8
+ * @param filepath - the path to the file
9
+ */
10
+ export declare const unlinkFile: (filepath: string) => Promise<void>;
11
+ /**
12
+ * Pause the thread for n milliseconds
13
+ * @param ms - the amount of time to sleep in milliseconds
14
+ */
15
+ export declare const sleep: (ms: number) => Promise<void>;
16
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../ts/utils/utils.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,eAAO,MAAM,KAAK,QAAO,OAAoC,CAAC;AAE9D;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAU,UAAU,MAAM,KAAG,OAAO,CAAC,IAAI,CAM/D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,KAAK,GAAU,IAAI,MAAM,KAAG,OAAO,CAAC,IAAI,CAIpD,CAAC"}
@@ -0,0 +1,36 @@
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.sleep = exports.unlinkFile = exports.isArm = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const os_1 = __importDefault(require("os"));
9
+ /**
10
+ * Check if we are running on an arm chip
11
+ * @returns whether we are running on an arm chip
12
+ */
13
+ const isArm = () => os_1.default.arch().includes("arm");
14
+ exports.isArm = isArm;
15
+ /**
16
+ * Remove a file
17
+ * @param filepath - the path to the file
18
+ */
19
+ const unlinkFile = async (filepath) => {
20
+ const isFileExists = fs_1.default.existsSync(filepath);
21
+ if (isFileExists) {
22
+ await fs_1.default.promises.unlink(filepath);
23
+ }
24
+ };
25
+ exports.unlinkFile = unlinkFile;
26
+ /**
27
+ * Pause the thread for n milliseconds
28
+ * @param ms - the amount of time to sleep in milliseconds
29
+ */
30
+ const sleep = async (ms) => {
31
+ await new Promise((resolve) => {
32
+ setTimeout(resolve, ms);
33
+ });
34
+ };
35
+ exports.sleep = sleep;
36
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../ts/utils/utils.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,4CAAoB;AAEpB;;;GAGG;AACI,MAAM,KAAK,GAAG,GAAY,EAAE,CAAC,YAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAAjD,QAAA,KAAK,SAA4C;AAE9D;;;GAGG;AACI,MAAM,UAAU,GAAG,KAAK,EAAE,QAAgB,EAAiB,EAAE;IAClE,MAAM,YAAY,GAAG,YAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAE7C,IAAI,YAAY,EAAE,CAAC;QACjB,MAAM,YAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC;AACH,CAAC,CAAC;AANW,QAAA,UAAU,cAMrB;AAEF;;;GAGG;AACI,MAAM,KAAK,GAAG,KAAK,EAAE,EAAU,EAAiB,EAAE;IACvD,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC5B,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAJW,QAAA,KAAK,SAIhB"}
@@ -0,0 +1,10 @@
1
+ import type { ICheckVerifyingKeysArgs } from "./types";
2
+ /**
3
+ * Command to confirm that the verifying keys in the contract match the
4
+ * local ones
5
+ * @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
6
+ * @param CheckVerifyingKeysArgs - The arguments for the checkVerifyingKeys command
7
+ * @returns Whether the verifying keys match or not
8
+ */
9
+ export declare const checkVerifyingKeys: ({ stateTreeDepth, intStateTreeDepth, voteOptionTreeDepth, messageBatchSize, processMessagesZkeyPath, tallyVotesZkeyPath, pollJoiningZkeyPath, pollJoinedZkeyPath, vkRegistry, signer, useQuadraticVoting, }: ICheckVerifyingKeysArgs) => Promise<boolean>;
10
+ //# sourceMappingURL=checkVerifyingKeys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkVerifyingKeys.d.ts","sourceRoot":"","sources":["../../../ts/verifyingKeys/checkVerifyingKeys.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAMvD;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAU,6MAYtC,uBAAuB,KAAG,OAAO,CAAC,OAAO,CA6D3C,CAAC"}
@@ -0,0 +1,67 @@
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.checkVerifyingKeys = void 0;
7
+ const contracts_1 = require("@maci-protocol/contracts");
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const utils_1 = require("../utils");
10
+ const utils_2 = require("./utils");
11
+ /**
12
+ * Command to confirm that the verifying keys in the contract match the
13
+ * local ones
14
+ * @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
15
+ * @param CheckVerifyingKeysArgs - The arguments for the checkVerifyingKeys command
16
+ * @returns Whether the verifying keys match or not
17
+ */
18
+ const checkVerifyingKeys = async ({ stateTreeDepth, intStateTreeDepth, voteOptionTreeDepth, messageBatchSize, processMessagesZkeyPath, tallyVotesZkeyPath, pollJoiningZkeyPath, pollJoinedZkeyPath, vkRegistry, signer, useQuadraticVoting = true, }) => {
19
+ if (!vkRegistry) {
20
+ throw new Error("Please provide a VkRegistry contract address");
21
+ }
22
+ const isVkExists = await (0, utils_1.contractExists)(signer.provider, vkRegistry);
23
+ if (!isVkExists) {
24
+ throw new Error("The VkRegistry contract does not exist");
25
+ }
26
+ // we need to ensure that the zkey files exist
27
+ const isProcessMessagesZkeyPathExists = fs_1.default.existsSync(processMessagesZkeyPath);
28
+ if (!isProcessMessagesZkeyPathExists) {
29
+ throw new Error("The provided Process messages zkey does not exist");
30
+ }
31
+ const isTallyVotesZkeyPathExists = fs_1.default.existsSync(tallyVotesZkeyPath);
32
+ if (!isTallyVotesZkeyPathExists) {
33
+ throw new Error("The provided Tally votes zkey does not exist");
34
+ }
35
+ // extract the verification keys from the zkey files
36
+ const { pollJoiningVk, pollJoinedVk, processVk, tallyVk } = await (0, utils_2.extractAllVks)({
37
+ processMessagesZkeyPath,
38
+ tallyVotesZkeyPath,
39
+ pollJoiningZkeyPath,
40
+ pollJoinedZkeyPath,
41
+ });
42
+ const mode = useQuadraticVoting ? contracts_1.EMode.QV : contracts_1.EMode.NON_QV;
43
+ const { pollJoiningVkOnChain, pollJoinedVkOnChain, processVkOnChain, tallyVkOnChain } = await (0, utils_2.getAllOnChainVks)({
44
+ vkRegistryAddress: vkRegistry,
45
+ signer,
46
+ stateTreeDepth,
47
+ voteOptionTreeDepth,
48
+ messageBatchSize,
49
+ intStateTreeDepth,
50
+ mode,
51
+ });
52
+ if (!(0, utils_2.compareVks)(pollJoiningVkOnChain, pollJoiningVk)) {
53
+ throw new Error("Poll verifying keys do not match");
54
+ }
55
+ if (!(0, utils_2.compareVks)(pollJoinedVkOnChain, pollJoinedVk)) {
56
+ throw new Error("Poll verifying keys do not match");
57
+ }
58
+ if (!(0, utils_2.compareVks)(processVkOnChain, processVk)) {
59
+ throw new Error("Process verifying keys do not match");
60
+ }
61
+ if (!(0, utils_2.compareVks)(tallyVkOnChain, tallyVk)) {
62
+ throw new Error("Tally verifying keys do not match");
63
+ }
64
+ return true;
65
+ };
66
+ exports.checkVerifyingKeys = checkVerifyingKeys;
67
+ //# sourceMappingURL=checkVerifyingKeys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkVerifyingKeys.js","sourceRoot":"","sources":["../../../ts/verifyingKeys/checkVerifyingKeys.ts"],"names":[],"mappings":";;;;;;AAAA,wDAAiD;AAEjD,4CAAoB;AAIpB,oCAA0C;AAE1C,mCAAsE;AAEtE;;;;;;GAMG;AACI,MAAM,kBAAkB,GAAG,KAAK,EAAE,EACvC,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,EACvB,kBAAk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B;QAChB,iBAAiB;QACjB,IAAI;KACL,CAAC,CAAC;IAEH,IAAI,CAAC,IAAA,kBAAU,EAAC,oBAAoB,EAAE,aAAa,CAAC,EAAE,CAAC;QACrD,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACtD,CAAC;IAED,IAAI,CAAC,IAAA,kBAAU,EAAC,mBAAmB,EAAE,YAAY,CAAC,EAAE,CAAC;QACnD,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACtD,CAAC;IAED,IAAI,CAAC,IAAA,kBAAU,EAAC,gBAAgB,EAAE,SAAS,CAAC,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzD,CAAC;IAED,IAAI,CAAC,IAAA,kBAAU,EAAC,cAAc,EAAE,OAAO,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvD,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAzEW,QAAA,kBAAkB,sBAyE7B"}
@@ -0,0 +1,5 @@
1
+ export { checkVerifyingKeys } from "./checkVerifyingKeys";
2
+ export { setVerifyingKeys } from "./setVerifyingKeys";
3
+ export { getAllOnChainVks, compareVks, extractAllVks, extractVkToFile } from "./utils";
4
+ export type { IGetAllVksArgs, IMaciVerifyingKeys, IExtractAllVksArgs, IMaciVks, ISetVerifyingKeysArgs, ICheckVerifyingKeysArgs, } from "./types";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../ts/verifyingKeys/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AACvF,YAAY,EACV,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,QAAQ,EACR,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,SAAS,CAAC"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractVkToFile = exports.extractAllVks = exports.compareVks = exports.getAllOnChainVks = exports.setVerifyingKeys = exports.checkVerifyingKeys = void 0;
4
+ var checkVerifyingKeys_1 = require("./checkVerifyingKeys");
5
+ Object.defineProperty(exports, "checkVerifyingKeys", { enumerable: true, get: function () { return checkVerifyingKeys_1.checkVerifyingKeys; } });
6
+ var setVerifyingKeys_1 = require("./setVerifyingKeys");
7
+ Object.defineProperty(exports, "setVerifyingKeys", { enumerable: true, get: function () { return setVerifyingKeys_1.setVerifyingKeys; } });
8
+ var utils_1 = require("./utils");
9
+ Object.defineProperty(exports, "getAllOnChainVks", { enumerable: true, get: function () { return utils_1.getAllOnChainVks; } });
10
+ Object.defineProperty(exports, "compareVks", { enumerable: true, get: function () { return utils_1.compareVks; } });
11
+ Object.defineProperty(exports, "extractAllVks", { enumerable: true, get: function () { return utils_1.extractAllVks; } });
12
+ Object.defineProperty(exports, "extractVkToFile", { enumerable: true, get: function () { return utils_1.extractVkToFile; } });
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ts/verifyingKeys/index.ts"],"names":[],"mappings":";;;AAAA,2DAA0D;AAAjD,wHAAA,kBAAkB,OAAA;AAC3B,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA;AACzB,iCAAuF;AAA9E,yGAAA,gBAAgB,OAAA;AAAE,mGAAA,UAAU,OAAA;AAAE,sGAAA,aAAa,OAAA;AAAE,wGAAA,eAAe,OAAA"}
@@ -0,0 +1,7 @@
1
+ import type { ISetVerifyingKeysArgs } from "./types";
2
+ /**
3
+ * Set the verifying keys on the contract
4
+ * @param args - The arguments for the setVerifyingKeys function
5
+ */
6
+ export declare const setVerifyingKeys: ({ pollJoiningVk, pollJoinedVk, processMessagesVk, tallyVotesVk, stateTreeDepth, intStateTreeDepth, voteOptionTreeDepth, messageBatchSize, vkRegistryAddress, signer, mode, }: ISetVerifyingKeysArgs) => Promise<void>;
7
+ //# sourceMappingURL=setVerifyingKeys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setVerifyingKeys.d.ts","sourceRoot":"","sources":["../../../ts/verifyingKeys/setVerifyingKeys.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAMrD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAAU,8KAYpC,qBAAqB,KAAG,OAAO,CAAC,IAAI,CAwFtC,CAAC"}
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setVerifyingKeys = void 0;
4
+ const contracts_1 = require("@maci-protocol/contracts");
5
+ const core_1 = require("@maci-protocol/core");
6
+ const utils_1 = require("../utils");
7
+ const utils_2 = require("./utils");
8
+ /**
9
+ * Set the verifying keys on the contract
10
+ * @param args - The arguments for the setVerifyingKeys function
11
+ */
12
+ const setVerifyingKeys = async ({ pollJoiningVk, pollJoinedVk, processMessagesVk, tallyVotesVk, stateTreeDepth, intStateTreeDepth, voteOptionTreeDepth, messageBatchSize, vkRegistryAddress, signer, mode, }) => {
13
+ // validate args
14
+ if (stateTreeDepth < 1 || intStateTreeDepth < 1 || voteOptionTreeDepth < 1 || messageBatchSize < 1) {
15
+ throw new Error("Invalid depth or batch size parameters");
16
+ }
17
+ if (stateTreeDepth < intStateTreeDepth) {
18
+ throw new Error("Invalid state tree depth or intermediate state tree depth");
19
+ }
20
+ const vkRegistryContractExists = await (0, utils_1.contractExists)(signer.provider, vkRegistryAddress);
21
+ // ensure we have a contract deployed at the provided address
22
+ if (!vkRegistryContractExists) {
23
+ throw new Error(`A VkRegistry contract is not deployed at ${vkRegistryAddress}`);
24
+ }
25
+ // connect to VkRegistry contract
26
+ const vkRegistryContract = contracts_1.VkRegistry__factory.connect(vkRegistryAddress, signer);
27
+ // check if the poll vk was already set
28
+ const pollJoiningVkSig = (0, core_1.genPollJoiningVkSig)(stateTreeDepth);
29
+ if (await vkRegistryContract.isPollJoiningVkSet(pollJoiningVkSig)) {
30
+ throw new Error("This poll verifying key is already set in the contract");
31
+ }
32
+ // check if the poll vk was already set
33
+ const pollJoinedVkSig = (0, core_1.genPollJoinedVkSig)(stateTreeDepth);
34
+ if (await vkRegistryContract.isPollJoinedVkSet(pollJoinedVkSig)) {
35
+ throw new Error("This poll verifying key is already set in the contract");
36
+ }
37
+ // check if the process messages vk was already set
38
+ const processVkSig = (0, core_1.genProcessVkSig)(stateTreeDepth, voteOptionTreeDepth, messageBatchSize);
39
+ if (await vkRegistryContract.isProcessVkSet(processVkSig, contracts_1.EMode.QV)) {
40
+ throw new Error("This process verifying key is already set in the contract");
41
+ }
42
+ // do the same for the tally votes vk
43
+ const tallyVkSig = (0, core_1.genTallyVkSig)(stateTreeDepth, intStateTreeDepth, voteOptionTreeDepth);
44
+ if (await vkRegistryContract.isTallyVkSet(tallyVkSig, mode)) {
45
+ throw new Error("This tally verifying key is already set in the contract");
46
+ }
47
+ // set them onchain
48
+ const tx = await vkRegistryContract.setVerifyingKeysBatch(stateTreeDepth, intStateTreeDepth, voteOptionTreeDepth, messageBatchSize, [mode], pollJoiningVk.asContractParam(), pollJoinedVk.asContractParam(), [processMessagesVk.asContractParam()], [tallyVotesVk.asContractParam()]);
49
+ const receipt = await tx.wait();
50
+ if (receipt?.status !== 1) {
51
+ throw new Error("Set verifying keys transaction failed");
52
+ }
53
+ const [pollJoiningVkOnChain, pollJoinedVkOnChain, processVkOnChain, tallyVkOnChain] = await Promise.all([
54
+ vkRegistryContract.getPollJoiningVk(stateTreeDepth),
55
+ vkRegistryContract.getPollJoinedVk(stateTreeDepth),
56
+ vkRegistryContract.getProcessVk(stateTreeDepth, voteOptionTreeDepth, messageBatchSize, mode),
57
+ vkRegistryContract.getTallyVk(stateTreeDepth, intStateTreeDepth, voteOptionTreeDepth, mode),
58
+ ]);
59
+ if (!(0, utils_2.compareVks)(pollJoiningVkOnChain, pollJoiningVk)) {
60
+ throw new Error("pollJoiningVk mismatch");
61
+ }
62
+ if (!(0, utils_2.compareVks)(pollJoinedVkOnChain, pollJoinedVk)) {
63
+ throw new Error("pollJoinedVk mismatch");
64
+ }
65
+ if (!(0, utils_2.compareVks)(processVkOnChain, processMessagesVk)) {
66
+ throw new Error("processVk mismatch");
67
+ }
68
+ if (!(0, utils_2.compareVks)(tallyVkOnChain, tallyVotesVk)) {
69
+ throw new Error("tallyVk mismatch");
70
+ }
71
+ };
72
+ exports.setVerifyingKeys = setVerifyingKeys;
73
+ //# sourceMappingURL=setVerifyingKeys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setVerifyingKeys.js","sourceRoot":"","sources":["../../../ts/verifyingKeys/setVerifyingKeys.ts"],"names":[],"mappings":";;;AAAA,wDAAgH;AAChH,8CAA8G;AAI9G,oCAA0C;AAE1C,mCAAqC;AAErC;;;GAGG;AACI,MAAM,gBAAgB,GAAG,KAAK,EAAE,EACrC,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,MAAM,EACN,IAAI,GACkB,EAAiB,EAAE;IACzC,gBAAgB;IAChB,IAAI,cAAc,GAAG,CAAC,IAAI,iBAAiB,GAAG,CAAC,IAAI,mBAAmB,GAAG,CAAC,IAAI,gBAAgB,GAAG,CAAC,EAAE,CAAC;QACnG,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IAED,IAAI,cAAc,GAAG,iBAAiB,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;IAC/E,C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