@maci-protocol/coordinator 0.0.0-ci.d969539 → 0.0.0-ci.da13fbb

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 (101) hide show
  1. package/LICENSE +1 -2
  2. package/README.md +31 -6
  3. package/build/hardhat.config.cjs +3 -0
  4. package/build/hardhat.config.cjs.map +1 -1
  5. package/build/hardhat.config.d.cts +3 -0
  6. package/build/scripts/generateMaciKeyPair.js +2 -2
  7. package/build/scripts/generateMaciKeyPair.js.map +1 -1
  8. package/build/tests/constants.d.ts +0 -1
  9. package/build/tests/constants.d.ts.map +1 -1
  10. package/build/tests/constants.js +0 -1
  11. package/build/tests/constants.js.map +1 -1
  12. package/build/tests/e2e.aa.test.js +18 -25
  13. package/build/tests/e2e.aa.test.js.map +1 -1
  14. package/build/tests/e2e.deploy.test.js +127 -82
  15. package/build/tests/e2e.deploy.test.js.map +1 -1
  16. package/build/tests/utils.d.ts +6 -0
  17. package/build/tests/utils.d.ts.map +1 -1
  18. package/build/tests/utils.js +12 -3
  19. package/build/tests/utils.js.map +1 -1
  20. package/build/ts/common/__tests__/common.test.js +9 -13
  21. package/build/ts/common/__tests__/common.test.js.map +1 -1
  22. package/build/ts/common/accountAbstraction.d.ts +2 -19
  23. package/build/ts/common/accountAbstraction.d.ts.map +1 -1
  24. package/build/ts/common/accountAbstraction.js +15 -44
  25. package/build/ts/common/accountAbstraction.js.map +1 -1
  26. package/build/ts/common/chain.d.ts +16 -0
  27. package/build/ts/common/chain.d.ts.map +1 -0
  28. package/build/ts/common/chain.js +32 -0
  29. package/build/ts/common/chain.js.map +1 -0
  30. package/build/ts/common/coordinatorKeypair.d.ts +7 -0
  31. package/build/ts/common/coordinatorKeypair.d.ts.map +1 -0
  32. package/build/ts/common/coordinatorKeypair.js +14 -0
  33. package/build/ts/common/coordinatorKeypair.js.map +1 -0
  34. package/build/ts/common/errors.d.ts +17 -18
  35. package/build/ts/common/errors.d.ts.map +1 -1
  36. package/build/ts/common/errors.js +17 -18
  37. package/build/ts/common/errors.js.map +1 -1
  38. package/build/ts/common/index.d.ts +2 -0
  39. package/build/ts/common/index.d.ts.map +1 -1
  40. package/build/ts/common/index.js +2 -0
  41. package/build/ts/common/index.js.map +1 -1
  42. package/build/ts/common/types.d.ts +2 -3
  43. package/build/ts/common/types.d.ts.map +1 -1
  44. package/build/ts/deployer/__tests__/deployer.service.test.js +30 -289
  45. package/build/ts/deployer/__tests__/deployer.service.test.js.map +1 -1
  46. package/build/ts/deployer/__tests__/utils.d.ts +27 -1
  47. package/build/ts/deployer/__tests__/utils.d.ts.map +1 -1
  48. package/build/ts/deployer/__tests__/utils.js +40 -11
  49. package/build/ts/deployer/__tests__/utils.js.map +1 -1
  50. package/build/ts/deployer/deployer.service.d.ts +17 -53
  51. package/build/ts/deployer/deployer.service.d.ts.map +1 -1
  52. package/build/ts/deployer/deployer.service.js +176 -462
  53. package/build/ts/deployer/deployer.service.js.map +1 -1
  54. package/build/ts/deployer/dto.d.ts +4 -4
  55. package/build/ts/deployer/dto.d.ts.map +1 -1
  56. package/build/ts/deployer/dto.js +9 -1
  57. package/build/ts/deployer/dto.js.map +1 -1
  58. package/build/ts/deployer/types.d.ts +53 -26
  59. package/build/ts/deployer/types.d.ts.map +1 -1
  60. package/build/ts/file/__tests__/file.service.test.js +12 -11
  61. package/build/ts/file/__tests__/file.service.test.js.map +1 -1
  62. package/build/ts/file/file.service.d.ts +4 -3
  63. package/build/ts/file/file.service.d.ts.map +1 -1
  64. package/build/ts/file/file.service.js +14 -9
  65. package/build/ts/file/file.service.js.map +1 -1
  66. package/build/ts/file/types.d.ts +2 -2
  67. package/build/ts/file/types.d.ts.map +1 -1
  68. package/build/ts/proof/__tests__/proof.controller.test.js +5 -3
  69. package/build/ts/proof/__tests__/proof.controller.test.js.map +1 -1
  70. package/build/ts/proof/__tests__/proof.gateway.test.js +6 -3
  71. package/build/ts/proof/__tests__/proof.gateway.test.js.map +1 -1
  72. package/build/ts/proof/__tests__/proof.service.test.js +18 -31
  73. package/build/ts/proof/__tests__/proof.service.test.js.map +1 -1
  74. package/build/ts/proof/dto.d.ts +13 -15
  75. package/build/ts/proof/dto.d.ts.map +1 -1
  76. package/build/ts/proof/dto.js +51 -44
  77. package/build/ts/proof/dto.js.map +1 -1
  78. package/build/ts/proof/proof.controller.d.ts +3 -2
  79. package/build/ts/proof/proof.controller.d.ts.map +1 -1
  80. package/build/ts/proof/proof.controller.js +1 -4
  81. package/build/ts/proof/proof.controller.js.map +1 -1
  82. package/build/ts/proof/proof.service.d.ts +4 -6
  83. package/build/ts/proof/proof.service.d.ts.map +1 -1
  84. package/build/ts/proof/proof.service.js +48 -130
  85. package/build/ts/proof/proof.service.js.map +1 -1
  86. package/build/ts/proof/types.d.ts +19 -14
  87. package/build/ts/proof/types.d.ts.map +1 -1
  88. package/build/ts/sessionKeys/provider/KernelEIP1193Provider.d.ts +53 -0
  89. package/build/ts/sessionKeys/provider/KernelEIP1193Provider.d.ts.map +1 -0
  90. package/build/ts/sessionKeys/provider/KernelEIP1193Provider.js +105 -0
  91. package/build/ts/sessionKeys/provider/KernelEIP1193Provider.js.map +1 -0
  92. package/build/ts/sessionKeys/sessionKeys.service.d.ts +13 -2
  93. package/build/ts/sessionKeys/sessionKeys.service.d.ts.map +1 -1
  94. package/build/ts/sessionKeys/sessionKeys.service.js +22 -4
  95. package/build/ts/sessionKeys/sessionKeys.service.js.map +1 -1
  96. package/build/tsconfig.build.tsbuildinfo +1 -1
  97. package/package.json +32 -32
  98. package/build/ts/deployer/utils.d.ts +0 -8
  99. package/build/ts/deployer/utils.d.ts.map +0 -1
  100. package/build/ts/deployer/utils.js +0 -9
  101. package/build/ts/deployer/utils.js.map +0 -1
