@cofhe/sdk 0.2.1 → 0.3.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 (54) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/core/baseBuilder.ts +18 -18
  3. package/core/client.test.ts +58 -55
  4. package/core/client.ts +50 -30
  5. package/core/clientTypes.ts +21 -17
  6. package/core/config.test.ts +32 -33
  7. package/core/config.ts +47 -48
  8. package/core/consts.ts +6 -2
  9. package/core/decrypt/{MockQueryDecrypterAbi.ts → MockThresholdNetworkAbi.ts} +71 -21
  10. package/core/decrypt/cofheMocksDecryptForTx.ts +142 -0
  11. package/core/decrypt/{cofheMocksSealOutput.ts → cofheMocksDecryptForView.ts} +12 -12
  12. package/core/decrypt/decryptForTxBuilder.ts +340 -0
  13. package/core/decrypt/{decryptHandleBuilder.ts → decryptForViewBuilder.ts} +75 -42
  14. package/core/decrypt/tnDecrypt.ts +232 -0
  15. package/core/decrypt/tnSealOutputV1.ts +5 -5
  16. package/core/decrypt/tnSealOutputV2.ts +27 -27
  17. package/core/encrypt/cofheMocksZkVerifySign.ts +15 -15
  18. package/core/encrypt/encryptInputsBuilder.test.ts +57 -61
  19. package/core/encrypt/encryptInputsBuilder.ts +65 -42
  20. package/core/encrypt/zkPackProveVerify.ts +11 -11
  21. package/core/error.ts +18 -18
  22. package/core/fetchKeys.test.ts +3 -3
  23. package/core/fetchKeys.ts +3 -3
  24. package/core/index.ts +14 -11
  25. package/core/utils.ts +10 -10
  26. package/dist/{chunk-I5WFEYXX.js → chunk-2TPSCOW3.js} +791 -209
  27. package/dist/{chunk-R3B5TMVX.js → chunk-NWDKXBIP.js} +3 -2
  28. package/dist/{clientTypes-RqkgkV2i.d.ts → clientTypes-6aTZPQ_4.d.ts} +204 -85
  29. package/dist/{clientTypes-e4filDzK.d.cts → clientTypes-Bhq7pCSA.d.cts} +204 -85
  30. package/dist/core.cjs +799 -214
  31. package/dist/core.d.cts +25 -23
  32. package/dist/core.d.ts +25 -23
  33. package/dist/core.js +2 -2
  34. package/dist/node.cjs +748 -165
  35. package/dist/node.d.cts +10 -10
  36. package/dist/node.d.ts +10 -10
  37. package/dist/node.js +7 -7
  38. package/dist/permits.js +1 -1
  39. package/dist/web.cjs +751 -168
  40. package/dist/web.d.cts +11 -11
  41. package/dist/web.d.ts +11 -11
  42. package/dist/web.js +9 -9
  43. package/node/client.test.ts +34 -34
  44. package/node/config.test.ts +11 -11
  45. package/node/encryptInputs.test.ts +29 -29
  46. package/node/index.ts +15 -15
  47. package/package.json +1 -1
  48. package/web/client.web.test.ts +34 -34
  49. package/web/config.web.test.ts +11 -11
  50. package/web/encryptInputs.web.test.ts +29 -29
  51. package/web/index.ts +19 -19
  52. package/web/worker.builder.web.test.ts +28 -28
  53. package/web/worker.config.web.test.ts +47 -47
  54. package/web/worker.output.web.test.ts +10 -10
