@waku/rln 0.1.5-9901863.0 → 0.1.5-a8ff776.0

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 (62) hide show
  1. package/bundle/index.js +0 -2
  2. package/bundle/packages/rln/dist/contract/constants.js +1 -1
  3. package/bundle/packages/rln/dist/contract/rln_contract.js +419 -9
  4. package/bundle/packages/rln/dist/create.js +1 -1
  5. package/bundle/packages/rln/dist/identity.js +0 -8
  6. package/bundle/packages/rln/dist/keystore/keystore.js +28 -19
  7. package/bundle/packages/rln/dist/rln.js +166 -56
  8. package/dist/.tsbuildinfo +1 -1
  9. package/dist/contract/constants.d.ts +1 -1
  10. package/dist/contract/constants.js +1 -1
  11. package/dist/contract/constants.js.map +1 -1
  12. package/dist/contract/rln_contract.d.ts +122 -5
  13. package/dist/contract/rln_contract.js +417 -8
  14. package/dist/contract/rln_contract.js.map +1 -1
  15. package/dist/create.js +1 -1
  16. package/dist/create.js.map +1 -1
  17. package/dist/identity.d.ts +0 -1
  18. package/dist/identity.js +0 -8
  19. package/dist/identity.js.map +1 -1
  20. package/dist/index.d.ts +1 -3
  21. package/dist/index.js +1 -3
  22. package/dist/index.js.map +1 -1
  23. package/dist/keystore/keystore.d.ts +1 -0
  24. package/dist/keystore/keystore.js +28 -19
  25. package/dist/keystore/keystore.js.map +1 -1
  26. package/dist/keystore/types.d.ts +1 -1
  27. package/dist/rln.d.ts +52 -9
  28. package/dist/rln.js +163 -54
  29. package/dist/rln.js.map +1 -1
  30. package/package.json +1 -1
  31. package/src/contract/constants.ts +1 -1
  32. package/src/contract/rln_contract.ts +663 -9
  33. package/src/create.ts +1 -1
  34. package/src/identity.ts +0 -9
  35. package/src/index.ts +0 -4
  36. package/src/keystore/keystore.ts +46 -31
  37. package/src/keystore/types.ts +1 -1
  38. package/src/rln.ts +259 -67
  39. package/bundle/packages/rln/dist/contract/rln_base_contract.js +0 -477
  40. package/bundle/packages/rln/dist/contract/types.js +0 -9
  41. package/bundle/packages/rln/dist/credentials_manager.js +0 -233
  42. package/bundle/packages/rln/node_modules/@noble/hashes/esm/_assert.js +0 -43
  43. package/bundle/packages/rln/node_modules/@noble/hashes/esm/_sha2.js +0 -116
  44. package/bundle/packages/rln/node_modules/@noble/hashes/esm/hmac.js +0 -79
  45. package/bundle/packages/rln/node_modules/@noble/hashes/esm/sha256.js +0 -126
  46. package/bundle/packages/rln/node_modules/@noble/hashes/esm/utils.js +0 -43
  47. package/dist/contract/rln_base_contract.d.ts +0 -96
  48. package/dist/contract/rln_base_contract.js +0 -460
  49. package/dist/contract/rln_base_contract.js.map +0 -1
  50. package/dist/contract/types.d.ts +0 -40
  51. package/dist/contract/types.js +0 -8
  52. package/dist/contract/types.js.map +0 -1
  53. package/dist/credentials_manager.d.ts +0 -50
  54. package/dist/credentials_manager.js +0 -215
  55. package/dist/credentials_manager.js.map +0 -1
  56. package/dist/types.d.ts +0 -27
  57. package/dist/types.js +0 -2
  58. package/dist/types.js.map +0 -1
  59. package/src/contract/rln_base_contract.ts +0 -707
  60. package/src/contract/types.ts +0 -48
  61. package/src/credentials_manager.ts +0 -306
  62. package/src/types.ts +0 -31
package/src/create.ts CHANGED
@@ -5,5 +5,5 @@ export async function createRLN(): Promise<RLNInstance> {
5
5
  // asynchronously. This file does the single async import, so
6
6
  // that no one else needs to worry about it again.
7
7
  const rlnModule = await import("./rln.js");
8
- return rlnModule.RLNInstance.create();
8
+ return rlnModule.create();
9
9
  }
