@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,4 @@
1
+ export { generateKeypair } from "./keypair";
2
+ export { generateMaciPublicKey } from "./publicKeys";
3
+ export type { IGenerateKeypairArgs, IGenerateKeypairData } from "./types";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../ts/maciKeys/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateMaciPublicKey = exports.generateKeypair = void 0;
4
+ var keypair_1 = require("./keypair");
5
+ Object.defineProperty(exports, "generateKeypair", { enumerable: true, get: function () { return keypair_1.generateKeypair; } });
6
+ var publicKeys_1 = require("./publicKeys");
7
+ Object.defineProperty(exports, "generateMaciPublicKey", { enumerable: true, get: function () { return publicKeys_1.generateMaciPublicKey; } });
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ts/maciKeys/index.ts"],"names":[],"mappings":";;;AAAA,qCAA4C;AAAnC,0GAAA,eAAe,OAAA;AACxB,2CAAqD;AAA5C,mHAAA,qBAAqB,OAAA"}
@@ -0,0 +1,9 @@
1
+ import type { IGenerateKeypairArgs, IGenerateKeypairData } from "./types";
2
+ /**
3
+ * Generate a new Maci Key Pair
4
+ * and print it to the screen
5
+ * @param {IGenerateKeypairArgs} args keypair generation params
6
+ * @returns {IGenerateKeypairData} keypair
7
+ */
8
+ export declare const generateKeypair: ({ seed }?: IGenerateKeypairArgs) => IGenerateKeypairData;
9
+ //# sourceMappingURL=keypair.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keypair.d.ts","sourceRoot":"","sources":["../../../ts/maciKeys/keypair.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE1E;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAI,WAAU,oBAAyB,KAAG,oBASrE,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateKeypair = void 0;
4
+ const domainobjs_1 = require("@maci-protocol/domainobjs");
5
+ /**
6
+ * Generate a new Maci Key Pair
7
+ * and print it to the screen
8
+ * @param {IGenerateKeypairArgs} args keypair generation params
9
+ * @returns {IGenerateKeypairData} keypair
10
+ */
11
+ const generateKeypair = ({ seed } = {}) => {
12
+ // create the new random keypair if there is no seed value
13
+ const keypair = new domainobjs_1.Keypair(seed ? new domainobjs_1.PrivateKey(seed) : undefined);
14
+ return {
15
+ publicKeyAsContractParam: keypair.publicKey.asContractParam(),
16
+ publicKey: keypair.publicKey.serialize(),
17
+ privateKey: keypair.privateKey.serialize(),
18
+ };
19
+ };
20
+ exports.generateKeypair = generateKeypair;
21
+ //# sourceMappingURL=keypair.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keypair.js","sourceRoot":"","sources":["../../../ts/maciKeys/keypair.ts"],"names":[],"mappings":";;;AAAA,0DAAgE;AAIhE;;;;;GAKG;AACI,MAAM,eAAe,GAAG,CAAC,EAAE,IAAI,KAA2B,EAAE,EAAwB,EAAE;IAC3F,0DAA0D;IAC1D,MAAM,OAAO,GAAG,IAAI,oBAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,uBAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAErE,OAAO;QACL,wBAAwB,EAAE,OAAO,CAAC,SAAS,CAAC,eAAe,EAAE;QAC7D,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,SAAS,EAAE;QACxC,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC,SAAS,EAAE;KAC3C,CAAC;AACJ,CAAC,CAAC;AATW,QAAA,eAAe,mBAS1B"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Generate a new Maci Public key from a private key
3
+ * @param privateKey - the user private key
4
+ * @param quiet - whether to log the output
5
+ * @return the public key serialized
6
+ */
7
+ export declare const generateMaciPublicKey: (privateKey: string) => string;
8
+ //# sourceMappingURL=publicKeys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publicKeys.d.ts","sourceRoot":"","sources":["../../../ts/maciKeys/publicKeys.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,YAAY,MAAM,KAAG,MAW1D,CAAC"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateMaciPublicKey = void 0;
4
+ const crypto_1 = require("@maci-protocol/crypto");
5
+ const domainobjs_1 = require("@maci-protocol/domainobjs");
6
+ /**
7
+ * Generate a new Maci Public key from a private key
8
+ * @param privateKey - the user private key
9
+ * @param quiet - whether to log the output
10
+ * @return the public key serialized
11
+ */
12
+ const generateMaciPublicKey = (privateKey) => {
13
+ // we check that the provided private key is valid
14
+ if (!domainobjs_1.PrivateKey.isValidSerialized(privateKey)) {
15
+ throw new Error("Invalid private key");
16
+ }
17
+ const unserializedKey = domainobjs_1.PrivateKey.deserialize(privateKey);
18
+ const publicKey = new domainobjs_1.PublicKey((0, crypto_1.generatePublicKey)(unserializedKey.raw));
19
+ // we give back the serialized public key
20
+ return publicKey.serialize();
21
+ };
22
+ exports.generateMaciPublicKey = generateMaciPublicKey;
23
+ //# sourceMappingURL=publicKeys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publicKeys.js","sourceRoot":"","sources":["../../../ts/maciKeys/publicKeys.ts"],"names":[],"mappings":";;;AAAA,kDAA0D;AAC1D,0DAAkE;AAElE;;;;;GAKG;AACI,MAAM,qBAAqB,GAAG,CAAC,UAAkB,EAAU,EAAE;IAClE,kDAAkD;IAClD,IAAI,CAAC,uBAAU,CAAC,iBAAiB,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACzC,CAAC;IAED,MAAM,eAAe,GAAG,uBAAU,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAC3D,MAAM,SAAS,GAAG,IAAI,sBAAS,CAAC,IAAA,0BAAiB,EAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC;IAExE,yCAAyC;IACzC,OAAO,SAAS,CAAC,SAAS,EAAE,CAAC;AAC/B,CAAC,CAAC;AAXW,QAAA,qBAAqB,yBAWhC"}
@@ -0,0 +1,28 @@
1
+ import { type IG1ContractParams } from "@maci-protocol/domainobjs";
2
+ /**
3
+ * Interface for the arguments for generate keypair command
4
+ */
5
+ export interface IGenerateKeypairArgs {
6
+ /**
7
+ * Seed value for keypair
8
+ */
9
+ seed?: bigint;
10
+ }
11
+ /**
12
+ * Interface for the return data type for generate keypair command
13
+ */
14
+ export interface IGenerateKeypairData {
15
+ /**
16
+ * Serialized public key as contract parameter
17
+ */
18
+ publicKeyAsContractParam: IG1ContractParams;
19
+ /**
20
+ * Serialized public key
21
+ */
22
+ publicKey: string;
23
+ /**
24
+ * Serialized private key
25
+ */
26
+ privateKey: string;
27
+ }
28
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../ts/maciKeys/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,wBAAwB,EAAE,iBAAiB,CAAC;IAE5C;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB"}
@@ -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/maciKeys/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ export { getPoll, getPollParams } from "./poll";
2
+ export { getPollContracts } from "./utils";
3
+ export type { IGetPollArgs, IGetPollData, IGetPollParamsArgs, IPollParams, IPollJoiningInputs, IPollJoinedInputs, } from "./types";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../ts/poll/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,SAAS,CAAC"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPollContracts = exports.getPollParams = exports.getPoll = void 0;
4
+ var poll_1 = require("./poll");
5
+ Object.defineProperty(exports, "getPoll", { enumerable: true, get: function () { return poll_1.getPoll; } });
6
+ Object.defineProperty(exports, "getPollParams", { enumerable: true, get: function () { return poll_1.getPollParams; } });
7
+ var utils_1 = require("./utils");
8
+ Object.defineProperty(exports, "getPollContracts", { enumerable: true, get: function () { return utils_1.getPollContracts; } });
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ts/poll/index.ts"],"names":[],"mappings":";;;AAAA,+BAAgD;AAAvC,+FAAA,OAAO,OAAA;AAAE,qGAAA,aAAa,OAAA;AAC/B,iCAA2C;AAAlC,yGAAA,gBAAgB,OAAA"}
@@ -0,0 +1,14 @@
1
+ import type { IGetPollArgs, IGetPollData, IGetPollParamsArgs, IPollParams } from "./types";
2
+ /**
3
+ * Get deployed poll from MACI contract
4
+ * @param {IGetPollArgs} args - The arguments for the get poll command
5
+ * @returns {IGetPollData} poll data
6
+ */
7
+ export declare const getPoll: ({ maciAddress, signer, provider, pollId }: IGetPollArgs) => Promise<IGetPollData>;
8
+ /**
9
+ * Get the parameters for the poll
10
+ * @param {IGetPollParamsArgs} args - The arguments for the get poll command
11
+ * @returns {IPollParams} poll parameters
12
+ */
13
+ export declare const getPollParams: ({ pollId, signer, maciContractAddress, }: IGetPollParamsArgs) => Promise<IPollParams>;
14
+ //# sourceMappingURL=poll.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"poll.d.ts","sourceRoot":"","sources":["../../../ts/poll/poll.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAI3F;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAU,2CAA2C,YAAY,KAAG,OAAO,CAAC,YAAY,CA+B3G,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAU,0CAIjC,kBAAkB,KAAG,OAAO,CAAC,WAAW,CAwB1C,CAAC"}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPollParams = exports.getPoll = void 0;
4
+ const utils_1 = require("./utils");
5
+ /**
6
+ * Get deployed poll from MACI contract
7
+ * @param {IGetPollArgs} args - The arguments for the get poll command
8
+ * @returns {IGetPollData} poll data
9
+ */
10
+ const getPoll = async ({ maciAddress, signer, provider, pollId }) => {
11
+ if (!signer && !provider) {
12
+ throw new Error("No signer and provider are provided");
13
+ }
14
+ const { id, poll: pollContract, tally: tallyContract, } = await (0, utils_1.getPollContracts)({ maciAddress, pollId, signer, provider });
15
+ const [[startDate, endDate], mergedStateRoot, pollAddress] = await Promise.all([
16
+ pollContract.getStartAndEndDate(),
17
+ pollContract.mergedStateRoot(),
18
+ pollContract.getAddress(),
19
+ ]);
20
+ const isMerged = mergedStateRoot !== 0n;
21
+ const totalSignups = await pollContract.totalSignups();
22
+ // get the poll mode
23
+ const mode = await tallyContract.mode();
24
+ return {
25
+ id,
26
+ address: pollAddress,
27
+ startDate,
28
+ endDate,
29
+ totalSignups,
30
+ isMerged,
31
+ mode,
32
+ };
33
+ };
34
+ exports.getPoll = getPoll;
35
+ /**
36
+ * Get the parameters for the poll
37
+ * @param {IGetPollParamsArgs} args - The arguments for the get poll command
38
+ * @returns {IPollParams} poll parameters
39
+ */
40
+ const getPollParams = async ({ pollId, signer, maciContractAddress, }) => {
41
+ // get the contract objects
42
+ const { poll: pollContract } = await (0, utils_1.getPollContracts)({
43
+ maciAddress: maciContractAddress,
44
+ pollId,
45
+ signer,
46
+ });
47
+ const treeDepths = await pollContract.treeDepths();
48
+ const voteOptionTreeDepth = Number(treeDepths.voteOptionTreeDepth);
49
+ const totalVoteOptions = 5 ** voteOptionTreeDepth;
50
+ const messageBatchSize = Number.parseInt((await pollContract.messageBatchSize()).toString(), 10);
51
+ const tallyProcessingStateTreeDepth = Number(treeDepths.tallyProcessingStateTreeDepth);
52
+ const tallyBatchSize = 5 ** tallyProcessingStateTreeDepth;
53
+ return {
54
+ messageBatchSize,
55
+ totalVoteOptions,
56
+ tallyBatchSize,
57
+ voteOptionTreeDepth,
58
+ tallyProcessingStateTreeDepth,
59
+ };
60
+ };
61
+ exports.getPollParams = getPollParams;
62
+ //# sourceMappingURL=poll.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"poll.js","sourceRoot":"","sources":["../../../ts/poll/poll.ts"],"names":[],"mappings":";;;AAEA,mCAA2C;AAE3C;;;;GAIG;AACI,MAAM,OAAO,GAAG,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAgB,EAAyB,EAAE;IAC9G,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzD,CAAC;IAED,MAAM,EACJ,EAAE,EACF,IAAI,EAAE,YAAY,EAClB,KAAK,EAAE,aAAa,GACrB,GAAG,MAAM,IAAA,wBAAgB,EAAC,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IAEtE,MAAM,CAAC,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,eAAe,EAAE,WAAW,CAAC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AChB,gBAAgB;QAChB,cAAc;QACd,mBAAmB;QACnB,6BAA6B;KAC9B,CAAC;AACJ,CAAC,CAAC;AA5BW,QAAA,aAAa,iBA4BxB"}
@@ -0,0 +1,151 @@
1
+ import type { Poll, MessageProcessor, Tally, MACI } from "@maci-protocol/contracts/typechain-types";
2
+ import type { BigNumberish, Provider, Signer } from "ethers";
3
+ /**
4
+ * Interface for the arguments to the get poll command
5
+ */
6
+ export interface IGetPollArgs {
7
+ /**
8
+ * A signer object
9
+ */
10
+ signer?: Signer;
11
+ /**
12
+ * A provider fallback object
13
+ */
14
+ provider?: Provider;
15
+ /**
16
+ * The address of the MACI contract
17
+ */
18
+ maciAddress: string;
19
+ /**
20
+ * The poll id. If not specified, latest poll id will be used
21
+ */
22
+ pollId?: BigNumberish;
23
+ }
24
+ /**
25
+ * Interface that represents get poll contracts data
26
+ */
27
+ export interface IGetPollContractsData {
28
+ /**
29
+ * Poll id
30
+ */
31
+ id: bigint;
32
+ /**
33
+ * MACI contract
34
+ */
35
+ maci: MACI;
36
+ /**
37
+ * Poll contract
38
+ */
39
+ poll: Poll;
40
+ /**
41
+ * MessageProcessor contract
42
+ */
43
+ messageProcessor: MessageProcessor;
44
+ /**
45
+ * Tally contract
46
+ */
47
+ tally: Tally;
48
+ }
49
+ /**
50
+ * Interface for the return data to the get poll command
51
+ */
52
+ export interface IGetPollData {
53
+ /**
54
+ * The poll id
55
+ */
56
+ id: BigNumberish;
57
+ /**
58
+ * The poll address
59
+ */
60
+ address: string;
61
+ /**
62
+ * The poll deployment timestamp
63
+ */
64
+ startDate: BigNumberish;
65
+ /**
66
+ * The poll end timestamp
67
+ */
68
+ endDate: BigNumberish;
69
+ /**
70
+ * The poll number of signups
71
+ */
72
+ totalSignups: BigNumberish;
73
+ /**
74
+ * Whether the MACI contract's state root has been merged
75
+ */
76
+ isMerged: boolean;
77
+ /**
78
+ * Mode of the poll
79
+ */
80
+ mode: BigNumberish;
81
+ }
82
+ /**
83
+ * Arguments for the get poll params command
84
+ */
85
+ export interface IGetPollParamsArgs {
86
+ /**
87
+ * The poll id
88
+ */
89
+ pollId: bigint;
90
+ /**
91
+ * The signer
92
+ */
93
+ signer: Signer;
94
+ /**
95
+ * The MACI contract address
96
+ */
97
+ maciContractAddress: string;
98
+ }
99
+ /**
100
+ * Poll parameters
101
+ */
102
+ export interface IPollParams {
103
+ /**
104
+ * The message batch size
105
+ */
106
+ messageBatchSize: number;
107
+ /**
108
+ * The number of vote options
109
+ */
110
+ totalVoteOptions: number;
111
+ /**
112
+ * Tally Batch Size
113
+ */
114
+ tallyBatchSize: number;
115
+ /**
116
+ * The vote option tree depth
117
+ */
118
+ voteOptionTreeDepth: number;
119
+ /**
120
+ * The depth of the tree holding the user ballots
121
+ */
122
+ tallyProcessingStateTreeDepth: number;
123
+ }
124
+ /**
125
+ * Inputs for circuit PollJoining
126
+ */
127
+ export interface IPollJoiningInputs {
128
+ privateKey: bigint;
129
+ pollPublicKey: bigint[][];
130
+ stateLeaf: bigint[];
131
+ siblings: bigint[][];
132
+ indices: bigint[];
133
+ nullifier: bigint;
134
+ credits: bigint;
135
+ stateRoot: bigint;
136
+ actualStateTreeDepth: bigint;
137
+ pollId: bigint;
138
+ }
139
+ /**
140
+ * Inputs for circuit PollJoined
141
+ */
142
+ export interface IPollJoinedInputs {
143
+ privateKey: bigint;
144
+ voiceCreditsBalance: bigint;
145
+ stateLeaf: bigint[];
146
+ pathElements: bigint[][];
147
+ pathIndices: bigint[];
148
+ credits: bigint;
149
+ stateRoot: bigint;
150
+ }
151
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../ts/poll/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,0CAA0C,CAAC;AACpG,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,MA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M,CAAC;IAE5B;;OAEG;IACH,6BAA6B,EAAE,MAAM,CAAC;CACvC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,EAAE,EAAE,CAAC;IAC1B,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,EAAE,MAAM,EAAE,EAAE,CAAC;IACzB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB"}
@@ -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/poll/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import type { IGetPollArgs, IGetPollContractsData } from "./types";
2
+ /**
3
+ * Get poll contracts
4
+ *
5
+ * @param args get poll contract args
6
+ * @returns poll contracts
7
+ */
8
+ export declare const getPollContracts: ({ maciAddress, pollId, signer, provider, }: IGetPollArgs) => Promise<IGetPollContractsData>;
9
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../ts/poll/utils.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAInE;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAU,4CAKpC,YAAY,KAAG,OAAO,CAAC,qBAAqB,CAqC9C,CAAC"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPollContracts = void 0;
4
+ const typechain_types_1 = require("@maci-protocol/contracts/typechain-types");
5
+ const ethers_1 = require("ethers");
6
+ const contracts_1 = require("../utils/contracts");
7
+ /**
8
+ * Get poll contracts
9
+ *
10
+ * @param args get poll contract args
11
+ * @returns poll contracts
12
+ */
13
+ const getPollContracts = async ({ maciAddress, pollId, signer, provider, }) => {
14
+ const maci = typechain_types_1.MACI__factory.connect(maciAddress, signer ?? provider);
15
+ const id = pollId === undefined ? await maci.nextPollId().then((nextPollId) => nextPollId - 1n) : BigInt(pollId);
16
+ if (id < 0n) {
17
+ throw new Error(`Invalid poll id ${id}`);
18
+ }
19
+ const isMaciExists = await (0, contracts_1.contractExists)(signer?.provider || provider, maciAddress);
20
+ if (!isMaciExists) {
21
+ throw new Error("MACI contract does not exist");
22
+ }
23
+ const pollContracts = await maci.polls(id);
24
+ if (pollContracts.poll === ethers_1.ZeroAddress) {
25
+ throw new Error(`MACI contract doesn't have any deployed poll ${id}`);
26
+ }
27
+ const isPollExists = await (0, contracts_1.contractExists)(signer?.provider || provider, pollContracts.poll);
28
+ if (!isPollExists) {
29
+ throw new Error("Poll contract does not exist");
30
+ }
31
+ const poll = typechain_types_1.Poll__factory.connect(pollContracts.poll, signer ?? provider);
32
+ const messageProcessor = typechain_types_1.MessageProcessor__factory.connect(pollContracts.messageProcessor, signer ?? provider);
33
+ const tally = typechain_types_1.Tally__factory.connect(pollContracts.tally, signer ?? provider);
34
+ return {
35
+ id,
36
+ maci,
37
+ poll,
38
+ messageProcessor,
39
+ tally,
40
+ };
41
+ };
42
+ exports.getPollCont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AAC;IAE7F,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAClD,CAAC;IAED,MAAM,IAAI,GAAG,+BAAW,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,IAAI,QAAQ,CAAC,CAAC;IACzE,MAAM,gBAAgB,GAAG,2CAAuB,CAAC,OAAO,CAAC,aAAa,CAAC,gBAAgB,EAAE,MAAM,IAAI,QAAQ,CAAC,CAAC;IAC7G,MAAM,KAAK,GAAG,gCAAY,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,EAAE,MAAM,IAAI,QAAQ,CAAC,CAAC;IAE5E,OAAO;QACL,EAAE;QACF,IAAI;QACJ,IAAI;QACJ,gBAAgB;QAChB,KAAK;KACN,CAAC;AACJ,CAAC,CAAC;AA1CW,QAAA,gBAAgB,oBA0C3B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=download.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"download.test.d.ts","sourceRoot":"","sources":["../../../../ts/proof/__tests__/download.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const contracts_1 = require("@maci-protocol/contracts");
4
+ const download_1 = require("../download");
5
+ /**
6
+ * The inputs for the proof generation
7
+ */
8
+ const inputs = {
9
+ privateKey: "1259082279488355278660453796037744749156697484507442909424227073450806091599",
10
+ pollPublicKey: [
11
+ "4604149953291977424931588219098726306922992659857425248363017596008978179462",
12
+ "1911350329545195833133079763781611226710101140694516439580176096139978229522",
13
+ ],
14
+ siblings: [
15
+ ["1309255631273308531193241901289907343161346846555918942743921933037802809814"],
16
+ ["0"],
17
+ ["0"],
18
+ ["0"],
19
+ ["0"],
20
+ ["0"],
21
+ ["0"],
22
+ ["0"],
23
+ ["0"],
24
+ ["0"],
25
+ ],
26
+ index: 1,
27
+ nullifier: "5960968591926285526739882209300764345427591192846309606519433839944864771425",
28
+ stateRoot: "19853258600018552129206808764461795697997153860385513081821578400505176714352",
29
+ actualStateTreeDepth: "1",
30
+ pollId: "0",
31
+ };
32
+ describe("downloadPollJoiningArtifactsBrowser", () => {
33
+ it("should allow to generate a proof using the downloaded artifacts", async () => {
34
+ const { zKey, wasm } = await (0, download_1.downloadPollJoiningArtifactsBrowser)({
35
+ testing: true,
36
+ stateTreeDepth: 10,
37
+ });
38
+ expect(zKey).toBeDefined();
39
+ expect(wasm).toBeDefined();
40
+ const { proof } = await (0, contracts_1.generateProofSnarkjs)({
41
+ inputs: inputs,
42
+ zkeyPath: zKey,
43
+ wasmPath: wasm,
44
+ });
45
+ expect(proof).toBeDefined();
46
+ expect(proof.protocol).toBe("groth16");
47
+ expect(proof.pi_a.length).toBe(3);
48
+ expect(proof.pi_b.length).toBe(3);
49
+ expect(proof.pi_c.length).toBe(3);
50
+ expect(proof.curve).toBe("bn128");
51
+ });
52
+ });
53
+ //# sourceMappingURL=download.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"download.test.js","sourceRoot":"","sources":["../../../../ts/proof/__tests__/download.test.ts"],"names":[],"mappings":";;AAAA,wDAAgE;AAGhE,0CAAkE;AAElE;;GAEG;AACH,MAAM,MAAM,GAAG;IACb,UAAU,EAAE,8EAA8E;IAC1F,aAAa,EAAE;QACb,8EAA8E;QAC9E,8EAA8E;KAC/E;IACD,QAAQ,EAAE;QACR,CAAC,8EAA8E,CAAC;QAChF,CAAC,GAAG,CAAC;QACL,CAAC,GAAG,CAAC;QACL,CAAC,GAAG,CAAC;QACL,CAAC,GAAG,CAAC;QACL,CAAC,GAAG,CAAC;QACL,CAAC,GAAG,CAAC;QACL,CAAC,GAAG,CAAC;QACL,CAAC,GAAG,CAAC;QACL,CAAC,GAAG,CAAC;KACN;IACD,KAAK,EAAE,CAAC;IACR,SAAS,EAAE,8EAA8E;IACzF,SAAS,EAAE,+EAA+E;IAC1F,oBAAoB,EAAE,GAAG;IACzB,MAAM,EAAE,GAAG;CACZ,CAAC;AAEF,QAAQ,CAAC,qCAAqC,EAAE,GAAG,EAAE;IACnD,EAAE,CAAC,iEAAiE,EAAE,KAAK,IAAI,EAAE;QAC/E,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,MAAM,IAAA,8CAAmC,EAAC;YAC/D,OAAO,EAAE,IAAI;YACb,cAAc,EAAE,EAAE;SACnB,CAAC,CAAC;QAEH,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;QAC3B,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;QAE3B,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAA,gCAAoB,EAAC;YAC3C,MAAM,EAAE,MAAmC;YAC3C,QAAQ,EAAE,IAAyB;YACnC,QAAQ,EAAE,IAAyB;SACpC,CAAC,CAAC;QAEH,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;QAC5B,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACvC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { IDownloadPollJoiningArtifactsBrowserArgs, IPollJoiningArtifacts } from "./types";
2
+ /**
3
+ * Download the poll joining artifacts for the browser
4
+ *
5
+ * @param args - The arguments to download the poll joining artifacts for the browser
6
+ * @returns The poll joining artifacts
7
+ */
8
+ export declare const downloadPollJoiningArtifactsBrowser: ({ testing, stateTreeDepth, }: IDownloadPollJoiningArtifactsBrowserArgs) => Promise<IPollJoiningArtifacts>;
9
+ //# sourceMappingURL=download.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../../ts/proof/download.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wCAAwC,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAuC/F;;;;;GAKG;AACH,eAAO,MAAM,mCAAmC,GAAU,8BAGvD,wCAAwC,KAAG,OAAO,CAAC,qBAAqB,CAe1E,CAAC"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.downloadPollJoiningArtifactsBrowser = void 0;
4
+ const utils_1 = require("./utils");
5
+ /**
6
+ * Read the chunks of a response
7
+ *
8
+ * @param response - The response to read the chunks from
9
+ * @returns The chunks and the length
10
+ */
11
+ const readChunks = async (reader) => {
12
+ let result = await reader.read();
13
+ const chunks = [];
14
+ let length = 0;
15
+ while (!result.done) {
16
+ const { value } = result;
17
+ length += value.length;
18
+ chunks.push(value);
19
+ // continue reading
20
+ // eslint-disable-next-line no-await-in-loop
21
+ result = await reader.read();
22
+ }
23
+ const { acc: obj } = chunks.reduce(({ acc, position }, chunk) => {
24
+ acc.set(chunk, position);
25
+ return { acc, position: position + chunk.length };
26
+ }, { acc: new Uint8Array(length), position: 0 });
27
+ return obj;
28
+ };
29
+ /**
30
+ * Download the poll joining artifacts for the browser
31
+ *
32
+ * @param args - The arguments to download the poll joining artifacts for the browser
33
+ * @returns The poll joining artifacts
34
+ */
35
+ const downloadPollJoiningArtifactsBrowser = async ({ testing = false, stateTreeDepth, }) => {
36
+ const { zKeyUrl, wasmUrl } = (0, utils_1.getPollJoiningArtifactsUrl)(testing, stateTreeDepth);
37
+ const [zKeyResponse, wasmResponse] = await Promise.all([fetch(zKeyUrl), fetch(wasmUrl)]);
38
+ const zKeyReader = zKeyResponse.body?.getReader();
39
+ const wasmReader = wasmResponse.body?.getReader();
40
+ if (!zKeyReader || !wasmReader) {
41
+ throw new Error("Failed to read zKey or wasm");
42
+ }
43
+ const [zKey, wasm] = await Promise.all([readChunks(zKeyReader), readChunks(wasmReader)]);
44
+ return { zKey, wasm };
45
+ };
46
+ exports.downloadPollJoiningArtifactsBrowser = downloadPollJoiningArtifactsBrowser;
47
+ //# sourceMappingURL=download.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"download.js","sourceRoot":"","sources":["../../../ts/proof/download.ts"],"names":[],"mappings":";;;AAEA,mCAAqD;AAErD;;;;;GAKG;AACH,MAAM,UAAU,GAAG,KAAK,EAAE,MAA+C,EAAuB,EAAE;IAChG,IAAI,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;IAEjC,MAAM,MAAM,GAAiB,EAAE,CAAC;IAChC,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;QAEzB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;QACvB,MAAM,CAAC,IAAI,CAAC,KAA8B,CAAC,CAAC;QAE5C,mBAAmB;QACnB,4CAA4C;QAC5C,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;IAC/B,CAAC;IAED,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC,MAAM,CAChC,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,KAAK,EAAE,EAAE;QAC3B,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAEzB,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;IACpD,CAAC,EACD,EAAE,GAAG,EAAE,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,CAC7C,CAAC;IAEF,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF;;;;;GAKG;AACI,MAAM,mCAAmC,GAAG,KAAK,EAAE,EACxD,OAAO,GAAG,KAAK,EACf,cAAc,GAC2B,EAAkC,EAAE;IAC7E,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,IAAA,kCAA0B,EAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAEjF,MAAM,CAAC,YAAY,EAAE,YAAY,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAEzF,MAAM,UAAU,GAAG,YAAY,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC;IAClD,MAAM,UAAU,GAAG,YAAY,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC;IAElD,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACjD,CAAC;IAED,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAEzF,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACxB,CAAC,CAAC;AAlBW,QAAA,mCAAmC,uCAkB9C"}
@@ -0,0 +1,8 @@
1
+ import type { IGenerateProofsArgs, IGenerateProofsData } from "./types";
2
+ /**
3
+ * Generate proofs for the message processing and tally calculations
4
+ * @param args - The arguments for the generateProofs command
5
+ * @returns The tally data
6
+ */
7
+ export declare const generateProofs: ({ outputDir, coordinatorPrivateKey, signer, maciAddress, pollId, ipfsMessageBackupFiles, stateFile, transactionHash, startBlock, endBlock, blocksPerBatch, rapidsnark, mode, voteTallyZkey, voteTallyWitnessGenerator, voteTallyWasm, messageProcessorZkey, messageProcessorWitnessGenerator, messageProcessorWasm, messageProcessorWitnessDatFile, voteTallyWitnessDatFile, tallyFile, useWasm, }: IGenerateProofsArgs) => Promise<IGenerateProofsData>;
8
+ //# sourceMappingURL=generate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../ts/proof/generate.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAKxE;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAU,oYAwBlC,mBAAmB,KAAG,OAAO,CAAC,mBAAmB,CAgJnD,CAAC"}