@zama-fhe/relayer-sdk 0.1.0-4 → 0.1.0-6
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/bundle/fhevm.js +2543 -2523
- package/bundle/fhevm.umd.cjs +12 -12
- package/lib/node.cjs +27 -4
- package/lib/node.d.ts +2 -0
- package/lib/node.js +27 -5
- package/lib/web.d.ts +2 -0
- package/lib/web.js +27 -5
- package/package.json +9 -6
package/lib/node.cjs
CHANGED
|
@@ -314,6 +314,8 @@ function checkDeadlineValidity(startTimestamp, durationDays) {
|
|
|
314
314
|
}
|
|
315
315
|
const userDecryptRequest = (kmsSigners, gatewayChainId, chainId, verifyingContractAddress, aclContractAddress, relayerUrl, provider) => async (_handles, privateKey, publicKey, signature, contractAddresses, userAddress, startTimestamp, durationDays) => {
|
|
316
316
|
// Casting handles if string
|
|
317
|
+
const signatureSanitized = signature.replace(/^(0x)/, '');
|
|
318
|
+
const publicKeySanitized = publicKey.replace(/^(0x)/, '');
|
|
317
319
|
const handles = _handles.map((h) => ({
|
|
318
320
|
handle: typeof h.handle === 'string'
|
|
319
321
|
? toHexString(fromHexString(h.handle), true)
|
|
@@ -355,8 +357,8 @@ const userDecryptRequest = (kmsSigners, gatewayChainId, chainId, verifyingContra
|
|
|
355
357
|
contractsChainId: chainId.toString(), // Convert to string
|
|
356
358
|
contractAddresses: contractAddresses.map((c) => ethers.getAddress(c)),
|
|
357
359
|
userAddress: ethers.getAddress(userAddress),
|
|
358
|
-
signature:
|
|
359
|
-
publicKey:
|
|
360
|
+
signature: signatureSanitized,
|
|
361
|
+
publicKey: publicKeySanitized,
|
|
360
362
|
};
|
|
361
363
|
const options = {
|
|
362
364
|
method: 'POST',
|
|
@@ -416,9 +418,9 @@ const userDecryptRequest = (kmsSigners, gatewayChainId, chainId, verifyingContra
|
|
|
416
418
|
salt: null,
|
|
417
419
|
};
|
|
418
420
|
const payloadForVerification = {
|
|
419
|
-
signature,
|
|
421
|
+
signature: signatureSanitized,
|
|
420
422
|
client_address: userAddress,
|
|
421
|
-
enc_key:
|
|
423
|
+
enc_key: publicKeySanitized,
|
|
422
424
|
ciphertext_handles: handles.map((h) => h.handle.replace(/^0x/, '')),
|
|
423
425
|
eip712_verifying_contract: verifyingContractAddress,
|
|
424
426
|
};
|
|
@@ -1079,6 +1081,26 @@ const generateKeypair = () => {
|
|
|
1079
1081
|
};
|
|
1080
1082
|
|
|
1081
1083
|
global.fetch = fetchRetry(global.fetch, { retries: 5, retryDelay: 500 });
|
|
1084
|
+
const SepoliaConfig = {
|
|
1085
|
+
// ACL_CONTRACT_ADDRESS (FHEVM Host chain)
|
|
1086
|
+
aclContractAddress: '0x687820221192C5B662b25367F70076A37bc79b6c',
|
|
1087
|
+
// KMS_VERIFIER_CONTRACT_ADDRESS (FHEVM Host chain)
|
|
1088
|
+
kmsContractAddress: '0x1364cBBf2cDF5032C47d8226a6f6FBD2AFCDacAC',
|
|
1089
|
+
// INPUT_VERIFIER_CONTRACT_ADDRESS (FHEVM Host chain)
|
|
1090
|
+
inputVerifierContractAddress: '0xbc91f3daD1A5F19F8390c400196e58073B6a0BC4',
|
|
1091
|
+
// DECRYPTION_ADDRESS (Gateway chain)
|
|
1092
|
+
verifyingContractAddressDecryption: '0xb6E160B1ff80D67Bfe90A85eE06Ce0A2613607D1',
|
|
1093
|
+
// INPUT_VERIFICATION_ADDRESS (Gateway chain)
|
|
1094
|
+
verifyingContractAddressInputVerification: '0x7048C39f048125eDa9d678AEbaDfB22F7900a29F',
|
|
1095
|
+
// FHEVM Host chain id
|
|
1096
|
+
chainId: 11155111,
|
|
1097
|
+
// Gateway chain id
|
|
1098
|
+
gatewayChainId: 55815,
|
|
1099
|
+
// Optional RPC provider to host chain
|
|
1100
|
+
network: 'https://eth-sepolia.public.blastapi.io',
|
|
1101
|
+
// Relayer URL
|
|
1102
|
+
relayerUrl: 'https://relayer.testnet.zama.cloud',
|
|
1103
|
+
};
|
|
1082
1104
|
const createInstance = async (config) => {
|
|
1083
1105
|
const { verifyingContractAddressDecryption, verifyingContractAddressInputVerification, publicKey, kmsContractAddress, aclContractAddress, gatewayChainId, } = config;
|
|
1084
1106
|
if (!kmsContractAddress || !ethers.isAddress(kmsContractAddress)) {
|
|
@@ -1150,6 +1172,7 @@ const createTfhePublicKey = () => {
|
|
|
1150
1172
|
};
|
|
1151
1173
|
|
|
1152
1174
|
exports.ENCRYPTION_TYPES = ENCRYPTION_TYPES;
|
|
1175
|
+
exports.SepoliaConfig = SepoliaConfig;
|
|
1153
1176
|
exports.createEIP712 = createEIP712;
|
|
1154
1177
|
exports.createInstance = createInstance;
|
|
1155
1178
|
exports.createTfheKeypair = createTfheKeypair;
|
package/lib/node.d.ts
CHANGED
package/lib/node.js
CHANGED
|
@@ -312,6 +312,8 @@ function checkDeadlineValidity(startTimestamp, durationDays) {
|
|
|
312
312
|
}
|
|
313
313
|
const userDecryptRequest = (kmsSigners, gatewayChainId, chainId, verifyingContractAddress, aclContractAddress, relayerUrl, provider) => async (_handles, privateKey, publicKey, signature, contractAddresses, userAddress, startTimestamp, durationDays) => {
|
|
314
314
|
// Casting handles if string
|
|
315
|
+
const signatureSanitized = signature.replace(/^(0x)/, '');
|
|
316
|
+
const publicKeySanitized = publicKey.replace(/^(0x)/, '');
|
|
315
317
|
const handles = _handles.map((h) => ({
|
|
316
318
|
handle: typeof h.handle === 'string'
|
|
317
319
|
? toHexString(fromHexString(h.handle), true)
|
|
@@ -353,8 +355,8 @@ const userDecryptRequest = (kmsSigners, gatewayChainId, chainId, verifyingContra
|
|
|
353
355
|
contractsChainId: chainId.toString(), // Convert to string
|
|
354
356
|
contractAddresses: contractAddresses.map((c) => getAddress(c)),
|
|
355
357
|
userAddress: getAddress(userAddress),
|
|
356
|
-
signature:
|
|
357
|
-
publicKey:
|
|
358
|
+
signature: signatureSanitized,
|
|
359
|
+
publicKey: publicKeySanitized,
|
|
358
360
|
};
|
|
359
361
|
const options = {
|
|
360
362
|
method: 'POST',
|
|
@@ -414,9 +416,9 @@ const userDecryptRequest = (kmsSigners, gatewayChainId, chainId, verifyingContra
|
|
|
414
416
|
salt: null,
|
|
415
417
|
};
|
|
416
418
|
const payloadForVerification = {
|
|
417
|
-
signature,
|
|
419
|
+
signature: signatureSanitized,
|
|
418
420
|
client_address: userAddress,
|
|
419
|
-
enc_key:
|
|
421
|
+
enc_key: publicKeySanitized,
|
|
420
422
|
ciphertext_handles: handles.map((h) => h.handle.replace(/^0x/, '')),
|
|
421
423
|
eip712_verifying_contract: verifyingContractAddress,
|
|
422
424
|
};
|
|
@@ -1077,6 +1079,26 @@ const generateKeypair = () => {
|
|
|
1077
1079
|
};
|
|
1078
1080
|
|
|
1079
1081
|
global.fetch = fetchRetry(global.fetch, { retries: 5, retryDelay: 500 });
|
|
1082
|
+
const SepoliaConfig = {
|
|
1083
|
+
// ACL_CONTRACT_ADDRESS (FHEVM Host chain)
|
|
1084
|
+
aclContractAddress: '0x687820221192C5B662b25367F70076A37bc79b6c',
|
|
1085
|
+
// KMS_VERIFIER_CONTRACT_ADDRESS (FHEVM Host chain)
|
|
1086
|
+
kmsContractAddress: '0x1364cBBf2cDF5032C47d8226a6f6FBD2AFCDacAC',
|
|
1087
|
+
// INPUT_VERIFIER_CONTRACT_ADDRESS (FHEVM Host chain)
|
|
1088
|
+
inputVerifierContractAddress: '0xbc91f3daD1A5F19F8390c400196e58073B6a0BC4',
|
|
1089
|
+
// DECRYPTION_ADDRESS (Gateway chain)
|
|
1090
|
+
verifyingContractAddressDecryption: '0xb6E160B1ff80D67Bfe90A85eE06Ce0A2613607D1',
|
|
1091
|
+
// INPUT_VERIFICATION_ADDRESS (Gateway chain)
|
|
1092
|
+
verifyingContractAddressInputVerification: '0x7048C39f048125eDa9d678AEbaDfB22F7900a29F',
|
|
1093
|
+
// FHEVM Host chain id
|
|
1094
|
+
chainId: 11155111,
|
|
1095
|
+
// Gateway chain id
|
|
1096
|
+
gatewayChainId: 55815,
|
|
1097
|
+
// Optional RPC provider to host chain
|
|
1098
|
+
network: 'https://eth-sepolia.public.blastapi.io',
|
|
1099
|
+
// Relayer URL
|
|
1100
|
+
relayerUrl: 'https://relayer.testnet.zama.cloud',
|
|
1101
|
+
};
|
|
1080
1102
|
const createInstance = async (config) => {
|
|
1081
1103
|
const { verifyingContractAddressDecryption, verifyingContractAddressInputVerification, publicKey, kmsContractAddress, aclContractAddress, gatewayChainId, } = config;
|
|
1082
1104
|
if (!kmsContractAddress || !isAddress(kmsContractAddress)) {
|
|
@@ -1147,4 +1169,4 @@ const createTfhePublicKey = () => {
|
|
|
1147
1169
|
return toHexString(publicKey.serialize());
|
|
1148
1170
|
};
|
|
1149
1171
|
|
|
1150
|
-
export { ENCRYPTION_TYPES, createEIP712, createInstance, createTfheKeypair, createTfhePublicKey, generateKeypair };
|
|
1172
|
+
export { ENCRYPTION_TYPES, SepoliaConfig, createEIP712, createInstance, createTfheKeypair, createTfhePublicKey, generateKeypair };
|
package/lib/web.d.ts
CHANGED
package/lib/web.js
CHANGED
|
@@ -26524,6 +26524,8 @@ function checkDeadlineValidity(startTimestamp, durationDays) {
|
|
|
26524
26524
|
}
|
|
26525
26525
|
const userDecryptRequest = (kmsSigners, gatewayChainId, chainId, verifyingContractAddress, aclContractAddress, relayerUrl, provider) => async (_handles, privateKey, publicKey, signature, contractAddresses, userAddress, startTimestamp, durationDays) => {
|
|
26526
26526
|
// Casting handles if string
|
|
26527
|
+
const signatureSanitized = signature.replace(/^(0x)/, '');
|
|
26528
|
+
const publicKeySanitized = publicKey.replace(/^(0x)/, '');
|
|
26527
26529
|
const handles = _handles.map((h) => ({
|
|
26528
26530
|
handle: typeof h.handle === 'string'
|
|
26529
26531
|
? toHexString(fromHexString(h.handle), true)
|
|
@@ -26565,8 +26567,8 @@ const userDecryptRequest = (kmsSigners, gatewayChainId, chainId, verifyingContra
|
|
|
26565
26567
|
contractsChainId: chainId.toString(), // Convert to string
|
|
26566
26568
|
contractAddresses: contractAddresses.map((c) => getAddress(c)),
|
|
26567
26569
|
userAddress: getAddress(userAddress),
|
|
26568
|
-
signature:
|
|
26569
|
-
publicKey:
|
|
26570
|
+
signature: signatureSanitized,
|
|
26571
|
+
publicKey: publicKeySanitized,
|
|
26570
26572
|
};
|
|
26571
26573
|
const options = {
|
|
26572
26574
|
method: 'POST',
|
|
@@ -26626,9 +26628,9 @@ const userDecryptRequest = (kmsSigners, gatewayChainId, chainId, verifyingContra
|
|
|
26626
26628
|
salt: null,
|
|
26627
26629
|
};
|
|
26628
26630
|
const payloadForVerification = {
|
|
26629
|
-
signature,
|
|
26631
|
+
signature: signatureSanitized,
|
|
26630
26632
|
client_address: userAddress,
|
|
26631
|
-
enc_key:
|
|
26633
|
+
enc_key: publicKeySanitized,
|
|
26632
26634
|
ciphertext_handles: handles.map((h) => h.handle.replace(/^0x/, '')),
|
|
26633
26635
|
eip712_verifying_contract: verifyingContractAddress,
|
|
26634
26636
|
};
|
|
@@ -27289,6 +27291,26 @@ const generateKeypair = () => {
|
|
|
27289
27291
|
};
|
|
27290
27292
|
|
|
27291
27293
|
global.fetch = fetchRetry(global.fetch, { retries: 5, retryDelay: 500 });
|
|
27294
|
+
const SepoliaConfig = {
|
|
27295
|
+
// ACL_CONTRACT_ADDRESS (FHEVM Host chain)
|
|
27296
|
+
aclContractAddress: '0x687820221192C5B662b25367F70076A37bc79b6c',
|
|
27297
|
+
// KMS_VERIFIER_CONTRACT_ADDRESS (FHEVM Host chain)
|
|
27298
|
+
kmsContractAddress: '0x1364cBBf2cDF5032C47d8226a6f6FBD2AFCDacAC',
|
|
27299
|
+
// INPUT_VERIFIER_CONTRACT_ADDRESS (FHEVM Host chain)
|
|
27300
|
+
inputVerifierContractAddress: '0xbc91f3daD1A5F19F8390c400196e58073B6a0BC4',
|
|
27301
|
+
// DECRYPTION_ADDRESS (Gateway chain)
|
|
27302
|
+
verifyingContractAddressDecryption: '0xb6E160B1ff80D67Bfe90A85eE06Ce0A2613607D1',
|
|
27303
|
+
// INPUT_VERIFICATION_ADDRESS (Gateway chain)
|
|
27304
|
+
verifyingContractAddressInputVerification: '0x7048C39f048125eDa9d678AEbaDfB22F7900a29F',
|
|
27305
|
+
// FHEVM Host chain id
|
|
27306
|
+
chainId: 11155111,
|
|
27307
|
+
// Gateway chain id
|
|
27308
|
+
gatewayChainId: 55815,
|
|
27309
|
+
// Optional RPC provider to host chain
|
|
27310
|
+
network: 'https://eth-sepolia.public.blastapi.io',
|
|
27311
|
+
// Relayer URL
|
|
27312
|
+
relayerUrl: 'https://relayer.testnet.zama.cloud',
|
|
27313
|
+
};
|
|
27292
27314
|
const createInstance = async (config) => {
|
|
27293
27315
|
const { verifyingContractAddressDecryption, verifyingContractAddressInputVerification, publicKey, kmsContractAddress, aclContractAddress, gatewayChainId, } = config;
|
|
27294
27316
|
if (!kmsContractAddress || !isAddress(kmsContractAddress)) {
|
|
@@ -27365,4 +27387,4 @@ const initFhevm = async ({ tfheParams, kmsParams, thread, } = {}) => {
|
|
|
27365
27387
|
return true;
|
|
27366
27388
|
};
|
|
27367
27389
|
|
|
27368
|
-
export { ENCRYPTION_TYPES, createEIP712, createInstance, generateKeypair, initFhevm };
|
|
27390
|
+
export { ENCRYPTION_TYPES, SepoliaConfig, createEIP712, createInstance, generateKeypair, initFhevm };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zama-fhe/relayer-sdk",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-6",
|
|
4
4
|
"description": "fhevm Relayer SDK",
|
|
5
5
|
"main": "lib/node.js",
|
|
6
6
|
"types": "lib/node.d.ts",
|
|
@@ -16,15 +16,18 @@
|
|
|
16
16
|
},
|
|
17
17
|
"./web": {
|
|
18
18
|
"import": "./lib/web.js",
|
|
19
|
-
"require": "./lib/web.js"
|
|
19
|
+
"require": "./lib/web.js",
|
|
20
|
+
"types": "./lib/web.d.ts"
|
|
20
21
|
},
|
|
21
22
|
"./bundle": {
|
|
22
23
|
"import": "./bundle.js",
|
|
23
|
-
"require": "./bundle.js"
|
|
24
|
+
"require": "./bundle.js",
|
|
25
|
+
"types": "./bundle.d.ts"
|
|
24
26
|
},
|
|
25
27
|
"./node": {
|
|
26
28
|
"import": "./lib/node.js",
|
|
27
|
-
"require": "./lib/node.cjs"
|
|
29
|
+
"require": "./lib/node.cjs",
|
|
30
|
+
"types": "./lib/node.d.ts"
|
|
28
31
|
}
|
|
29
32
|
},
|
|
30
33
|
"engines": {
|
|
@@ -63,9 +66,9 @@
|
|
|
63
66
|
"fetch-retry": "^6.0.0",
|
|
64
67
|
"keccak": "^3.0.4",
|
|
65
68
|
"node-tfhe": "^1.1.2",
|
|
66
|
-
"node-tkms": "
|
|
69
|
+
"node-tkms": "0.11.0-rc17",
|
|
67
70
|
"tfhe": "^1.1.2",
|
|
68
|
-
"tkms": "
|
|
71
|
+
"tkms": "0.11.0-rc17",
|
|
69
72
|
"wasm-feature-detect": "^1.8.0"
|
|
70
73
|
},
|
|
71
74
|
"devDependencies": {
|