@zama-fhe/relayer-sdk 0.2.0 → 0.3.0-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.cjs CHANGED
@@ -912,10 +912,13 @@ const ENCRYPTION_TYPES = {
912
912
  };
913
913
 
914
914
  const MAX_UINT64 = BigInt('18446744073709551615'); // 2^64 - 1
915
+ const RAW_CT_HASH_DOMAIN_SEPARATOR = 'ZK-w_rct';
916
+ const HANDLE_HASH_DOMAIN_SEPARATOR = 'ZK-w_hdl';
915
917
  const computeHandles = (ciphertextWithZKProof, bitwidths, aclContractAddress, chainId, ciphertextVersion) => {
916
918
  // Should be identical to:
917
919
  // https://github.com/zama-ai/fhevm-backend/blob/bae00d1b0feafb63286e94acdc58dc88d9c481bf/fhevm-engine/zkproof-worker/src/verifier.rs#L301
918
920
  const blob_hash = createHash('keccak256')
921
+ .update(Buffer.from(RAW_CT_HASH_DOMAIN_SEPARATOR))
919
922
  .update(Buffer.from(ciphertextWithZKProof))
920
923
  .digest();
921
924
  const aclContractAddress20Bytes = Buffer.from(fromHexString(aclContractAddress));
@@ -925,6 +928,7 @@ const computeHandles = (ciphertextWithZKProof, bitwidths, aclContractAddress, ch
925
928
  const encryptionType = ENCRYPTION_TYPES[bitwidth];
926
929
  const encryptionIndex1Byte = Buffer.from([encryptionIndex]);
927
930
  const handleHash = createHash('keccak256')
931
+ .update(Buffer.from(HANDLE_HASH_DOMAIN_SEPARATOR))
928
932
  .update(blob_hash)
929
933
  .update(encryptionIndex1Byte)
930
934
  .update(aclContractAddress20Bytes)
@@ -1278,7 +1282,6 @@ const createEIP712 = (verifyingContract, contractsChainId) => (publicKey, contra
1278
1282
  DelegatedUserDecryptRequestVerification: [
1279
1283
  { name: 'publicKey', type: 'bytes' },
1280
1284
  { name: 'contractAddresses', type: 'address[]' },
1281
- { name: 'contractsChainId', type: 'uint256' },
1282
1285
  { name: 'startTimestamp', type: 'uint256' },
1283
1286
  { name: 'durationDays', type: 'uint256' },
1284
1287
  { name: 'extraData', type: 'bytes' },
@@ -1293,7 +1296,6 @@ const createEIP712 = (verifyingContract, contractsChainId) => (publicKey, contra
1293
1296
  message: {
1294
1297
  publicKey: formattedPublicKey,
1295
1298
  contractAddresses,
1296
- contractsChainId,
1297
1299
  startTimestamp: formattedStartTimestamp,
1298
1300
  durationDays: formattedDurationDays,
1299
1301
  extraData,
@@ -1307,7 +1309,6 @@ const createEIP712 = (verifyingContract, contractsChainId) => (publicKey, contra
1307
1309
  UserDecryptRequestVerification: [
1308
1310
  { name: 'publicKey', type: 'bytes' },
1309
1311
  { name: 'contractAddresses', type: 'address[]' },
1310
- { name: 'contractsChainId', type: 'uint256' },
1311
1312
  { name: 'startTimestamp', type: 'uint256' },
1312
1313
  { name: 'durationDays', type: 'uint256' },
1313
1314
  { name: 'extraData', type: 'bytes' },
@@ -1318,7 +1319,6 @@ const createEIP712 = (verifyingContract, contractsChainId) => (publicKey, contra
1318
1319
  message: {
1319
1320
  publicKey: formattedPublicKey,
1320
1321
  contractAddresses,
1321
- contractsChainId,
1322
1322
  startTimestamp: formattedStartTimestamp,
1323
1323
  durationDays: formattedDurationDays,
1324
1324
  extraData,
package/lib/node.js CHANGED
@@ -891,10 +891,13 @@ const ENCRYPTION_TYPES = {
891
891
  };
892
892
 
893
893
  const MAX_UINT64 = BigInt('18446744073709551615'); // 2^64 - 1
894
+ const RAW_CT_HASH_DOMAIN_SEPARATOR = 'ZK-w_rct';
895
+ const HANDLE_HASH_DOMAIN_SEPARATOR = 'ZK-w_hdl';
894
896
  const computeHandles = (ciphertextWithZKProof, bitwidths, aclContractAddress, chainId, ciphertextVersion) => {
895
897
  // Should be identical to:
896
898
  // https://github.com/zama-ai/fhevm-backend/blob/bae00d1b0feafb63286e94acdc58dc88d9c481bf/fhevm-engine/zkproof-worker/src/verifier.rs#L301
897
899
  const blob_hash = createHash('keccak256')
900
+ .update(Buffer.from(RAW_CT_HASH_DOMAIN_SEPARATOR))
898
901
  .update(Buffer.from(ciphertextWithZKProof))
899
902
  .digest();
900
903
  const aclContractAddress20Bytes = Buffer.from(fromHexString(aclContractAddress));
@@ -904,6 +907,7 @@ const computeHandles = (ciphertextWithZKProof, bitwidths, aclContractAddress, ch
904
907
  const encryptionType = ENCRYPTION_TYPES[bitwidth];
905
908
  const encryptionIndex1Byte = Buffer.from([encryptionIndex]);
906
909
  const handleHash = createHash('keccak256')
910
+ .update(Buffer.from(HANDLE_HASH_DOMAIN_SEPARATOR))
907
911
  .update(blob_hash)
908
912
  .update(encryptionIndex1Byte)
909
913
  .update(aclContractAddress20Bytes)
@@ -1257,7 +1261,6 @@ const createEIP712 = (verifyingContract, contractsChainId) => (publicKey, contra
1257
1261
  DelegatedUserDecryptRequestVerification: [
1258
1262
  { name: 'publicKey', type: 'bytes' },
1259
1263
  { name: 'contractAddresses', type: 'address[]' },
1260
- { name: 'contractsChainId', type: 'uint256' },
1261
1264
  { name: 'startTimestamp', type: 'uint256' },
1262
1265
  { name: 'durationDays', type: 'uint256' },
1263
1266
  { name: 'extraData', type: 'bytes' },
@@ -1272,7 +1275,6 @@ const createEIP712 = (verifyingContract, contractsChainId) => (publicKey, contra
1272
1275
  message: {
1273
1276
  publicKey: formattedPublicKey,
1274
1277
  contractAddresses,
1275
- contractsChainId,
1276
1278
  startTimestamp: formattedStartTimestamp,
1277
1279
  durationDays: formattedDurationDays,
1278
1280
  extraData,
@@ -1286,7 +1288,6 @@ const createEIP712 = (verifyingContract, contractsChainId) => (publicKey, contra
1286
1288
  UserDecryptRequestVerification: [
1287
1289
  { name: 'publicKey', type: 'bytes' },
1288
1290
  { name: 'contractAddresses', type: 'address[]' },
1289
- { name: 'contractsChainId', type: 'uint256' },
1290
1291
  { name: 'startTimestamp', type: 'uint256' },
1291
1292
  { name: 'durationDays', type: 'uint256' },
1292
1293
  { name: 'extraData', type: 'bytes' },
@@ -1297,7 +1298,6 @@ const createEIP712 = (verifyingContract, contractsChainId) => (publicKey, contra
1297
1298
  message: {
1298
1299
  publicKey: formattedPublicKey,
1299
1300
  contractAddresses,
1300
- contractsChainId,
1301
1301
  startTimestamp: formattedStartTimestamp,
1302
1302
  durationDays: formattedDurationDays,
1303
1303
  extraData,
package/lib/web.js CHANGED
@@ -17022,10 +17022,13 @@ const ENCRYPTION_TYPES = {
17022
17022
  };
17023
17023
 
17024
17024
  const MAX_UINT64 = BigInt('18446744073709551615'); // 2^64 - 1
17025
+ const RAW_CT_HASH_DOMAIN_SEPARATOR = 'ZK-w_rct';
17026
+ const HANDLE_HASH_DOMAIN_SEPARATOR = 'ZK-w_hdl';
17025
17027
  const computeHandles = (ciphertextWithZKProof, bitwidths, aclContractAddress, chainId, ciphertextVersion) => {
17026
17028
  // Should be identical to:
17027
17029
  // https://github.com/zama-ai/fhevm-backend/blob/bae00d1b0feafb63286e94acdc58dc88d9c481bf/fhevm-engine/zkproof-worker/src/verifier.rs#L301
17028
17030
  const blob_hash = createHash('keccak256')
17031
+ .update(Buffer.from(RAW_CT_HASH_DOMAIN_SEPARATOR))
17029
17032
  .update(Buffer.from(ciphertextWithZKProof))
17030
17033
  .digest();
17031
17034
  const aclContractAddress20Bytes = Buffer.from(fromHexString(aclContractAddress));
@@ -17035,6 +17038,7 @@ const computeHandles = (ciphertextWithZKProof, bitwidths, aclContractAddress, ch
17035
17038
  const encryptionType = ENCRYPTION_TYPES[bitwidth];
17036
17039
  const encryptionIndex1Byte = Buffer.from([encryptionIndex]);
17037
17040
  const handleHash = createHash('keccak256')
17041
+ .update(Buffer.from(HANDLE_HASH_DOMAIN_SEPARATOR))
17038
17042
  .update(blob_hash)
17039
17043
  .update(encryptionIndex1Byte)
17040
17044
  .update(aclContractAddress20Bytes)
@@ -17388,7 +17392,6 @@ const createEIP712 = (verifyingContract, contractsChainId) => (publicKey, contra
17388
17392
  DelegatedUserDecryptRequestVerification: [
17389
17393
  { name: 'publicKey', type: 'bytes' },
17390
17394
  { name: 'contractAddresses', type: 'address[]' },
17391
- { name: 'contractsChainId', type: 'uint256' },
17392
17395
  { name: 'startTimestamp', type: 'uint256' },
17393
17396
  { name: 'durationDays', type: 'uint256' },
17394
17397
  { name: 'extraData', type: 'bytes' },
@@ -17403,7 +17406,6 @@ const createEIP712 = (verifyingContract, contractsChainId) => (publicKey, contra
17403
17406
  message: {
17404
17407
  publicKey: formattedPublicKey,
17405
17408
  contractAddresses,
17406
- contractsChainId,
17407
17409
  startTimestamp: formattedStartTimestamp,
17408
17410
  durationDays: formattedDurationDays,
17409
17411
  extraData,
@@ -17417,7 +17419,6 @@ const createEIP712 = (verifyingContract, contractsChainId) => (publicKey, contra
17417
17419
  UserDecryptRequestVerification: [
17418
17420
  { name: 'publicKey', type: 'bytes' },
17419
17421
  { name: 'contractAddresses', type: 'address[]' },
17420
- { name: 'contractsChainId', type: 'uint256' },
17421
17422
  { name: 'startTimestamp', type: 'uint256' },
17422
17423
  { name: 'durationDays', type: 'uint256' },
17423
17424
  { name: 'extraData', type: 'bytes' },
@@ -17428,7 +17429,6 @@ const createEIP712 = (verifyingContract, contractsChainId) => (publicKey, contra
17428
17429
  message: {
17429
17430
  publicKey: formattedPublicKey,
17430
17431
  contractAddresses,
17431
- contractsChainId,
17432
17432
  startTimestamp: formattedStartTimestamp,
17433
17433
  durationDays: formattedDurationDays,
17434
17434
  extraData,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zama-fhe/relayer-sdk",
3
- "version": "0.2.0",
3
+ "version": "0.3.0-1",
4
4
  "description": "fhevm Relayer SDK",
5
5
  "main": "lib/node.js",
6
6
  "types": "lib/node.d.ts",
@@ -26,9 +26,6 @@
26
26
  "types": "./lib/node.d.ts"
27
27
  }
28
28
  },
29
- "engines": {
30
- "node": ">=20"
31
- },
32
29
  "scripts": {
33
30
  "lint": "eslint src/",
34
31
  "generateKeys": "./generateKeys.js",
@@ -87,7 +84,7 @@
87
84
  "buffer": "6.0.3",
88
85
  "crypto-browserify": "3.12.1",
89
86
  "fetch-mock": "12.5.3",
90
- "jest": "30.0.4",
87
+ "jest": "^30.0.4",
91
88
  "jest-raw-loader": "1.0.1",
92
89
  "path-browserify": "1.0.1",
93
90
  "prettier": "3.6.2",
@@ -103,5 +100,8 @@
103
100
  "vite": "7.0.5",
104
101
  "vite-plugin-node-polyfills": "0.24.0",
105
102
  "vite-plugin-static-copy": "^3.1.2"
103
+ },
104
+ "engines": {
105
+ "node": ">=22"
106
106
  }
107
107
  }