@@ -0,0 +1,232 @@
1
+ import { type Permission } from '@/permits';
2
+
3
+ import { CofheError, CofheErrorCode } from '../error.js';
4
+
5
+ type TnDecryptResponse = {
6
+ // TN returns bytes in big-endian order, e.g. [0,0,0,42]
7
+ decrypted: number[];
8
+ signature: string;
9
+ encryption_type: number;
10
+ error_message: string | null;
11
+ };
12
+
13
+ function normalizeSignature(signature: unknown): string {
14
+ if (typeof signature !== 'string') {
15
+ throw new CofheError({
16
+ code: CofheErrorCode.DecryptReturnedNull,
17
+ message: 'decrypt response missing signature',
18
+ context: {
19
+ signature,
20
+ },
21
+ });
22
+ }
23
+
24
+ const trimmed = signature.trim();
25
+ if (trimmed.length === 0) {
26
+ throw new CofheError({
27
+ code: CofheErrorCode.DecryptReturnedNull,
28
+ message: 'decrypt response returned empty signature',
29
+ });
30
+ }
31
+
32
+ // SDK uses "no-0x" signatures in mocks/tests; normalize to that format.
33
+ return trimmed.startsWith('0x') ? trimmed.slice(2) : trimmed;
34
+ }
35
+
36
+ function parseDecryptedBytesToBigInt(decrypted: unknown): bigint {
37
+ if (!Array.isArray(decrypted)) {
38
+ throw new CofheError({
39
+ code: CofheErrorCode.DecryptReturnedNull,
40
+ message: 'decrypt response field <decrypted> must be a byte array',
41
+ context: {
42
+ decrypted,
43
+ },
44
+ });
45
+ }
46
+
47
+ if (decrypted.length === 0) {
48
+ throw new CofheError({
49
+ code: CofheErrorCode.DecryptReturnedNull,
50
+ message: 'decrypt response field <decrypted> was an empty byte array',
51
+ context: {
52
+ decrypted,
53
+ },
54
+ });
55
+ }
56
+
57
+ let hex = '';
58
+ for (const b of decrypted as unknown[]) {
59
+ if (typeof b !== 'number' || !Number.isInteger(b) || b < 0 || b > 255) {
60
+ throw new CofheError({
61
+ code: CofheErrorCode.DecryptReturnedNull,
62
+ message: 'decrypt response field <decrypted> contained a non-byte value',
63
+ context: {
64
+ badElement: b,
65
+ decrypted,
66
+ },
67
+ });
68
+ }
69
+ hex += b.toString(16).padStart(2, '0');
70
+ }
71
+
72
+ return BigInt(`0x${hex}`);
73
+ }
74
+
75
+ function assertTnDecryptResponse(value: unknown): TnDecryptResponse {
76
+ if (value == null || typeof value !== 'object') {
77
+ throw new CofheError({
78
+ code: CofheErrorCode.DecryptFailed,
79
+ message: 'decrypt response must be a JSON object',
80
+ context: {
81
+ value,
82
+ },
83
+ });
84
+ }
85
+
86
+ const v = value as Record<string, unknown>;
87
+ const decrypted = v.decrypted;
88
+ const signature = v.signature;
89
+ const encryptionType = v.encryption_type;
90
+ const errorMessage = v.error_message;
91
+
92
+ if (!Array.isArray(decrypted)) {
93
+ throw new CofheError({
94
+ code: CofheErrorCode.DecryptReturnedNull,
95
+ message: 'decrypt response missing <decrypted> byte array',
96
+ context: { decryptResponse: value },
97
+ });
98
+ }
99
+ if (typeof signature !== 'string') {
100
+ throw new CofheError({
101
+ code: CofheErrorCode.DecryptReturnedNull,
102
+ message: 'decrypt response missing <signature> string',
103
+ context: { decryptResponse: value },
104
+ });
105
+ }
106
+ if (typeof encryptionType !== 'number') {
107
+ throw new CofheError({
108
+ code: CofheErrorCode.DecryptFailed,
109
+ message: 'decrypt response missing <encryption_type> number',
110
+ context: { decryptResponse: value },
111
+ });
112
+ }
113
+ if (!(typeof errorMessage === 'string' || errorMessage === null)) {
114
+ throw new CofheError({
115
+ code: CofheErrorCode.DecryptFailed,
116
+ message: 'decrypt response field <error_message> must be string or null',
117
+ context: { decryptResponse: value },
118
+ });
119
+ }
120
+
121
+ return {
122
+ decrypted: decrypted as number[],
123
+ signature,
124
+ encryption_type: encryptionType,
125
+ error_message: errorMessage,
126
+ };
127
+ }
128
+
129
+ export async function tnDecrypt(
130
+ ctHash: bigint,
131
+ chainId: number,
132
+ permission: Permission | null,
133
+ thresholdNetworkUrl: string
134
+ ): Promise<{ decryptedValue: bigint; signature: string }> {
135
+ const body: {
136
+ ct_tempkey: string;
137
+ host_chain_id: number;
138
+ permit?: Permission;
139
+ } = {
140
+ ct_tempkey: ctHash.toString(16).padStart(64, '0'),
141
+ host_chain_id: chainId,
142
+ };
143
+
144
+ if (permission) {
145
+ body.permit = permission;
146
+ }
147
+
148
+ let response: Response;
149
+ try {
150
+ response = await fetch(`${thresholdNetworkUrl}/decrypt`, {
151
+ method: 'POST',
152
+ headers: {
153
+ 'Content-Type': 'application/json',
154
+ },
155
+ body: JSON.stringify(body),
156
+ });
157
+ } catch (e) {
158
+ throw new CofheError({
159
+ code: CofheErrorCode.DecryptFailed,
160
+ message: `decrypt request failed`,
161
+ hint: 'Ensure the threshold network URL is valid and reachable.',
162
+ cause: e instanceof Error ? e : undefined,
163
+ context: {
164
+ thresholdNetworkUrl,
165
+ body,
166
+ },
167
+ });
168
+ }
169
+
170
+ const responseText = await response.text();
171
+
172
+ // Even on non-200 responses, TN may return JSON with { error_message }.
173
+ if (!response.ok) {
174
+ let errorMessage = response.statusText || `HTTP ${response.status}`;
175
+ try {
176
+ const errorBody = JSON.parse(responseText) as Record<string, unknown>;
177
+ const maybeMessage = (errorBody.error_message || errorBody.message) as unknown;
178
+ if (typeof maybeMessage === 'string' && maybeMessage.length > 0) errorMessage = maybeMessage;
179
+ } catch {
180
+ const trimmed = responseText.trim();
181
+ if (trimmed.length > 0) errorMessage = trimmed;
182
+ }
183
+
184
+ throw new CofheError({
185
+ code: CofheErrorCode.DecryptFailed,
186
+ message: `decrypt request failed: ${errorMessage}`,
187
+ hint: 'Check the threshold network URL and request parameters.',
188
+ context: {
189
+ thresholdNetworkUrl,
190
+ status: response.status,
191
+ statusText: response.statusText,
192
+ body,
193
+ responseText,
194
+ },
195
+ });
196
+ }
197
+
198
+ let rawJson: unknown;
199
+ try {
200
+ rawJson = JSON.parse(responseText) as unknown;
201
+ } catch (e) {
202
+ throw new CofheError({
203
+ code: CofheErrorCode.DecryptFailed,
204
+ message: `Failed to parse decrypt response`,
205
+ cause: e instanceof Error ? e : undefined,
206
+ context: {
207
+ thresholdNetworkUrl,
208
+ body,
209
+ responseText,
210
+ },
211
+ });
212
+ }
213
+
214
+ const decryptResponse = assertTnDecryptResponse(rawJson);
215
+
216
+ if (decryptResponse.error_message) {
217
+ throw new CofheError({
218
+ code: CofheErrorCode.DecryptFailed,
219
+ message: `decrypt request failed: ${decryptResponse.error_message}`,
220
+ context: {
221
+ thresholdNetworkUrl,
222
+ body,
223
+ decryptResponse,
224
+ },
225
+ });
226
+ }
227
+
228
+ const decryptedValue = parseDecryptedBytesToBigInt(decryptResponse.decrypted);
229
+ const signature = normalizeSignature(decryptResponse.signature);
230
+
231
+ return { decryptedValue, signature };
232
+ }
@@ -1,6 +1,6 @@
1
1
  import { type Permission, type EthEncryptedData } from '@/permits';
