@fhevm/sdk 1.1.0-alpha.7 → 1.1.0-alpha.8
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/README.md +5 -5
- package/_cjs/core/_version.js +1 -1
- package/_cjs/core/actions/encrypt/encryptValue.js +2 -1
- package/_cjs/core/actions/encrypt/encryptValue.js.map +1 -1
- package/_cjs/core/actions/encrypt/encryptValues.js +2 -1
- package/_cjs/core/actions/encrypt/encryptValues.js.map +1 -1
- package/_cjs/core/actions/encrypt/generateZkProof.js +2 -1
- package/_cjs/core/actions/encrypt/generateZkProof.js.map +1 -1
- package/_cjs/core/actions/host/readKmsVerifierContractData.js +1 -1
- package/_cjs/core/actions/host/readKmsVerifierContractData.js.map +1 -1
- package/_cjs/core/base/cachedFetch.js +1 -1
- package/_cjs/core/base/cachedFetch.js.map +1 -1
- package/_cjs/core/handle/FheType.js +4 -0
- package/_cjs/core/handle/FheType.js.map +1 -1
- package/_cjs/core/host-contracts/HostContractVersion-p.js +4 -0
- package/_cjs/core/host-contracts/HostContractVersion-p.js.map +1 -1
- package/_cjs/core/host-contracts/KmsSignersContext-p.js +15 -25
- package/_cjs/core/host-contracts/KmsSignersContext-p.js.map +1 -1
- package/_cjs/core/host-contracts/getKmsContextSignersAndThreshold-p.js.map +1 -1
- package/_cjs/core/host-contracts/getKmsContextSignersAndThresholdFromExtraData-p.js +7 -6
- package/_cjs/core/host-contracts/getKmsContextSignersAndThresholdFromExtraData-p.js.map +1 -1
- package/_cjs/core/host-contracts/readKmsSignersContext-p.js +54 -66
- package/_cjs/core/host-contracts/readKmsSignersContext-p.js.map +1 -1
- package/_cjs/core/kms/KmsSigncryptedShares-p.js +40 -4
- package/_cjs/core/kms/KmsSigncryptedShares-p.js.map +1 -1
- package/_cjs/core/kms/PublicDecryptionProof-p.js +4 -3
- package/_cjs/core/kms/PublicDecryptionProof-p.js.map +1 -1
- package/_cjs/core/kms/SignedDecryptionPermitV1-p.js +1 -14
- package/_cjs/core/kms/SignedDecryptionPermitV1-p.js.map +1 -1
- package/_cjs/core/kms/SignedDecryptionPermitV2-p.js +3 -15
- package/_cjs/core/kms/SignedDecryptionPermitV2-p.js.map +1 -1
- package/_cjs/core/kms/createKmsDelegatedUserDecryptEip712V1.js +3 -4
- package/_cjs/core/kms/createKmsDelegatedUserDecryptEip712V1.js.map +1 -1
- package/_cjs/core/kms/createKmsUserDecryptEip712V1.js +6 -5
- package/_cjs/core/kms/createKmsUserDecryptEip712V1.js.map +1 -1
- package/_cjs/core/kms/createKmsUserDecryptEip712V2.js +4 -5
- package/_cjs/core/kms/createKmsUserDecryptEip712V2.js.map +1 -1
- package/_cjs/core/kms/fetchKmsSigncryptedSharesV1-p.js +1 -1
- package/_cjs/core/kms/fetchKmsSigncryptedSharesV1-p.js.map +1 -1
- package/_cjs/core/kms/fetchKmsSigncryptedSharesV2-p.js +1 -1
- package/_cjs/core/kms/fetchKmsSigncryptedSharesV2-p.js.map +1 -1
- package/_cjs/core/kms/kmsExtraData-p.js +234 -0
- package/_cjs/core/kms/kmsExtraData-p.js.map +1 -0
- package/_cjs/core/kms/publicDecrypt.js +4 -4
- package/_cjs/core/kms/publicDecrypt.js.map +1 -1
- package/_cjs/core/kms/verifyKmsPublicDecryptEip712-p.js +5 -4
- package/_cjs/core/kms/verifyKmsPublicDecryptEip712-p.js.map +1 -1
- package/_cjs/core/modules/decrypt/mock.js +6 -6
- package/_cjs/core/modules/decrypt/mock.js.map +1 -1
- package/_cjs/core/modules/decrypt/module/api-p.js +7 -7
- package/_cjs/core/modules/decrypt/module/api-p.js.map +1 -1
- package/_cjs/core/modules/relayer/cleartext/fetchCoprocessorSignatures.js +53 -3
- package/_cjs/core/modules/relayer/cleartext/fetchCoprocessorSignatures.js.map +1 -1
- package/_cjs/core/modules/relayer/cleartext/{fetchDelegatedUserDecrypt.js → fetchDelegatedUserDecryptV1.js} +67 -21
- package/_cjs/core/modules/relayer/cleartext/fetchDelegatedUserDecryptV1.js.map +1 -0
- package/_cjs/core/modules/relayer/cleartext/fetchPublicDecrypt.js +61 -4
- package/_cjs/core/modules/relayer/cleartext/fetchPublicDecrypt.js.map +1 -1
- package/_cjs/core/modules/relayer/cleartext/fetchUserDecrypt.js +9 -108
- package/_cjs/core/modules/relayer/cleartext/fetchUserDecrypt.js.map +1 -1
- package/_cjs/core/modules/relayer/cleartext/fetchUserDecryptV1.js +163 -0
- package/_cjs/core/modules/relayer/cleartext/fetchUserDecryptV1.js.map +1 -0
- package/_cjs/core/modules/relayer/cleartext/fetchUserDecryptV2.js +7 -0
- package/_cjs/core/modules/relayer/cleartext/fetchUserDecryptV2.js.map +1 -0
- package/_cjs/core/modules/relayer/cleartext/forgeFhevmV1.js +83 -0
- package/_cjs/core/modules/relayer/cleartext/forgeFhevmV1.js.map +1 -0
- package/_cjs/core/modules/relayer/cleartext/mock.js +2 -2
- package/_cjs/core/modules/relayer/cleartext/mock.js.map +1 -1
- package/_cjs/core/modules/relayer/cleartext/signers.js +14 -0
- package/_cjs/core/modules/relayer/cleartext/signers.js.map +1 -1
- package/_cjs/ethers/internal/ethereum-ct.js +11 -0
- package/_cjs/ethers/internal/ethereum-ct.js.map +1 -1
- package/_cjs/ethers/internal/runtime-ct.js +9 -7
- package/_cjs/ethers/internal/runtime-ct.js.map +1 -1
- package/_cjs/viem/internal/ethereum-ct.js +8 -0
- package/_cjs/viem/internal/ethereum-ct.js.map +1 -1
- package/_cjs/viem/internal/runtime-ct.js +9 -7
- package/_cjs/viem/internal/runtime-ct.js.map +1 -1
- package/_cjs/wasm/tfhe/loadTfheLib.js.map +1 -1
- package/_cjs/wasm/tkms/loadKmsLib.js.map +1 -1
- package/_esm/core/_version.js +1 -1
- package/_esm/core/actions/encrypt/encryptValue.js +2 -1
- package/_esm/core/actions/encrypt/encryptValue.js.map +1 -1
- package/_esm/core/actions/encrypt/encryptValues.js +2 -1
- package/_esm/core/actions/encrypt/encryptValues.js.map +1 -1
- package/_esm/core/actions/encrypt/generateZkProof.js +2 -1
- package/_esm/core/actions/encrypt/generateZkProof.js.map +1 -1
- package/_esm/core/actions/host/readKmsVerifierContractData.js +2 -2
- package/_esm/core/actions/host/readKmsVerifierContractData.js.map +1 -1
- package/_esm/core/base/cachedFetch.js +1 -1
- package/_esm/core/base/cachedFetch.js.map +1 -1
- package/_esm/core/handle/FheType.js +10 -0
- package/_esm/core/handle/FheType.js.map +1 -1
- package/_esm/core/host-contracts/HostContractVersion-p.js +6 -0
- package/_esm/core/host-contracts/HostContractVersion-p.js.map +1 -1
- package/_esm/core/host-contracts/KmsSignersContext-p.js +16 -25
- package/_esm/core/host-contracts/KmsSignersContext-p.js.map +1 -1
- package/_esm/core/host-contracts/getKmsContextSignersAndThreshold-p.js.map +1 -1
- package/_esm/core/host-contracts/getKmsContextSignersAndThresholdFromExtraData-p.js +6 -5
- package/_esm/core/host-contracts/getKmsContextSignersAndThresholdFromExtraData-p.js.map +1 -1
- package/_esm/core/host-contracts/readKmsSignersContext-p.js +132 -68
- package/_esm/core/host-contracts/readKmsSignersContext-p.js.map +1 -1
- package/_esm/core/kms/KmsSigncryptedShares-p.js +70 -4
- package/_esm/core/kms/KmsSigncryptedShares-p.js.map +1 -1
- package/_esm/core/kms/PublicDecryptionProof-p.js +4 -3
- package/_esm/core/kms/PublicDecryptionProof-p.js.map +1 -1
- package/_esm/core/kms/SignedDecryptionPermitV1-p.js +2 -32
- package/_esm/core/kms/SignedDecryptionPermitV1-p.js.map +1 -1
- package/_esm/core/kms/SignedDecryptionPermitV2-p.js +4 -16
- package/_esm/core/kms/SignedDecryptionPermitV2-p.js.map +1 -1
- package/_esm/core/kms/createKmsDelegatedUserDecryptEip712V1.js +3 -4
- package/_esm/core/kms/createKmsDelegatedUserDecryptEip712V1.js.map +1 -1
- package/_esm/core/kms/createKmsUserDecryptEip712V1.js +7 -6
- package/_esm/core/kms/createKmsUserDecryptEip712V1.js.map +1 -1
- package/_esm/core/kms/createKmsUserDecryptEip712V2.js +4 -5
- package/_esm/core/kms/createKmsUserDecryptEip712V2.js.map +1 -1
- package/_esm/core/kms/fetchKmsSigncryptedSharesV1-p.js +26 -2
- package/_esm/core/kms/fetchKmsSigncryptedSharesV1-p.js.map +1 -1
- package/_esm/core/kms/fetchKmsSigncryptedSharesV2-p.js +2 -2
- package/_esm/core/kms/fetchKmsSigncryptedSharesV2-p.js.map +1 -1
- package/_esm/core/kms/kmsExtraData-p.js +298 -0
- package/_esm/core/kms/kmsExtraData-p.js.map +1 -0
- package/_esm/core/kms/publicDecrypt.js +5 -5
- package/_esm/core/kms/publicDecrypt.js.map +1 -1
- package/_esm/core/kms/verifyKmsPublicDecryptEip712-p.js +5 -4
- package/_esm/core/kms/verifyKmsPublicDecryptEip712-p.js.map +1 -1
- package/_esm/core/modules/decrypt/mock.js +6 -6
- package/_esm/core/modules/decrypt/mock.js.map +1 -1
- package/_esm/core/modules/decrypt/module/api-p.js +7 -7
- package/_esm/core/modules/decrypt/module/api-p.js.map +1 -1
- package/_esm/core/modules/relayer/cleartext/fetchCoprocessorSignatures.js +69 -12
- package/_esm/core/modules/relayer/cleartext/fetchCoprocessorSignatures.js.map +1 -1
- package/_esm/core/modules/relayer/cleartext/{fetchDelegatedUserDecrypt.js → fetchDelegatedUserDecryptV1.js} +76 -22
- package/_esm/core/modules/relayer/cleartext/fetchDelegatedUserDecryptV1.js.map +1 -0
- package/_esm/core/modules/relayer/cleartext/fetchPublicDecrypt.js +77 -4
- package/_esm/core/modules/relayer/cleartext/fetchPublicDecrypt.js.map +1 -1
- package/_esm/core/modules/relayer/cleartext/fetchUserDecrypt.js +13 -114
- package/_esm/core/modules/relayer/cleartext/fetchUserDecrypt.js.map +1 -1
- package/_esm/core/modules/relayer/cleartext/fetchUserDecryptV1.js +173 -0
- package/_esm/core/modules/relayer/cleartext/fetchUserDecryptV1.js.map +1 -0
- package/_esm/core/modules/relayer/cleartext/fetchUserDecryptV2.js +6 -0
- package/_esm/core/modules/relayer/cleartext/fetchUserDecryptV2.js.map +1 -0
- package/_esm/core/modules/relayer/cleartext/forgeFhevmV1.js +140 -0
- package/_esm/core/modules/relayer/cleartext/forgeFhevmV1.js.map +1 -0
- package/_esm/core/modules/relayer/cleartext/mock.js +1 -1
- package/_esm/core/modules/relayer/cleartext/mock.js.map +1 -1
- package/_esm/core/modules/relayer/cleartext/signers.js +26 -0
- package/_esm/core/modules/relayer/cleartext/signers.js.map +1 -1
- package/_esm/ethers/internal/ethereum-ct.js +12 -1
- package/_esm/ethers/internal/ethereum-ct.js.map +1 -1
- package/_esm/ethers/internal/runtime-ct.js +9 -7
- package/_esm/ethers/internal/runtime-ct.js.map +1 -1
- package/_esm/viem/internal/ethereum-ct.js +10 -2
- package/_esm/viem/internal/ethereum-ct.js.map +1 -1
- package/_esm/viem/internal/runtime-ct.js +9 -7
- package/_esm/viem/internal/runtime-ct.js.map +1 -1
- package/_types/core/actions/encrypt/encryptValue.d.ts.map +1 -1
- package/_types/core/actions/encrypt/encryptValues.d.ts.map +1 -1
- package/_types/core/actions/encrypt/generateZkProof.d.ts.map +1 -1
- package/_types/core/base/cachedFetch.d.ts.map +1 -1
- package/_types/core/handle/FheType.d.ts +8 -0
- package/_types/core/handle/FheType.d.ts.map +1 -1
- package/_types/core/host-contracts/HostContractVersion-p.d.ts +8 -0
- package/_types/core/host-contracts/HostContractVersion-p.d.ts.map +1 -1
- package/_types/core/host-contracts/KmsSignersContext-p.d.ts +3 -2
- package/_types/core/host-contracts/KmsSignersContext-p.d.ts.map +1 -1
- package/_types/core/host-contracts/getKmsContextSignersAndThresholdFromExtraData-p.d.ts +3 -2
- package/_types/core/host-contracts/getKmsContextSignersAndThresholdFromExtraData-p.d.ts.map +1 -1
- package/_types/core/host-contracts/readKmsSignersContext-p.d.ts +43 -26
- package/_types/core/host-contracts/readKmsSignersContext-p.d.ts.map +1 -1
- package/_types/core/kms/KmsSigncryptedShares-p.d.ts +18 -0
- package/_types/core/kms/KmsSigncryptedShares-p.d.ts.map +1 -1
- package/_types/core/kms/PublicDecryptionProof-p.d.ts.map +1 -1
- package/_types/core/kms/SignedDecryptionPermitV1-p.d.ts.map +1 -1
- package/_types/core/kms/SignedDecryptionPermitV2-p.d.ts.map +1 -1
- package/_types/core/kms/createKmsDelegatedUserDecryptEip712V1.d.ts +2 -1
- package/_types/core/kms/createKmsDelegatedUserDecryptEip712V1.d.ts.map +1 -1
- package/_types/core/kms/createKmsUserDecryptEip712V1.d.ts +2 -1
- package/_types/core/kms/createKmsUserDecryptEip712V1.d.ts.map +1 -1
- package/_types/core/kms/createKmsUserDecryptEip712V2.d.ts +2 -1
- package/_types/core/kms/createKmsUserDecryptEip712V2.d.ts.map +1 -1
- package/_types/core/kms/fetchKmsSigncryptedSharesV1-p.d.ts.map +1 -1
- package/_types/core/kms/kmsExtraData-p.d.ts +66 -0
- package/_types/core/kms/kmsExtraData-p.d.ts.map +1 -0
- package/_types/core/kms/publicDecrypt.d.ts.map +1 -1
- package/_types/core/kms/verifyKmsPublicDecryptEip712-p.d.ts.map +1 -1
- package/_types/core/modules/ethereum/types-ct.d.ts +20 -2
- package/_types/core/modules/ethereum/types-ct.d.ts.map +1 -1
- package/_types/core/modules/relayer/cleartext/fetchCoprocessorSignatures.d.ts.map +1 -1
- package/_types/core/modules/relayer/cleartext/{fetchDelegatedUserDecrypt.d.ts → fetchDelegatedUserDecryptV1.d.ts} +1 -1
- package/_types/core/modules/relayer/cleartext/fetchDelegatedUserDecryptV1.d.ts.map +1 -0
- package/_types/core/modules/relayer/cleartext/fetchPublicDecrypt.d.ts.map +1 -1
- package/_types/core/modules/relayer/cleartext/fetchUserDecrypt.d.ts +2 -2
- package/_types/core/modules/relayer/cleartext/fetchUserDecrypt.d.ts.map +1 -1
- package/_types/core/modules/relayer/cleartext/fetchUserDecryptV1.d.ts +3 -0
- package/_types/core/modules/relayer/cleartext/fetchUserDecryptV1.d.ts.map +1 -0
- package/_types/core/modules/relayer/cleartext/fetchUserDecryptV2.d.ts +3 -0
- package/_types/core/modules/relayer/cleartext/fetchUserDecryptV2.d.ts.map +1 -0
- package/_types/core/modules/relayer/cleartext/forgeFhevmV1.d.ts +29 -0
- package/_types/core/modules/relayer/cleartext/forgeFhevmV1.d.ts.map +1 -0
- package/_types/core/modules/relayer/cleartext/signers.d.ts +1 -0
- package/_types/core/modules/relayer/cleartext/signers.d.ts.map +1 -1
- package/_types/core/types/kms-p.d.ts +7 -1
- package/_types/core/types/kms-p.d.ts.map +1 -1
- package/_types/ethers/internal/ethereum-ct.d.ts.map +1 -1
- package/_types/ethers/internal/runtime-ct.d.ts.map +1 -1
- package/_types/viem/internal/ethereum-ct.d.ts.map +1 -1
- package/_types/viem/internal/runtime-ct.d.ts.map +1 -1
- package/core/_version.ts +1 -1
- package/core/actions/encrypt/encryptValue.ts +4 -1
- package/core/actions/encrypt/encryptValues.ts +5 -1
- package/core/actions/encrypt/generateZkProof.ts +2 -1
- package/core/actions/host/readKmsVerifierContractData.ts +2 -2
- package/core/base/cachedFetch.ts +1 -1
- package/core/handle/FheType.ts +11 -0
- package/core/host-contracts/HostContractVersion-p.ts +12 -0
- package/core/host-contracts/KmsSignersContext-p.ts +29 -36
- package/core/host-contracts/getKmsContextSignersAndThreshold-p.ts +1 -0
- package/core/host-contracts/getKmsContextSignersAndThresholdFromExtraData-p.ts +10 -7
- package/core/host-contracts/readKmsSignersContext-p.ts +156 -115
- package/core/kms/KmsSigncryptedShares-p.ts +87 -4
- package/core/kms/PublicDecryptionProof-p.ts +6 -4
- package/core/kms/SignedDecryptionPermitV1-p.ts +5 -47
- package/core/kms/SignedDecryptionPermitV2-p.ts +8 -25
- package/core/kms/createKmsDelegatedUserDecryptEip712V1.ts +5 -5
- package/core/kms/createKmsUserDecryptEip712V1.ts +9 -7
- package/core/kms/createKmsUserDecryptEip712V2.ts +6 -6
- package/core/kms/fetchKmsSigncryptedSharesV1-p.ts +27 -15
- package/core/kms/fetchKmsSigncryptedSharesV2-p.ts +2 -2
- package/core/kms/kmsExtraData-p.ts +374 -0
- package/core/kms/publicDecrypt.ts +8 -7
- package/core/kms/verifyKmsPublicDecryptEip712-p.ts +7 -5
- package/core/modules/decrypt/mock.ts +6 -6
- package/core/modules/decrypt/module/api-p.ts +7 -7
- package/core/modules/ethereum/types-ct.ts +25 -2
- package/core/modules/relayer/cleartext/fetchCoprocessorSignatures.ts +98 -15
- package/core/modules/relayer/cleartext/{fetchDelegatedUserDecrypt.ts → fetchDelegatedUserDecryptV1.ts} +115 -27
- package/core/modules/relayer/cleartext/fetchPublicDecrypt.ts +112 -6
- package/core/modules/relayer/cleartext/fetchUserDecrypt.ts +24 -132
- package/core/modules/relayer/cleartext/fetchUserDecryptV1.ts +229 -0
- package/core/modules/relayer/cleartext/fetchUserDecryptV2.ts +11 -0
- package/core/modules/relayer/cleartext/forgeFhevmV1.ts +185 -0
- package/core/modules/relayer/cleartext/mock.ts +1 -1
- package/core/modules/relayer/cleartext/signers.ts +35 -0
- package/core/types/kms-p.ts +16 -1
- package/ethers/internal/ethereum-ct.ts +15 -1
- package/ethers/internal/runtime-ct.ts +9 -7
- package/package.json +1 -1
- package/viem/internal/ethereum-ct.ts +14 -2
- package/viem/internal/runtime-ct.ts +9 -7
- package/_cjs/core/kms/kmsExtraData.js +0 -82
- package/_cjs/core/kms/kmsExtraData.js.map +0 -1
- package/_cjs/core/modules/relayer/cleartext/fetchDelegatedUserDecrypt.js.map +0 -1
- package/_esm/core/kms/kmsExtraData.js +0 -99
- package/_esm/core/kms/kmsExtraData.js.map +0 -1
- package/_esm/core/modules/relayer/cleartext/fetchDelegatedUserDecrypt.js.map +0 -1
- package/_types/core/kms/kmsExtraData.d.ts +0 -25
- package/_types/core/kms/kmsExtraData.d.ts.map +0 -1
- package/_types/core/modules/relayer/cleartext/fetchDelegatedUserDecrypt.d.ts.map +0 -1
- package/core/kms/kmsExtraData.ts +0 -127
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import type { SignedDecryptionPermit, SignedDecryptionPermitV1 } from '../types/signedDecryptionPermit.js';
|
|
2
2
|
import type { KmsDelegatedUserDecryptEip712V1, KmsUserDecryptEip712V1 } from '../types/kms.js';
|
|
3
|
-
import type {
|
|
4
|
-
Bytes65Hex,
|
|
5
|
-
BytesHex,
|
|
6
|
-
ChecksummedAddress,
|
|
7
|
-
Uint256BigInt,
|
|
8
|
-
Uint8Number,
|
|
9
|
-
UintNumber,
|
|
10
|
-
} from '../types/primitives.js';
|
|
3
|
+
import type { Bytes65Hex, BytesHex, ChecksummedAddress, Uint8Number, UintNumber } from '../types/primitives.js';
|
|
11
4
|
import type { FhevmChain } from '../types/fhevmChain.js';
|
|
12
5
|
import type { FhevmRuntime } from '../types/coreFhevmRuntime.js';
|
|
13
|
-
import type { KmsSignersContext } from '../types/kmsSignersContext.js';
|
|
14
6
|
import type { SignDecryptionPermitContext, SignDecryptionPermitParameters } from './SignedDecryptionPermit-p.js';
|
|
7
|
+
import type { KmsExtraData } from '../types/kms-p.js';
|
|
15
8
|
import { verifyKmsUserDecryptEip712V1 } from '../utils-p/decrypt/verifyKmsUserDecryptEip712V1.js';
|
|
16
9
|
import { verifyKmsDelegatedUserDecryptEip712V1 } from '../utils-p/decrypt/verifyKmsDelegatedUserDecryptEip712V1.js';
|
|
17
10
|
import { assertRecordNonNullableProperty } from '../base/record.js';
|
|
@@ -24,9 +17,8 @@ import {
|
|
|
24
17
|
} from './createKmsDelegatedUserDecryptEip712V1.js';
|
|
25
18
|
import { assertRecordStringProperty } from '../base/string.js';
|
|
26
19
|
import { assertIsTransportKeyPair, type TransportKeyPair } from './TransportKeyPair-p.js';
|
|
27
|
-
import {
|
|
20
|
+
import { readCurrentKmsSignersContext } from '../host-contracts/readKmsSignersContext-p.js';
|
|
28
21
|
import { kmsSignersContextToExtraData } from '../host-contracts/KmsSignersContext-p.js';
|
|
29
|
-
import { fromKmsExtraData } from './kmsExtraData.js';
|
|
30
22
|
|
|
31
23
|
////////////////////////////////////////////////////////////////////////////////
|
|
32
24
|
|
|
@@ -123,44 +115,10 @@ class SignedDecryptionPermitV1Impl implements SignedDecryptionPermitV1 {
|
|
|
123
115
|
assertKmsEip712V1DeadlineValidity(this.#eip712.message, MAX_USER_DECRYPT_DURATION_DAYS);
|
|
124
116
|
}
|
|
125
117
|
|
|
126
|
-
/**
|
|
127
|
-
* Asserts that this permit was signed against the given {@link KmsSignersContext}.
|
|
128
|
-
*
|
|
129
|
-
* Compares the `extraData` embedded in the permit's EIP-712 message with the
|
|
130
|
-
* `extraData` derived from the provided context. A mismatch indicates the permit
|
|
131
|
-
* was created for a different KMS context (e.g. different context ID or version)
|
|
132
|
-
* and must not be used for decryption.
|
|
133
|
-
*
|
|
134
|
-
* @todo The current check is a strict byte-level comparison. A permit signed
|
|
135
|
-
* with the correct `kmsContextId` but a different `extraData` encoding format
|
|
136
|
-
* (e.g. a version change in the serialization scheme) will be rejected even
|
|
137
|
-
* though the context ID matches. Consider comparing the decoded `kmsContextId`
|
|
138
|
-
* instead of the raw `extraData` bytes.
|
|
139
|
-
*
|
|
140
|
-
* @param kmsSignersContext - The current KMS signers context to validate against.
|
|
141
|
-
* @throws If the permit's `extraData` does not match the context's `extraData`.
|
|
142
|
-
*/
|
|
143
|
-
public assertMatchesKmsContext(kmsSignersContext: KmsSignersContext): void {
|
|
144
|
-
const expectedExtraData = kmsSignersContextToExtraData(kmsSignersContext);
|
|
145
|
-
if (expectedExtraData !== this.#eip712.message.extraData) {
|
|
146
|
-
throw new Error(
|
|
147
|
-
`Invalid permit: extraData "${this.#eip712.message.extraData}" does not match expected "${expectedExtraData}" from KmsSignersContext.`,
|
|
148
|
-
);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
118
|
public get transportPublicKey(): BytesHex {
|
|
153
119
|
return this.#eip712.message.publicKey;
|
|
154
120
|
}
|
|
155
121
|
|
|
156
|
-
public get kmsContextId(): Uint256BigInt {
|
|
157
|
-
return fromKmsExtraData(this.#eip712.message.extraData).kmsContextId;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
public get kmsEpochId(): Uint256BigInt {
|
|
161
|
-
return fromKmsExtraData(this.#eip712.message.extraData).kmsEpochId;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
122
|
public get encryptedDataOwnerAddress(): ChecksummedAddress {
|
|
165
123
|
if (this.eip712.primaryType === 'DelegatedUserDecryptRequestVerification') {
|
|
166
124
|
return this.eip712.message.delegatorAddress;
|
|
@@ -235,12 +193,12 @@ export async function signDecryptionPermitV1(
|
|
|
235
193
|
context: SignDecryptionPermitContext,
|
|
236
194
|
parameters: SignDecryptionPermitParameters,
|
|
237
195
|
): Promise<SignedDecryptionPermit> {
|
|
238
|
-
const kmsSignersContext = await
|
|
196
|
+
const kmsSignersContext = await readCurrentKmsSignersContext(context, {
|
|
239
197
|
kmsVerifierAddress: context.chain.fhevm.contracts.kmsVerifier.address as ChecksummedAddress,
|
|
240
198
|
protocolConfigAddress: context.chain.fhevm.contracts.protocolConfig?.address as ChecksummedAddress | undefined,
|
|
241
199
|
});
|
|
242
200
|
|
|
243
|
-
const extraData:
|
|
201
|
+
const extraData: KmsExtraData = kmsSignersContextToExtraData(kmsSignersContext);
|
|
244
202
|
|
|
245
203
|
const {
|
|
246
204
|
contractAddresses,
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import type { SignedDecryptionPermit, SignedDecryptionPermitV2 } from '../types/signedDecryptionPermit.js';
|
|
2
2
|
import type { KmsUserDecryptEip712V2 } from '../types/kms.js';
|
|
3
|
-
import type { Bytes65Hex, BytesHex, ChecksummedAddress,
|
|
3
|
+
import type { Bytes65Hex, BytesHex, ChecksummedAddress, Uint8Number } from '../types/primitives.js';
|
|
4
4
|
import type { FhevmChain } from '../types/fhevmChain.js';
|
|
5
5
|
import type { FhevmRuntime } from '../types/coreFhevmRuntime.js';
|
|
6
|
-
import type { KmsSignersContext } from '../types/kmsSignersContext.js';
|
|
7
6
|
import type { SignDecryptionPermitContext, SignDecryptionPermitParameters } from './SignedDecryptionPermit-p.js';
|
|
7
|
+
import type { KmsExtraData } from '../types/kms-p.js';
|
|
8
8
|
import { assertRecordNonNullableProperty } from '../base/record.js';
|
|
9
9
|
import { assertRecordBytes65HexProperty } from '../base/bytes.js';
|
|
10
10
|
import { addressToChecksummedAddress, assertIsAddress, assertRecordAddressProperty } from '../base/address.js';
|
|
11
11
|
import { assertRecordStringProperty } from '../base/string.js';
|
|
12
12
|
import { assertIsTransportKeyPair, type TransportKeyPair } from './TransportKeyPair-p.js';
|
|
13
|
-
import {
|
|
13
|
+
import { readCurrentKmsSignersContext } from '../host-contracts/readKmsSignersContext-p.js';
|
|
14
14
|
import { kmsSignersContextToExtraData } from '../host-contracts/KmsSignersContext-p.js';
|
|
15
|
-
import { EXTRA_DATA_V2, fromKmsExtraData } from './kmsExtraData.js';
|
|
16
15
|
import { assertIsKmsUserDecryptEip712V2, createKmsUserDecryptEip712V2 } from './createKmsUserDecryptEip712V2.js';
|
|
17
16
|
import { verifyKmsUserDecryptEip712V2 } from '../utils-p/decrypt/verifyKmsUserDecryptEip712V2.js';
|
|
18
17
|
import { assert } from '../base/errors/InternalError.js';
|
|
18
|
+
import { EXTRA_DATA_V2 } from './kmsExtraData-p.js';
|
|
19
19
|
|
|
20
20
|
////////////////////////////////////////////////////////////////////////////////
|
|
21
21
|
|
|
@@ -106,23 +106,6 @@ class SignedDecryptionPermitV2Impl implements SignedDecryptionPermitV2 {
|
|
|
106
106
|
const { startTimestamp, durationSeconds } = this.#eip712.message;
|
|
107
107
|
assertKmsEip712V2DeadlineValidity({ startTimestamp, durationSeconds });
|
|
108
108
|
}
|
|
109
|
-
|
|
110
|
-
public assertMatchesKmsContext(kmsSignersContext: KmsSignersContext): void {
|
|
111
|
-
const expectedExtraData = kmsSignersContextToExtraData(kmsSignersContext);
|
|
112
|
-
if (expectedExtraData !== this.#eip712.message.extraData) {
|
|
113
|
-
throw new Error(
|
|
114
|
-
`Invalid permit: extraData "${this.#eip712.message.extraData}" does not match expected "${expectedExtraData}" from KmsSignersContext.`,
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
public get kmsContextId(): Uint256BigInt {
|
|
120
|
-
return fromKmsExtraData(this.#eip712.message.extraData).kmsContextId;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
public get kmsEpochId(): Uint256BigInt {
|
|
124
|
-
return fromKmsExtraData(this.#eip712.message.extraData).kmsEpochId;
|
|
125
|
-
}
|
|
126
109
|
}
|
|
127
110
|
|
|
128
111
|
////////////////////////////////////////////////////////////////////////////////
|
|
@@ -168,20 +151,20 @@ export async function signDecryptionPermitV2(
|
|
|
168
151
|
context: SignDecryptionPermitContext,
|
|
169
152
|
parameters: SignDecryptionPermitParameters,
|
|
170
153
|
): Promise<SignedDecryptionPermit> {
|
|
171
|
-
const kmsSignersContext = await
|
|
154
|
+
const kmsSignersContext = await readCurrentKmsSignersContext(context, {
|
|
172
155
|
kmsVerifierAddress: context.chain.fhevm.contracts.kmsVerifier.address as ChecksummedAddress,
|
|
173
156
|
protocolConfigAddress: context.chain.fhevm.contracts.protocolConfig?.address as ChecksummedAddress | undefined,
|
|
174
157
|
});
|
|
175
158
|
|
|
176
|
-
const extraData:
|
|
159
|
+
const extraData: KmsExtraData = kmsSignersContextToExtraData(kmsSignersContext);
|
|
177
160
|
|
|
178
161
|
// For debug purpose only:
|
|
179
162
|
// -----------------------
|
|
180
163
|
// In theory, it should not be possible to produce a unified eip712 (protocol v14+)
|
|
181
164
|
// with an extraData coming from an old protocol v11/12/13
|
|
182
165
|
assert(
|
|
183
|
-
|
|
184
|
-
`signDecryptionPermitV2 error: Invalid extraData version extraData=${extraData}`,
|
|
166
|
+
extraData.version >= EXTRA_DATA_V2,
|
|
167
|
+
`signDecryptionPermitV2 error: Invalid extraData version extraData=${extraData.toBytesHex()}`,
|
|
185
168
|
);
|
|
186
169
|
|
|
187
170
|
const {
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import type { KmsDelegatedUserDecryptEip712V1 } from '../types/kms.js';
|
|
2
2
|
import type { BytesHex } from '../types/primitives.js';
|
|
3
3
|
import type { ErrorMetadataParams } from '../base/errors/ErrorBase.js';
|
|
4
|
+
import type { KmsExtraData } from '../types/kms-p.js';
|
|
4
5
|
import {
|
|
5
6
|
addressToChecksummedAddress,
|
|
6
7
|
assertIsAddress,
|
|
7
8
|
assertIsAddressArray,
|
|
8
9
|
assertRecordChecksummedAddressProperty,
|
|
9
10
|
} from '../base/address.js';
|
|
10
|
-
import { asBytesHex,
|
|
11
|
+
import { asBytesHex, bytesToHexLarge } from '../base/bytes.js';
|
|
11
12
|
import { ensure0x } from '../base/string.js';
|
|
12
13
|
import { assertIsUintNumber } from '../base/uint.js';
|
|
13
14
|
import { createKmsEip712Domain } from './createKmsEip712Domain.js';
|
|
14
15
|
import { _assertIsKmsUserDecryptEip712V1Base } from './createKmsUserDecryptEip712V1.js';
|
|
15
16
|
import { kmsDelegatedUserDecryptEip712V1Types } from './kmsDelegatedUserDecryptEip712V1Types.js';
|
|
16
|
-
import { assertIsKmsExtraData } from './kmsExtraData.js';
|
|
17
|
+
import { assertIsKmsExtraData } from './kmsExtraData-p.js';
|
|
17
18
|
|
|
18
19
|
////////////////////////////////////////////////////////////////////////////////
|
|
19
20
|
|
|
@@ -24,7 +25,7 @@ export type CreateKmsDelegatedUserDecryptEip712V1Parameters = {
|
|
|
24
25
|
readonly contractAddresses: readonly string[];
|
|
25
26
|
readonly startTimestamp: number;
|
|
26
27
|
readonly durationDays: number;
|
|
27
|
-
readonly extraData:
|
|
28
|
+
readonly extraData: KmsExtraData;
|
|
28
29
|
readonly delegatorAddress: string;
|
|
29
30
|
};
|
|
30
31
|
|
|
@@ -50,7 +51,6 @@ export function createKmsDelegatedUserDecryptEip712V1(
|
|
|
50
51
|
assertIsAddressArray(contractAddresses, {});
|
|
51
52
|
assertIsUintNumber(startTimestamp, {});
|
|
52
53
|
assertIsUintNumber(durationDays, {});
|
|
53
|
-
assertIsBytesHex(extraData, {});
|
|
54
54
|
assertIsAddress(delegatorAddress, {});
|
|
55
55
|
assertIsKmsExtraData(extraData, {});
|
|
56
56
|
|
|
@@ -75,7 +75,7 @@ export function createKmsDelegatedUserDecryptEip712V1(
|
|
|
75
75
|
delegatorAddress: checksummedDelegatorAddress,
|
|
76
76
|
startTimestamp: startTimestamp.toString(),
|
|
77
77
|
durationDays: durationDays.toString(),
|
|
78
|
-
extraData,
|
|
78
|
+
extraData: extraData.toBytesHex(),
|
|
79
79
|
},
|
|
80
80
|
};
|
|
81
81
|
|
|
@@ -2,6 +2,7 @@ import type { ErrorMetadataParams } from '../base/errors/ErrorBase.js';
|
|
|
2
2
|
import type { KmsEip712Domain, KmsUserDecryptEip712V1 } from '../types/kms.js';
|
|
3
3
|
import type { BytesHex } from '../types/primitives.js';
|
|
4
4
|
import type { KmsUserDecryptEip712V1Message } from '../types/kms.js';
|
|
5
|
+
import type { KmsExtraData } from '../types/kms-p.js';
|
|
5
6
|
import {
|
|
6
7
|
addressToChecksummedAddress,
|
|
7
8
|
assertIsAddress,
|
|
@@ -9,14 +10,14 @@ import {
|
|
|
9
10
|
assertRecordChecksummedAddressArrayProperty,
|
|
10
11
|
} from '../base/address.js';
|
|
11
12
|
import { assertIsKmsEip712Domain, createKmsEip712Domain } from './createKmsEip712Domain.js';
|
|
12
|
-
import { asBytesHex,
|
|
13
|
+
import { asBytesHex, assertRecordBytesHexProperty, bytesToHexLarge } from '../base/bytes.js';
|
|
13
14
|
import { assertRecordNonNullableProperty } from '../base/record.js';
|
|
14
15
|
import { assertRecordStringProperty, ensure0x } from '../base/string.js';
|
|
15
|
-
import { assertIsUint64, assertIsUintNumber } from '../base/uint.js';
|
|
16
|
-
import { assertIsKmsExtraData } from './kmsExtraData.js';
|
|
16
|
+
import { assertIsUint64, assertIsUintNumber, assertIsUintString, MAX_UINT256 } from '../base/uint.js';
|
|
17
17
|
import { kmsUserDecryptEip712V1Types } from './kmsUserDecryptEip712V1Types.js';
|
|
18
18
|
import { kmsDelegatedUserDecryptEip712V1Types } from './kmsDelegatedUserDecryptEip712V1Types.js';
|
|
19
19
|
import { isDeepEqual } from '../base/object.js';
|
|
20
|
+
import { assertIsKmsExtraData, assertIsKmsExtraDataBytesHex } from './kmsExtraData-p.js';
|
|
20
21
|
|
|
21
22
|
////////////////////////////////////////////////////////////////////////////////
|
|
22
23
|
|
|
@@ -27,7 +28,7 @@ export type CreateKmsUserDecryptEip712V1Parameters = {
|
|
|
27
28
|
readonly contractAddresses: readonly string[];
|
|
28
29
|
readonly startTimestamp: number;
|
|
29
30
|
readonly durationDays: number;
|
|
30
|
-
readonly extraData:
|
|
31
|
+
readonly extraData: KmsExtraData;
|
|
31
32
|
};
|
|
32
33
|
|
|
33
34
|
////////////////////////////////////////////////////////////////////////////////
|
|
@@ -53,7 +54,6 @@ export function createKmsUserDecryptEip712V1(
|
|
|
53
54
|
assertIsAddressArray(contractAddresses, {});
|
|
54
55
|
assertIsUintNumber(startTimestamp, {});
|
|
55
56
|
assertIsUintNumber(durationDays, {});
|
|
56
|
-
assertIsBytesHex(extraData, {});
|
|
57
57
|
assertIsKmsExtraData(extraData, {});
|
|
58
58
|
|
|
59
59
|
const checksummedContractAddresses = contractAddresses.map(addressToChecksummedAddress);
|
|
@@ -74,7 +74,7 @@ export function createKmsUserDecryptEip712V1(
|
|
|
74
74
|
contractAddresses: checksummedContractAddresses,
|
|
75
75
|
startTimestamp: startTimestamp.toString(),
|
|
76
76
|
durationDays: durationDays.toString(),
|
|
77
|
-
extraData,
|
|
77
|
+
extraData: extraData.toBytesHex(),
|
|
78
78
|
},
|
|
79
79
|
};
|
|
80
80
|
|
|
@@ -159,7 +159,9 @@ function _assertIsKmsUserDecryptEip712V1Message(
|
|
|
159
159
|
assertRecordStringProperty(msg, 'startTimestamp' satisfies keyof MessageType, msgName, options);
|
|
160
160
|
assertRecordStringProperty(msg, 'durationDays' satisfies keyof MessageType, msgName, options);
|
|
161
161
|
assertRecordBytesHexProperty(msg, 'extraData' satisfies keyof MessageType, msgName, options);
|
|
162
|
-
|
|
162
|
+
assertIsKmsExtraDataBytesHex(msg.extraData, options);
|
|
163
|
+
assertIsUintString(msg.startTimestamp, { max: MAX_UINT256 });
|
|
164
|
+
assertIsUintString(msg.durationDays, { max: MAX_UINT256 });
|
|
163
165
|
}
|
|
164
166
|
|
|
165
167
|
////////////////////////////////////////////////////////////////////////////////
|
|
@@ -2,6 +2,7 @@ import type { ErrorMetadataParams } from '../base/errors/ErrorBase.js';
|
|
|
2
2
|
import type { KmsUserDecryptEip712V2 } from '../types/kms.js';
|
|
3
3
|
import type { BytesHex } from '../types/primitives.js';
|
|
4
4
|
import type { KmsUserDecryptEip712V2Message } from '../types/kms.js';
|
|
5
|
+
import type { KmsExtraData } from '../types/kms-p.js';
|
|
5
6
|
import {
|
|
6
7
|
addressToChecksummedAddress,
|
|
7
8
|
assertIsAddress,
|
|
@@ -10,13 +11,13 @@ import {
|
|
|
10
11
|
assertRecordChecksummedAddressArrayProperty,
|
|
11
12
|
} from '../base/address.js';
|
|
12
13
|
import { assertIsKmsEip712Domain, createKmsEip712Domain } from './createKmsEip712Domain.js';
|
|
13
|
-
import { asBytesHex,
|
|
14
|
+
import { asBytesHex, assertRecordBytesHexProperty, bytesToHexLarge } from '../base/bytes.js';
|
|
14
15
|
import { isDeepEqual } from '../base/object.js';
|
|
15
16
|
import { assertRecordNonNullableProperty } from '../base/record.js';
|
|
16
17
|
import { assertRecordStringProperty, ensure0x } from '../base/string.js';
|
|
17
18
|
import { assertIsUint256, assertIsUint64, assertIsUintString, MAX_UINT256 } from '../base/uint.js';
|
|
18
|
-
import { assertIsKmsExtraData } from './kmsExtraData.js';
|
|
19
19
|
import { kmsUserDecryptEip712V2Types } from './kmsUserDecryptEip712V2Types.js';
|
|
20
|
+
import { assertIsKmsExtraData, assertIsKmsExtraDataBytesHex } from './kmsExtraData-p.js';
|
|
20
21
|
|
|
21
22
|
////////////////////////////////////////////////////////////////////////////////
|
|
22
23
|
|
|
@@ -28,7 +29,7 @@ export type CreateKmsUserDecryptEip712V2Parameters = {
|
|
|
28
29
|
readonly allowedContracts: readonly string[];
|
|
29
30
|
readonly startTimestamp: number | bigint;
|
|
30
31
|
readonly durationSeconds: bigint;
|
|
31
|
-
readonly extraData:
|
|
32
|
+
readonly extraData: KmsExtraData;
|
|
32
33
|
};
|
|
33
34
|
|
|
34
35
|
////////////////////////////////////////////////////////////////////////////////
|
|
@@ -56,7 +57,6 @@ export function createKmsUserDecryptEip712V2(
|
|
|
56
57
|
assertIsAddressArray(allowedContracts, {});
|
|
57
58
|
assertIsUint256(startTimestamp, {});
|
|
58
59
|
assertIsUint256(durationSeconds, {});
|
|
59
|
-
assertIsBytesHex(extraData, {});
|
|
60
60
|
assertIsKmsExtraData(extraData, {});
|
|
61
61
|
|
|
62
62
|
const checksummedUserAddress = addressToChecksummedAddress(userAddress);
|
|
@@ -79,7 +79,7 @@ export function createKmsUserDecryptEip712V2(
|
|
|
79
79
|
allowedContracts: checksummedContractAddresses,
|
|
80
80
|
startTimestamp: startTimestamp.toString(),
|
|
81
81
|
durationSeconds: durationSeconds.toString(),
|
|
82
|
-
extraData,
|
|
82
|
+
extraData: extraData.toBytesHex(),
|
|
83
83
|
} satisfies KmsUserDecryptEip712V2Message,
|
|
84
84
|
};
|
|
85
85
|
|
|
@@ -131,7 +131,7 @@ function _assertIsKmsUserDecryptEip712V2Message(
|
|
|
131
131
|
assertRecordStringProperty(msg, 'startTimestamp' satisfies keyof MessageType, msgName, options);
|
|
132
132
|
assertRecordStringProperty(msg, 'durationSeconds' satisfies keyof MessageType, msgName, options);
|
|
133
133
|
assertRecordBytesHexProperty(msg, 'extraData' satisfies keyof MessageType, msgName, options);
|
|
134
|
-
|
|
134
|
+
assertIsKmsExtraDataBytesHex(msg.extraData, options);
|
|
135
135
|
assertIsUintString(msg.startTimestamp, { max: MAX_UINT256 });
|
|
136
136
|
assertIsUintString(msg.durationSeconds, { max: MAX_UINT256 });
|
|
137
137
|
}
|
|
@@ -9,7 +9,7 @@ import type { SignedDecryptionPermit, SignedDecryptionPermitV1 } from '../types/
|
|
|
9
9
|
import type { Handle } from '../types/encryptedTypes-p.js';
|
|
10
10
|
import { assertHandlesBelongToSameChainId } from '../handle/FhevmHandle.js';
|
|
11
11
|
import { createKmsSigncryptedShares } from './KmsSigncryptedShares-p.js';
|
|
12
|
-
import {
|
|
12
|
+
import { readCurrentKmsSignersContext } from '../host-contracts/readKmsSignersContext-p.js';
|
|
13
13
|
import { assertIsSignedDecryptionPermit } from './SignedDecryptionPermit-p.js';
|
|
14
14
|
import { assertKmsDecryptionBitLimit } from './utils.js';
|
|
15
15
|
import { checkPersistAllowed } from '../host-contracts/checkPersistAllowed.js';
|
|
@@ -18,19 +18,6 @@ import { createKmsEip712Domain } from './createKmsEip712Domain.js';
|
|
|
18
18
|
import { checkDelegation } from '../host-contracts/checkDelegation.js';
|
|
19
19
|
import { resolveFhevmTkmsVersion } from '../runtime/resolveFhevmVersions-p.js';
|
|
20
20
|
|
|
21
|
-
/*
|
|
22
|
-
See: in KMS (eip712Domain)
|
|
23
|
-
json.response[i].signature is an eip712 sig potentially on this message:
|
|
24
|
-
|
|
25
|
-
struct UserDecryptResponseVerification {
|
|
26
|
-
bytes publicKey;
|
|
27
|
-
bytes32[] ctHandles;
|
|
28
|
-
bytes userDecryptedShare;
|
|
29
|
-
bytes extraData;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
21
|
////////////////////////////////////////////////////////////////////////////////
|
|
35
22
|
|
|
36
23
|
type Context = {
|
|
@@ -164,7 +151,7 @@ export async function fetchKmsSigncryptedSharesV1(context: Context, parameters:
|
|
|
164
151
|
// (e.g. a version change in the serialization scheme) will be rejected even
|
|
165
152
|
// though the context ID matches. Consider comparing the decoded `kmsContextId`
|
|
166
153
|
// instead of the raw `extraData` bytes.
|
|
167
|
-
const requestedKmsSignersContext: KmsSignersContext = await
|
|
154
|
+
const requestedKmsSignersContext: KmsSignersContext = await readCurrentKmsSignersContext(context, {
|
|
168
155
|
kmsVerifierAddress: context.chain.fhevm.contracts.kmsVerifier.address as ChecksummedAddress,
|
|
169
156
|
protocolConfigAddress: context.chain.fhevm.contracts.protocolConfig?.address as ChecksummedAddress | undefined,
|
|
170
157
|
});
|
|
@@ -215,6 +202,31 @@ export async function fetchKmsSigncryptedSharesV1(context: Context, parameters:
|
|
|
215
202
|
tkmsVersion,
|
|
216
203
|
};
|
|
217
204
|
|
|
205
|
+
/*
|
|
206
|
+
|
|
207
|
+
----------------------------------------------------------------------------
|
|
208
|
+
KMS response-signature verification.
|
|
209
|
+
|
|
210
|
+
Each share's signature is an EIP-712 signature over the
|
|
211
|
+
`UserDecryptResponseVerification` struct (see `verifyKmsSigncryptedShare` and
|
|
212
|
+
gateway `Decryption.sol`). This check is already performed inside the tkms WASM
|
|
213
|
+
during reconstruction (verify=true); the call below is an equivalent JS-only
|
|
214
|
+
pass, kept for testing / debugging. To fully check, loop over every share.
|
|
215
|
+
----------------------------------------------------------------------------
|
|
216
|
+
|
|
217
|
+
for (const share of shares) {
|
|
218
|
+
await verifyKmsSigncryptedShare(
|
|
219
|
+
context,
|
|
220
|
+
{
|
|
221
|
+
metadata: sharesMetadata,
|
|
222
|
+
share,
|
|
223
|
+
transportPublicKey: signedPermit.transportPublicKey,
|
|
224
|
+
}
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
*/
|
|
229
|
+
|
|
218
230
|
// 12. The returned KmsSigncryptedShares is guaranteed to be fully verified:
|
|
219
231
|
// uniform extraData across shares, valid extraData format, and consistency
|
|
220
232
|
// with the KmsSignersContext (see KmsSigncryptedSharesImpl invariants).
|
|
@@ -9,7 +9,7 @@ import type { SignedDecryptionPermit, SignedDecryptionPermitV2 } from '../types/
|
|
|
9
9
|
import type { Handle } from '../types/encryptedTypes-p.js';
|
|
10
10
|
import { assertHandlesBelongToSameChainId } from '../handle/FhevmHandle.js';
|
|
11
11
|
import { createKmsSigncryptedShares } from './KmsSigncryptedShares-p.js';
|
|
12
|
-
import {
|
|
12
|
+
import { readCurrentKmsSignersContext } from '../host-contracts/readKmsSignersContext-p.js';
|
|
13
13
|
import { assertIsSignedDecryptionPermit } from './SignedDecryptionPermit-p.js';
|
|
14
14
|
import { assertKmsDecryptionBitLimit } from './utils.js';
|
|
15
15
|
import { checkPersistAllowed } from '../host-contracts/checkPersistAllowed.js';
|
|
@@ -130,7 +130,7 @@ export async function fetchKmsSigncryptedSharesV2(context: Context, parameters:
|
|
|
130
130
|
// (e.g. a version change in the serialization scheme) will be rejected even
|
|
131
131
|
// though the context ID matches. Consider comparing the decoded `kmsContextId`
|
|
132
132
|
// instead of the raw `extraData` bytes.
|
|
133
|
-
const requestedKmsSignersContext: KmsSignersContext = await
|
|
133
|
+
const requestedKmsSignersContext: KmsSignersContext = await readCurrentKmsSignersContext(context, {
|
|
134
134
|
kmsVerifierAddress: context.chain.fhevm.contracts.kmsVerifier.address as ChecksummedAddress,
|
|
135
135
|
protocolConfigAddress: context.chain.fhevm.contracts.protocolConfig?.address as ChecksummedAddress | undefined,
|
|
136
136
|
});
|