@@ -8,23 +8,21 @@ var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
10
  var ProofGeneratorService_1;
11
- import { Keypair, PrivKey, PubKey } from "@maci-protocol/domainobjs";
12
- import { Deployment, EContracts, ProofGenerator, Poll__factory as PollFactory, MACI__factory as MACIFactory, Prover, getPoll, mergeSignups, } from "@maci-protocol/sdk";
11
+ import { PublicKey } from "@maci-protocol/domainobjs";
12
+ import { Deployment, EContracts, getPoll, mergeSignups, EMode, } from "@maci-protocol/sdk";
13
+ import { generateProofs, proveOnChain } from "@maci-protocol/sdk";
13
14
  import { Logger, Injectable } from "@nestjs/common";
14
- import { ZeroAddress } from "ethers";
15
15
  import hre from "hardhat";
16
16
  import fs from "fs";
17
17
  import path from "path";
18
18
  import { ErrorCodes } from "../common";
19
- import { getPublicClient } from "../common/accountAbstraction";
20
- import { CryptoService } from "../crypto/crypto.service";
19
+ import { getCoordinatorKeypair } from "../common/coordinatorKeypair";
21
20
  import { FileService } from "../file/file.service";
22
21
  import { SessionKeysService } from "../sessionKeys/sessionKeys.service";
23
22
  /**
24
23
  * ProofGeneratorService is responsible for generating message processing and tally proofs.
25
24
  */