2
2
 
3
- import { CofhesdkError, CofhesdkErrorCode } from '../error.js';
3
+ import { CofheError, CofheErrorCode } from '../error.js';
4
4
 
5
5
  export async function tnSealOutputV1(
6
6
  ctHash: bigint,
@@ -31,8 +31,8 @@ export async function tnSealOutputV1(
31
31
  sealed = sealOutputResult.sealed;
32
32
  errorMessage = sealOutputResult.error_message;
33
33
  } catch (e) {
34
- throw new CofhesdkError({
35
- code: CofhesdkErrorCode.SealOutputFailed,
34
+ throw new CofheError({
35
+ code: CofheErrorCode.SealOutputFailed,
36
36
  message: `sealOutput request failed`,
37
37
  hint: 'Ensure the threshold network URL is valid.',
38
38
  cause: e instanceof Error ? e : undefined,
@@ -44,8 +44,8 @@ export async function tnSealOutputV1(
44
44
  }
45
45
 
46
46
  if (sealed == null) {
47
- throw new CofhesdkError({
48
- code: CofhesdkErrorCode.SealOutputReturnedNull,
47
+ throw new CofheError({
48
+ code: CofheErrorCode.SealOutputReturnedNull,
49
49
  message: `sealOutput request returned no data | Caused by: ${errorMessage}`,
50
50
  context: {
51
51
  thresholdNetworkUrl,
@@ -1,6 +1,6 @@
1
1
  import { type Permission, type EthEncryptedData } from '@/permits';
2
2
 
3
- import { CofhesdkError, CofhesdkErrorCode } from '../error.js';
3
+ import { CofheError, CofheErrorCode } from '../error.js';
4
4
 
5
5
  // Polling configuration
6
6
  const POLL_INTERVAL_MS = 1000; // 1 second
@@ -39,8 +39,8 @@ function numberArrayToUint8Array(arr: number[]): Uint8Array {
39
39
  */
40
40
  function convertSealedData(sealed: SealOutputStatusResponse['sealed']): EthEncryptedData {
41
41
  if (!sealed) {
42
- throw new CofhesdkError({
43
- code: CofhesdkErrorCode.SealOutputReturnedNull,
42
+ throw new CofheError({
43
+ code: CofheErrorCode.SealOutputReturnedNull,
44
44
  message: 'Sealed data is missing from completed response',
45
45
  });
46
46
  }
@@ -77,8 +77,8 @@ async function submitSealOutputRequest(
77
77
  body: JSON.stringify(body),
78
78
  });
79
79
  } catch (e) {
80
- throw new CofhesdkError({
81
- code: CofhesdkErrorCode.SealOutputFailed,
80
+ throw new CofheError({
81
+ code: CofheErrorCode.SealOutputFailed,
82
82
  message: `sealOutput request failed`,
83
83
  hint: 'Ensure the threshold network URL is valid and reachable.',
84
84
  cause: e instanceof Error ? e : undefined,
@@ -100,8 +100,8 @@ async function submitSealOutputRequest(
100
100
  errorMessage = response.statusText || errorMessage;
101
101
  }
102
102
 
103
- throw new CofhesdkError({
104
- code: CofhesdkErrorCode.SealOutputFailed,
103
+ throw new CofheError({
104
+ code: CofheErrorCode.SealOutputFailed,
105
105
  message: `sealOutput request failed: ${errorMessage}`,
106
106
  hint: 'Check the threshold network URL and request parameters.',
107
107
  context: {
@@ -117,8 +117,8 @@ async function submitSealOutputRequest(
117
117
  try {
118
118
  submitResponse = (await response.json()) as SealOutputSubmitResponse;
119
119
  } catch (e) {
120
- throw new CofhesdkError({
121
- code: CofhesdkErrorCode.SealOutputFailed,
120
+ throw new CofheError({
121
+ code: CofheErrorCode.SealOutputFailed,
122
122
  message: `Failed to parse sealOutput submit response`,
123
123
  cause: e instanceof Error ? e : undefined,
124
124
  context: {
@@ -129,8 +129,8 @@ async function submitSealOutputRequest(
129
129
  }
130
130
 
131
131
  if (!submitResponse.request_id) {
132
- throw new CofhesdkError({
133
- code: CofhesdkErrorCode.SealOutputFailed,
132
+ throw new CofheError({
133
+ code: CofheErrorCode.SealOutputFailed,
134
134
  message: `sealOutput submit response missing request_id`,
135
135
  context: {
136
136
  thresholdNetworkUrl,
@@ -153,8 +153,8 @@ async function pollSealOutputStatus(thresholdNetworkUrl: string, requestId: stri
153
153
  while (!completed) {
154
154
  // Check timeout
155
155
  if (Date.now() - startTime > POLL_TIMEOUT_MS) {
156
- throw new CofhesdkError({
157
- code: CofhesdkErrorCode.SealOutputFailed,
156
+ throw new CofheError({
157
+ code: CofheErrorCode.SealOutputFailed,
158
158
  message: `sealOutput polling timed out after ${POLL_TIMEOUT_MS}ms`,
159
159
  hint: 'The request may still be processing. Try again later.',
160
160
  context: {
@@ -174,8 +174,8 @@ async function pollSealOutputStatus(thresholdNetworkUrl: string, requestId: stri
174
174
  },
175
175
  });
176
176
  } catch (e) {
177
- throw new CofhesdkError({
178
- code: CofhesdkErrorCode.SealOutputFailed,
177
+ throw new CofheError({
178
+ code: CofheErrorCode.SealOutputFailed,
179
179
  message: `sealOutput status poll failed`,
180
180
  hint: 'Ensure the threshold network URL is valid and reachable.',
181
181
  cause: e instanceof Error ? e : undefined,
@@ -188,8 +188,8 @@ async function pollSealOutputStatus(thresholdNetworkUrl: string, requestId: stri
188
188
 
189
189
  // Handle 404 - request not found
190
190
  if (response.status === 404) {
191
- throw new CofhesdkError({
192
- code: CofhesdkErrorCode.SealOutputFailed,
191
+ throw new CofheError({
192
+ code: CofheErrorCode.SealOutputFailed,
193
193
  message: `sealOutput request not found: ${requestId}`,
194
194
  hint: 'The request may have expired or been invalid.',
195
195
  context: {
@@ -209,8 +209,8 @@ async function pollSealOutputStatus(thresholdNetworkUrl: string, requestId: stri
209
209
  errorMessage = response.statusText || errorMessage;
210
210
  }
211
211
 
212
- throw new CofhesdkError({
213
- code: CofhesdkErrorCode.SealOutputFailed,
212
+ throw new CofheError({
213
+ code: CofheErrorCode.SealOutputFailed,
214
214
  message: `sealOutput status poll failed: ${errorMessage}`,
215
215
  context: {
216
216
  thresholdNetworkUrl,
@@ -225,8 +225,8 @@ async function pollSealOutputStatus(thresholdNetworkUrl: string, requestId: stri
225
225
  try {
226
226
  statusResponse = (await response.json()) as SealOutputStatusResponse;
227
227
  } catch (e) {
228
- throw new CofhesdkError({
229
- code: CofhesdkErrorCode.SealOutputFailed,
228
+ throw new CofheError({
229
+ code: CofheErrorCode.SealOutputFailed,
230
230
  message: `Failed to parse sealOutput status response`,
231
231
  cause: e instanceof Error ? e : undefined,
232
232
  context: {
@@ -241,8 +241,8 @@ async function pollSealOutputStatus(thresholdNetworkUrl: string, requestId: stri
241
241
  // Check if succeeded
242
242
  if (statusResponse.is_succeed === false) {
243
243
  const errorMessage = statusResponse.error_message || 'Unknown error';
244
- throw new CofhesdkError({
245
- code: CofhesdkErrorCode.SealOutputFailed,
244
+ throw new CofheError({
245
+ code: CofheErrorCode.SealOutputFailed,
246
246
  message: `sealOutput request failed: ${errorMessage}`,
247
247
  context: {
248
248
  thresholdNetworkUrl,
@@ -254,8 +254,8 @@ async function pollSealOutputStatus(thresholdNetworkUrl: string, requestId: stri
254
254
 
255
255
  // Check if sealed data exists
256
256
  if (!statusResponse.sealed) {
257
- throw new CofhesdkError({
258
- code: CofhesdkErrorCode.SealOutputReturnedNull,
257
+ throw new CofheError({
258
+ code: CofheErrorCode.SealOutputReturnedNull,
259
259
  message: `sealOutput request completed but returned no sealed data`,
260
260
  context: {
261
261
  thresholdNetworkUrl,
@@ -274,8 +274,8 @@ async function pollSealOutputStatus(thresholdNetworkUrl: string, requestId: stri
274
274
  }
275
275
 
276
276
  // This should never be reached, but TypeScript requires it
277
- throw new CofhesdkError({
278
- code: CofhesdkErrorCode.SealOutputFailed,
277
+ throw new CofheError({
278
+ code: CofheErrorCode.SealOutputFailed,
279
279
  message: 'Polling loop exited unexpectedly',
280
280
  context: {
281
281
  thresholdNetworkUrl,
@@ -12,7 +12,7 @@ import {
12
12
  } from 'viem';
13
13
  import { MockZkVerifierAbi } from './MockZkVerifierAbi.js';
14
14
  import { hardhat } from 'viem/chains';
15
- import { CofhesdkError, CofhesdkErrorCode } from '../error.js';
15
+ import { CofheError, CofheErrorCode } from '../error.js';
16
16
  import { privateKeyToAccount } from 'viem/accounts';
17
17
  import { MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY, MOCKS_ZK_VERIFIER_ADDRESS } from '../consts.js';
18
18
 
@@ -70,8 +70,8 @@ export async function cofheMocksCheckEncryptableBits(items: EncryptableItem[]):
70
70
  }
71
71
  }
72
72
  if (totalBits > MAX_ENCRYPTABLE_BITS) {
73
- throw new CofhesdkError({
74
- code: CofhesdkErrorCode.ZkPackFailed,
73
+ throw new CofheError({
74
+ code: CofheErrorCode.ZkPackFailed,
75
75
  message: `Total bits ${totalBits} exceeds ${MAX_ENCRYPTABLE_BITS}`,
76
76
  hint: `Ensure that the total bits of the items to encrypt does not exceed ${MAX_ENCRYPTABLE_BITS}`,
77
77
  context: {
@@ -110,8 +110,8 @@ async function calcCtHashes(
110
110
  args: calcCtHashesArgs,
111
111
  })) as bigint[];
112
112
  } catch (err) {
113
- throw new CofhesdkError({
114
- code: CofhesdkErrorCode.ZkMocksCalcCtHashesFailed,
113
+ throw new CofheError({
114
+ code: CofheErrorCode.ZkMocksCalcCtHashesFailed,
115
115
  message: `mockZkVerifySign calcCtHashes failed while calling zkVerifyCalcCtHashesPacked`,
116
116
  cause: err instanceof Error ? err : undefined,
117
117
  context: {
@@ -126,8 +126,8 @@ async function calcCtHashes(
126
126
  }
127
127
 
128
128
  if (ctHashes.length !== items.length) {
129
- throw new CofhesdkError({
130
- code: CofhesdkErrorCode.ZkMocksCalcCtHashesFailed,
129
+ throw new CofheError({
130
+ code: CofheErrorCode.ZkMocksCalcCtHashesFailed,
131
131
  message: `mockZkVerifySign calcCtHashes returned incorrect number of ctHashes`,
132
132
  context: {
133
133
  items,
@@ -164,8 +164,8 @@ async function insertCtHashes(items: EncryptableItemWithCtHash[], walletClient:
164
164
  account: account,
165
165
  });
166
166
  } catch (err) {
167
- throw new CofhesdkError({
168
- code: CofhesdkErrorCode.ZkMocksInsertCtHashesFailed,
167
+ throw new CofheError({
168
+ code: CofheErrorCode.ZkMocksInsertCtHashesFailed,
169
169
  message: `mockZkVerifySign insertPackedCtHashes failed while calling insertPackedCtHashes`,
170
170
  cause: err instanceof Error ? err : undefined,
171
171
  context: {
@@ -192,8 +192,8 @@ async function createProofSignatures(items: EncryptableItemWithCtHash[], securit
192
192
  try {
193
193
  encInputSignerClient = createMockZkVerifierSigner();
194
194
  } catch (err) {
195
- throw new CofhesdkError({
196
- code: CofhesdkErrorCode.ZkMocksCreateProofSignatureFailed,
195
+ throw new CofheError({
196
+ code: CofheErrorCode.ZkMocksCreateProofSignatureFailed,
197
197
  message: `mockZkVerifySign createProofSignatures failed while creating wallet client`,
198
198
  cause: err instanceof Error ? err : undefined,
199
199
  context: {
@@ -220,8 +220,8 @@ async function createProofSignatures(items: EncryptableItemWithCtHash[], securit
220
220
  signatures.push(signature);
221
221
  }
222
222
  } catch (err) {
223
- throw new CofhesdkError({
224
- code: CofhesdkErrorCode.ZkMocksCreateProofSignatureFailed,
223
+ throw new CofheError({
224
+ code: CofheErrorCode.ZkMocksCreateProofSignatureFailed,
225
225
  message: `mockZkVerifySign createProofSignatures failed while calling signMessage`,
226
226
  cause: err instanceof Error ? err : undefined,
227
227
  context: {
@@ -232,8 +232,8 @@ async function createProofSignatures(items: EncryptableItemWithCtHash[], securit
232
232
  }
233
233
 
234
234
  if (signatures.length !== items.length) {
235
- throw new CofhesdkError({
236
- code: CofhesdkErrorCode.ZkMocksCreateProofSignatureFailed,
235
+ throw new CofheError({
236
+ code: CofheErrorCode.ZkMocksCreateProofSignatureFailed,
237
237
  message: `mockZkVerifySign createProofSignatures returned incorrect number of signatures`,
238
238
  context: {
239
239
  items,