package/src/identity.ts CHANGED
@@ -28,13 +28,4 @@ export class IdentityCredential {
28
28
  idCommitmentBigInt
29
29
  );
30
30
  }
31
-
32
- public toJSON(): Record<string, number[]> {
33
- return {
34
- idTrapdoor: Array.from(this.IDTrapdoor),
35
- idNullifier: Array.from(this.IDNullifier),
36
- idSecretHash: Array.from(this.IDSecretHash),
37
- idCommitment: Array.from(this.IDCommitment)
38
- };
39
- }
40
31
  }
package/src/index.ts CHANGED
@@ -1,9 +1,7 @@
1
1
  import { RLNDecoder, RLNEncoder } from "./codec.js";
2
2
  import { RLN_ABI } from "./contract/abi.js";
3
3
  import { LINEA_CONTRACT, RLNContract } from "./contract/index.js";
4
- import { RLNBaseContract } from "./contract/rln_base_contract.js";
5
4
  import { createRLN } from "./create.js";
6
- import { RLNCredentialsManager } from "./credentials_manager.js";
7
5
  import { IdentityCredential } from "./identity.js";
8
6
  import { Keystore } from "./keystore/index.js";
9
7
  import { Proof } from "./proof.js";
@@ -12,8 +10,6 @@ import { MerkleRootTracker } from "./root_tracker.js";
12
10
  import { extractMetaMaskSigner } from "./utils/index.js";
13
11
 