26
25
  let ProofGeneratorService = ProofGeneratorService_1 = class ProofGeneratorService {
27
- cryptoService;
28
26
  fileService;
29
27
  sessionKeysService;
30
28
  /**
@@ -38,8 +36,7 @@ let ProofGeneratorService = ProofGeneratorService_1 = class ProofGeneratorServic
38
36
  /**
39
37
  * Proof generator initialization
40
38
  */
41
- constructor(cryptoService, fileService, sessionKeysService) {
42
- this.cryptoService = cryptoService;
39
+ constructor(fileService, sessionKeysService) {
43
40
  this.fileService = fileService;
44
41
  this.sessionKeysService = sessionKeysService;
45
42
  this.deployment = Deployment.getInstance({ hre });
@@ -65,13 +62,9 @@ let ProofGeneratorService = ProofGeneratorService_1 = class ProofGeneratorServic
65
62
  * @param args - generate proofs arguments
66
63
  * @returns - generated proofs for message processing and tally
67
64
  */
68
- async generate({ poll, maciContractAddress, tallyContractAddress, useQuadraticVoting, encryptedCoordinatorPrivateKey, startBlock, endBlock, blocksPerBatch, }, options) {
65
+ async generate({ approval, sessionKeyAddress, chain, poll, maciContractAddress, mode, startBlock, endBlock, blocksPerBatch, useWasm, }, options) {
69
66
  try {
70
- const maciContract = await this.deployment.getContract({
71
- name: EContracts.MACI,
72
- address: maciContractAddress,
73
- });
74
- const signer = await this.deployment.getDeployer();
67
+ const signer = await this.sessionKeysService.getCoordinatorSigner(chain, sessionKeyAddress, approval);
75
68
  const pollData = await getPoll({
76
69
  maciAddress: maciContractAddress,
77
70
  pollId: poll,
@@ -81,58 +74,41 @@ let ProofGeneratorService = ProofGeneratorService_1 = class ProofGeneratorServic
81
74
  name: EContracts.Poll,
82
75
  address: pollData.address,
83
76
  });
84
- const [coordinatorPublicKey, isStateAqMerged] = await Promise.all([
85
- pollContract.coordinatorPubKey(),
86
- pollContract.stateMerged(),
87
- ]);
88
- if (!isStateAqMerged) {
89
- this.logger.error(`Error: ${ErrorCodes.NOT_MERGED_STATE_TREE}, state tree is not merged`);
90
- throw new Error(ErrorCodes.NOT_MERGED_STATE_TREE.toString());
91
- }
92
- const { privateKey } = await this.fileService.getPrivateKey();
93
- const maciPrivateKey = PrivKey.deserialize(this.cryptoService.decrypt(privateKey, encryptedCoordinatorPrivateKey));
94
- const coordinatorKeypair = new Keypair(maciPrivateKey);
95
- const publicKey = new PubKey([
96
- BigInt(coordinatorPublicKey.x.toString()),
97
- BigInt(coordinatorPublicKey.y.toString()),
77
+ const publicKeyOnChain = await pollContract.coordinatorPublicKey();
78
+ const coordinatorPublicKeyOnChain = new PublicKey([
79
+ BigInt(publicKeyOnChain.x.toString()),
80
+ BigInt(publicKeyOnChain.y.toString()),
98
81
  ]);
99
- if (!coordinatorKeypair.pubKey.equals(publicKey)) {
82
+ const coordinatorKeypair = getCoordinatorKeypair();
83
+ if (!coordinatorKeypair.publicKey.equals(coordinatorPublicKeyOnChain)) {
100
84
  this.logger.error(`Error: ${ErrorCodes.PRIVATE_KEY_MISMATCH}, wrong private key`);
101
85
  throw new Error(ErrorCodes.PRIVATE_KEY_MISMATCH.toString());
102
86
  }
103
- const outputDir = path.resolve("./proofs");
104
- const maciState = await ProofGenerator.prepareState({
105
- maciContract,
106
- pollContract,
107
- maciPrivateKey,
108
- coordinatorKeypair,
109
- pollId: poll,
87
+ // There are only QV and Non-QV modes available for tally circuit
88
+ const tally = this.fileService.getZkeyFilePaths(process.env.COORDINATOR_TALLY_ZKEY_NAME,
89
+ // if FULL use NON_QV because there are only VoteTallyQV and VoteTallyNonQV zkeys
90
+ mode === EMode.FULL ? EMode.NON_QV : mode);
91
+ const messageProcessor = this.fileService.getZkeyFilePaths(process.env.COORDINATOR_MESSAGE_PROCESS_ZKEY_NAME, mode);
92
+ const { processProofs, tallyProofs, tallyData } = await generateProofs({
93
+ outputDir: path.resolve("./proofs"),
94
+ coordinatorPrivateKey: coordinatorKeypair.privateKey.serialize(),
110
95
  signer,
111
- outputDir,
112
- options: {
113
- startBlock,
114
- endBlock,
115
- blocksPerBatch,
116
- },
117
- });
118
- const foundPoll = maciState.polls.get(BigInt(poll));
119
- if (!foundPoll) {
120
- this.logger.error(`Error: ${ErrorCodes.POLL_NOT_FOUND}, Poll ${poll} not found in maci state`);
121
- throw new Error(ErrorCodes.POLL_NOT_FOUND.toString());
122
- }
123
- const proofGenerator = new ProofGenerator({
124
- poll: foundPoll,
125
- maciContractAddress,
126
- tallyContractAddress,
127
- tally: this.fileService.getZkeyFilePaths(process.env.COORDINATOR_TALLY_ZKEY_NAME, useQuadraticVoting),
128
- mp: this.fileService.getZkeyFilePaths(process.env.COORDINATOR_MESSAGE_PROCESS_ZKEY_NAME, useQuadraticVoting),
96
+ maciAddress: maciContractAddress,
97
+ pollId: BigInt(poll),
98
+ startBlock,
99
+ endBlock,
100
+ blocksPerBatch,
101
+ useWasm,
129
102
  rapidsnark: process.env.COORDINATOR_RAPIDSNARK_EXE,
130
- outputDir,
131
- tallyOutputFile: path.resolve("./tally.json"),
132
- useQuadraticVoting,
103
+ mode,
104
+ voteTallyZkey: tally.zkey,
105
+ voteTallyWitnessGenerator: tally.witnessGenerator,
106
+ voteTallyWasm: tally.wasm,
107
+ messageProcessorZkey: messageProcessor.zkey,
108
+ messageProcessorWitnessGenerator: messageProcessor.witnessGenerator,
109
+ messageProcessorWasm: messageProcessor.wasm,
110
+ tallyFile: path.resolve("./tally.json"),
133
111
  });
134
- const processProofs = await proofGenerator.generateMpProofs(options);
135
- const { proofs: tallyProofs, tallyData } = await proofGenerator.generateTallyProofs(hre.network.name, String(hre.network.config.chainId || 1), options);
136
112
  return {
137
113
  processProofs,
138
114
  tallyProofs,
@@ -151,9 +127,7 @@ let ProofGeneratorService = ProofGeneratorService_1 = class ProofGeneratorServic
151
127
  * @returns whether the proofs were successfully merged
152
128
  */
153
129
  async merge({ maciContractAddress, pollId, approval, sessionKeyAddress, chain }) {
154
- // get a kernel client
155
- const kernelClient = await this.sessionKeysService.generateClientFromSessionKey(sessionKeyAddress, approval, chain);
156
- const signer = await this.sessionKeysService.getKernelClientSigner(kernelClient);
130
+ const signer = await this.sessionKeysService.getCoordinatorSigner(chain, sessionKeyAddress, approval);
157
131
  await mergeSignups({
158
132
  maciAddress: maciContractAddress,
159
133
  pollId: BigInt(pollId),
@@ -166,80 +140,24 @@ let ProofGeneratorService = ProofGeneratorService_1 = class ProofGeneratorServic
166
140
  *
167
141
  * @param args - submit proofs on-chain arguments
168
142
  */
169
- async submit({ maciContractAddress, pollId, chain }) {
170
- const publicClient = getPublicClient(chain);
171
- // get the poll address
172
- const pollContracts = await publicClient.readContract({
173
- address: maciContractAddress,
174
- abi: MACIFactory.abi,
175
- functionName: "getPoll",
176
- args: [BigInt(pollId)],
177
- });
178
- const pollAddress = pollContracts.poll;
179
- if (pollAddress.toLowerCase() === ZeroAddress.toLowerCase()) {
180
- this.logger.error(`Error: ${ErrorCodes.POLL_NOT_FOUND}, Poll ${pollId} not found`);
181
- throw new Error(ErrorCodes.POLL_NOT_FOUND.toString());
182
- }
183
- // check if state tree has been merged
184
- const isStateMerged = await publicClient.readContract({
185
- address: pollAddress,
186
- abi: PollFactory.abi,
187
- functionName: "stateMerged",
143
+ async submit({ maciContractAddress, pollId, sessionKeyAddress, approval, chain, }) {
144
+ const signer = await this.sessionKeysService.getCoordinatorSigner(chain, sessionKeyAddress, approval);
145
+ const tallyData = await proveOnChain({
146
+ pollId: BigInt(pollId),
147
+ maciAddress: maciContractAddress,
148
+ proofDir: "./proofs",
149
+ tallyFile: "./tally.json",
150
+ signer,
188
151
  });
189
- if (!isStateMerged) {
190
- this.logger.error(`Error: ${ErrorCodes.NOT_MERGED_STATE_TREE}, state tree is not merged`);
191
- throw new Error(ErrorCodes.NOT_MERGED_STATE_TREE.toString());
152
+ if (!tallyData) {
153
+ throw new Error("Tally data is undefined");
192
154
  }
193
- const [maciContract, mpContract, pollContract, tallyContract, vkRegistryContract, verifierContract] = await Promise.all([
194
- this.deployment.getContract({
195
- name: EContracts.MACI,
196
- address: maciContractAddress,
197
- }),
198
- this.deployment.getContract({
199
- name: EContracts.MessageProcessor,
200
- address: pollContracts.messageProcessor,
201
- }),
202
- this.deployment.getContract({
203
- name: EContracts.Poll,
204
- address: pollContracts.poll,
205
- }),
206
- this.deployment.getContract({
207
- name: EContracts.Tally,
208
- address: pollContracts.tally,
209
- }),
210
- this.deployment.getContract({ name: EContracts.VkRegistry }),
211
- this.deployment.getContract({ name: EContracts.Verifier }),
212
- ]);
213
- const prover = new Prover({
214
- maciContract,
215
- mpContract,
216
- pollContract,
217
- tallyContract,
218
- vkRegistryContract,
219
- verifierContract,
220
- });
221
- const data = {
222
- processProofs: await this.readProofs(path.resolve("./proofs"), "process"),
223
- tallyProofs: await this.readProofs(path.resolve("./proofs"), "tally"),
224
- };
225
- // prove message processing
226
- await prover.proveMessageProcessing(data.processProofs);
227
- // read tally data
228
- const tallyData = await fs.promises
229
- .readFile("./tally.json", "utf8")
230
- .then((result) => JSON.parse(result));
231
- // prove tally
232
- await prover.proveTally(data.tallyProofs);
233
- // submit results
234
- const voteOptions = Number(await pollContract.voteOptions());
235
- await prover.submitResults(tallyData, voteOptions);
236
- return true;
155
+ return tallyData;
237
156
  }
238
157
  };
239
158
  ProofGeneratorService = ProofGeneratorService_1 = __decorate([
240
159
  Injectable(),
241
- __metadata("design:paramtypes", [CryptoService,
242
- FileService,
160
+ __metadata("design:paramtypes", [FileService,
243
161
  SessionKeysService])
244
162
  ], ProofGeneratorService);
245
163
  export { ProofGeneratorService };
@@ -1 +1 @@
1
- {"version":3,"file":"proof.service.js","sourceRoot":"","sources":["../../../ts/proof/proof.service.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EACL,UAAU,EACV,UAAU,EACV,cAAc,EAId,aAAa,IAAI,WAAW,EAC5B,aAAa,IAAI,WAAW,EAC5B,MAAM,EAKN,OAAO,EACP,YAAY,GACb,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,GAAG,MAAM,SAAS,CAAC;AAG1B,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAIxB,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAExE;;GAEG;AAEI,IAAM,qBAAqB,6BAA3B,MAAM,qBAAqB;IAeb;IACA;IACA;IAhBnB;;OAEG;IACc,UAAU,CAAa;IAExC;;OAEG;IACc,MAAM,CAAS;IAEhC;;OAEG;IACH,YACmB,aAA4B,EAC5B,WAAwB,EACxB,kBAAsC;QAFtC,kBA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mBAAmB;YAChC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;YACtB,MAAM;SACP,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,EACX,mBAAmB,EACnB,MAAM,EACN,iBAAiB,EACjB,QAAQ,EACR,KAAK,GACa;QAClB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,oBAAoB,CAAC,KAAK,EAAE,iBAAiB,EAAE,QAAQ,CAAC,CAAC;QAEtG,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC;YACnC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;YACtB,WAAW,EAAE,mBAAmB;YAChC,QAAQ,EAAE,UAAU;YACpB,SAAS,EAAE,cAAc;YACzB,MAAM;SACP,CAAC,CAAC;QAEH,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC7C,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF,CAAA;AAjLY,qBAAqB;IADjC,UAAU,EAAE;qCAgBqB,WAAW;QACJ,kBAAkB;GAhB9C,qBAAqB,CAiLjC"}
@@ -1,4 +1,4 @@
1
- import type { ITallyData, IProof } from "@maci-protocol/sdk";
1
+ import type { ITallyData, IProof, EMode } from "@maci-protocol/sdk";
2
2
  import type { Hex } from "viem";
3
3
  import { ESupportedNetworks } from "../common";
4
4
  /**
@@ -24,6 +24,18 @@ export interface IReadProofsResults {
24
24
  * Interface that represents generate proofs arguments
25
25
  */
26
26
  export interface IGenerateArgs {
27
+ /**
28
+ * Approval for the session key
29
+ */
30
+ approval?: string;
31
+ /**
32
+ * Session key address
33
+ */
34
+ sessionKeyAddress?: Hex;
35
+ /**
36
+ * Chain
37
+ */
38
+ chain: ESupportedNetworks;
27
39
  /**
28
40
  * Poll id
29
41
  */
@@ -32,18 +44,10 @@ export interface IGenerateArgs {
32
44
  * Maci contract address
33
45
  */
34
46
  maciContractAddress: string;
35
- /**
36
- * Tally contract address
37
- */
38
- tallyContractAddress: string;
39
47
  /**
40
48
  * Whether to use Qv or NonQv
41
49
  */
42
- useQuadraticVoting: boolean;
43
- /**
44
- * Encrypted coordinator private key with RSA public key (see .env.example)
45
- */
46
- encryptedCoordinatorPrivateKey: string;
50
+ mode: EMode;
47
51
  /**
48
52
  * Start block for event processing
49
53
  */
@@ -56,6 +60,7 @@ export interface IGenerateArgs {
56
60
  * Blocks per batch for event processing
57
61
  */
58
62
  blocksPerBatch?: number;
63
+ useWasm?: boolean;
59
64
  }
60
65
  /**
61
66
  * Interface that represents generated proofs data
@@ -102,11 +107,11 @@ export interface IMergeArgs {
102
107
  /**
103
108
  * Approval for the session key
104
109
  */
105
- approval: string;
110
+ approval?: string;
106
111
  /**
107
112
  * Session key address
108
113
  */
109
- sessionKeyAddress: Hex;
114
+ sessionKeyAddress?: Hex;
110
115
  /**
111
116
  * Chain
112
117
  */
@@ -127,11 +132,11 @@ export interface ISubmitProofsArgs {
127
132
  /**
128
133
  * Approval for the session key
129
134
  */
130
- approval: string;
135
+ approval?: string;
131
136
  /**
132
137
  * Session key address
133
138
  */
134
- sessionKeyAddress: Hex;
139
+ sessionKeyAddress?: Hex;
135
140
  /**
136
141
  * Chain
137
142
  */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../ts/proof/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C;;GAEG;AACH,oBAAY,sBAAsB;IAChC,KAAK,qBAAqB;IAC1B,QAAQ,wBAAwB;IAChC,MAAM,sBAAsB;IAC5B,KAAK,cAAc;CACpB;AAKD,MAAM,WAAW,kBAAkB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IACH,WAAW,EAAE,MAAM,EAAE,CAAC;IAEtB;;OAEG;IACH,SAAS,EAAE,UAAU,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,iBAAiB,CAAC,EAAE,GAAG,CAAC;IAExB;;OAEG;IACH,KAAK,EAAE,kBAAkB,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,iBAAiB,CAAC,EAAE,GAAG,CAAC;IAExB;;OAEG;IACH,KAAK,EAAE,kBAAkB,CAAC;CAC3B"}
@@ -0,0 +1,53 @@
1
+ import { KernelAccountClient } from "@zerodev/sdk";
2
+ import { encodeFunctionData } from "viem";
3
+ import { EventEmitter } from "events";
4
+ import type { EIP1193Parameters, EIP1193RequestFn, Hex } from "viem";
5
+ export declare const SafeCreateCallAbi: readonly [{
6
+ readonly name: "performCreate";
7
+ readonly type: "function";
8
+ readonly stateMutability: "nonpayable";
9
+ readonly inputs: readonly [{
10
+ readonly type: "uint256";
11
+ readonly name: "value";
12
+ }, {
13
+ readonly type: "bytes";
14
+ readonly name: "deploymentData";
15
+ }];
16
+ readonly outputs: readonly [{
17
+ readonly type: "address";
18
+ readonly name: "newContract";
19
+ }];
20
+ }, {
21
+ readonly name: "performCreate2";
22
+ readonly type: "function";
23
+ readonly stateMutability: "nonpayable";
24
+ readonly inputs: readonly [{
25
+ readonly type: "uint256";
26
+ readonly name: "value";
27
+ }, {
28
+ readonly type: "bytes";
29
+ readonly name: "deploymentData";
30
+ }, {
31
+ readonly type: "bytes32";
32
+ readonly name: "salt";
33
+ }];
34
+ readonly outputs: readonly [{
35
+ readonly type: "address";
36
+ readonly name: "newContract";
37
+ }];
38
+ }];
39
+ type EncodeExecuteDelegateCallArgs = Parameters<typeof encodeFunctionData<typeof SafeCreateCallAbi, "performCreate">>[0]["args"];
40
+ export declare const encodeSafeCreateCall: (args: EncodeExecuteDelegateCallArgs) => Hex;
41
+ export declare class KernelEIP1193Provider extends EventEmitter {
42
+ private kernelClient;
43
+ constructor(kernelClient: KernelAccountClient);
44
+ request({ method, params }: EIP1193Parameters): ReturnType<EIP1193RequestFn>;
45
+ private handleEthRequestAccounts;
46
+ private handleEthAccounts;
47
+ private handleEthSendTransaction;
48
+ private handleEthSign;
49
+ private handlePersonalSign;
50
+ private handleEthSignTypedDataV4;
51
+ }
52
+ export {};
53
+ //# sourceMappingURL=KernelEIP1193Provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KernelEIP1193Provider.d.ts","sourceRoot":"","sources":["../../../../ts/sessionKeys/provider/KernelEIP1193Provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAE,kBAAkB,EAAY,MAAM,MAAM,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAQ,GAAG,EAA8C,MAAM,MAAM,CAAC;AAEvH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAG5B,CAAC;AAEH,KAAK,6BAA6B,GAAG,UAAU,CAC7C,OAAO,kBAAkB,CAAC,OAAO,iBAAiB,EAAE,eAAe,CAAC,CACrE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAEb,eAAO,MAAM,oBAAoB,GAAI,MAAM,6BAA6B,KAAG,GAKvE,CAAC;AAEL,qBAAa,qBAAsB,SAAQ,YAAY;IACrD,OAAO,CAAC,YAAY,CAAsB;gBAE9B,YAAY,EAAE,mBAAmB;IAKvC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAW,EAAE,EAAE,iBAAiB,GAAG,UAAU,CAAC,gBAAgB,CAAC;IAoBvF,OAAO,CAAC,wBAAwB;IAQhC,OAAO,CAAC,iBAAiB;YAQX,wBAAwB;YAexB,aAAa;YAiBb,kBAAkB;YAiBlB,wBAAwB;CA0BvC"}
@@ -0,0 +1,105 @@
1
+ import { safeCreateCallAddress } from "@zerodev/sdk/constants";
2
+ import { encodeFunctionData, parseAbi } from "viem";
3
+ import { EventEmitter } from "events";
4
+ export const SafeCreateCallAbi = parseAbi([
5
+ "function performCreate(uint256 value, bytes memory deploymentData) public returns (address newContract)",
6
+ "function performCreate2(uint256 value, bytes memory deploymentData, bytes32 salt) public returns (address newContract)",
7
+ ]);
8
+ export const encodeSafeCreateCall = (args) => encodeFunctionData({
9
+ abi: SafeCreateCallAbi,
10
+ functionName: "performCreate",
11
+ args,
12
+ });
13
+ export class KernelEIP1193Provider extends EventEmitter {
14
+ kernelClient;
15
+ constructor(kernelClient) {
16
+ super();
17
+ this.kernelClient = kernelClient;
18
+ }
19
+ async request({ method, params = [] }) {
20
+ switch (method) {
21
+ case "eth_requestAccounts":
22
+ return this.handleEthRequestAccounts();
23
+ case "eth_accounts":
24
+ return this.handleEthAccounts();
25
+ case "eth_sendTransaction":
26
+ return this.handleEthSendTransaction(params);
27
+ case "eth_sign":
28
+ return this.handleEthSign(params);
29
+ case "personal_sign":
30
+ return this.handlePersonalSign(params);
31
+ case "eth_signTypedData":
32
+ case "eth_signTypedData_v4":
33
+ return this.handleEthSignTypedDataV4(params);
34
+ default:
35
+ return this.kernelClient.transport.request({ method, params });
36
+ }
37
+ }
38
+ handleEthRequestAccounts() {
39
+ if (!this.kernelClient.account) {
40
+ return [];
41
+ }
42
+ return [this.kernelClient.account.address];
43
+ }
44
+ handleEthAccounts() {
45
+ if (!this.kernelClient.account) {
46
+ return [];
47
+ }
48
+ return [this.kernelClient.account.address];
49
+ }
50
+ async handleEthSendTransaction(params) {
51
+ const [tx] = params;
52
+ if (!("to" in tx) && tx.data) {
53
+ // contract deployment
54
+ tx.data = encodeSafeCreateCall([0n, tx.data]);
55
+ tx.to = safeCreateCallAddress;
56
+ return this.kernelClient.sendTransaction(tx);
57
+ }
58
+ // eth transaction (function call or eth transfer)
59
+ return this.kernelClient.sendTransaction(tx);
60
+ }
61
+ async handleEthSign(params) {
62
+ if (!this.kernelClient.account) {
63
+ throw new Error("account not connected!");
64
+ }
65
+ const [address, message] = params;
66
+ if (address.toLowerCase() !== this.kernelClient.account.address.toLowerCase()) {
67
+ throw new Error("cannot sign for address that is not the current account");
68
+ }
69
+ return this.kernelClient.signMessage({
70
+ message,
71
+ account: this.kernelClient.account,
72
+ });
73
+ }
74
+ async handlePersonalSign(params) {
75
+ if (!this.kernelClient.account) {
76
+ throw new Error("account not connected!");
77
+ }
78
+ const [message, address] = params;
79
+ if (address.toLowerCase() !== this.kernelClient.account.address.toLowerCase()) {
80
+ throw new Error("cannot sign for address that is not the current account");
81
+ }
82
+ return this.kernelClient.signMessage({
83
+ message,
84
+ account: this.kernelClient.account,
85
+ });
86
+ }
87
+ async handleEthSignTypedDataV4(params) {
88
+ if (!this.kernelClient.account) {
89
+ throw new Error("account not connected!");
90
+ }
91
+ const [address, typedDataJSON] = params;
92
+ const typedData = JSON.parse(typedDataJSON);
93
+ if (address.toLowerCase() !== this.kernelClient.account.address.toLowerCase()) {
94
+ throw new Error("cannot sign for address that is not the current account");
95
+ }
96
+ return this.kernelClient.signTypedData({
97
+ account: this.kernelClient.account,
98
+ domain: typedData.domain,
99
+ types: typedData.types,
100
+ message: typedData.message,
101
+ primaryType: typedData.primaryType,
102
+ });
103
+ }
104
+ }
105
+ //# sourceMappingURL=KernelEIP1193Provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KernelEIP1193Provider.js","sourceRoot":"","sources":["../../../../ts/sessionKeys/provider/KernelEIP1193Provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAItC,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACxC,yGAAyG;IACzG,wHAAwH;CACzH,CAAC,CAAC;AAMH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,IAAmC,EAAO,EAAE,CAC/E,kBAAkB,CAAC;IACjB,GAAG,EAAE,iBAAiB;IACtB,YAAY,EAAE,eAAe;IAC7B,IAAI;CACL,CAAC,CAAC;AAEL,MAAM,OAAO,qBAAsB,SAAQ,YAAY;IAC7C,YAAY,CAAsB;IAE1C,YAAY,YAAiC;QAC3C,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,EAAE,EAAqB;QACtD,QAAQ,MAAM,EAAE,CAAC;YACf,KAAK,qBAAqB;gBACxB,OAAO,IAAI,CAAC,wBAAwB,EAAE,CAAC;YACzC,KAAK,cAAc;gBACjB,OAAO,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAClC,KAAK,qBAAqB;gBACxB,OAAO,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAC;YAC/C,KAAK,UAAU;gBACb,OAAO,IAAI,CAAC,aAAa,CAAC,MAA0B,CAAC,CAAC;YACxD,KAAK,eAAe;gBAClB,OAAO,IAAI,CAAC,kBAAkB,CAAC,MAA0B,CAAC,CAAC;Y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,CAAC,KAAK,CAAC,aAAa,CAKzC,CAAC;QAEF,IAAI,OAAO,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;YAC9E,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;QAC7E,CAAC;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC;YACrC,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,OAAO;YAClC,MAAM,EAAE,SAAS,CAAC,MAAM;YACxB,KAAK,EAAE,SAAS,CAAC,KAAK;YACtB,OAAO,EAAE,SAAS,CAAC,OAAO;YAC1B,WAAW,EAAE,SAAS,CAAC,WAAW;SACnC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -1,4 +1,5 @@
1
- import { JsonRpcSigner } from "ethers";
1
+ import { Signer } from "ethers";
2
+ import type { AASigner } from "@maci-protocol/contracts";
2
3
  import type { Hex } from "viem";
3
4
  import { ESupportedNetworks, KernelClientType } from "../common";
4
5
  import { FileService } from "../file/file.service";
@@ -39,7 +40,17 @@ export declare class SessionKeysService {
39
40
  * @param kernelClient - kernel client
40
41
  * @returns signer
41
42
  */
42
- getKernelClientSigner(kernelClient: KernelClientType): Promise<JsonRpcSigner>;
43
+ getKernelClientSigner(kernelClient: KernelClientType): Promise<AASigner>;
44
+ /**
45
+ * Get a signer that would execute all the contract interactions in the coordinator service.
46
+ * There are particular cases where the AA signer does not work so we default to the normal signer.
47
+ * (e.g. `deployPoll`)
48
+ * @param chain - the chain to use
49
+ * @param sessionKeyAddress - the address of the session key. Defaults to normal signer if not provided
50
+ * @param approval - the approval string. Defaults to normal signer if not provided
51
+ * @returns a signer
52
+ */
53
+ getCoordinatorSigner(chain: ESupportedNetworks, sessionKeyAddress?: Hex, approval?: string): Promise<AASigner | Signer>;
43
54
  /**
44
55
  * Deactivate a session key
45
56
  *
@@ -1 +1 @@
1
- {"version":3,"file":"sessionKeys.service.d.ts","sourceRoot":"","sources":["../../../ts/sessionKeys/sessionKeys.service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmB,aAAa,EAAE,MAAM,QAAQ,CAAC;AAGxD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC,OAAO,EAAc,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7E,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAEpD;;GAEG;AACH,qBACa,kBAAkB;IAWjB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAVxC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC;;;;OAIG;gBAC0B,WAAW,EAAE,WAAW;IAIrD;;;;OAIG;IACG,kBAAkB,IAAI,OAAO,CAAC,yBAAyB,CAAC;IAiB9D;;;;;;;OAOG;IACG,4BAA4B,CAChC,iBAAiB,EAAE,GAAG,EACtB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,kBAAkB,GACxB,OAAO,CAAC,gBAAgB,CAAC;IAkB5B;;;;;OAKG;IACG,qBAAqB,CAAC,YAAY,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC;IAOnF;;;;OAIG;IACH,oBAAoB,CAAC,iBAAiB,EAAE,GAAG,GAAG,IAAI;CAGnD"}
1
+ {"version":3,"file":"sessionKeys.service.d.ts","sourceRoot":"","sources":["../../../ts/sessionKeys/sessionKeys.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmB,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC,OAAO,EAAc,kBAAkB,EAAa,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAExF,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAEpD;;GAEG;AACH,qBACa,kBAAkB;IAWjB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAVxC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC;;;;OAIG;gBAC0B,WAAW,EAAE,WAAW;IAIrD;;;;OAIG;IACG,kBAAkB,IAAI,OAAO,CAAC,yBAAyB,CAAC;IAiB9D;;;;;;;OAOG;IACG,4BAA4B,CAChC,iBAAiB,EAAE,GAAG,EACtB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,kBAAkB,GACxB,OAAO,CAAC,gBAAgB,CAAC;IAkB5B;;;;;OAKG;IACG,qBAAqB,CAAC,YAAY,EAAE,gBAAgB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAU9E;;;;;;;;OAQG;IACG,oBAAoB,CACxB,KAAK,EAAE,kBAAkB,EACzB,iBAAiB,CAAC,EAAE,GAAG,EACvB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,QAAQ,GAAG,MAAM,CAAC;IAS7B;;;;OAIG;IACH,oBAAoB,CAAC,iBAAiB,EAAE,GAAG,GAAG,IAAI;CAGnD"}
@@ -10,12 +10,12 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  var SessionKeysService_1;
11
11
  import { Injectable, Logger } from "@nestjs/common";
12
12
  import { toECDSASigner } from "@zerodev/permissions/signers";
13
- import { KernelEIP1193Provider } from "@zerodev/sdk";
14
13
  import { BrowserProvider } from "ethers";
15
14
  import { generatePrivateKey, privateKeyToAccount } from "viem/accounts";
16
- import { ErrorCodes } from "../common";
15
+ import { ErrorCodes, getSigner } from "../common";
17
16
  import { getKernelClient } from "../common/accountAbstraction";
18
17
  import { FileService } from "../file/file.service";
18
+ import { KernelEIP1193Provider } from "./provider/KernelEIP1193Provider";
19
19
  /**
20
20
  * SessionKeysService is responsible for generating and managing session keys.
21
21
  */
@@ -71,7 +71,7 @@ let SessionKeysService = SessionKeysService_1 = class SessionKeysService {
71
71
  return kernelClient;
72
72
  }
73
73
  catch (error) {
74
- this.logger.error(`Error: ${ErrorCodes.INVALID_APPROVAL}`, error);
74
+ this.logger.error("Error:", error);
75
75
  throw new Error(ErrorCodes.INVALID_APPROVAL.toString());
76
76
  }
77
77
  }
@@ -85,7 +85,25 @@ let SessionKeysService = SessionKeysService_1 = class SessionKeysService {
85
85
  const kernelProvider = new KernelEIP1193Provider(kernelClient);
86
86
  const ethersProvider = new BrowserProvider(kernelProvider);
87
87
  const signer = await ethersProvider.getSigner();
88
- return signer;
88
+ const aaSigner = signer;
89
+ aaSigner.isAA = true;
90
+ return aaSigner;
91
+ }
92
+ /**
93
+ * Get a signer that would execute all the contract interactions in the coordinator service.
94
+ * There are particular cases where the AA signer does not work so we default to the normal signer.
95
+ * (e.g. `deployPoll`)
96
+ * @param chain - the chain to use
97
+ * @param sessionKeyAddress - the address of the session key. Defaults to normal signer if not provided
98
+ * @param approval - the approval string. Defaults to normal signer if not provided
99
+ * @returns a signer
100
+ */
101
+ async getCoordinatorSigner(chain, sessionKeyAddress, approval) {
102
+ if (sessionKeyAddress && approval) {
103
+ const kernelClient = await this.generateClientFromSessionKey(sessionKeyAddress, approval, chain);
104
+ return this.getKernelClientSigner(kernelClient);
105
+ }
106
+ return getSigner(chain);
89
107
  }
90
108
  /**
91
109
  * Deactivate a session key