@zama-fhe/relayer-sdk 0.4.0-alpha.0 → 0.4.0-alpha.1

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.
package/lib/node.js CHANGED
@@ -1,37 +1,15 @@
1
1
  import * as TFHEPkg from 'node-tfhe';
2
2
  import { ShortintParameters, ShortintParametersName, ShortintCompactPublicKeyEncryptionParameters, ShortintCompactPublicKeyEncryptionParametersName, TfheConfigBuilder, TfheClientKey, TfheCompactPublicKey, CompactPkeCrs } from 'node-tfhe';
3
3
  import * as TKMSPkg from 'node-tkms';
4
- import { JsonRpcProvider, BrowserProvider, Contract, getAddress as getAddress$2, ethers, isAddress as isAddress$1, keccak256, AbiCoder } from 'ethers';
4
+ import { JsonRpcProvider, BrowserProvider, Contract, getAddress as getAddress$2, isAddress as isAddress$1, keccak256, ethers, AbiCoder } from 'ethers';
5
5
 
6
6
  const SERIALIZED_SIZE_LIMIT_CIPHERTEXT = BigInt(1024 * 1024 * 512);
7
7
  const SERIALIZED_SIZE_LIMIT_PK = BigInt(1024 * 1024 * 512);
8
8
  const SERIALIZED_SIZE_LIMIT_CRS = BigInt(1024 * 1024 * 512);
9
9
 
10
- function setAuth(init, auth) {
11
- if (auth) {
12
- switch (auth.__type) {
13
- case 'BearerToken':
14
- init.headers['Authorization'] =
15
- `Bearer ${auth.token}`;
16
- break;
17
- case 'ApiKeyHeader':
18
- init.headers[auth.header || 'x-api-key'] =
19
- auth.value;
20
- break;
21
- case 'ApiKeyCookie':
22
- if (typeof window !== 'undefined') {
23
- document.cookie = `${auth.cookie || 'x-api-key'}=${auth.value}; path=/; SameSite=Lax; Secure; HttpOnly;`;
24
- init.credentials = 'include';
25
- }
26
- else {
27
- let cookie = `${auth.cookie || 'x-api-key'}=${auth.value};`;
28
- init.headers['Cookie'] = cookie;
29
- }
30
- break;
31
- }
32
- }
33
- return init;
34
- }
10
+ // This file is auto-generated
11
+ const version = '0.4.0-alpha.1';
12
+ const sdkName = '@zama-fhe/relayer-sdk';
35
13
 
36
14
  function getErrorCause(e) {
37
15
  if (e instanceof Error && typeof e.cause === 'object' && e.cause !== null) {
@@ -213,7 +191,39 @@ function throwRelayerUnknownError(operation, error, message) {
213
191
  });
214
192
  }
215
193
 