14
12
  export {
15
- RLNCredentialsManager,
16
- RLNBaseContract,
17
13
  createRLN,
18
14
  Keystore,
19
15
  RLNInstance,
@@ -14,7 +14,6 @@ import {
14
14
  import _ from "lodash";
15
15
  import { v4 as uuidV4 } from "uuid";
16
16
 
17
- import { IdentityCredential } from "../identity.js";
18
17
  import { buildBigIntFromUint8Array } from "../utils/bytes.js";
19
18
 
20
19
  import { decryptEipKeystore, keccak256Checksum } from "./cipher.js";
@@ -251,32 +250,32 @@ export class Keystore {
251
250
  const str = bytesToUtf8(bytes);
252
251
  const obj = JSON.parse(str);
253
252
 
254
- // Get identity fields from named object
255
- const { idTrapdoor, idNullifier, idSecretHash, idCommitment } = _.get(
256
- obj,
257
- "identityCredential",
258
- {}
259
- );
260
-
261
- const idTrapdoorArray = new Uint8Array(idTrapdoor || []);
262
- const idNullifierArray = new Uint8Array(idNullifier || []);
263
- const idSecretHashArray = new Uint8Array(idSecretHash || []);
264
- const idCommitmentArray = new Uint8Array(idCommitment || []);
265
- const idCommitmentBigInt = buildBigIntFromUint8Array(idCommitmentArray);
266
-
253
+ // TODO: add runtime validation of nwaku credentials
267
254
  return {
268
- identity: new IdentityCredential(
269
- idTrapdoorArray,
270
- idNullifierArray,
271
- idSecretHashArray,
272
- idCommitmentArray,
273
- idCommitmentBigInt
274
- ),
255
+ identity: {
256
+ IDCommitment: Keystore.fromArraylikeToBytes(
257
+ _.get(obj, "identityCredential.idCommitment", [])
258
+ ),
259
+ IDTrapdoor: Keystore.fromArraylikeToBytes(
260
+ _.get(obj, "identityCredential.idTrapdoor", [])
261
+ ),
262
+ IDNullifier: Keystore.fromArraylikeToBytes(
263
+ _.get(obj, "identityCredential.idNullifier", [])
264
+ ),
265
+ IDCommitmentBigInt: buildBigIntFromUint8Array(
266
+ Keystore.fromArraylikeToBytes(
267
+ _.get(obj, "identityCredential.idCommitment", [])
268
+ )
269
+ ),
270
+ IDSecretHash: Keystore.fromArraylikeToBytes(
271
+ _.get(obj, "identityCredential.idSecretHash", [])
272
+ )
273
+ },
275
274
  membership: {
276
275
  treeIndex: _.get(obj, "treeIndex"),
277
276
  chainId: _.get(obj, "membershipContract.chainId"),
278
277
  address: _.get(obj, "membershipContract.address"),
279
- rateLimit: _.get(obj, "userMessageLimit")
278
+ rateLimit: _.get(obj, "membershipContract.rateLimit")
280
279
  }
281
280
  };
282
281
  } catch (err) {
@@ -285,6 +284,23 @@ export class Keystore {
285
284
  }
286
285
  }
287
286
 
287
+ private static fromArraylikeToBytes(obj: {
288
+ [key: number]: number;
289
+ }): Uint8Array {
290
+ const bytes = [];
291
+
292
+ let index = 0;
293
+ let lastElement = obj[index];
294
+
295
+ while (lastElement !== undefined) {
296
+ bytes.push(lastElement);
297
+ index += 1;
298
+ lastElement = obj[index];
299
+ }
300
+
301
+ return new Uint8Array(bytes);
302
+ }
303
+
288
304
  // follows nwaku implementation
289
305
  // https://github.com/waku-org/nwaku/blob/f05528d4be3d3c876a8b07f9bb7dfaae8aa8ec6e/waku/waku_keystore/protocol_types.nim#L111
290
306
  private static computeMembershipHash(info: MembershipInfo): MembershipHash {
@@ -298,18 +314,17 @@ export class Keystore {
298
314
  private static fromIdentityToBytes(options: KeystoreEntity): Uint8Array {
299
315
  return utf8ToBytes(
300
316
  JSON.stringify({
301
- membershipContract: {
302
- chainId: options.membership.chainId,
303
- address: options.membership.address
304
- },
305
317
  treeIndex: options.membership.treeIndex,
306
318
  identityCredential: {
307
- idTrapdoor: Array.from(options.identity.IDTrapdoor),
308
- idNullifier: Array.from(options.identity.IDNullifier),
309
- idSecretHash: Array.from(options.identity.IDSecretHash),
310
- idCommitment: Array.from(options.identity.IDCommitment)
319
+ idCommitment: options.identity.IDCommitment,
320
+ idNullifier: options.identity.IDNullifier,
321
+ idSecretHash: options.identity.IDSecretHash,
322
+ idTrapdoor: options.identity.IDTrapdoor
311
323
  },
312
- userMessageLimit: options.membership.rateLimit
324
+ membershipContract: {
325
+ chainId: options.membership.chainId,
326
+ address: options.membership.address
327
+ }
313
328
  })
314
329
  );
315
330
  }
@@ -8,7 +8,7 @@ export type Password = string | Uint8Array;
8
8
  // see reference
9
9
  // https://github.com/waku-org/nwaku/blob/f05528d4be3d3c876a8b07f9bb7dfaae8aa8ec6e/waku/waku_keystore/protocol_types.nim#L111
10
10
  export type MembershipInfo = {
11
- chainId: string;
11
+ chainId: number;
12
12
  address: string;
13
13
  treeIndex: number;
14
14
  rateLimit: number;
package/src/rln.ts CHANGED
@@ -7,6 +7,7 @@ import type {
7
7
  import { Logger } from "@waku/utils";
8
8
  import init from "@waku/zerokit-rln-wasm";
9
9
  import * as zerokitRLN from "@waku/zerokit-rln-wasm";
10
+ import { ethers } from "ethers";
10
11
 
11
12
  import {
12
13
  createRLNDecoder,
@@ -15,51 +16,258 @@ import {
15
16
  type RLNEncoder
16
17
  } from "./codec.js";
17
18
  import { DEFAULT_RATE_LIMIT } from "./contract/constants.js";
18
- import { RLNCredentialsManager } from "./credentials_manager.js";
19
+ import { LINEA_CONTRACT, RLNContract } from "./contract/index.js";
20
+ import { IdentityCredential } from "./identity.js";
21
+ import { Keystore } from "./keystore/index.js";
19
22
  import type {
20
23
  DecryptedCredentials,
21
24
  EncryptedCredentials
22
25
  } from "./keystore/index.js";
26
+ import { KeystoreEntity, Password } from "./keystore/types.js";
23
27
  import verificationKey from "./resources/verification_key";
24
28
  import * as wc from "./resources/witness_calculator";
25
29
  import { WitnessCalculator } from "./resources/witness_calculator";
30
+ import { extractMetaMaskSigner } from "./utils/index.js";
26
31
  import { Zerokit } from "./zerokit.js";
27
32
 
28
33
  const log = new Logger("waku:rln");
29
34
 
35
+ async function loadWitnessCalculator(): Promise<WitnessCalculator> {
36
+ try {
37
+ const url = new URL("./resources/rln.wasm", import.meta.url);
38
+ const response = await fetch(url);
39
+
40
+ if (!response.ok) {
41
+ throw new Error(
42
+ `Failed to fetch witness calculator: ${response.status} ${response.statusText}`
43
+ );
44
+ }
45
+
46
+ return await wc.builder(
47
+ new Uint8Array(await response.arrayBuffer()),
48
+ false
49
+ );
50
+ } catch (error) {
51
+ log.error("Error loading witness calculator:", error);
52
+ throw new Error(
53
+ `Failed to load witness calculator: ${error instanceof Error ? error.message : String(error)}`
54
+ );
55
+ }
56
+ }
57
+
58
+ async function loadZkey(): Promise<Uint8Array> {
59
+ try {
60
+ const url = new URL("./resources/rln_final.zkey", import.meta.url);
61
+ const response = await fetch(url);
62
+
63
+ if (!response.ok) {
64
+ throw new Error(
65
+ `Failed to fetch zkey: ${response.status} ${response.statusText}`
66
+ );
67
+ }
68
+
69
+ return new Uint8Array(await response.arrayBuffer());
70
+ } catch (error) {
71
+ log.error("Error loading zkey:", error);
72
+ throw new Error(
73
+ `Failed to load zkey: ${error instanceof Error ? error.message : String(error)}`
74
+ );
75
+ }
76
+ }
77
+
78
+ /**
79
+ * Create an instance of RLN
80
+ * @returns RLNInstance
81
+ */
82
+ export async function create(): Promise<RLNInstance> {
83
+ try {
84
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
85
+ await (init as any)?.();
86
+ zerokitRLN.init_panic_hook();
87
+
88
+ const witnessCalculator = await loadWitnessCalculator();
89
+ const zkey = await loadZkey();
90
+
91
+ const stringEncoder = new TextEncoder();
92
+ const vkey = stringEncoder.encode(JSON.stringify(verificationKey));
93
+
94
+ const DEPTH = 20;
95
+ const zkRLN = zerokitRLN.newRLN(DEPTH, zkey, vkey);
96
+ const zerokit = new Zerokit(zkRLN, witnessCalculator, DEFAULT_RATE_LIMIT);
97
+
98
+ return new RLNInstance(zerokit);
99
+ } catch (error) {
100
+ log.error("Failed to initialize RLN:", error);
101
+ throw error;
102
+ }
103
+ }
104
+
105
+ type StartRLNOptions = {
106
+ /**
107
+ * If not set - will extract MetaMask account and get signer from it.
108
+ */
109
+ signer?: ethers.Signer;
110
+ /**
111
+ * If not set - will use default LINEA_CONTRACT address.
112
+ */
113
+ address?: string;
114
+ /**
115
+ * Credentials to use for generating proofs and connecting to the contract and network.
116
+ * If provided used for validating the network chainId and connecting to registry contract.
117
+ */
118
+ credentials?: EncryptedCredentials | DecryptedCredentials;
119
+ /**
120
+ * Rate limit for the member.
121
+ */
122
+ rateLimit?: number;
123
+ };
124
+
125
+ type RegisterMembershipOptions =
126
+ | { signature: string }
127
+ | { identity: IdentityCredential };
128
+
30
129
  type WakuRLNEncoderOptions = WakuEncoderOptions & {
31
130
  credentials: EncryptedCredentials | DecryptedCredentials;
32
131
  };
33
132
 
34
- export class RLNInstance extends RLNCredentialsManager {
35
- /**
36
- * Create an instance of RLN
37
- * @returns RLNInstance
38
- */
39
- public static async create(): Promise<RLNInstance> {
133
+ export class RLNInstance {
134
+ private started = false;
135
+ private starting = false;
136
+
137
+ private _contract: undefined | RLNContract;
138
+ private _signer: undefined | ethers.Signer;
139
+
140
+ private keystore = Keystore.create();
141
+ private _credentials: undefined | DecryptedCredentials;
142
+
143
+ public constructor(public zerokit: Zerokit) {}
144
+
145
+ public get contract(): undefined | RLNContract {
146
+ return this._contract;
147
+ }
148
+
149
+ public get signer(): undefined | ethers.Signer {
150
+ return this._signer;
151
+ }
152
+
153
+ public async start(options: StartRLNOptions = {}): Promise<void> {
154
+ if (this.started || this.starting) {
155
+ return;
156
+ }
157
+
158
+ this.starting = true;
159
+
40
160
  try {
41
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
42
- await (init as any)?.();
43
- zerokitRLN.init_panic_hook();
161
+ const { credentials, keystore } =
162
+ await RLNInstance.decryptCredentialsIfNeeded(options.credentials);
163
+ const { signer, address } = await this.determineStartOptions(
164
+ options,
165
+ credentials
166
+ );
167
+
168
+ if (keystore) {
169
+ this.keystore = keystore;
170
+ }
44
171
 
45
- const witnessCalculator = await RLNInstance.loadWitnessCalculator();
46
- const zkey = await RLNInstance.loadZkey();
172
+ this._credentials = credentials;
173
+ this._signer = signer!;
174
+ this._contract = await RLNContract.init(this, {
175
+ address: address!,
176
+ signer: signer!,
177
+ rateLimit: options.rateLimit ?? this.zerokit.getRateLimit
178
+ });
179
+ this.started = true;
180
+ } finally {
181
+ this.starting = false;
182
+ }
183
+ }
47
184
 
48
- const stringEncoder = new TextEncoder();
49
- const vkey = stringEncoder.encode(JSON.stringify(verificationKey));
185
+ private async determineStartOptions(
186
+ options: StartRLNOptions,
187
+ credentials: KeystoreEntity | undefined
188
+ ): Promise<StartRLNOptions> {
189
+ let chainId = credentials?.membership.chainId;
190
+ const address =
191
+ credentials?.membership.address ||
192
+ options.address ||
193
+ LINEA_CONTRACT.address;
194
+
195
+ if (address === LINEA_CONTRACT.address) {
196
+ chainId = LINEA_CONTRACT.chainId;
197
+ }
50
198
 
51
- const DEPTH = 20;
52
- const zkRLN = zerokitRLN.newRLN(DEPTH, zkey, vkey);
53
- const zerokit = new Zerokit(zkRLN, witnessCalculator, DEFAULT_RATE_LIMIT);
199
+ const signer = options.signer || (await extractMetaMaskSigner());
200
+ const currentChainId = await signer.getChainId();
54
201
 
55
- return new RLNInstance(zerokit);
56
- } catch (error) {
57
- log.error("Failed to initialize RLN:", error);
58
- throw error;
202
+ if (chainId && chainId !== currentChainId) {
203
+ throw Error(
204
+ `Failed to start RLN contract, chain ID of contract is different from current one: contract-${chainId}, current network-${currentChainId}`
205
+ );
59
206
  }
207
+
208
+ return {
209
+ signer,
210
+ address
211
+ };
60
212
  }
61
- private constructor(public zerokit: Zerokit) {
62
- super(zerokit);
213
+
214
+ private static async decryptCredentialsIfNeeded(
215
+ credentials?: EncryptedCredentials | DecryptedCredentials
216
+ ): Promise<{ credentials?: DecryptedCredentials; keystore?: Keystore }> {
217
+ if (!credentials) {
218
+ return {};
219
+ }
220
+
221
+ if ("identity" in credentials) {
222
+ return { credentials };
223
+ }
224
+
225
+ const keystore = Keystore.fromString(credentials.keystore);
226
+
227
+ if (!keystore) {
228
+ return {};
229
+ }
230
+
231
+ const decryptedCredentials = await keystore.readCredential(
232
+ credentials.id,
233
+ credentials.password
234
+ );
235
+
236
+ return {
237
+ keystore,
238
+ credentials: decryptedCredentials
239
+ };
240
+ }
241
+
242
+ public async registerMembership(
243
+ options: RegisterMembershipOptions
244
+ ): Promise<undefined | DecryptedCredentials> {
245
+ if (!this.contract) {
246
+ throw Error("RLN Contract is not initialized.");
247
+ }
248
+
249
+ let identity = "identity" in options && options.identity;
250
+
251
+ if ("signature" in options) {
252
+ identity = this.zerokit.generateSeededIdentityCredential(
253
+ options.signature
254
+ );
255
+ }
256
+
257
+ if (!identity) {
258
+ throw Error("Missing signature or identity to register membership.");
259
+ }
260
+
261
+ return this.contract.registerWithIdentity(identity);
262
+ }
263
+
264
+ /**
265
+ * Changes credentials in use by relying on provided Keystore earlier in rln.start
266
+ * @param id: string, hash of credentials to select from Keystore
267
+ * @param password: string or bytes to use to decrypt credentials from Keystore
268
+ */
269
+ public async useCredentials(id: string, password: Password): Promise<void> {
270
+ this._credentials = await this.keystore?.readCredential(id, password);
63
271
  }
64
272
 
65
273
  public async createEncoder(
@@ -67,7 +275,7 @@ export class RLNInstance extends RLNCredentialsManager {
67
275
  ): Promise<RLNEncoder> {
68
276
  const { credentials: decryptedCredentials } =
69
277
  await RLNInstance.decryptCredentialsIfNeeded(options.credentials);
70
- const credentials = decryptedCredentials || this.credentials;
278
+ const credentials = decryptedCredentials || this._credentials;
71
279
 
72
280
  if (!credentials) {
73
281
  throw Error(
@@ -85,6 +293,33 @@ export class RLNInstance extends RLNCredentialsManager {
85
293
  });
86
294
  }
87
295
 
296
+ private async verifyCredentialsAgainstContract(
297
+ credentials: KeystoreEntity
298
+ ): Promise<void> {
299
+ if (!this._contract) {
300
+ throw Error(
301
+ "Failed to verify chain coordinates: no contract initialized."
302
+ );
303
+ }
304
+
305
+ const registryAddress = credentials.membership.address;
306
+ const currentRegistryAddress = this._contract.address;
307
+ if (registryAddress !== currentRegistryAddress) {
308
+ throw Error(
309
+ `Failed to verify chain coordinates: credentials contract address=${registryAddress} is not equal to registryContract address=${currentRegistryAddress}`
310
+ );
311
+ }
312
+
313
+ const chainId = credentials.membership.chainId;
314
+ const network = await this._contract.provider.getNetwork();
315
+ const currentChainId = network.chainId;
316
+ if (chainId !== currentChainId) {
317
+ throw Error(
318
+ `Failed to verify chain coordinates: credentials chainID=${chainId} is not equal to registryContract chainID=${currentChainId}`
319
+ );
320
+ }
321
+ }
322
+
88
323
  public createDecoder(
89
324
  contentTopic: ContentTopic
90
325
  ): RLNDecoder<IDecodedMessage> {
@@ -93,47 +328,4 @@ export class RLNInstance extends RLNCredentialsManager {
93
328
  decoder: createDecoder(contentTopic)
94
329
  });
95
330
  }
96
-
97
- public static async loadWitnessCalculator(): Promise<WitnessCalculator> {
98
- try {
99
- const url = new URL("./resources/rln.wasm", import.meta.url);
100
- const response = await fetch(url);
101
-
102
- if (!response.ok) {
103
- throw new Error(
104
- `Failed to fetch witness calculator: ${response.status} ${response.statusText}`
105
- );
106
- }
107
-
108
- return await wc.builder(
109
- new Uint8Array(await response.arrayBuffer()),
110
- false
111
- );
112
- } catch (error) {
113
- log.error("Error loading witness calculator:", error);
114
- throw new Error(
115
- `Failed to load witness calculator: ${error instanceof Error ? error.message : String(error)}`
116
- );
117
- }
118
- }
119
-
120
- public static async loadZkey(): Promise<Uint8Array> {
121
- try {
122
- const url = new URL("./resources/rln_final.zkey", import.meta.url);
123
- const response = await fetch(url);
124
-
125
- if (!response.ok) {
126
- throw new Error(
127
- `Failed to fetch zkey: ${response.status} ${response.statusText}`
128
- );
129
- }
130
-
131
- return new Uint8Array(await response.arrayBuffer());
132
- } catch (error) {
133
- log.error("Error loading zkey:", error);
134
- throw new Error(
135
- `Failed to load zkey: ${error instanceof Error ? error.message : String(error)}`
136
- );
137
- }
138
- }
139
331
  }