@zama-fhe/relayer-sdk 0.2.0-3 → 0.2.0-4

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
@@ -616,6 +616,7 @@ function checkDeadlineValidity(startTimestamp, durationDays) {
616
616
  }
617
617
  }
618
618
  const userDecryptRequest = (kmsSigners, gatewayChainId, chainId, verifyingContractAddress, aclContractAddress, relayerUrl, provider, options) => async (_handles, privateKey, publicKey, signature, contractAddresses, userAddress, startTimestamp, durationDays) => {
619
+ const extraData = '0x00';
619
620
  let pubKey;
620
621
  let privKey;
621
622
  try {
@@ -671,6 +672,7 @@ const userDecryptRequest = (kmsSigners, gatewayChainId, chainId, verifyingContra
671
672
  userAddress: getAddress$1(userAddress),
672
673
  signature: signatureSanitized,
673
674
  publicKey: publicKeySanitized,
675
+ extraData,
674
676
  };
675
677
  const json = await fetchRelayerJsonRpcPost('USER_DECRYPT', `${relayerUrl}/v1/user-decrypt`, payloadForRequest, options);
676
678
  // assume the KMS Signers have the correct order
@@ -1007,6 +1009,7 @@ const createRelayerEncryptedInput = (aclContractAddress, verifyingContractAddres
1007
1009
  return input.getBits();
1008
1010
  },
1009
1011
  encrypt: async (options) => {
1012
+ const extraData = '0x00';
1010
1013
  const bits = input.getBits();
1011
1014
  const ciphertext = input.encrypt();
1012
1015
  const payload = {
@@ -1014,6 +1017,7 @@ const createRelayerEncryptedInput = (aclContractAddress, verifyingContractAddres
1014
1017
  userAddress: getAddress(userAddress),
1015
1018
  ciphertextWithInputVerification: toHexString(ciphertext),
1016
1019
  contractChainId: ('0x' + chainId.toString(16)),
1020
+ extraData,
1017
1021
  };
1018
1022
  const json = await fetchRelayerJsonRpcPost('INPUT_PROOF', `${relayerUrl}/v1/input-proof`, payload, options);
1019
1023
  if (!isFhevmRelayerInputProofResponse(json)) {
@@ -1050,6 +1054,7 @@ const createRelayerEncryptedInput = (aclContractAddress, verifyingContractAddres
1050
1054
  { name: 'userAddress', type: 'address' },
1051
1055
  { name: 'contractAddress', type: 'address' },
1052
1056
  { name: 'contractChainId', type: 'uint256' },
1057
+ { name: 'extraData', type: 'bytes' },
1053
1058
  ],
1054
1059
  };
1055
1060
  const recoveredAddresses = signatures.map((signature) => {
@@ -1059,6 +1064,7 @@ const createRelayerEncryptedInput = (aclContractAddress, verifyingContractAddres
1059
1064
  userAddress,
1060
1065
  contractAddress,
1061
1066
  contractChainId: chainId,
1067
+ extraData,
1062
1068
  }, sig);
1063
1069
  return recoveredAddress;
1064
1070
  });
@@ -1073,6 +1079,8 @@ const createRelayerEncryptedInput = (aclContractAddress, verifyingContractAddres
1073
1079
  const listHandlesStr = handles.map((i) => toHexString(i));
1074
1080
  listHandlesStr.map((handle) => (inputProof += handle));
1075
1081
  signatures.map((signature) => (inputProof += signature.slice(2))); // removes the '0x' prefix from the `signature` string
1082
+ // Append the extra data to the input proof
1083
+ inputProof += extraData.slice(2);
1076
1084
  return {
1077
1085
  handles,
1078
1086
  inputProof: fromHexString(inputProof),
@@ -1134,6 +1142,7 @@ function deserializeDecryptedResult(handles, decryptedResult) {
1134
1142
  return results;
1135
1143
  }
1136
1144
  const publicDecryptRequest = (kmsSigners, thresholdSigners, gatewayChainId, verifyingContractAddress, aclContractAddress, relayerUrl, provider, options) => async (_handles) => {
1145
+ const extraData = '0x00';
1137
1146
  const acl = new ethers.ethers.Contract(aclContractAddress, aclABI, provider);
1138
1147
  let handles;
1139
1148
  try {
@@ -1155,6 +1164,7 @@ const publicDecryptRequest = (kmsSigners, thresholdSigners, gatewayChainId, veri
1155
1164
  checkEncryptedBits(handles);
1156
1165
  const payloadForRequest = {
1157
1166
  ciphertextHandles: handles,
1167
+ extraData,
1158
1168
  };
1159
1169
  const json = await fetchRelayerJsonRpcPost('PUBLIC_DECRYPT', `${relayerUrl}/v1/public-decrypt`, payloadForRequest, options);
1160
1170
  // verify signatures on decryption:
@@ -1168,6 +1178,7 @@ const publicDecryptRequest = (kmsSigners, thresholdSigners, gatewayChainId, veri
1168
1178
  PublicDecryptVerification: [
1169
1179
  { name: 'ctHandles', type: 'bytes32[]' },
1170
1180
  { name: 'decryptedResult', type: 'bytes' },
1181
+ { name: 'extraData', type: 'bytes' },
1171
1182
  ],
1172
1183
  };
1173
1184
  const result = json.response[0];
@@ -1177,7 +1188,7 @@ const publicDecryptRequest = (kmsSigners, thresholdSigners, gatewayChainId, veri
1177
1188
  const signatures = result.signatures;
1178
1189
  const recoveredAddresses = signatures.map((signature) => {
1179
1190
  const sig = signature.startsWith('0x') ? signature : `0x${signature}`;
1180
- const recoveredAddress = ethers.ethers.verifyTypedData(domain, types, { ctHandles: handles, decryptedResult }, sig);
1191
+ const recoveredAddress = ethers.ethers.verifyTypedData(domain, types, { ctHandles: handles, decryptedResult, extraData }, sig);
1181
1192
  return recoveredAddress;
1182
1193
  });
1183
1194
  const thresholdReached = isThresholdReached(kmsSigners, recoveredAddresses, thresholdSigners);
@@ -1198,9 +1209,11 @@ const publicDecryptRequest = (kmsSigners, thresholdSigners, gatewayChainId, veri
1198
1209
  * @param contractsChainId - The chain ID where the contracts are deployed
1199
1210
  * @param startTimestamp - The timestamp when the decryption permission becomes valid
1200
1211
  * @param durationDays - How many days the decryption permission remains valid
1212
+ * @param delegatedAccount - Optional delegated account address
1201
1213
  * @returns EIP712 typed data structure for user decryption
1202
1214
  */
1203
1215
  const createEIP712 = (verifyingContract, contractsChainId) => (publicKey, contractAddresses, startTimestamp, durationDays, delegatedAccount) => {
1216
+ const extraData = '0x00';
1204
1217
  if (delegatedAccount && !ethers.isAddress(delegatedAccount))
1205
1218
  throw new Error('Invalid delegated account.');
1206
1219
  if (!ethers.isAddress(verifyingContract)) {
@@ -1242,6 +1255,7 @@ const createEIP712 = (verifyingContract, contractsChainId) => (publicKey, contra
1242
1255
  { name: 'contractsChainId', type: 'uint256' },
1243
1256
  { name: 'startTimestamp', type: 'uint256' },
1244
1257
  { name: 'durationDays', type: 'uint256' },
1258
+ { name: 'extraData', type: 'bytes' },
1245
1259
  {
1246
1260
  name: 'delegatedAccount',
1247
1261
  type: 'address',
@@ -1256,6 +1270,7 @@ const createEIP712 = (verifyingContract, contractsChainId) => (publicKey, contra
1256
1270
  contractsChainId,
1257
1271
  startTimestamp: formattedStartTimestamp,
1258
1272
  durationDays: formattedDurationDays,
1273
+ extraData,
1259
1274
  delegatedAccount: delegatedAccount,
1260
1275
  },
1261
1276
  };
@@ -1269,6 +1284,7 @@ const createEIP712 = (verifyingContract, contractsChainId) => (publicKey, contra
1269
1284
  { name: 'contractsChainId', type: 'uint256' },
1270
1285
  { name: 'startTimestamp', type: 'uint256' },
1271
1286
  { name: 'durationDays', type: 'uint256' },
1287
+ { name: 'extraData', type: 'bytes' },
1272
1288
  ],
1273
1289
  },
1274
1290
  primaryType: 'UserDecryptRequestVerification',
@@ -1279,6 +1295,7 @@ const createEIP712 = (verifyingContract, contractsChainId) => (publicKey, contra
1279
1295
  contractsChainId,
1280
1296
  startTimestamp: formattedStartTimestamp,
1281
1297
  durationDays: formattedDurationDays,
1298
+ extraData,
1282
1299
  },
1283
1300
  };
1284
1301
  };
package/lib/node.d.ts CHANGED
@@ -13,6 +13,7 @@ import { TfheCompactPublicKey } from 'node-tfhe';
13
13
  * @param contractsChainId - The chain ID where the contracts are deployed
14
14
  * @param startTimestamp - The timestamp when the decryption permission becomes valid
15
15
  * @param durationDays - How many days the decryption permission remains valid
16
+ * @param delegatedAccount - Optional delegated account address
16
17
  * @returns EIP712 typed data structure for user decryption
17
18
  */
18
19
  export declare const createEIP712: (verifyingContract: string, contractsChainId: number) => (publicKey: string | Uint8Array, contractAddresses: string[], startTimestamp: string | number, durationDays: string | number, delegatedAccount?: string) => EIP712;
package/lib/node.js CHANGED
@@ -595,6 +595,7 @@ function checkDeadlineValidity(startTimestamp, durationDays) {
595
595
  }
596
596
  }
597
597
  const userDecryptRequest = (kmsSigners, gatewayChainId, chainId, verifyingContractAddress, aclContractAddress, relayerUrl, provider, options) => async (_handles, privateKey, publicKey, signature, contractAddresses, userAddress, startTimestamp, durationDays) => {
598
+ const extraData = '0x00';
598
599
  let pubKey;
599
600
  let privKey;
600
601
  try {
@@ -650,6 +651,7 @@ const userDecryptRequest = (kmsSigners, gatewayChainId, chainId, verifyingContra
650
651
  userAddress: getAddress$1(userAddress),
651
652
  signature: signatureSanitized,
652
653
  publicKey: publicKeySanitized,
654
+ extraData,
653
655
  };
654
656
  const json = await fetchRelayerJsonRpcPost('USER_DECRYPT', `${relayerUrl}/v1/user-decrypt`, payloadForRequest, options);
655
657
  // assume the KMS Signers have the correct order
@@ -986,6 +988,7 @@ const createRelayerEncryptedInput = (aclContractAddress, verifyingContractAddres
986
988
  return input.getBits();
987
989
  },
988
990
  encrypt: async (options) => {
991
+ const extraData = '0x00';
989
992
  const bits = input.getBits();
990
993
  const ciphertext = input.encrypt();
991
994
  const payload = {
@@ -993,6 +996,7 @@ const createRelayerEncryptedInput = (aclContractAddress, verifyingContractAddres
993
996
  userAddress: getAddress(userAddress),
994
997
  ciphertextWithInputVerification: toHexString(ciphertext),
995
998
  contractChainId: ('0x' + chainId.toString(16)),
999
+ extraData,
996
1000
  };
997
1001
  const json = await fetchRelayerJsonRpcPost('INPUT_PROOF', `${relayerUrl}/v1/input-proof`, payload, options);
998
1002
  if (!isFhevmRelayerInputProofResponse(json)) {
@@ -1029,6 +1033,7 @@ const createRelayerEncryptedInput = (aclContractAddress, verifyingContractAddres
1029
1033
  { name: 'userAddress', type: 'address' },
1030
1034
  { name: 'contractAddress', type: 'address' },
1031
1035
  { name: 'contractChainId', type: 'uint256' },
1036
+ { name: 'extraData', type: 'bytes' },
1032
1037
  ],
1033
1038
  };
1034
1039
  const recoveredAddresses = signatures.map((signature) => {
@@ -1038,6 +1043,7 @@ const createRelayerEncryptedInput = (aclContractAddress, verifyingContractAddres
1038
1043
  userAddress,
1039
1044
  contractAddress,
1040
1045
  contractChainId: chainId,
1046
+ extraData,
1041
1047
  }, sig);
1042
1048
  return recoveredAddress;
1043
1049
  });
@@ -1052,6 +1058,8 @@ const createRelayerEncryptedInput = (aclContractAddress, verifyingContractAddres
1052
1058
  const listHandlesStr = handles.map((i) => toHexString(i));
1053
1059
  listHandlesStr.map((handle) => (inputProof += handle));
1054
1060
  signatures.map((signature) => (inputProof += signature.slice(2))); // removes the '0x' prefix from the `signature` string
1061
+ // Append the extra data to the input proof
1062
+ inputProof += extraData.slice(2);
1055
1063
  return {
1056
1064
  handles,
1057
1065
  inputProof: fromHexString(inputProof),
@@ -1113,6 +1121,7 @@ function deserializeDecryptedResult(handles, decryptedResult) {
1113
1121
  return results;
1114
1122
  }
1115
1123
  const publicDecryptRequest = (kmsSigners, thresholdSigners, gatewayChainId, verifyingContractAddress, aclContractAddress, relayerUrl, provider, options) => async (_handles) => {
1124
+ const extraData = '0x00';
1116
1125
  const acl = new ethers.Contract(aclContractAddress, aclABI, provider);
1117
1126
  let handles;
1118
1127
  try {
@@ -1134,6 +1143,7 @@ const publicDecryptRequest = (kmsSigners, thresholdSigners, gatewayChainId, veri
1134
1143
  checkEncryptedBits(handles);
1135
1144
  const payloadForRequest = {
1136
1145
  ciphertextHandles: handles,
1146
+ extraData,
1137
1147
  };
1138
1148
  const json = await fetchRelayerJsonRpcPost('PUBLIC_DECRYPT', `${relayerUrl}/v1/public-decrypt`, payloadForRequest, options);
1139
1149
  // verify signatures on decryption:
@@ -1147,6 +1157,7 @@ const publicDecryptRequest = (kmsSigners, thresholdSigners, gatewayChainId, veri
1147
1157
  PublicDecryptVerification: [
1148
1158
  { name: 'ctHandles', type: 'bytes32[]' },
1149
1159
  { name: 'decryptedResult', type: 'bytes' },
1160
+ { name: 'extraData', type: 'bytes' },
1150
1161
  ],
1151
1162
  };
1152
1163
  const result = json.response[0];
@@ -1156,7 +1167,7 @@ const publicDecryptRequest = (kmsSigners, thresholdSigners, gatewayChainId, veri
1156
1167
  const signatures = result.signatures;
1157
1168
  const recoveredAddresses = signatures.map((signature) => {
1158
1169
  const sig = signature.startsWith('0x') ? signature : `0x${signature}`;
1159
- const recoveredAddress = ethers.verifyTypedData(domain, types, { ctHandles: handles, decryptedResult }, sig);
1170
+ const recoveredAddress = ethers.verifyTypedData(domain, types, { ctHandles: handles, decryptedResult, extraData }, sig);
1160
1171
  return recoveredAddress;
1161
1172
  });
1162
1173
  const thresholdReached = isThresholdReached(kmsSigners, recoveredAddresses, thresholdSigners);
@@ -1177,9 +1188,11 @@ const publicDecryptRequest = (kmsSigners, thresholdSigners, gatewayChainId, veri
1177
1188
  * @param contractsChainId - The chain ID where the contracts are deployed
1178
1189
  * @param startTimestamp - The timestamp when the decryption permission becomes valid
1179
1190
  * @param durationDays - How many days the decryption permission remains valid
1191
+ * @param delegatedAccount - Optional delegated account address
1180
1192
  * @returns EIP712 typed data structure for user decryption
1181
1193
  */
1182
1194
  const createEIP712 = (verifyingContract, contractsChainId) => (publicKey, contractAddresses, startTimestamp, durationDays, delegatedAccount) => {
1195
+ const extraData = '0x00';
1183
1196
  if (delegatedAccount && !isAddress(delegatedAccount))
1184
1197
  throw new Error('Invalid delegated account.');
1185
1198
  if (!isAddress(verifyingContract)) {
@@ -1221,6 +1234,7 @@ const createEIP712 = (verifyingContract, contractsChainId) => (publicKey, contra
1221
1234
  { name: 'contractsChainId', type: 'uint256' },
1222
1235
  { name: 'startTimestamp', type: 'uint256' },
1223
1236
  { name: 'durationDays', type: 'uint256' },
1237
+ { name: 'extraData', type: 'bytes' },
1224
1238
  {
1225
1239
  name: 'delegatedAccount',
1226
1240
  type: 'address',
@@ -1235,6 +1249,7 @@ const createEIP712 = (verifyingContract, contractsChainId) => (publicKey, contra
1235
1249
  contractsChainId,
1236
1250
  startTimestamp: formattedStartTimestamp,
1237
1251
  durationDays: formattedDurationDays,
1252
+ extraData,
1238
1253
  delegatedAccount: delegatedAccount,
1239
1254
  },
1240
1255
  };
@@ -1248,6 +1263,7 @@ const createEIP712 = (verifyingContract, contractsChainId) => (publicKey, contra
1248
1263
  { name: 'contractsChainId', type: 'uint256' },
1249
1264
  { name: 'startTimestamp', type: 'uint256' },
1250
1265
  { name: 'durationDays', type: 'uint256' },
1266
+ { name: 'extraData', type: 'bytes' },
1251
1267
  ],
1252
1268
  },
1253
1269
  primaryType: 'UserDecryptRequestVerification',
@@ -1258,6 +1274,7 @@ const createEIP712 = (verifyingContract, contractsChainId) => (publicKey, contra
1258
1274
  contractsChainId,
1259
1275
  startTimestamp: formattedStartTimestamp,
1260
1276
  durationDays: formattedDurationDays,
1277
+ extraData,
1261
1278
  },
1262
1279
  };
1263
1280
  };
package/lib/web.d.ts CHANGED
@@ -12,6 +12,7 @@ import { InitInput as TFHEInput } from 'tfhe';
12
12
  * @param contractsChainId - The chain ID where the contracts are deployed
13
13
  * @param startTimestamp - The timestamp when the decryption permission becomes valid
14
14
  * @param durationDays - How many days the decryption permission remains valid
15
+ * @param delegatedAccount - Optional delegated account address
15
16
  * @returns EIP712 typed data structure for user decryption
16
17
  */
17
18
  export declare const createEIP712: (verifyingContract: string, contractsChainId: number) => (publicKey: string | Uint8Array, contractAddresses: string[], startTimestamp: string | number, durationDays: string | number, delegatedAccount?: string) => EIP712;
package/lib/web.js CHANGED
@@ -16704,6 +16704,7 @@ function checkDeadlineValidity(startTimestamp, durationDays) {
16704
16704
  }
16705
16705
  }
16706
16706
  const userDecryptRequest = (kmsSigners, gatewayChainId, chainId, verifyingContractAddress, aclContractAddress, relayerUrl, provider, options) => async (_handles, privateKey, publicKey, signature, contractAddresses, userAddress, startTimestamp, durationDays) => {
16707
+ const extraData = '0x00';
16707
16708
  let pubKey;
16708
16709
  let privKey;
16709
16710
  try {
@@ -16759,6 +16760,7 @@ const userDecryptRequest = (kmsSigners, gatewayChainId, chainId, verifyingContra
16759
16760
  userAddress: getAddress$1(userAddress),
16760
16761
  signature: signatureSanitized,
16761
16762
  publicKey: publicKeySanitized,
16763
+ extraData,
16762
16764
  };
16763
16765
  const json = await fetchRelayerJsonRpcPost('USER_DECRYPT', `${relayerUrl}/v1/user-decrypt`, payloadForRequest, options);
16764
16766
  // assume the KMS Signers have the correct order
@@ -17095,6 +17097,7 @@ const createRelayerEncryptedInput = (aclContractAddress, verifyingContractAddres
17095
17097
  return input.getBits();
17096
17098
  },
17097
17099
  encrypt: async (options) => {
17100
+ const extraData = '0x00';
17098
17101
  const bits = input.getBits();
17099
17102
  const ciphertext = input.encrypt();
17100
17103
  const payload = {
@@ -17102,6 +17105,7 @@ const createRelayerEncryptedInput = (aclContractAddress, verifyingContractAddres
17102
17105
  userAddress: getAddress(userAddress),
17103
17106
  ciphertextWithInputVerification: toHexString(ciphertext),
17104
17107
  contractChainId: ('0x' + chainId.toString(16)),
17108
+ extraData,
17105
17109
  };
17106
17110
  const json = await fetchRelayerJsonRpcPost('INPUT_PROOF', `${relayerUrl}/v1/input-proof`, payload, options);
17107
17111
  if (!isFhevmRelayerInputProofResponse(json)) {
@@ -17138,6 +17142,7 @@ const createRelayerEncryptedInput = (aclContractAddress, verifyingContractAddres
17138
17142
  { name: 'userAddress', type: 'address' },
17139
17143
  { name: 'contractAddress', type: 'address' },
17140
17144
  { name: 'contractChainId', type: 'uint256' },
17145
+ { name: 'extraData', type: 'bytes' },
17141
17146
  ],
17142
17147
  };
17143
17148
  const recoveredAddresses = signatures.map((signature) => {
@@ -17147,6 +17152,7 @@ const createRelayerEncryptedInput = (aclContractAddress, verifyingContractAddres
17147
17152
  userAddress,
17148
17153
  contractAddress,
17149
17154
  contractChainId: chainId,
17155
+ extraData,
17150
17156
  }, sig);
17151
17157
  return recoveredAddress;
17152
17158
  });
@@ -17161,6 +17167,8 @@ const createRelayerEncryptedInput = (aclContractAddress, verifyingContractAddres
17161
17167
  const listHandlesStr = handles.map((i) => toHexString(i));
17162
17168
  listHandlesStr.map((handle) => (inputProof += handle));
17163
17169
  signatures.map((signature) => (inputProof += signature.slice(2))); // removes the '0x' prefix from the `signature` string
17170
+ // Append the extra data to the input proof
17171
+ inputProof += extraData.slice(2);
17164
17172
  return {
17165
17173
  handles,
17166
17174
  inputProof: fromHexString(inputProof),
@@ -17222,6 +17230,7 @@ function deserializeDecryptedResult(handles, decryptedResult) {
17222
17230
  return results;
17223
17231
  }
17224
17232
  const publicDecryptRequest = (kmsSigners, thresholdSigners, gatewayChainId, verifyingContractAddress, aclContractAddress, relayerUrl, provider, options) => async (_handles) => {
17233
+ const extraData = '0x00';
17225
17234
  const acl = new ethers.Contract(aclContractAddress, aclABI, provider);
17226
17235
  let handles;
17227
17236
  try {
@@ -17243,6 +17252,7 @@ const publicDecryptRequest = (kmsSigners, thresholdSigners, gatewayChainId, veri
17243
17252
  checkEncryptedBits(handles);
17244
17253
  const payloadForRequest = {
17245
17254
  ciphertextHandles: handles,
17255
+ extraData,
17246
17256
  };
17247
17257
  const json = await fetchRelayerJsonRpcPost('PUBLIC_DECRYPT', `${relayerUrl}/v1/public-decrypt`, payloadForRequest, options);
17248
17258
  // verify signatures on decryption:
@@ -17256,6 +17266,7 @@ const publicDecryptRequest = (kmsSigners, thresholdSigners, gatewayChainId, veri
17256
17266
  PublicDecryptVerification: [
17257
17267
  { name: 'ctHandles', type: 'bytes32[]' },
17258
17268
  { name: 'decryptedResult', type: 'bytes' },
17269
+ { name: 'extraData', type: 'bytes' },
17259
17270
  ],
17260
17271
  };
17261
17272
  const result = json.response[0];
@@ -17265,7 +17276,7 @@ const publicDecryptRequest = (kmsSigners, thresholdSigners, gatewayChainId, veri
17265
17276
  const signatures = result.signatures;
17266
17277
  const recoveredAddresses = signatures.map((signature) => {
17267
17278
  const sig = signature.startsWith('0x') ? signature : `0x${signature}`;
17268
- const recoveredAddress = ethers.verifyTypedData(domain, types, { ctHandles: handles, decryptedResult }, sig);
17279
+ const recoveredAddress = ethers.verifyTypedData(domain, types, { ctHandles: handles, decryptedResult, extraData }, sig);
17269
17280
  return recoveredAddress;
17270
17281
  });
17271
17282
  const thresholdReached = isThresholdReached(kmsSigners, recoveredAddresses, thresholdSigners);
@@ -17286,9 +17297,11 @@ const publicDecryptRequest = (kmsSigners, thresholdSigners, gatewayChainId, veri
17286
17297
  * @param contractsChainId - The chain ID where the contracts are deployed
17287
17298
  * @param startTimestamp - The timestamp when the decryption permission becomes valid
17288
17299
  * @param durationDays - How many days the decryption permission remains valid
17300
+ * @param delegatedAccount - Optional delegated account address
17289
17301
  * @returns EIP712 typed data structure for user decryption
17290
17302
  */
17291
17303
  const createEIP712 = (verifyingContract, contractsChainId) => (publicKey, contractAddresses, startTimestamp, durationDays, delegatedAccount) => {
17304
+ const extraData = '0x00';
17292
17305
  if (delegatedAccount && !isAddress(delegatedAccount))
17293
17306
  throw new Error('Invalid delegated account.');
17294
17307
  if (!isAddress(verifyingContract)) {
@@ -17330,6 +17343,7 @@ const createEIP712 = (verifyingContract, contractsChainId) => (publicKey, contra
17330
17343
  { name: 'contractsChainId', type: 'uint256' },
17331
17344
  { name: 'startTimestamp', type: 'uint256' },
17332
17345
  { name: 'durationDays', type: 'uint256' },
17346
+ { name: 'extraData', type: 'bytes' },
17333
17347
  {
17334
17348
  name: 'delegatedAccount',
17335
17349
  type: 'address',
@@ -17344,6 +17358,7 @@ const createEIP712 = (verifyingContract, contractsChainId) => (publicKey, contra
17344
17358
  contractsChainId,
17345
17359
  startTimestamp: formattedStartTimestamp,
17346
17360
  durationDays: formattedDurationDays,
17361
+ extraData,
17347
17362
  delegatedAccount: delegatedAccount,
17348
17363
  },
17349
17364
  };
@@ -17357,6 +17372,7 @@ const createEIP712 = (verifyingContract, contractsChainId) => (publicKey, contra
17357
17372
  { name: 'contractsChainId', type: 'uint256' },
17358
17373
  { name: 'startTimestamp', type: 'uint256' },
17359
17374
  { name: 'durationDays', type: 'uint256' },
17375
+ { name: 'extraData', type: 'bytes' },
17360
17376
  ],
17361
17377
  },
17362
17378
  primaryType: 'UserDecryptRequestVerification',
@@ -17367,6 +17383,7 @@ const createEIP712 = (verifyingContract, contractsChainId) => (publicKey, contra
17367
17383
  contractsChainId,
17368
17384
  startTimestamp: formattedStartTimestamp,
17369
17385
  durationDays: formattedDurationDays,
17386
+ extraData,
17370
17387
  },
17371
17388
  };
17372
17389
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zama-fhe/relayer-sdk",
3
- "version": "0.2.0-3",
3
+ "version": "0.2.0-4",
4
4
  "description": "fhevm Relayer SDK",
5
5
  "main": "lib/node.js",
6
6
  "types": "lib/node.d.ts",