@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,127 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getMerkleProofPolicyData = exports.getEASPolicyData = exports.getZupassPolicyData = exports.getSemaphorePolicyData = exports.getPolicyContractNamesByTrait = exports.getPolicyTrait = void 0;
4
+ const contracts_1 = require("@maci-protocol/contracts");
5
+ const typechain_types_1 = require("@maci-protocol/contracts/typechain-types");
6
+ const types_1 = require("./types");
7
+ /**
8
+ * Get the policy type of the MACI contract
9
+ * @param IGetPolicyTraitArgs - The arguments for the get policy type command
10
+ * @returns The policy type
11
+ */
12
+ const getPolicyTrait = async ({ maciAddress, signer }) => {
13
+ const maciContract = typechain_types_1.MACI__factory.connect(maciAddress, signer);
14
+ // get the address of the signup policy
15
+ const policyContractAddress = await maciContract.signUpPolicy();
16
+ const policyContract = typechain_types_1.IBasePolicy__factory.connect(policyContractAddress, signer);
17
+ const policyType = await policyContract.trait();
18
+ return policyType;
19
+ };
20
+ exports.getPolicyTrait = getPolicyTrait;
21
+ const POLICY_CONTRACT_NAMES_BY_TRAIT = {
22
+ [types_1.EPolicyTrait.EAS]: contracts_1.EPolicies.EAS,
23
+ [types_1.EPolicyTrait.FreeForAll]: contracts_1.EPolicies.FreeForAll,
24
+ [types_1.EPolicyTrait.GitcoinPassport]: contracts_1.EPolicies.GitcoinPassport,
25
+ [types_1.EPolicyTrait.Hats]: contracts_1.EPolicies.Hats,
26
+ [types_1.EPolicyTrait.Semaphore]: contracts_1.EPolicies.Semaphore,
27
+ [types_1.EPolicyTrait.Token]: contracts_1.EPolicies.Token,
28
+ [types_1.EPolicyTrait.Zupass]: contracts_1.EPolicies.Zupass,
29
+ [types_1.EPolicyTrait.MerkleProof]: contracts_1.EPolicies.MerkleProof,
30
+ };
31
+ /**
32
+ * Get policy contract names associated with the trait provided.
33
+ *
34
+ * @param trait the policy trait
35
+ * @returns the policy contract names
36
+ */
37
+ const getPolicyContractNamesByTrait = (trait) => POLICY_CONTRACT_NAMES_BY_TRAIT[trait];
38
+ exports.getPolicyContractNamesByTrait = getPolicyContractNamesByTrait;
39
+ /**
40
+ * Get the semaphore policy data
41
+ * @param IGetSemaphorePolicyDataArgs - The arguments for the get semaphore policy data command
42
+ * @returns The semaphore policy data
43
+ */
44
+ const getSemaphorePolicyData = async ({ maciAddress, signer, }) => {
45
+ const maciContract = typechain_types_1.MACI__factory.connect(maciAddress, signer);
46
+ // get the address of the signup policy
47
+ const policyContractAddress = await maciContract.signUpPolicy();
48
+ const policyContract = typechain_types_1.SemaphorePolicy__factory.connect(policyContractAddress, signer);
49
+ const checkerAddress = await policyContract.BASE_CHECKER();
50
+ const checkerContract = typechain_types_1.SemaphoreChecker__factory.connect(checkerAddress, signer);
51
+ // get the group ID and semaphore contract address
52
+ const [groupId, semaphoreContractAddress] = await Promise.all([
53
+ checkerContract.groupId(),
54
+ checkerContract.semaphore(),
55
+ ]);
56
+ return {
57
+ address: semaphoreContractAddress,
58
+ groupId: groupId.toString(),
59
+ };
60
+ };
61
+ exports.getSemaphorePolicyData = getSemaphorePolicyData;
62
+ /**
63
+ * Get the zupass policy data
64
+ * @param IGetPolicyDataArgs - The arguments for the get zupass policy data command
65
+ * @returns The zupass policy data
66
+ */
67
+ const getZupassPolicyData = async ({ maciAddress, signer }) => {
68
+ const maciContract = typechain_types_1.MACI__factory.connect(maciAddress, signer);
69
+ // get the address of the signup policy
70
+ const policyContractAddress = await maciContract.signUpPolicy();
71
+ const policyContract = typechain_types_1.ZupassPolicy__factory.connect(policyContractAddress, signer);
72
+ const checkerAddress = await policyContract.BASE_CHECKER();
73
+ const checkerContract = typechain_types_1.ZupassChecker__factory.connect(checkerAddress, signer);
74
+ const [validEventId, validSigner1, validSigner2] = await Promise.all([
75
+ checkerContract.validEventId(),
76
+ checkerContract.validSigner1(),
77
+ checkerContract.validSigner2(),
78
+ ]);
79
+ return {
80
+ eventId: validEventId.toString(),
81
+ signer1: validSigner1.toString(),
82
+ signer2: validSigner2.toString(),
83
+ };
84
+ };
85
+ exports.getZupassPolicyData = getZupassPolicyData;
86
+ /**
87
+ * Get the EAS policy data
88
+ * @param IGetPolicyDataArgs - The arguments for the get eas policy data command
89
+ * @returns The eas policy data
90
+ */
91
+ const getEASPolicyData = async ({ maciAddress, signer }) => {
92
+ const maciContract = typechain_types_1.MACI__factory.connect(maciAddress, signer);
93
+ const policyContractAddress = await maciContract.signUpPolicy();
94
+ const policyContract = typechain_types_1.EASPolicy__factory.connect(policyContractAddress, signer);
95
+ const checkerAddress = await policyContract.BASE_CHECKER();
96
+ const checkerContract = typechain_types_1.EASChecker__factory.connect(checkerAddress, signer);
97
+ const [eas, schema, attester] = await Promise.all([
98
+ checkerContract.eas(),
99
+ checkerContract.schema(),
100
+ checkerContract.attester(),
101
+ ]);
102
+ return {
103
+ eas: eas.toString(),
104
+ schema: schema.toString(),
105
+ attester: attester.toString(),
106
+ };
107
+ };
108
+ exports.getEASPolicyData = getEASPolicyData;
109
+ /**
110
+ * Get the merkleproof policy data
111
+ * @param IGetPolicyDataArgs - The arguments for the get merkleproof policy data command
112
+ * @returns The merkleproof policy data
113
+ */
114
+ const getMerkleProofPolicyData = async ({ maciAddress, signer, }) => {
115
+ const maciContract = typechain_types_1.MACI__factory.connect(maciAddress, signer);
116
+ // get the address of the signup policy
117
+ const policyContractAddress = await maciContract.signUpPolicy();
118
+ const policyContract = typechain_types_1.MerkleProofPolicy__factory.connect(policyContractAddress, signer);
119
+ const checkerAddress = await policyContract.BASE_CHECKER();
120
+ const checkerContract = contracts_1.MerkleProofChecker__factory.connect(checkerAddress, signer);
121
+ const [validRoot] = await Promise.all([checkerContract.root()]);
122
+ return {
123
+ root: validRoot.toString(),
124
+ };
125
+ };
126
+ exports.getMerkleProofPolicyData = getMerkleProofPolicyData;
127
+ //# sourceMappingURL=policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.js","sourceRoot":"","sources":["../../../ts/maci/policy.ts"],"names":[],"mappings":";;;AAAA,wDAA+G;AAC/G,8EAUkD;AAWlD,mCAAuC;AAEvC;;;;GAIG;AACI,MAAM,cAAc,GAAG,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,EAAuB,EAAyB,EAAE;IAC1G,MAAM,YAAY,GAAG,+BAAW,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC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,CAAC,CAAC;IAE9D,uCAAuC;IACvC,MAAM,qBAAqB,GAAG,MAAM,YAAY,CAAC,YAAY,EAAE,CAAC;IAEhE,MAAM,cAAc,GAAG,4CAAwB,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;IACvF,MAAM,cAAc,GAAG,MAAM,cAAc,CAAC,YAAY,EAAE,CAAC;IAC3D,MAAM,eAAe,GAAG,uCAAyB,CAAC,OAAO,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;IAElF,MAAM,CAAC,SAAS,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAEhE,OAAO;QACL,IAAI,EAAE,SAAS,CAAC,QAAQ,EAAE;KAC3B,CAAC;AACJ,CAAC,CAAC;AAlBW,QAAA,wBAAwB,4BAkBnC"}
@@ -0,0 +1,8 @@
1
+ import type { IGenerateMaciStateArgs } from "./types";
2
+ import type { MaciState } from "@maci-protocol/core";
3
+ /**
4
+ * Generate a local MACI state from the smart contracts events
5
+ * @param args The arguments for the genLocalState command
6
+ */
7
+ export declare const generateMaciState: ({ outputPath, pollId, maciAddress, coordinatorPrivateKey, provider, endBlock, startBlock, blockPerBatch, transactionHash, sleep, signer, ipfsMessageBackupFiles, logsOutputPath, }: IGenerateMaciStateArgs) => Promise<MaciState>;
8
+ //# sourceMappingURL=state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../ts/maci/state.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAIrD;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAU,oLAcrC,sBAAsB,KAAG,OAAO,CAAC,SAAS,CAgF5C,CAAC"}
@@ -0,0 +1,82 @@
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.generateMaciState = void 0;
7
+ const contracts_1 = require("@maci-protocol/contracts");
8
+ const domainobjs_1 = require("@maci-protocol/domainobjs");
9
+ const ethers_1 = require("ethers");
10
+ const fs_1 = __importDefault(require("fs"));
11
+ const utils_1 = require("../utils");
12
+ /**
13
+ * Generate a local MACI state from the smart contracts events
14
+ * @param args The arguments for the genLocalState command
15
+ */
16
+ const generateMaciState = async ({ outputPath, pollId, maciAddress, coordinatorPrivateKey, provider, endBlock, startBlock, blockPerBatch, transactionHash, sleep, signer, ipfsMessageBackupFiles, logsOutputPath, }) => {
17
+ if (!maciAddress) {
18
+ throw new Error("MACI contract address is empty");
19
+ }
20
+ const isMaciExists = await (0, utils_1.contractExists)(signer.provider, maciAddress);
21
+ if (!isMaciExists) {
22
+ throw new Error("MACI contract does not exist");
23
+ }
24
+ // if no private key is passed we ask it securely
25
+ if (!domainobjs_1.PrivKey.isValidSerializedPrivKey(coordinatorPrivateKey)) {
26
+ throw new Error("Invalid MACI private key");
27
+ }
28
+ const coordinatorMaciPrivKey = domainobjs_1.PrivKey.deserialize(coordinatorPrivateKey);
29
+ const coordinatorKeypair = new domainobjs_1.Keypair(coordinatorMaciPrivKey);
30
+ const maciContract = contracts_1.MACI__factory.connect(maciAddress, signer);
31
+ const pollContracts = await maciContract.polls(pollId);
32
+ const isPollExists = await (0, utils_1.contractExists)(signer.provider, pollContracts.poll);
33
+ if (!isPollExists) {
34
+ throw new Error("Poll contract does not exist");
35
+ }
36
+ const pollContract = contracts_1.Poll__factory.connect(pollContracts.poll, signer);
37
+ const [defaultStartBlockSignup, defaultStartBlockPoll, stateRoot, numSignups] = await Promise.all([
38
+ maciContract.queryFilter(maciContract.filters.SignUp(), startBlock).then((events) => events[0]?.blockNumber ?? 0),
39
+ maciContract
40
+ .queryFilter(maciContract.filters.DeployPoll(), startBlock)
41
+ .then((events) => events[0]?.blockNumber ?? 0),
42
+ maciContract.getStateTreeRoot(),
43
+ maciContract.numSignUps(),
44
+ ]);
45
+ const defaultStartBlock = Math.min(defaultStartBlockPoll, defaultStartBlockSignup);
46
+ let fromBlock = startBlock ? Number(startBlock) : defaultStartBlock;
47
+ const defaultEndBlock = await Promise.all([
48
+ pollContract
49
+ .queryFilter(pollContract.filters.MergeState(stateRoot, numSignups), fromBlock)
50
+ .then((events) => events[events.length - 1]?.blockNumber),
51
+ ]).then((blocks) => Math.max(...blocks));
52
+ if (transactionHash) {
53
+ const tx = await signer.provider.getTransaction(transactionHash);
54
+ fromBlock = tx?.blockNumber ?? defaultStartBlock;
55
+ }
56
+ // calculate the end block number
57
+ const endBlockNumber = endBlock || defaultEndBlock;
58
+ if (transactionHash) {
59
+ const tx = await signer.provider.getTransaction(transactionHash);
60
+ fromBlock = tx?.blockNumber ?? defaultStartBlock;
61
+ }
62
+ const maciState = await (0, contracts_1.genMaciStateFromContract)({
63
+ provider: provider ? new ethers_1.JsonRpcProvider(provider) : signer.provider,
64
+ address: maciAddress,
65
+ coordinatorKeypair,
66
+ pollId,
67
+ fromBlock,
68
+ blocksPerRequest: blockPerBatch || 50,
69
+ endBlock: endBlockNumber,
70
+ sleepAmount: sleep,
71
+ ipfsMessageBackupFiles,
72
+ logsOutputPath,
73
+ });
74
+ // write the state to a file
75
+ if (outputPath) {
76
+ const serializedState = maciState.toJSON();
77
+ await fs_1.default.promises.writeFile(outputPath, JSON.stringify(serializedState, null, 4));
78
+ }
79
+ return maciState;
80
+ };
81
+ exports.generateMaciState = generateMaciState;
82
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.js","sourceRoot":"","sources":["../../../ts/maci/state.ts"],"names":[],"mappings":";;;;;;AAAA,wDAIkC;AAClC,0DAA6D;AAC7D,mCAAyC;AAEzC,4CAAoB;AAKpB,oCAA0C;AAE1C;;;GAGG;AACI,MAAM,i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,eAAe,CAAC,CAAC;QAClE,SAAS,GAAG,EAAE,EAAE,WAAW,IAAI,iBAAiB,CAAC;IACnD,CAAC;IAED,iCAAiC;IACjC,MAAM,cAAc,GAAG,QAAQ,IAAI,eAAe,CAAC;IAEnD,IAAI,eAAe,EAAE,CAAC;QACpB,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,QAAS,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;QAClE,SAAS,GAAG,EAAE,EAAE,WAAW,IAAI,iBAAiB,CAAC;IACnD,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,IAAA,oCAAwB,EAAC;QAC/C,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,wBAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAS;QACrE,OAAO,EAAE,WAAW;QACpB,kBAAkB;QAClB,MAAM;QACN,SAAS;QACT,gBAAgB,EAAE,aAAa,IAAI,EAAE;QACrC,QAAQ,EAAE,cAAc;QACxB,WAAW,EAAE,KAAK;QAClB,sBAAsB;QACtB,cAAc;KACf,CAAC,CAAC;IAEH,4BAA4B;IAC5B,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,eAAe,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC;QAC3C,MAAM,YAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACpF,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AA9FW,QAAA,iBAAiB,qBA8F5B"}
@@ -0,0 +1,176 @@
1
+ import type { Signer } from "ethers";
2
+ /**
3
+ * Enum for the policy type
4
+ */
5
+ export declare enum EPolicyTrait {
6
+ EAS = "EAS",
7
+ FreeForAll = "FreeForAll",
8
+ GitcoinPassport = "GitcoinPassport",
9
+ Hats = "Hats",
10
+ Semaphore = "Semaphore",
11
+ Token = "Token",
12
+ Zupass = "Zupass",
13
+ MerkleProof = "MerkleProof"
14
+ }
15
+ /**
16
+ * Interface for the arguments to the getPolicyTrait command
17
+ */
18
+ export interface IGetPolicyTraitArgs {
19
+ /**
20
+ * The address of the MACI contract
21
+ */
22
+ maciAddress: string;
23
+ /**
24
+ * A signer object
25
+ */
26
+ signer: Signer;
27
+ }
28
+ /**
29
+ * Interface for the arguments to the get a policy data command
30
+ */
31
+ export interface IGetPolicyDataArgs {
32
+ /**
33
+ * The address of the MACI contract
34
+ */
35
+ maciAddress: string;
36
+ /**
37
+ * A signer object
38
+ */
39
+ signer: Signer;
40
+ }
41
+ /**
42
+ * Interface for the semaphore policy data
43
+ */
44
+ export interface ISemaphorePolicyData {
45
+ /**
46
+ * The address of the semaphore policy
47
+ */
48
+ address: string;
49
+ /**
50
+ * The group ID
51
+ */
52
+ groupId: string;
53
+ }
54
+ /**
55
+ * Interface for the zupass policy data
56
+ */
57
+ export interface IZupassPolicyData {
58
+ /**
59
+ * The event ID
60
+ */
61
+ eventId: string;
62
+ /**
63
+ * The first signer
64
+ */
65
+ signer1: string;
66
+ /**
67
+ * The second signer
68
+ */
69
+ signer2: string;
70
+ }
71
+ /**
72
+ * Interface for the EAS policy data
73
+ */
74
+ export interface IEASPolicyData {
75
+ /**
76
+ * The EAS
77
+ */
78
+ eas: string;
79
+ /**
80
+ * The schema
81
+ */
82
+ schema: string;
83
+ /**
84
+ * The attester
85
+ */
86
+ attester: string;
87
+ }
88
+ /**
89
+ * Interface for the MerkleProof policy data
90
+ */
91
+ export interface IMerkleProofPolicyData {
92
+ /**
93
+ * The merkle tree root
94
+ */
95
+ root: string;
96
+ }
97
+ /**
98
+ * Interface for the arguments to the mergeSignups command
99
+ */
100
+ export interface IMergeSignupsArgs {
101
+ /**
102
+ * The id of the poll
103
+ */
104
+ pollId: bigint;
105
+ /**
106
+ * A signer object
107
+ */
108
+ signer: Signer;
109
+ /**
110
+ * The address of the MACI contract
111
+ */
112
+ maciAddress: string;
113
+ /**
114
+ * The number of queue operations to perform
115
+ */
116
+ numQueueOps?: string;
117
+ }
118
+ /**
119
+ * Interface for the arguments to the genLocalState command
120
+ * Generate a local MACI state from the smart contracts events
121
+ */
122
+ export interface IGenerateMaciStateArgs {
123
+ /**
124
+ * The id of the poll
125
+ */
126
+ pollId: bigint;
127
+ /**
128
+ * A signer object
129
+ */
130
+ signer: Signer;
131
+ /**
132
+ * The address of the MACI contract
133
+ */
134
+ maciAddress: string;
135
+ /**
136
+ * The private key of the MACI coordinator
137
+ */
138
+ coordinatorPrivateKey: string;
139
+ /**
140
+ * The ethereum provider
141
+ */
142
+ provider?: string;
143
+ /**
144
+ * The path where to write the state
145
+ */
146
+ outputPath?: string;
147
+ /**
148
+ * The start block number
149
+ */
150
+ startBlock?: number;
151
+ /**
152
+ * The end block number
153
+ */
154
+ endBlock?: number;
155
+ /**
156
+ * The number of blocks to fetch per batch
157
+ */
158
+ blockPerBatch?: number;
159
+ /**
160
+ * The transaction hash
161
+ */
162
+ transactionHash?: string;
163
+ /**
164
+ * The sleep time between batches
165
+ */
166
+ sleep?: number;
167
+ /**
168
+ * Backup files for ipfs messages (name format: ipfsHash.json)
169
+ */
170
+ ipfsMessageBackupFiles?: string[];
171
+ /**
172
+ * The file path where to save the logs for debugging and auditing purposes
173
+ */
174
+ logsOutputPath?: string;
175
+ }
176
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../ts/maci/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC;;GAEG;AACH,oBAAY,YAAY;IACtB,GAAG,QAAQ;IACX,UAAU,eAAe;IACzB,eAAe,oBAAoB;IACnC,IAAI,SAAS;IACb,SAAS,cAAc;IACvB,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,WAAW,gBAAgB;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;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EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,sBAAsB,CAAC,EAAE,MAAM,EAAE,CAAC;IAElC;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EPolicyTrait = void 0;
4
+ /**
5
+ * Enum for the policy type
6
+ */
7
+ var EPolicyTrait;
8
+ (function (EPolicyTrait) {
9
+ EPolicyTrait["EAS"] = "EAS";
10
+ EPolicyTrait["FreeForAll"] = "FreeForAll";
11
+ EPolicyTrait["GitcoinPassport"] = "GitcoinPassport";
12
+ EPolicyTrait["Hats"] = "Hats";
13
+ EPolicyTrait["Semaphore"] = "Semaphore";
14
+ EPolicyTrait["Token"] = "Token";
15
+ EPolicyTrait["Zupass"] = "Zupass";
16
+ EPolicyTrait["MerkleProof"] = "MerkleProof";
17
+ })(EPolicyTrait || (exports.EPolicyTrait = EPolicyTrait = {}));
18
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../ts/maci/types.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,IAAY,YASX;AATD,WAAY,YAAY;IACtB,2BAAW,CAAA;IACX,yCAAyB,CAAA;IACzB,mDAAmC,CAAA;IACnC,6BAAa,CAAA;IACb,uCAAuB,CAAA;IACvB,+BAAe,CAAA;IACf,iCAAiB,CAAA;IACjB,2CAA2B,CAAA;AAC7B,CAAC,EATW,YAAY,4BAAZ,YAAY,QASvB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=keypair.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keypair.test.d.ts","sourceRoot":"","sources":["../../../../ts/maciKeys/__tests__/keypair.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const crypto_1 = require("@maci-protocol/crypto");
4
+ const domainobjs_1 = require("@maci-protocol/domainobjs");
5
+ const keypair_1 = require("../keypair");
6
+ describe("generateKeypair", () => {
7
+ it("should output a random private key and public key", () => {
8
+ const keypair1 = (0, keypair_1.generateKeypair)();
9
+ const keypair2 = (0, keypair_1.generateKeypair)({
10
+ seed: 2801240355254658294358555831749515294960721159561923188361445519585440177746075496738285268291285781469276476510188450870897435498492786799730508035869388059n,
11
+ });
12
+ // Invoking the same command twice should result in different private keys
13
+ expect(keypair1.privateKey).not.toBe(keypair2.privateKey);
14
+ expect(keypair1.publicKey).not.toBe(keypair2.publicKey);
15
+ expect(domainobjs_1.PrivKey.deserialize(keypair1.privateKey)).toBeInstanceOf(domainobjs_1.PrivKey);
16
+ expect(domainobjs_1.PubKey.deserialize(keypair1.publicKey)).toBeInstanceOf(domainobjs_1.PubKey);
17
+ expect(domainobjs_1.PrivKey.deserialize(keypair2.privateKey)).toBeInstanceOf(domainobjs_1.PrivKey);
18
+ expect(domainobjs_1.PubKey.deserialize(keypair2.publicKey)).toBeInstanceOf(domainobjs_1.PubKey);
19
+ const publicKey2 = (0, crypto_1.genPubKey)(domainobjs_1.PrivKey.deserialize(keypair2.privateKey).rawPrivKey);
20
+ expect(domainobjs_1.PubKey.deserialize(keypair2.publicKey).rawPubKey[0].toString()).toBe(publicKey2[0].toString());
21
+ expect(domainobjs_1.PubKey.deserialize(keypair2.publicKey).rawPubKey[1].toString()).toBe(publicKey2[1].toString());
22
+ });
23
+ });
24
+ //# sour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AAW,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QACtG,MAAM,CAAC,mBAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;IACxG,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=publicKeys.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publicKeys.test.d.ts","sourceRoot":"","sources":["../../../../ts/maciKeys/__tests__/publicKeys.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const crypto_1 = require("@maci-protocol/crypto");
4
+ const domainobjs_1 = require("@maci-protocol/domainobjs");
5
+ const keypair_1 = require("../keypair");
6
+ const publicKeys_1 = require("../publicKeys");
7
+ describe("generateMaciPublicKey", () => {
8
+ test("should output a valid public key", () => {
9
+ const keypair = (0, keypair_1.generateKeypair)();
10
+ const pubKey = (0, publicKeys_1.generateMaciPublicKey)(keypair.privateKey);
11
+ expect(pubKey).toBe(keypair.publicKey);
12
+ const unserialisedPrivkey = domainobjs_1.PrivKey.deserialize(keypair.privateKey);
13
+ const pk2 = (0, crypto_1.genPubKey)(unserialisedPrivkey.rawPrivKey);
14
+ const unserializedPk = domainobjs_1.PubKey.deserialize(keypair.publicKey);
15
+ expect(unserializedPk.rawPubKey[0].toString()).toBe(pk2[0].toString());
16
+ expect(unserializedPk.rawPubKey[1].toString()).toBe(pk2[1].toString());
17
+ });
18
+ test("should throw when given an invalid private key", () => {
19
+ expect(() => (0, publicKeys_1.generateMaciPublicKey)("invalid")).toThrow("Invalid private key");
20
+ });
21
+ });
22
+ //# sourceMappingURL=publicKeys.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publicKeys.test.js","sourceRoot":"","sources":["../../../../ts/maciKeys/__tests__/publicKeys.test.ts"],"names":[],"mappings":";;AAAA,kDAAkD;AAClD,0DAA4D;AAE5D,wCAA6C;AAC7C,8CAAsD;AAEtD,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,IAAI,CAAC,kCAAkC,EAAE,GAAG,EAAE;QAC5C,MAAM,OAAO,GAAG,IAAA,yBAAe,GAAE,CAAC;QAClC,MAAM,MAAM,GAAG,IAAA,kCAAqB,EAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAEzD,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAEvC,MAAM,mBAAmB,GAAG,oBAAO,CAAC,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACpE,MAAM,GAAG,GAAG,IAAA,kBAAS,EAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;QACtD,MAAM,cAAc,GAAG,mBAAM,CAAC,WAAW,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAC7D,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QACvE,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;IACzE,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,gDAAgD,EAAE,GAAG,EAAE;QAC1D,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,kCAAqB,EAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAChF,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -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,oBAQrE,CAAC"}
@@ -0,0 +1,20 @@
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.PrivKey(seed) : undefined);
14
+ return {
15
+ publicKey: keypair.pubKey.serialize(),
16
+ privateKey: keypair.privKey.serialize(),
17
+ };
18
+ };
19
+ exports.generateKeypair = generateKeypair;
20
+ //# sourceMappingURL=keypair.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keypair.js","sourceRoot":"","sources":["../../../ts/maciKeys/keypair.ts"],"names":[],"mappings":";;;AAAA,0DAA6D;AAI7D;;;;;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,oBAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAElE,OAAO;QACL,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE;QACrC,UAAU,EAAE,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE;KACxC,CAAC;AACJ,CAAC,CAAC;AARW,QAAA,eAAe,mBAQ1B"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Generate a new Maci Public key from a private key
3
+ * @param privKey - the user private key
4
+ * @param quiet - whether to log the output
5
+ * @return the public key serialized
6
+ */
7
+ export declare const generateMaciPublicKey: (privkey: 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,SAAS,MAAM,KAAG,MAWvD,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 privKey - the user private key
9
+ * @param quiet - whether to log the output
10
+ * @return the public key serialized
11
+ */
12
+ const generateMaciPublicKey = (privkey) => {
13
+ // we check that the provided private key is valid
14
+ if (!domainobjs_1.PrivKey.isValidSerializedPrivKey(privkey)) {
15
+ throw new Error("Invalid private key");
16
+ }
17
+ const unserializedKey = domainobjs_1.PrivKey.deserialize(privkey);
18
+ const pubKey = new domainobjs_1.PubKey((0, crypto_1.genPubKey)(unserializedKey.rawPrivKey));
19
+ // we give back the serialized public key
20
+ return pubKey.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,kDAAkD;AAClD,0DAA4D;AAE5D;;;;;GAKG;AACI,MAAM,qBAAqB,GAAG,CAAC,OAAe,EAAU,EAAE;IAC/D,kDAAkD;IAClD,IAAI,CAAC,oBAAO,CAAC,wBAAwB,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACzC,CAAC;IAED,MAAM,eAAe,GAAG,oBAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACrD,MAAM,MAAM,GAAG,IAAI,mBAAM,CAAC,IAAA,kBAAS,EAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjE,yCAAyC;IACzC,OAAO,MAAM,CAAC,SAAS,EAAE,CAAC;AAC5B,CAAC,CAAC;AAXW,QAAA,qBAAqB,yBAWhC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Interface for the arguments for generate keypair command
3
+ */
4
+ export interface IGenerateKeypairArgs {
5
+ /**
6
+ * Seed value for keypair
7
+ */
8
+ seed?: bigint;
9
+ }
10
+ /**
11
+ * Interface for the return data type for generate keypair command
12
+ */
13
+ export interface IGenerateKeypairData {
14
+ /**
15
+ * Serialized public key
16
+ */
17
+ publicKey: string;
18
+ /**
19
+ * Serialized private key
20
+ */
21
+ privateKey: string;
22
+ }
23
+ //# sourceMappingURL=types.d.ts.map