216
- ////////////////////////////////////////////////////////////////////////////////
194
+ /**
195
+ * Set the authentication method for the request. The default is no authentication.
196
+ * It supports:
197
+ * - Bearer Token
198
+ * - Custom header
199
+ * - Custom cookie
200
+ */
201
+ function setAuth(init, auth) {
202
+ if (auth) {
203
+ switch (auth.__type) {
204
+ case 'BearerToken':
205
+ init.headers['Authorization'] =
206
+ `Bearer ${auth.token}`;
207
+ break;
208
+ case 'ApiKeyHeader':
209
+ init.headers[auth.header || 'x-api-key'] =
210
+ auth.value;
211
+ break;
212
+ case 'ApiKeyCookie':
213
+ if (typeof window !== 'undefined') {
214
+ document.cookie = `${auth.cookie || 'x-api-key'}=${auth.value}; path=/; SameSite=Lax; Secure; HttpOnly;`;
215
+ init.credentials = 'include';
216
+ }
217
+ else {
218
+ let cookie = `${auth.cookie || 'x-api-key'}=${auth.value};`;
219
+ init.headers['Cookie'] = cookie;
220
+ }
221
+ break;
222
+ }
223
+ }
224
+ return init;
225
+ }
226
+
217
227
  function assertIsRelayerV1FetchResponseJson(json) {
218
228
  if (!json || typeof json !== 'object') {
219
229
  throw new Error('Unexpected response JSON.');
@@ -224,11 +234,13 @@ function assertIsRelayerV1FetchResponseJson(json) {
224
234
  throw new Error("Unexpected response JSON format: missing 'response' property.");
225
235
  }
226
236
  }
227
- async function fetchRelayerJsonRpcPost(relayerOperation, url, payload, options) {
237
+ async function fetchRelayerV1Post(relayerOperation, url, payload, options) {
228
238
  const init = setAuth({
229
239
  method: 'POST',
230
240
  headers: {
231
241
  'Content-Type': 'application/json',
242
+ 'ZAMA-SDK-VERSION': `${version}`,
243
+ 'ZAMA-SDK-NAME': `${sdkName}`,
232
244
  },
233
245
  body: JSON.stringify(payload),
234
246
  }, options?.auth);
@@ -259,14 +271,20 @@ async function fetchRelayerJsonRpcPost(relayerOperation, url, payload, options)
259
271
  }
260
272
  return json;
261
273
  }
262
- async function fetchRelayerGet(relayerOperation, url) {
274
+ async function fetchRelayerV1Get(relayerOperation, url) {
275
+ const init = {
276
+ method: 'GET',
277
+ headers: {
278
+ 'ZAMA-SDK-VERSION': `${version}`,
279
+ 'ZAMA-SDK-NAME': `${sdkName}`,
280
+ },
281
+ };
263
282
  let response;
264
283
  let json;
265
284
  try {
266
- response = await fetch(url);
285
+ response = await fetch(url, init);
267
286
  }
268
287
  catch (e) {
269
- console.log(e);
270
288
  throwRelayerUnknownError(relayerOperation, e);
271
289
  }
272
290
  if (!response.ok) {
@@ -294,7 +312,7 @@ const getKeysFromRelayer = async (versionUrl, publicKeyId) => {
294
312
  if (keyurlCache[versionUrl]) {
295
313
  return keyurlCache[versionUrl];
296
314
  }
297
- const data = await fetchRelayerGet('KEY_URL', `${versionUrl}/keyurl`);
315
+ const data = await fetchRelayerV1Get('KEY_URL', `${versionUrl}/keyurl`);
298
316
  try {
299
317
  let pubKeyUrl;
300
318
  // If no publicKeyId is provided, use the first one
@@ -383,7 +401,7 @@ class RelayerErrorBase extends Error {
383
401
  _docsPath;
384
402
  _docsUrl;
385
403
  _version;
386
- static VERSION = '0.3.0-6';
404
+ static VERSION = version;
387
405
  static DEFAULT_DOCS_BASE_URL = 'https//docs.zama.org';
388
406
  static FULL_VERSION = `@zama-fhe/relayer-sdk@${RelayerErrorBase.VERSION}`;
389
407
  constructor(params) {
@@ -792,6 +810,14 @@ function assertRecordStringArrayProperty(o, property, objName) {
792
810
  }
793
811
  }
794
812
  }
813
+ function safeJSONstringify(o) {
814
+ try {
815
+ return JSON.stringify(o, (_, v) => typeof v === 'bigint' ? v.toString() : v);
816
+ }
817
+ catch {
818
+ return '';
819
+ }
820
+ }
795
821
 
796
822
  const abiKmsVerifier = [
797
823
  'function getKmsSigners() view returns (address[])',
@@ -891,6 +917,7 @@ const getCoprocessorSignersThreshold = async (provider, inputVerifierContractAdd
891
917
  return Number(threshold); // threshold is always supposed to fit in a number
892
918
  };
893
919
 
920
+ // This file contains common utilities for both user and public decryption requests
894
921
  const NumEncryptedBits = {
895
922
  0: 2, // ebool
896
923
  2: 8, // euint8
@@ -901,17 +928,6 @@ const NumEncryptedBits = {
901
928
  7: 160, // eaddress
902
929
  8: 256, // euint256
903
930
  };
904
- function getHandleType(handle) {
905
- if (handle.length !== 66) {
906
- throw new Error(`Handle ${handle} is not of valid length`);
907
- }
908
- const hexPair = handle.slice(-4, -2).toLowerCase();
909
- const typeDiscriminant = parseInt(hexPair, 16);
910
- if (!(typeDiscriminant in NumEncryptedBits)) {
911
- throw new Error(`Handle ${handle} is not of valid type`);
912
- }
913
- return typeDiscriminant;
914
- }
915
931
  function checkEncryptedBits(handles) {
916
932
  let total = 0;
917
933
  for (const handle of handles) {
@@ -1321,9 +1337,7 @@ function checkDeadlineValidity(startTimestamp, durationDays) {
1321
1337
  throw Error('User decrypt request has expired');
1322
1338
  }
1323
1339
  }
1324
- const userDecryptRequest = (kmsSigners, gatewayChainId, chainId, verifyingContractAddress, aclContractAddress,
1325
- //relayerUrl: string,
1326
- relayerProvider, provider, instanceOptions) => async (_handles, privateKey, publicKey, signature, contractAddresses, userAddress, startTimestamp, durationDays, options) => {
1340
+ const userDecryptRequest = (kmsSigners, gatewayChainId, chainId, verifyingContractAddress, aclContractAddress, relayerProvider, provider, defaultOptions) => async (_handles, privateKey, publicKey, signature, contractAddresses, userAddress, startTimestamp, durationDays, options) => {
1327
1341
  const extraData = '0x00';
1328
1342
  let pubKey;
1329
1343
  let privKey;
@@ -1337,16 +1351,16 @@ relayerProvider, provider, instanceOptions) => async (_handles, privateKey, publ
1337
1351
  // Casting handles if string
1338
1352
  const signatureSanitized = signature.replace(/^(0x)/, '');
1339
1353
  const publicKeySanitized = publicKey.replace(/^(0x)/, '');
1340
- const handles = _handles.map((h) => ({
1354
+ const handleContractPairs = _handles.map((h) => ({
1341
1355
  handle: typeof h.handle === 'string'
1342
1356
  ? toHexString(hexToBytes(h.handle), true)
1343
1357
  : toHexString(h.handle, true),
1344
1358
  contractAddress: getAddress$1(h.contractAddress),
1345
1359
  }));
1346
- checkEncryptedBits(handles.map((h) => h.handle));
1360
+ checkEncryptedBits(handleContractPairs.map((h) => h.handle));
1347
1361
  checkDeadlineValidity(BigInt(startTimestamp), BigInt(durationDays));
1348
- const acl = new ethers.Contract(aclContractAddress, aclABI$1, provider);
1349
- const verifications = handles.map(async ({ handle, contractAddress }) => {
1362
+ const acl = new Contract(aclContractAddress, aclABI$1, provider);
1363
+ const verifications = handleContractPairs.map(async ({ handle, contractAddress }) => {
1350
1364
  const userAllowed = await acl.persistAllowed(handle, userAddress);
1351
1365
  const contractAllowed = await acl.persistAllowed(handle, contractAddress);
1352
1366
  if (!userAllowed) {
@@ -1370,7 +1384,7 @@ relayerProvider, provider, instanceOptions) => async (_handles, privateKey, publ
1370
1384
  throw e;
1371
1385
  });
1372
1386
  const payloadForRequest = {
1373
- handleContractPairs: handles,
1387
+ handleContractPairs,
1374
1388
  requestValidity: {
1375
1389
  startTimestamp: startTimestamp.toString(), // Convert to string
1376
1390
  durationDays: durationDays.toString(), // Convert to string
@@ -1382,13 +1396,10 @@ relayerProvider, provider, instanceOptions) => async (_handles, privateKey, publ
1382
1396
  publicKey: publicKeySanitized,
1383
1397
  extraData,
1384
1398
  };
1385
- const json = await relayerProvider.fetchPostUserDecrypt(payloadForRequest, options ?? instanceOptions);
1386
- // const json = await fetchRelayerJsonRpcPost(
1387
- // 'USER_DECRYPT',
1388
- // `${relayerUrl}/v1/user-decrypt`,
1389
- // payloadForRequest,
1390
- // instanceOptions ?? options,
1391
- // );
1399
+ const json = await relayerProvider.fetchPostUserDecrypt(payloadForRequest, {
1400
+ ...defaultOptions,
1401
+ ...options,
1402
+ });
1392
1403
  // assume the KMS Signers have the correct order
1393
1404
  let indexedKmsSigners = kmsSigners.map((signer, index) => {
1394
1405
  return TKMS.new_server_id_addr(index + 1, signer);
@@ -1410,13 +1421,13 @@ relayerProvider, provider, instanceOptions) => async (_handles, privateKey, publ
1410
1421
  signature: signatureSanitized,
1411
1422
  client_address: userAddress,
1412
1423
  enc_key: publicKeySanitized,
1413
- ciphertext_handles: handles.map((h) => h.handle.replace(/^0x/, '')),
1424
+ ciphertext_handles: handleContractPairs.map((h) => h.handle.replace(/^0x/, '')),
1414
1425
  eip712_verifying_contract: verifyingContractAddress,
1415
1426
  };
1416
1427
  const decryption = TKMS.process_user_decryption_resp_from_js(client, payloadForVerification, eip712Domain, json, //json.response,
1417
1428
  pubKey, privKey, true);
1418
1429
  const listBigIntDecryptions = decryption.map((d) => bytesToBigInt(d.bytes));
1419
- const results = buildUserDecryptResults(handles.map((h) => h.handle), listBigIntDecryptions);
1430
+ const results = buildUserDecryptResults(handleContractPairs.map((h) => h.handle), listBigIntDecryptions);
1420
1431
  return results;
1421
1432
  }
1422
1433
  catch (e) {
@@ -1708,6 +1719,15 @@ function checksummedAddressToBytes20(address) {
1708
1719
  return bytes;
1709
1720
  }
1710
1721
 
1722
+ class FhevmHandleError extends RelayerErrorBase {
1723
+ constructor({ handle, message }) {
1724
+ super({
1725
+ message: message ?? `FHEVM Handle "${handle}" is invalid.`,
1726
+ name: 'FhevmHandleError',
1727
+ });
1728
+ }
1729
+ }
1730
+
1711
1731
  ////////////////////////////////////////////////////////////////////////////////
1712
1732
  // FhevmHandle
1713
1733
  ////////////////////////////////////////////////////////////////////////////////
@@ -1740,6 +1760,16 @@ class FhevmHandle {
1740
1760
  160: 7,
1741
1761
  256: 8,
1742
1762
  };
1763
+ static FheTypeIdToSolidityPrimitiveType = {
1764
+ 0: 'bool',
1765
+ 2: 'uint256',
1766
+ 3: 'uint256',
1767
+ 4: 'uint256',
1768
+ 5: 'uint256',
1769
+ 6: 'uint256',
1770
+ 7: 'address',
1771
+ 8: 'uint256',
1772
+ };
1743
1773
  static {
1744
1774
  Object.freeze(FhevmHandle.FheTypeIdToEncryptionBitwidths);
1745
1775
  Object.freeze(FhevmHandle.FheTypeEncryptionBitwidthsToId);
@@ -1874,6 +1904,41 @@ class FhevmHandle {
1874
1904
  toBytes32Hex() {
1875
1905
  return bytesToHex(this.toBytes32());
1876
1906
  }
1907
+ static checkHandleHex(handle) {
1908
+ if (!isBytes32Hex(handle)) {
1909
+ throw new FhevmHandleError({ handle });
1910
+ }
1911
+ }
1912
+ static isFheTypeId(value) {
1913
+ switch (value) {
1914
+ case 0:
1915
+ // 1: euint4 is deprecated
1916
+ case 2:
1917
+ case 3:
1918
+ case 4:
1919
+ case 5:
1920
+ case 6:
1921
+ case 7:
1922
+ case 8:
1923
+ return true;
1924
+ default:
1925
+ return false;
1926
+ }
1927
+ }
1928
+ static getFheTypeId(handle) {
1929
+ if (!isBytes32Hex(handle)) {
1930
+ throw new FhevmHandleError({ handle });
1931
+ }
1932
+ const hexPair = handle.slice(-4, -2).toLowerCase();
1933
+ const typeDiscriminant = parseInt(hexPair, 16);
1934
+ if (!FhevmHandle.isFheTypeId(typeDiscriminant)) {
1935
+ throw new FhevmHandleError({
1936
+ handle,
1937
+ message: `FHEVM Handle "${handle}" is invalid. Unknown FheType: ${typeDiscriminant}`,
1938
+ });
1939
+ }
1940
+ return typeDiscriminant;
1941
+ }
1877
1942
  }
1878
1943
 
1879
1944
  // Add type checking
@@ -1912,9 +1977,7 @@ function isFhevmRelayerInputProofResponse(json) {
1912
1977
  return (response.signatures.every((s) => typeof s === 'string') &&
1913
1978
  response.handles.every((h) => typeof h === 'string'));
1914
1979
  }
1915
- const createRelayerEncryptedInput = (aclContractAddress, verifyingContractAddressInputVerification, chainId, gatewayChainId,
1916
- //relayerUrl: string,
1917
- relayerProvider, tfheCompactPublicKey, publicParams, coprocessorSigners, thresholdCoprocessorSigners, instanceOptions) => (contractAddress, userAddress) => {
1980
+ const createRelayerEncryptedInput = (aclContractAddress, verifyingContractAddressInputVerification, chainId, gatewayChainId, relayerProvider, tfheCompactPublicKey, publicParams, coprocessorSigners, thresholdCoprocessorSigners, defaultOptions) => (contractAddress, userAddress) => {
1918
1981
  if (!isAddress$1(contractAddress)) {
1919
1982
  throw new Error('Contract address is not a valid address.');
1920
1983
  }
@@ -1966,11 +2029,13 @@ relayerProvider, tfheCompactPublicKey, publicParams, coprocessorSigners, thresho
1966
2029
  getBits() {
1967
2030
  return input.getBits();
1968
2031
  },
2032
+ getCiphertextWithInputVerification() {
2033
+ return input.encrypt();
2034
+ },
1969
2035
  encrypt: async (options) => {
1970
2036
  const extraData = '0x00';
1971
2037
  const bits = input.getBits();
1972
2038
  const ciphertext = input.encrypt();
1973
- //console.log(`ciphertext=${toHexString(ciphertext)}`);
1974
2039
  const payload = {
1975
2040
  contractAddress: getAddress(contractAddress),
1976
2041
  userAddress: getAddress(userAddress),
@@ -1978,13 +2043,10 @@ relayerProvider, tfheCompactPublicKey, publicParams, coprocessorSigners, thresho
1978
2043
  contractChainId: ('0x' + chainId.toString(16)),
1979
2044
  extraData,
1980
2045
  };
1981
- const json = await relayerProvider.fetchPostInputProof(payload, options ?? instanceOptions);
1982
- // const json = await fetchRelayerJsonRpcPost(
1983
- // 'INPUT_PROOF',
1984
- // `${relayerUrl}/v1/input-proof`,
1985
- // payload,
1986
- // options ?? instanceOptions,
1987
- // );
2046
+ const json = await relayerProvider.fetchPostInputProof(payload, {
2047
+ ...defaultOptions,
2048
+ ...options,
2049
+ });
1988
2050
  if (!isFhevmRelayerInputProofResponse(json)) {
1989
2051
  throwRelayerInternalError('INPUT_PROOF', json);
1990
2052
  }
@@ -1996,7 +2058,6 @@ relayerProvider, tfheCompactPublicKey, publicParams, coprocessorSigners, thresho
1996
2058
  fheTypeEncryptionBitwidths: bits,
1997
2059
  });
1998
2060
  const handles = fhevmHandles.map((h) => h.toBytes32());
1999
- //const result = json.response;
2000
2061
  const result = json;
2001
2062
  // Note that the hex strings returned by the relayer do have have the 0x prefix
2002
2063
  if (result.handles && result.handles.length > 0) {
@@ -2063,6 +2124,21 @@ relayerProvider, tfheCompactPublicKey, publicParams, coprocessorSigners, thresho
2063
2124
  };
2064
2125
  };
2065
2126
 
2127
+ function ensureError(e) {
2128
+ if (e instanceof Error) {
2129
+ return e;
2130
+ }
2131
+ const message = e.message ?? 'Non-Error value caught in exception handler';
2132
+ const name = e.name ?? 'ErrorWrapper';
2133
+ const cause = e.cause ?? e;
2134
+ const err = new Error(message, { cause });
2135
+ err.name = name;
2136
+ return err;
2137
+ }
2138
+ function assertNever(value, message) {
2139
+ throw new InternalError({ message });
2140
+ }
2141
+
2066
2142
  const aclABI = [
2067
2143
  'function isAllowedForDecryption(bytes32 handle) view returns (bool)',
2068
2144
  ];
@@ -2088,7 +2164,7 @@ function abiEncodeClearValues(clearValues) {
2088
2164
  const abiValues = [];
2089
2165
  for (let i = 0; i < handlesBytes32Hex.length; ++i) {
2090
2166
  const handle = handlesBytes32Hex[i];
2091
- const handleType = getHandleType(handle);
2167
+ const handleType = FhevmHandle.getFheTypeId(handle);
2092
2168
  let clearTextValue = clearValues[handle];
2093
2169
  if (typeof clearTextValue === 'boolean') {
2094
2170
  clearTextValue = clearTextValue ? '0x01' : '0x00';
@@ -2125,7 +2201,7 @@ function abiEncodeClearValues(clearValues) {
2125
2201
  break;
2126
2202
  }
2127
2203
  default: {
2128
- throw new Error(`Unsupported Fhevm primitive type id: ${handleType}`);
2204
+ assertNever(handleType, `Unsupported Fhevm primitive type id: ${handleType}`);
2129
2205
  }
2130
2206
  }
2131
2207
  }
@@ -2150,21 +2226,11 @@ function buildDecryptionProof(kmsSignatures, extraData) {
2150
2226
  ]);
2151
2227
  return decryptionProof;
2152
2228
  }
2153
- const CiphertextType = {
2154
- 0: 'bool',
2155
- 2: 'uint256',
2156
- 3: 'uint256',
2157
- 4: 'uint256',
2158
- 5: 'uint256',
2159
- 6: 'uint256',
2160
- 7: 'address',
2161
- 8: 'uint256',
2162
- };
2163
2229
  function deserializeClearValues(handles, decryptedResult) {
2164
2230
  let typesList = [];
2165
2231
  for (const handle of handles) {
2166
- const hexPair = handle.slice(-4, -2).toLowerCase();
2167
- const typeDiscriminant = parseInt(hexPair, 16);
2232
+ const typeDiscriminant = FhevmHandle.getFheTypeId(handle);
2233
+ assertRelayer(FhevmHandle.isFheTypeId(typeDiscriminant));
2168
2234
  typesList.push(typeDiscriminant);
2169
2235
  }
2170
2236
  const restoredEncoded = '0x' +
@@ -2172,7 +2238,7 @@ function deserializeClearValues(handles, decryptedResult) {
2172
2238
  decryptedResult.slice(2) +
2173
2239
  '00'.repeat(32); // dummy empty bytes[] length (ignored)
2174
2240
  const abiTypes = typesList.map((t) => {
2175
- const abiType = CiphertextType[t]; // all types are valid because this was supposedly checked already inside the `checkEncryptedBits` function
2241
+ const abiType = FhevmHandle.FheTypeIdToSolidityPrimitiveType[t]; // all types are valid because this was supposedly checked already inside the `checkEncryptedBits` function
2176
2242
  return abiType;
2177
2243
  });
2178
2244
  const coder = new AbiCoder();
@@ -2183,9 +2249,7 @@ function deserializeClearValues(handles, decryptedResult) {
2183
2249
  handles.forEach((handle, idx) => (results[handle] = rawValues[idx]));
2184
2250
  return results;
2185
2251
  }
2186
- const publicDecryptRequest = (kmsSigners, thresholdSigners, gatewayChainId, verifyingContractAddress, aclContractAddress,
2187
- //relayerUrl: string,
2188
- relayerProvider, provider, instanceOptions) => async (_handles, options) => {
2252
+ const publicDecryptRequest = (kmsSigners, thresholdSigners, gatewayChainId, verifyingContractAddress, aclContractAddress, relayerProvider, provider, defaultOptions) => async (_handles, options) => {
2189
2253
  const extraData = '0x00';
2190
2254
  const acl = new ethers.Contract(aclContractAddress, aclABI, provider);
2191
2255
  let handles;
@@ -2210,13 +2274,10 @@ relayerProvider, provider, instanceOptions) => async (_handles, options) => {
2210
2274
  ciphertextHandles: handles,
2211
2275
  extraData,
2212
2276
  };
2213
- const json = await relayerProvider.fetchPostPublicDecrypt(payloadForRequest, options ?? instanceOptions);
2214
- // const json = await fetchRelayerJsonRpcPost(
2215
- // 'PUBLIC_DECRYPT',
2216
- // `${relayerUrl}/v1/public-decrypt`,
2217
- // payloadForRequest,
2218
- // options ?? instanceOptions,
2219
- // );
2277
+ const json = await relayerProvider.fetchPostPublicDecrypt(payloadForRequest, {
2278
+ ...defaultOptions,
2279
+ ...options,
2280
+ });
2220
2281
  // verify signatures on decryption:
2221
2282
  const domain = {
2222
2283
  name: 'Decryption',
@@ -2412,7 +2473,7 @@ class RelayerV1Provider extends AbstractRelayerProvider {
2412
2473
  return 1;
2413
2474
  }
2414
2475
  async fetchGetKeyUrl() {
2415
- const response = await fetchRelayerGet('KEY_URL', this.keyUrl);
2476
+ const response = await fetchRelayerV1Get('KEY_URL', this.keyUrl);
2416
2477
  return response;
2417
2478
  }
2418
2479
  async fetchPostInputProof(payload, options) {
@@ -2430,12 +2491,12 @@ class RelayerV1Provider extends AbstractRelayerProvider {
2430
2491
  }
2431
2492
  }
2432
2493
  */
2433
- const json = await fetchRelayerJsonRpcPost('INPUT_PROOF', this.inputProof, payload, options);
2494
+ const json = await fetchRelayerV1Post('INPUT_PROOF', this.inputProof, payload, options);
2434
2495
  assertIsRelayerInputProofResult(json.response, 'fetchPostInputProof()');
2435
2496
  return json.response;
2436
2497
  }
2437
2498
  async fetchPostPublicDecrypt(payload, options) {
2438
- const json = await fetchRelayerJsonRpcPost('PUBLIC_DECRYPT', this.publicDecrypt, payload, options);
2499
+ const json = await fetchRelayerV1Post('PUBLIC_DECRYPT', this.publicDecrypt, payload, options);
2439
2500
  const response = json.response[0];
2440
2501
  const result = {
2441
2502
  signatures: response.signatures,
@@ -2446,24 +2507,12 @@ class RelayerV1Provider extends AbstractRelayerProvider {
2446
2507
  return result;
2447
2508
  }
2448
2509
  async fetchPostUserDecrypt(payload, options) {
2449
- const json = await fetchRelayerJsonRpcPost('USER_DECRYPT', this.userDecrypt, payload, options);
2510
+ const json = await fetchRelayerV1Post('USER_DECRYPT', this.userDecrypt, payload, options);
2450
2511
  assertIsRelayerUserDecryptResult(json.response, 'RelayerUserDecryptResult()');
2451
2512
  return json.response;
2452
2513
  }
2453
2514
  }
2454
2515
 
2455
- function ensureError(e) {
2456
- if (e instanceof Error) {
2457
- return e;
2458
- }
2459
- const message = e.message ?? 'Non-Error value caught in exception handler';
2460
- const name = e.name ?? 'ErrorWrapper';
2461
- const cause = e.cause ?? e;
2462
- const err = new Error(message, { cause });
2463
- err.name = name;
2464
- return err;
2465
- }
2466
-
2467
2516
  class RelayerV2ProviderError extends RelayerErrorBase {
2468
2517
  _operation;
2469
2518
  constructor(params) {
@@ -2940,22 +2989,6 @@ class RelayerV2RequestInternalError extends RelayerV2RequestErrorBase {
2940
2989
  }
2941
2990
  }
2942
2991
 
2943
- function assertIsRelayerV2ResultQueued(value, name) {
2944
- assertRecordStringProperty(value, 'jobId', name);
2945
- }
2946
-
2947
- /*
2948
- type RelayerV2ResponseQueued = {
2949
- status: "queued";
2950
- result: RelayerV2ResultQueued;
2951
- }
2952
- */
2953
- function assertIsRelayerV2ResponseQueued(value, name) {
2954
- assertRecordStringProperty(value, 'status', name, 'queued');
2955
- assertNonNullableRecordProperty(value, 'result', name);
2956
- assertIsRelayerV2ResultQueued(value.result, `${name}.result`);
2957
- }
2958
-
2959
2992
  class RelayerV2ResponseApiError extends RelayerV2ResponseErrorBase {
2960
2993
  constructor(params) {
2961
2994
  super({
@@ -3017,6 +3050,36 @@ class RelayerV2MaxRetryError extends RelayerV2FetchErrorBase {
3017
3050
  }
3018
3051
  }
3019
3052
 
3053
+ function assertIsRelayerV2PostResultQueued(value, name) {
3054
+ assertRecordStringProperty(value, 'jobId', name);
3055
+ }
3056
+
3057
+ /*
3058
+ {
3059
+ status: 'queued';
3060
+ requestId: string;
3061
+ result: {
3062
+ jobId: string;
3063
+ };
3064
+ }
3065
+ */
3066
+ function assertIsRelayerV2PostResponseQueued(value, name) {
3067
+ assertRecordStringProperty(value, 'status', name, 'queued');
3068
+ assertRecordStringProperty(value, 'requestId', name);
3069
+ assertNonNullableRecordProperty(value, 'result', name);
3070
+ assertIsRelayerV2PostResultQueued(value.result, `${name}.result`);
3071
+ }
3072
+ /*
3073
+ {
3074
+ status: 'queued';
3075
+ requestId: string;
3076
+ }
3077
+ */
3078
+ function assertIsRelayerV2GetResponseQueued(value, name) {
3079
+ assertRecordStringProperty(value, 'status', name, 'queued');
3080
+ assertRecordStringProperty(value, 'requestId', name);
3081
+ }
3082
+
3020
3083
  class RelayerV2AsyncRequest {
3021
3084
  _jobId;
3022
3085
  _jobIdTimestamp;
@@ -3261,14 +3324,15 @@ class RelayerV2AsyncRequest {
3261
3324
  // - SyntaxError: Expected property name or '}' in JSON at position 1 (line 1 column 2) at JSON.parse (<anonymous>)
3262
3325
  const bodyJson = await this._getResponseJson(response);
3263
3326
  try {
3264
- assertIsRelayerV2ResponseQueued(bodyJson, 'body');
3327
+ assertIsRelayerV2PostResponseQueued(bodyJson, 'body');
3265
3328
  }
3266
3329
  catch (cause) {
3267
- this._throwInvalidResponseError({
3330
+ this._throwResponseInvalidBodyError({
3268
3331
  fetchMethod: 'POST',
3269
3332
  status: responseStatus,
3270
3333
  cause: cause,
3271
3334
  elapsed,
3335
+ bodyJson: safeJSONstringify(bodyJson),
3272
3336
  });
3273
3337
  }
3274
3338
  let retry_after_sec = this._getRetryAfterHeaderValueInSecs(response);
@@ -3303,11 +3367,12 @@ class RelayerV2AsyncRequest {
3303
3367
  assertIsRelayerV2ResponseFailedWithError400(bodyJson, 'body');
3304
3368
  }
3305
3369
  catch (cause) {
3306
- this._throwInvalidResponseError({
3370
+ this._throwResponseInvalidBodyError({
3307
3371
  fetchMethod: 'POST',
3308
3372
  status: responseStatus,
3309
3373
  cause: cause,
3310
3374
  elapsed,
3375
+ bodyJson: safeJSONstringify(bodyJson),
3311
3376
  });
3312
3377
  }
3313
3378
  this._throwRelayerV2ResponseApiError({
@@ -3327,11 +3392,12 @@ class RelayerV2AsyncRequest {
3327
3392
  assertIsRelayerV2ResponseFailedWithError429(bodyJson, 'body');
3328
3393
  }
3329
3394
  catch (cause) {
3330
- this._throwInvalidResponseError({
3395
+ this._throwResponseInvalidBodyError({
3331
3396
  fetchMethod: 'POST',
3332
3397
  status: responseStatus,
3333
3398
  cause: cause,
3334
3399
  elapsed,
3400
+ bodyJson: safeJSONstringify(bodyJson),
3335
3401
  });
3336
3402
  }
3337
3403
  let retry_after_sec = this._getRetryAfterHeaderValueInSecs(response);
@@ -3362,11 +3428,12 @@ class RelayerV2AsyncRequest {
3362
3428
  assertIsRelayerV2ResponseFailedWithError500(bodyJson, 'body');
3363
3429
  }
3364
3430
  catch (cause) {
3365
- this._throwInvalidResponseError({
3431
+ this._throwResponseInvalidBodyError({
3366
3432
  fetchMethod: 'POST',
3367
3433
  status: responseStatus,
3368
3434
  cause: cause,
3369
3435
  elapsed,
3436
+ bodyJson: safeJSONstringify(bodyJson),
3370
3437
  });
3371
3438
  }
3372
3439
  this._throwRelayerV2ResponseApiError({
@@ -3386,11 +3453,12 @@ class RelayerV2AsyncRequest {
3386
3453
  assertIsRelayerV2ResponseFailedWithError503(bodyJson, 'body');
3387
3454
  }
3388
3455
  catch (cause) {
3389
- this._throwInvalidResponseError({
3456
+ this._throwResponseInvalidBodyError({
3390
3457
  fetchMethod: 'POST',
3391
3458
  status: responseStatus,
3392
3459
  cause: cause,
3393
3460
  elapsed,
3461
+ bodyJson: safeJSONstringify(bodyJson),
3394
3462
  });
3395
3463
  }
3396
3464
  this._throwRelayerV2ResponseApiError({
@@ -3514,6 +3582,7 @@ class RelayerV2AsyncRequest {
3514
3582
  status: responseStatus,
3515
3583
  elapsed,
3516
3584
  cause: cause,
3585
+ bodyJson: safeJSONstringify(bodyJson),
3517
3586
  });
3518
3587
  }
3519
3588
  // RelayerV2ResultPublicDecrypt
@@ -3525,7 +3594,7 @@ class RelayerV2AsyncRequest {
3525
3594
  case 202: {
3526
3595
  const bodyJson = await this._getResponseJson(response);
3527
3596
  try {
3528
- assertIsRelayerV2ResponseQueued(bodyJson, 'body');
3597
+ assertIsRelayerV2GetResponseQueued(bodyJson, 'body');
3529
3598
  }
3530
3599
  catch (cause) {
3531
3600
  this._throwResponseInvalidBodyError({
@@ -3533,6 +3602,7 @@ class RelayerV2AsyncRequest {
3533
3602
  status: responseStatus,
3534
3603
  elapsed,
3535
3604
  cause: cause,
3605
+ bodyJson: safeJSONstringify(bodyJson),
3536
3606
  });
3537
3607
  }
3538
3608
  let retry_after_sec = this._getRetryAfterHeaderValueInSecs(response);
@@ -3568,6 +3638,7 @@ class RelayerV2AsyncRequest {
3568
3638
  status: responseStatus,
3569
3639
  elapsed,
3570
3640
  cause: cause,
3641
+ bodyJson: safeJSONstringify(bodyJson),
3571
3642
  });
3572
3643
  }
3573
3644
  this._throwRelayerV2ResponseApiError({
@@ -3590,6 +3661,7 @@ class RelayerV2AsyncRequest {
3590
3661
  status: responseStatus,
3591
3662
  elapsed,
3592
3663
  cause: cause,
3664
+ bodyJson: safeJSONstringify(bodyJson),
3593
3665
  });
3594
3666
  }
3595
3667
  this._throwRelayerV2ResponseApiError({
@@ -3614,6 +3686,7 @@ class RelayerV2AsyncRequest {
3614
3686
  status: responseStatus,
3615
3687
  elapsed,
3616
3688
  cause: cause,
3689
+ bodyJson: safeJSONstringify(bodyJson),
3617
3690
  });
3618
3691
  }
3619
3692
  this._throwRelayerV2ResponseApiError({
@@ -3638,6 +3711,7 @@ class RelayerV2AsyncRequest {
3638
3711
  status: responseStatus,
3639
3712
  elapsed,
3640
3713
  cause: cause,
3714
+ bodyJson: safeJSONstringify(bodyJson),
3641
3715
  });
3642
3716
  }
3643
3717
  this._throwRelayerV2ResponseApiError({
@@ -3662,6 +3736,7 @@ class RelayerV2AsyncRequest {
3662
3736
  status: responseStatus,
3663
3737
  elapsed,
3664
3738
  cause: cause,
3739
+ bodyJson: safeJSONstringify(bodyJson),
3665
3740
  });
3666
3741
  }
3667
3742
  this._throwRelayerV2ResponseApiError({
@@ -3762,6 +3837,8 @@ class RelayerV2AsyncRequest {
3762
3837
  method: 'POST',
3763
3838
  headers: {
3764
3839
  'Content-Type': 'application/json',
3840
+ 'ZAMA-SDK-VERSION': `${version}`,
3841
+ 'ZAMA-SDK-NAME': `${sdkName}`,
3765
3842
  },
3766
3843
  body: JSON.stringify(this._payload),
3767
3844
  ...(this._internalAbortSignal
@@ -3811,9 +3888,16 @@ class RelayerV2AsyncRequest {
3811
3888
  this._assert(!this._state.terminated, '!this._state.terminated');
3812
3889
  this._assert(!this._state.fetching, '!this._state.fetching');
3813
3890
  this._trace('_fetchGet', `jobId=${this.jobId}`);
3814
- const init = this._internalAbortSignal
3815
- ? { signal: this._internalAbortSignal }
3816
- : undefined;
3891
+ const init = {
3892
+ method: 'GET',
3893
+ headers: {
3894
+ 'ZAMA-SDK-VERSION': `${version}`,
3895
+ 'ZAMA-SDK-NAME': `${sdkName}`,
3896
+ },
3897
+ ...(this._internalAbortSignal
3898
+ ? { signal: this._internalAbortSignal }
3899
+ : {}),
3900
+ };
3817
3901
  this._state.fetching = true;
3818
3902
  let response;
3819
3903
  try {
@@ -4066,20 +4150,11 @@ class RelayerV2AsyncRequest {
4066
4150
  elapsed,
4067
4151
  });
4068
4152
  }
4069
- _throwInvalidResponseError(params) {
4070
- throw new RelayerV2ResponseInvalidBodyError({
4071
- ...params,
4072
- url: this._url,
4073
- operation: this._relayerOperation,
4074
- state: { ...this._state },
4075
- retryCount: this._retryCount,
4076
- });
4077
- }
4078
4153
  _throwResponseInvalidBodyError(params) {
4079
4154
  throw new RelayerV2ResponseInvalidBodyError({
4080
4155
  ...params,
4081
4156
  url: this._url,
4082
- jobId: this.jobId,
4157
+ jobId: this._jobId,
4083
4158
  operation: this._relayerOperation,
4084
4159
  state: { ...this._state },
4085
4160
  retryCount: this._retryCount,
@@ -4150,7 +4225,7 @@ function assertIsRelayerV2KeyData(value, name) {
4150
4225
  assertRecordStringProperty(value, 'dataId', name);
4151
4226
  assertRecordStringArrayProperty(value, 'urls', name);
4152
4227
  }
4153
- function toRelayerKeyUrlResponse(response) {
4228
+ function toRelayerV1KeyUrlResponse(response) {
4154
4229
  const fheKeyInfoV1 = response.response.fheKeyInfo.map((v2Info) => ({
4155
4230
  fhe_public_key: {
4156
4231
  data_id: v2Info.fhePublicKey.dataId,
@@ -4180,7 +4255,7 @@ class RelayerV2Provider extends AbstractRelayerProvider {
4180
4255
  return 2;
4181
4256
  }
4182
4257
  async fetchGetKeyUrlV2() {
4183
- const response = await fetchRelayerGet('KEY_URL', this.keyUrl);
4258
+ const response = await fetchRelayerV1Get('KEY_URL', this.keyUrl);
4184
4259
  // Relayer error
4185
4260
  try {
4186
4261
  assertIsRelayerV2GetResponseKeyUrl(response, 'fetchGetKeyUrl()');
@@ -4194,7 +4269,7 @@ class RelayerV2Provider extends AbstractRelayerProvider {
4194
4269
  }
4195
4270
  async fetchGetKeyUrl() {
4196
4271
  const response = await this.fetchGetKeyUrlV2();
4197
- return toRelayerKeyUrlResponse(response);
4272
+ return toRelayerV1KeyUrlResponse(response);
4198
4273
  }
4199
4274
  async fetchPostInputProof(payload, instanceOptions, fetchOptions) {
4200
4275
  const request = new RelayerV2AsyncRequest({
@@ -4884,60 +4959,39 @@ function _resolveRelayerUrl(value, defaultVersion) {
4884
4959
  };
4885
4960
  }
4886
4961
 
4887
- /**
4888
- * **FHE Type Mapping for Input Builders**
4889
- * * Maps the **number of encrypted bits** used by a FHEVM primary type
4890
- * to its corresponding **FheTypeId**. This constant is primarily used by
4891
- * `EncryptedInput` and `RelayerEncryptedInput` builders to determine the correct
4892
- * input type and calculate the total required bit-length.
4893
- *
4894
- * **Structure: \{ Encrypted Bit Length: FheTypeId \}**
4895
- *
4896
- * | Bits | FheTypeId | FHE Type Name | Note |
4897
- * | :--- | :-------- | :------------ | :--- |
4898
- * | 2 | 0 | `ebool` | The boolean type. |
4899
- * | (N/A)| 1 | `euint4` | **Deprecated** and omitted from this map. |
4900
- * | 8 | 2 | `euint8` | |
4901
- * | 16 | 3 | `euint16` | |
4902
- * | 32 | 4 | `euint32` | |
4903
- * | 64 | 5 | `euint64` | |
4904
- * | 128 | 6 | `euint128` | |
4905
- * | 160 | 7 | `eaddress` | Used for encrypted Ethereum addresses. |
4906
- * | 256 | 8 | `euint256` | The maximum supported integer size. |
4907
- */
4908
- const ENCRYPTION_TYPES = {
4909
- 2: 0, // ebool (FheTypeId=0) is using 2 encrypted bits
4910
- // euint4 (FheTypeId=1) is deprecated
4911
- 8: 2, // euint8 (FheTypeId=2) is using 8 encrypted bits
4912
- 16: 3, // euint16 (FheTypeId=3) is using 16 encrypted bits
4913
- 32: 4, // euint32 (FheTypeId=4) is using 32 encrypted bits
4914
- 64: 5, // euint64 (FheTypeId=5) is using 64 encrypted bits
4915
- 128: 6, // euint128 (FheTypeId=128) is using 128 encrypted bits
4916
- 160: 7, // eaddress (FheTypeId=7) is using 160 encrypted bits
4917
- 256: 8, // euint256 (FheTypeId=8) is using 256 encrypted bits
4962
+ ////////////////////////////////////////////////////////////////////////////////
4963
+ // MainnetConfig
4964
+ ////////////////////////////////////////////////////////////////////////////////
4965
+ const MainnetConfig = {
4966
+ aclContractAddress: '0xcA2E8f1F656CD25C01F05d0b243Ab1ecd4a8ffb6',
4967
+ kmsContractAddress: '0x77627828a55156b04Ac0DC0eb30467f1a552BB03',
4968
+ inputVerifierContractAddress: '0xCe0FC2e05CFff1B719EFF7169f7D80Af770c8EA2',
4969
+ verifyingContractAddressDecryption: '0x0f6024a97684f7d90ddb0fAAD79cB15F2C888D24',
4970
+ verifyingContractAddressInputVerification: '0xcB1bB072f38bdAF0F328CdEf1Fc6eDa1DF029287',
4971
+ chainId: 1,
4972
+ gatewayChainId: 261131,
4973
+ network: 'https://ethereum-rpc.publicnode.com',
4974
+ relayerUrl: 'https://relayer.mainnet.zama.org',
4918
4975
  };
4919
-
4976
+ Object.freeze(MainnetConfig);
4977
+ ////////////////////////////////////////////////////////////////////////////////
4978
+ // SepoliaConfig
4979
+ ////////////////////////////////////////////////////////////////////////////////
4920
4980
  const SepoliaConfig = {
4921
- // ACL_CONTRACT_ADDRESS (FHEVM Host chain)
4922
4981
  aclContractAddress: '0xf0Ffdc93b7E186bC2f8CB3dAA75D86d1930A433D',
4923
- // KMS_VERIFIER_CONTRACT_ADDRESS (FHEVM Host chain)
4924
4982
  kmsContractAddress: '0xbE0E383937d564D7FF0BC3b46c51f0bF8d5C311A',
4925
- // INPUT_VERIFIER_CONTRACT_ADDRESS (FHEVM Host chain)
4926
4983
  inputVerifierContractAddress: '0xBBC1fFCdc7C316aAAd72E807D9b0272BE8F84DA0',
4927
- // DECRYPTION_ADDRESS (Gateway chain)
4928
4984
  verifyingContractAddressDecryption: '0x5D8BD78e2ea6bbE41f26dFe9fdaEAa349e077478',
4929
- // INPUT_VERIFICATION_ADDRESS (Gateway chain)
4930
4985
  verifyingContractAddressInputVerification: '0x483b9dE06E4E4C7D35CCf5837A1668487406D955',
4931
- // FHEVM Host chain id
4932
4986
  chainId: 11155111,
4933
- // Gateway chain id
4934
4987
  gatewayChainId: 10901,
4935
- // Optional RPC provider to host chain
4936
4988
  network: 'https://ethereum-sepolia-rpc.publicnode.com',
4937
- // Relayer URL
4938
4989
  relayerUrl: 'https://relayer.testnet.zama.org',
4939
4990
  };
4940
4991
  Object.freeze(SepoliaConfig);
4992
+ ////////////////////////////////////////////////////////////////////////////////
4993
+ // createInstance
4994
+ ////////////////////////////////////////////////////////////////////////////////
4941
4995
  const createInstance = async (config) => {
4942
4996
  const { verifyingContractAddressDecryption, verifyingContractAddressInputVerification, publicKey, inputVerifierContractAddress, kmsContractAddress, aclContractAddress, gatewayChainId, auth, } = config;
4943
4997
  if (!isChecksummedAddress(aclContractAddress)) {
@@ -4969,29 +5023,12 @@ const createInstance = async (config) => {
4969
5023
  defaultRelayerVersion: 1,
4970
5024
  });
4971
5025
  const chainId = await getChainId(provider, config);
4972
- // const relayerVersionUrl = `${config.relayerUrl!}/v1`;
4973
- // const publicKeyData = await getTfheCompactPublicKey({
4974
- // relayerVersionUrl: relayerFhevm.relayerVersionUrl,
4975
- // publicKey: config.publicKey,
4976
- // });
4977
- //const aaa = relayerFhevm.getPublicKey();
4978
- // const publicParamsData = await getPublicParams({
4979
- // relayerVersionUrl,
4980
- // publicParams: config.publicParams,
4981
- // });
4982
5026
  const kmsSigners = await getKMSSigners(provider, kmsContractAddress);
4983
5027
  const thresholdKMSSigners = await getKMSSignersThreshold(provider, kmsContractAddress);
4984
5028
  const coprocessorSigners = await getCoprocessorSigners(provider, inputVerifierContractAddress);
4985
5029
  const thresholdCoprocessorSigners = await getCoprocessorSignersThreshold(provider, inputVerifierContractAddress);
4986
5030
  return {
4987
- createEncryptedInput: createRelayerEncryptedInput(aclContractAddress, verifyingContractAddressInputVerification, chainId, gatewayChainId,
4988
- //cleanURL(config.relayerUrl),
4989
- //relayerFhevm.relayerVersionUrl,
4990
- relayerFhevm.relayerProvider,
4991
- //publicKeyData.publicKey,
4992
- relayerFhevm.getPublicKeyWasm().publicKey,
4993
- //publicParamsData,
4994
- { 2048: relayerFhevm.getPublicParamsWasm(2048) }, coprocessorSigners, thresholdCoprocessorSigners),
5031
+ createEncryptedInput: createRelayerEncryptedInput(aclContractAddress, verifyingContractAddressInputVerification, chainId, gatewayChainId, relayerFhevm.relayerProvider, relayerFhevm.getPublicKeyWasm().publicKey, { 2048: relayerFhevm.getPublicParamsWasm(2048) }, coprocessorSigners, thresholdCoprocessorSigners, auth && { auth }),
4995
5032
  generateKeypair,
4996
5033
  createEIP712: createEIP712(verifyingContractAddressDecryption, chainId),
4997
5034
  publicDecrypt: publicDecryptRequest(kmsSigners, thresholdKMSSigners, gatewayChainId, verifyingContractAddressDecryption, aclContractAddress,
@@ -5045,4 +5082,4 @@ const createTfhePublicKey = () => {
5045
5082
  global.TFHE = TFHEPkg;
5046
5083
  global.TKMS = TKMSPkg;
5047
5084
 
5048
- export { ENCRYPTION_TYPES, SepoliaConfig, createEIP712, createInstance, createTfheKeypair, createTfhePublicKey, generateKeypair, getErrorCauseCode, getErrorCauseStatus };
5085
+ export { MainnetConfig, SepoliaConfig, createEIP712, createInstance, createTfheKeypair, createTfhePublicKey, generateKeypair, getErrorCauseCode, getErrorCauseStatus };