@fhevm/sdk 0.14.5 → 0.14.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/_cjs/core/_version.js +1 -1
- package/_cjs/core/actions/chain/fetchFheEncryptionKeyBytes.js +2 -1
- package/_cjs/core/actions/chain/fetchFheEncryptionKeyBytes.js.map +1 -1
- package/_cjs/core/chains/definitions/mainnet.js +3 -0
- package/_cjs/core/chains/definitions/mainnet.js.map +1 -1
- package/_cjs/core/chains/definitions/sepolia.js +3 -0
- package/_cjs/core/chains/definitions/sepolia.js.map +1 -1
- package/_cjs/core/clients/decorators/base.js.map +1 -1
- package/_cjs/core/clients/decorators/encrypt.js +4 -0
- package/_cjs/core/clients/decorators/encrypt.js.map +1 -1
- package/_cjs/core/coprocessor/ZkProofBuilder-p.js.map +1 -1
- package/_cjs/core/coprocessor/encrypt.js +5 -1
- package/_cjs/core/coprocessor/encrypt.js.map +1 -1
- package/_cjs/core/errors/FheEncryptionKeyVerificationError.js +14 -0
- package/_cjs/core/errors/FheEncryptionKeyVerificationError.js.map +1 -0
- package/_cjs/core/errors/FhevmErrorBase.js +0 -1
- package/_cjs/core/errors/FhevmErrorBase.js.map +1 -1
- package/_cjs/core/errors/RelayerErrorBase.js +0 -1
- package/_cjs/core/errors/RelayerErrorBase.js.map +1 -1
- package/_cjs/core/host-contracts/HostContractVersion-p.js +2 -0
- package/_cjs/core/host-contracts/HostContractVersion-p.js.map +1 -1
- package/_cjs/core/host-contracts/abi-fragments/fragments.js +50 -1
- package/_cjs/core/host-contracts/abi-fragments/fragments.js.map +1 -1
- package/_cjs/core/key/FheEncryptionKeyCache-p.js +50 -56
- package/_cjs/core/key/FheEncryptionKeyCache-p.js.map +1 -1
- package/_cjs/core/key/copyFheEncryptionKeyBytes-p.js +17 -0
- package/_cjs/core/key/copyFheEncryptionKeyBytes-p.js.map +1 -0
- package/_cjs/core/key/ensureFheEncryptionKeyDownload.js +134 -0
- package/_cjs/core/key/ensureFheEncryptionKeyDownload.js.map +1 -0
- package/_cjs/core/key/fetchFheEncryptionKey.js +4 -24
- package/_cjs/core/key/fetchFheEncryptionKey.js.map +1 -1
- package/_cjs/core/key/fetchFheEncryptionKeyBytes.js +2 -32
- package/_cjs/core/key/fetchFheEncryptionKeyBytes.js.map +1 -1
- package/_cjs/core/key/verifyFheEncryptionKeyBytes-p.js +245 -0
- package/_cjs/core/key/verifyFheEncryptionKeyBytes-p.js.map +1 -0
- package/_cjs/core/modules/encrypt/mock.js +7 -90
- package/_cjs/core/modules/encrypt/mock.js.map +1 -1
- package/_cjs/core/modules/encrypt/module/api-p.js +0 -65
- package/_cjs/core/modules/encrypt/module/api-p.js.map +1 -1
- package/_cjs/core/modules/encrypt/module/index.js +0 -3
- package/_cjs/core/modules/encrypt/module/index.js.map +1 -1
- package/_cjs/core/modules/relayer/cleartext/mock.js +1 -0
- package/_cjs/core/modules/relayer/cleartext/mock.js.map +1 -1
- package/_cjs/core/runtime/CoreFhevm-p.js +88 -11
- package/_cjs/core/runtime/CoreFhevm-p.js.map +1 -1
- package/_cjs/core/types/index.js.map +1 -1
- package/_cjs/ethers/clients/createFhevmDecryptClient.js +4 -1
- package/_cjs/ethers/clients/createFhevmDecryptClient.js.map +1 -1
- package/_cjs/viem/clients/createFhevmDecryptClient.js +4 -1
- package/_cjs/viem/clients/createFhevmDecryptClient.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/chain/fetchFheEncryptionKeyBytes.js +7 -1
- package/_esm/core/actions/chain/fetchFheEncryptionKeyBytes.js.map +1 -1
- package/_esm/core/chains/definitions/mainnet.js +3 -0
- package/_esm/core/chains/definitions/mainnet.js.map +1 -1
- package/_esm/core/chains/definitions/sepolia.js +3 -0
- package/_esm/core/chains/definitions/sepolia.js.map +1 -1
- package/_esm/core/clients/decorators/base.js.map +1 -1
- package/_esm/core/clients/decorators/encrypt-p.js +1 -1
- package/_esm/core/clients/decorators/encrypt-p.js.map +1 -1
- package/_esm/core/clients/decorators/encrypt.js +6 -0
- package/_esm/core/clients/decorators/encrypt.js.map +1 -1
- package/_esm/core/coprocessor/ZkProofBuilder-p.js +1 -1
- package/_esm/core/coprocessor/ZkProofBuilder-p.js.map +1 -1
- package/_esm/core/coprocessor/encrypt.js +5 -1
- package/_esm/core/coprocessor/encrypt.js.map +1 -1
- package/_esm/core/errors/FheEncryptionKeyVerificationError.js +15 -0
- package/_esm/core/errors/FheEncryptionKeyVerificationError.js.map +1 -0
- package/_esm/core/errors/FhevmErrorBase.js +0 -1
- package/_esm/core/errors/FhevmErrorBase.js.map +1 -1
- package/_esm/core/errors/RelayerErrorBase.js +0 -1
- package/_esm/core/errors/RelayerErrorBase.js.map +1 -1
- package/_esm/core/host-contracts/HostContractVersion-p.js +2 -1
- package/_esm/core/host-contracts/HostContractVersion-p.js.map +1 -1
- package/_esm/core/host-contracts/abi-fragments/fragments.js +61 -0
- package/_esm/core/host-contracts/abi-fragments/fragments.js.map +1 -1
- package/_esm/core/key/FheEncryptionKeyCache-p.js +91 -75
- package/_esm/core/key/FheEncryptionKeyCache-p.js.map +1 -1
- package/_esm/core/key/copyFheEncryptionKeyBytes-p.js +21 -0
- package/_esm/core/key/copyFheEncryptionKeyBytes-p.js.map +1 -0
- package/_esm/core/key/ensureFheEncryptionKeyDownload.js +213 -0
- package/_esm/core/key/ensureFheEncryptionKeyDownload.js.map +1 -0
- package/_esm/core/key/fetchFheEncryptionKey.js +6 -26
- package/_esm/core/key/fetchFheEncryptionKey.js.map +1 -1
- package/_esm/core/key/fetchFheEncryptionKeyBytes.js +4 -41
- package/_esm/core/key/fetchFheEncryptionKeyBytes.js.map +1 -1
- package/_esm/core/key/verifyFheEncryptionKeyBytes-p.js +345 -0
- package/_esm/core/key/verifyFheEncryptionKeyBytes-p.js.map +1 -0
- package/_esm/core/modules/encrypt/mock.js +7 -96
- package/_esm/core/modules/encrypt/mock.js.map +1 -1
- package/_esm/core/modules/encrypt/module/api-p.js +0 -71
- package/_esm/core/modules/encrypt/module/api-p.js.map +1 -1
- package/_esm/core/modules/encrypt/module/index.js +1 -4
- package/_esm/core/modules/encrypt/module/index.js.map +1 -1
- package/_esm/core/modules/relayer/cleartext/mock.js +1 -0
- package/_esm/core/modules/relayer/cleartext/mock.js.map +1 -1
- package/_esm/core/runtime/CoreFhevm-p.js +128 -15
- package/_esm/core/runtime/CoreFhevm-p.js.map +1 -1
- package/_esm/core/types/index.js.map +1 -1
- package/_esm/ethers/clients/createFhevmDecryptClient.js +5 -1
- package/_esm/ethers/clients/createFhevmDecryptClient.js.map +1 -1
- package/_esm/viem/clients/createFhevmDecryptClient.js +5 -1
- package/_esm/viem/clients/createFhevmDecryptClient.js.map +1 -1
- package/_types/core/actions/chain/fetchFheEncryptionKeyBytes.d.ts +5 -0
- package/_types/core/actions/chain/fetchFheEncryptionKeyBytes.d.ts.map +1 -1
- package/_types/core/chains/definitions/mainnet.d.ts +3 -0
- package/_types/core/chains/definitions/mainnet.d.ts.map +1 -1
- package/_types/core/chains/definitions/sepolia.d.ts.map +1 -1
- package/_types/core/clients/decorators/base.d.ts +4 -1
- package/_types/core/clients/decorators/base.d.ts.map +1 -1
- package/_types/core/clients/decorators/encrypt.d.ts.map +1 -1
- package/_types/core/coprocessor/ZkProofBuilder-p.d.ts +2 -4
- package/_types/core/coprocessor/ZkProofBuilder-p.d.ts.map +1 -1
- package/_types/core/coprocessor/encrypt.d.ts +2 -8
- package/_types/core/coprocessor/encrypt.d.ts.map +1 -1
- package/_types/core/errors/FheEncryptionKeyVerificationError.d.ts +16 -0
- package/_types/core/errors/FheEncryptionKeyVerificationError.d.ts.map +1 -0
- package/_types/core/errors/FhevmErrorBase.d.ts.map +1 -1
- package/_types/core/errors/RelayerErrorBase.d.ts.map +1 -1
- package/_types/core/errors/TfheError.d.ts +1 -1
- package/_types/core/host-contracts/HostContractVersion-p.d.ts +4 -0
- package/_types/core/host-contracts/HostContractVersion-p.d.ts.map +1 -1
- package/_types/core/host-contracts/abi-fragments/fragments.d.ts +12 -0
- package/_types/core/host-contracts/abi-fragments/fragments.d.ts.map +1 -1
- package/_types/core/key/FheEncryptionKeyCache-p.d.ts +45 -21
- package/_types/core/key/FheEncryptionKeyCache-p.d.ts.map +1 -1
- package/_types/core/key/copyFheEncryptionKeyBytes-p.d.ts +9 -0
- package/_types/core/key/copyFheEncryptionKeyBytes-p.d.ts.map +1 -0
- package/_types/core/key/ensureFheEncryptionKeyDownload.d.ts +73 -0
- package/_types/core/key/ensureFheEncryptionKeyDownload.d.ts.map +1 -0
- package/_types/core/key/fetchFheEncryptionKey.d.ts +2 -4
- package/_types/core/key/fetchFheEncryptionKey.d.ts.map +1 -1
- package/_types/core/key/fetchFheEncryptionKeyBytes.d.ts +2 -4
- package/_types/core/key/fetchFheEncryptionKeyBytes.d.ts.map +1 -1
- package/_types/core/key/verifyFheEncryptionKeyBytes-p.d.ts +61 -0
- package/_types/core/key/verifyFheEncryptionKeyBytes-p.d.ts.map +1 -0
- package/_types/core/modules/encrypt/mock.d.ts +1 -4
- package/_types/core/modules/encrypt/mock.d.ts.map +1 -1
- package/_types/core/modules/encrypt/module/api-p.d.ts +1 -4
- package/_types/core/modules/encrypt/module/api-p.d.ts.map +1 -1
- package/_types/core/modules/encrypt/module/index.d.ts.map +1 -1
- package/_types/core/modules/encrypt/types.d.ts +2 -26
- package/_types/core/modules/encrypt/types.d.ts.map +1 -1
- package/_types/core/modules/relayer/cleartext/mock.d.ts.map +1 -1
- package/_types/core/modules/relayer/types.d.ts +9 -1
- package/_types/core/modules/relayer/types.d.ts.map +1 -1
- package/_types/core/runtime/CoreFhevm-p.d.ts +23 -1
- package/_types/core/runtime/CoreFhevm-p.d.ts.map +1 -1
- package/_types/core/types/coreFhevmClient.d.ts +31 -4
- package/_types/core/types/coreFhevmClient.d.ts.map +1 -1
- package/_types/core/types/fhevmChain.d.ts +7 -0
- package/_types/core/types/fhevmChain.d.ts.map +1 -1
- package/_types/core/types/hostContract.d.ts +1 -0
- package/_types/core/types/hostContract.d.ts.map +1 -1
- package/_types/core/types/index.d.ts +1 -0
- package/_types/core/types/index.d.ts.map +1 -1
- package/_types/core/types/zkProofBuilder-p.d.ts +2 -4
- package/_types/core/types/zkProofBuilder-p.d.ts.map +1 -1
- package/_types/ethers/cleartext/createFhevmCleartextBaseClient.d.ts +1 -1
- package/_types/ethers/cleartext/createFhevmCleartextBaseClient.d.ts.map +1 -1
- package/_types/ethers/cleartext/createFhevmCleartextClient.d.ts +1 -1
- package/_types/ethers/cleartext/createFhevmCleartextClient.d.ts.map +1 -1
- package/_types/ethers/cleartext/createFhevmCleartextDecryptClient.d.ts +1 -1
- package/_types/ethers/cleartext/createFhevmCleartextDecryptClient.d.ts.map +1 -1
- package/_types/ethers/cleartext/createFhevmCleartextEncryptClient.d.ts +1 -1
- package/_types/ethers/cleartext/createFhevmCleartextEncryptClient.d.ts.map +1 -1
- package/_types/ethers/clients/createFhevmBaseClient.d.ts +1 -1
- package/_types/ethers/clients/createFhevmBaseClient.d.ts.map +1 -1
- package/_types/ethers/clients/createFhevmClient.d.ts +2 -2
- package/_types/ethers/clients/createFhevmClient.d.ts.map +1 -1
- package/_types/ethers/clients/createFhevmDecryptClient.d.ts +2 -2
- package/_types/ethers/clients/createFhevmDecryptClient.d.ts.map +1 -1
- package/_types/ethers/clients/createFhevmEncryptClient.d.ts +2 -2
- package/_types/ethers/clients/createFhevmEncryptClient.d.ts.map +1 -1
- package/_types/viem/cleartext/createFhevmCleartextBaseClient.d.ts +1 -1
- package/_types/viem/cleartext/createFhevmCleartextBaseClient.d.ts.map +1 -1
- package/_types/viem/cleartext/createFhevmCleartextClient.d.ts +1 -1
- package/_types/viem/cleartext/createFhevmCleartextClient.d.ts.map +1 -1
- package/_types/viem/cleartext/createFhevmCleartextDecryptClient.d.ts +1 -1
- package/_types/viem/cleartext/createFhevmCleartextDecryptClient.d.ts.map +1 -1
- package/_types/viem/cleartext/createFhevmCleartextEncryptClient.d.ts +1 -1
- package/_types/viem/cleartext/createFhevmCleartextEncryptClient.d.ts.map +1 -1
- package/_types/viem/clients/createFhevmBaseClient.d.ts +1 -1
- package/_types/viem/clients/createFhevmBaseClient.d.ts.map +1 -1
- package/_types/viem/clients/createFhevmClient.d.ts +2 -2
- package/_types/viem/clients/createFhevmClient.d.ts.map +1 -1
- package/_types/viem/clients/createFhevmDecryptClient.d.ts +2 -2
- package/_types/viem/clients/createFhevmDecryptClient.d.ts.map +1 -1
- package/_types/viem/clients/createFhevmEncryptClient.d.ts +2 -2
- package/_types/viem/clients/createFhevmEncryptClient.d.ts.map +1 -1
- package/core/_version.ts +1 -1
- package/core/actions/chain/fetchFheEncryptionKeyBytes.ts +7 -1
- package/core/chains/definitions/mainnet.ts +3 -0
- package/core/chains/definitions/sepolia.ts +3 -0
- package/core/clients/decorators/base.ts +4 -1
- package/core/clients/decorators/encrypt-p.ts +1 -1
- package/core/clients/decorators/encrypt.ts +6 -0
- package/core/coprocessor/ZkProofBuilder-p.ts +3 -5
- package/core/coprocessor/encrypt.ts +10 -10
- package/core/errors/FheEncryptionKeyVerificationError.ts +27 -0
- package/core/errors/FhevmErrorBase.ts +0 -1
- package/core/errors/RelayerErrorBase.ts +0 -1
- package/core/errors/TfheError.ts +1 -1
- package/core/host-contracts/HostContractVersion-p.ts +2 -1
- package/core/host-contracts/abi-fragments/fragments.ts +69 -0
- package/core/key/FheEncryptionKeyCache-p.ts +92 -91
- package/core/key/copyFheEncryptionKeyBytes-p.ts +23 -0
- package/core/key/ensureFheEncryptionKeyDownload.ts +293 -0
- package/core/key/fetchFheEncryptionKey.ts +8 -35
- package/core/key/fetchFheEncryptionKeyBytes.ts +7 -56
- package/core/key/verifyFheEncryptionKeyBytes-p.ts +452 -0
- package/core/modules/encrypt/mock.ts +4 -149
- package/core/modules/encrypt/module/api-p.ts +1 -126
- package/core/modules/encrypt/module/index.ts +0 -12
- package/core/modules/encrypt/types.ts +2 -57
- package/core/modules/relayer/cleartext/mock.ts +1 -0
- package/core/modules/relayer/types.ts +9 -1
- package/core/runtime/CoreFhevm-p.ts +159 -21
- package/core/types/coreFhevmClient.ts +33 -4
- package/core/types/fhevmChain.ts +7 -0
- package/core/types/hostContract.ts +2 -0
- package/core/types/index.ts +1 -0
- package/core/types/zkProofBuilder-p.ts +2 -1
- package/ethers/cleartext/createFhevmCleartextBaseClient.ts +1 -1
- package/ethers/cleartext/createFhevmCleartextClient.ts +1 -1
- package/ethers/cleartext/createFhevmCleartextDecryptClient.ts +1 -1
- package/ethers/cleartext/createFhevmCleartextEncryptClient.ts +1 -1
- package/ethers/clients/createFhevmBaseClient.ts +1 -1
- package/ethers/clients/createFhevmClient.ts +2 -2
- package/ethers/clients/createFhevmDecryptClient.ts +7 -3
- package/ethers/clients/createFhevmEncryptClient.ts +2 -2
- package/package.json +1 -1
- package/viem/cleartext/createFhevmCleartextBaseClient.ts +1 -1
- package/viem/cleartext/createFhevmCleartextClient.ts +1 -1
- package/viem/cleartext/createFhevmCleartextDecryptClient.ts +1 -1
- package/viem/cleartext/createFhevmCleartextEncryptClient.ts +1 -1
- package/viem/clients/createFhevmBaseClient.ts +1 -1
- package/viem/clients/createFhevmClient.ts +2 -2
- package/viem/clients/createFhevmDecryptClient.ts +7 -3
- package/viem/clients/createFhevmEncryptClient.ts +2 -2
- package/_cjs/core/key/serializeFheEncryptionKey.js +0 -25
- package/_cjs/core/key/serializeFheEncryptionKey.js.map +0 -1
- package/_esm/core/key/serializeFheEncryptionKey.js +0 -24
- package/_esm/core/key/serializeFheEncryptionKey.js.map +0 -1
- package/_types/core/key/serializeFheEncryptionKey.d.ts +0 -6
- package/_types/core/key/serializeFheEncryptionKey.d.ts.map +0 -1
- package/core/key/serializeFheEncryptionKey.ts +0 -42
|
@@ -13,17 +13,20 @@ import type {
|
|
|
13
13
|
} from '../types/coreFhevmClient.js';
|
|
14
14
|
import type { FhevmRuntime, WithModule, WithModuleMap } from '../types/coreFhevmRuntime.js';
|
|
15
15
|
import type { FhevmClientFrozenContext } from '../types/fhevmClientFrozenContext-p.js';
|
|
16
|
+
import type { FheEncryptionKeyBytes } from '../types/fheEncryptionKey.js';
|
|
16
17
|
import type { TfheVersion } from '../../wasm/tfhe/TfheApi.js';
|
|
17
18
|
import type { TkmsVersion } from '../../wasm/tkms/KmsLibApi.js';
|
|
18
19
|
import type { RelayerFeatures } from '../relayerFeatures/resolveRelayerFeatures-p.js';
|
|
20
|
+
import type { FheEncryptionKeyVerificationError } from '../errors/FheEncryptionKeyVerificationError.js';
|
|
19
21
|
import { InvalidTypeError } from '../base/errors/InvalidTypeError.js';
|
|
22
|
+
import { FhevmConfigError } from '../errors/FhevmConfigError.js';
|
|
20
23
|
import { verifyTrustedValue } from '../base/trustedValue.js';
|
|
21
24
|
import { uid } from '../base/uid.js';
|
|
22
25
|
import { createTrustedClient } from '../modules/ethereum/createTrustedClient.js';
|
|
23
26
|
import { asFhevmRuntimeWith, assertIsFhevmRuntime, assertIsFhevmRuntimeWith } from './CoreFhevmRuntime-p.js';
|
|
24
|
-
import { globalFheEncryptionKeyCache } from '../key/FheEncryptionKeyCache-p.js';
|
|
25
27
|
import { cloneModuleVersions } from '../runtimeConfig-p.js';
|
|
26
28
|
import { cloneFhevmClientFrozenContext } from '../frozenContext/fhevmClientFrozenContext-p.js';
|
|
29
|
+
import { copyFheEncryptionKeyBytes } from '../key/copyFheEncryptionKeyBytes-p.js';
|
|
27
30
|
|
|
28
31
|
////////////////////////////////////////////////////////////////////////////////
|
|
29
32
|
|
|
@@ -36,6 +39,9 @@ const GET_RELAYER_FEATURES = Symbol('CoreFhevmHostClient.getRelayerFeatures');
|
|
|
36
39
|
const SET_RELAYER_FEATURES = Symbol('CoreFhevmHostClient.setRelayerFeatures');
|
|
37
40
|
const GET_RELAYER_FEATURES_PROMISE = Symbol('CoreFhevmHostClient.getRelayerFeaturesPromise');
|
|
38
41
|
const SET_RELAYER_FEATURES_PROMISE = Symbol('CoreFhevmHostClient.setRelayerFeaturesPromise');
|
|
42
|
+
const GET_PROVIDED_FHE_ENCRYPTION_KEY = Symbol('CoreFhevmHostClient.getProvidedFheEncryptionKey');
|
|
43
|
+
const RELEASE_PROVIDED_FHE_ENCRYPTION_KEY = Symbol('CoreFhevmHostClient.releaseProvidedFheEncryptionKey');
|
|
44
|
+
const GET_PROVIDED_FHE_ENCRYPTION_KEY_ERROR = Symbol('CoreFhevmHostClient.getProvidedFheEncryptionKeyError');
|
|
39
45
|
|
|
40
46
|
const UNRESOLVED_FHEVM_CONTEXT_MESSAGE = 'Fhevm context has not been resolved. Await client.ready before.';
|
|
41
47
|
|
|
@@ -47,6 +53,12 @@ type GetRelayerFeaturesFn = () => RelayerFeatures | undefined;
|
|
|
47
53
|
type SetRelayerFeaturesFn = (relayerFeatures: RelayerFeatures) => void;
|
|
48
54
|
type GetRelayerFeaturesPromiseFn = () => Promise<RelayerFeatures> | undefined;
|
|
49
55
|
type SetRelayerFeaturesPromiseFn = (relayerFeaturesPromise: Promise<RelayerFeatures> | undefined) => void;
|
|
56
|
+
type GetProvidedFheEncryptionKeyFn = () => FheEncryptionKeyBytes | undefined;
|
|
57
|
+
type ReleaseProvidedFheEncryptionKeyFn = (
|
|
58
|
+
fheEncryptionKey: FheEncryptionKeyBytes,
|
|
59
|
+
error?: FheEncryptionKeyVerificationError,
|
|
60
|
+
) => void;
|
|
61
|
+
type GetProvidedFheEncryptionKeyErrorFn = () => FheEncryptionKeyVerificationError | undefined;
|
|
50
62
|
|
|
51
63
|
////////////////////////////////////////////////////////////////////////////////
|
|
52
64
|
// CoreFhevmImpl
|
|
@@ -67,6 +79,15 @@ class CoreFhevmImpl<
|
|
|
67
79
|
readonly #trustedClient: TrustedClient<client> | undefined;
|
|
68
80
|
readonly #chain: chain | undefined;
|
|
69
81
|
readonly #options: ResolvedFhevmOptions;
|
|
82
|
+
// Caller-provided key / CRS bytes (`options.fheEncryptionKey`), kept out of
|
|
83
|
+
// the public resolved options and released once checked: on a pass, the
|
|
84
|
+
// cache holds them; on a failed check, only the error is kept.
|
|
85
|
+
#providedFheEncryptionKey: FheEncryptionKeyBytes | undefined;
|
|
86
|
+
// A client whose own key fails the check keeps the error, never the key:
|
|
87
|
+
// every later call throws it, and the client never falls back to the
|
|
88
|
+
// relayer's key. A key that is not the active one fails too (only the active
|
|
89
|
+
// key may be used). To use another key, create a new client.
|
|
90
|
+
#providedFheEncryptionKeyError: FheEncryptionKeyVerificationError | undefined;
|
|
70
91
|
readonly #initFns: Set<(client: FhevmBase<FhevmChain>) => Promise<void>>;
|
|
71
92
|
#readyPromise: Promise<void> | undefined;
|
|
72
93
|
|
|
@@ -111,7 +132,13 @@ class CoreFhevmImpl<
|
|
|
111
132
|
this.#trustedClient =
|
|
112
133
|
parameters.client !== undefined ? createTrustedClient(parameters.client, ownerToken) : undefined;
|
|
113
134
|
this.#chain = parameters.chain;
|
|
114
|
-
this.#options = resolveOptions(parameters.options);
|
|
135
|
+
this.#options = resolveOptions(parameters.options, ownerToken);
|
|
136
|
+
const providedFheEncryptionKey = parameters.options?.fheEncryptionKey;
|
|
137
|
+
_assertProvidedFheEncryptionKeyRelayerUrl(providedFheEncryptionKey, parameters.chain);
|
|
138
|
+
// A copy: the caller changing its arrays later cannot bypass the check.
|
|
139
|
+
this.#providedFheEncryptionKey =
|
|
140
|
+
providedFheEncryptionKey === undefined ? undefined : copyFheEncryptionKeyBytes(providedFheEncryptionKey);
|
|
141
|
+
this.#providedFheEncryptionKeyError = undefined;
|
|
115
142
|
this.#initFns = new Set();
|
|
116
143
|
this.#readyPromise = undefined;
|
|
117
144
|
|
|
@@ -319,6 +346,30 @@ class CoreFhevmImpl<
|
|
|
319
346
|
enumerable: false,
|
|
320
347
|
writable: false,
|
|
321
348
|
},
|
|
349
|
+
[GET_PROVIDED_FHE_ENCRYPTION_KEY]: {
|
|
350
|
+
value: (): FheEncryptionKeyBytes | undefined => this.#providedFheEncryptionKey,
|
|
351
|
+
configurable: false,
|
|
352
|
+
enumerable: false,
|
|
353
|
+
writable: false,
|
|
354
|
+
},
|
|
355
|
+
[RELEASE_PROVIDED_FHE_ENCRYPTION_KEY]: {
|
|
356
|
+
// Only the bytes that were checked: a no-op if already released.
|
|
357
|
+
value: (fheEncryptionKey: FheEncryptionKeyBytes, error?: FheEncryptionKeyVerificationError): void => {
|
|
358
|
+
if (this.#providedFheEncryptionKey === fheEncryptionKey) {
|
|
359
|
+
this.#providedFheEncryptionKey = undefined;
|
|
360
|
+
this.#providedFheEncryptionKeyError = error;
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
configurable: false,
|
|
364
|
+
enumerable: false,
|
|
365
|
+
writable: false,
|
|
366
|
+
},
|
|
367
|
+
[GET_PROVIDED_FHE_ENCRYPTION_KEY_ERROR]: {
|
|
368
|
+
value: (): FheEncryptionKeyVerificationError | undefined => this.#providedFheEncryptionKeyError,
|
|
369
|
+
configurable: false,
|
|
370
|
+
enumerable: false,
|
|
371
|
+
writable: false,
|
|
372
|
+
},
|
|
322
373
|
extend: {
|
|
323
374
|
value: (actionsFactory: (client: typeof this) => FhevmExtension) =>
|
|
324
375
|
extendCoreFhevm(this, actionsFactory, (fn) => {
|
|
@@ -331,10 +382,25 @@ class CoreFhevmImpl<
|
|
|
331
382
|
},
|
|
332
383
|
init: {
|
|
333
384
|
value: (): Promise<void> => {
|
|
334
|
-
this.#readyPromise
|
|
335
|
-
|
|
336
|
-
//
|
|
337
|
-
|
|
385
|
+
if (this.#readyPromise === undefined) {
|
|
386
|
+
// Settles once every init fn has settled, with the first error if
|
|
387
|
+
// any: a retry never runs alongside an init fn still running.
|
|
388
|
+
const readyPromise = Promise.allSettled([...this.#initFns].map((fn) => fn(this))).then((results) => {
|
|
389
|
+
for (const result of results) {
|
|
390
|
+
if (result.status === 'rejected') {
|
|
391
|
+
throw result.reason;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
// A failed init is forgotten (e.g. a network error): its callers
|
|
396
|
+
// get the error, the next call runs init again.
|
|
397
|
+
readyPromise.catch(() => {
|
|
398
|
+
if (this.#readyPromise === readyPromise) {
|
|
399
|
+
this.#readyPromise = undefined;
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
this.#readyPromise = readyPromise;
|
|
403
|
+
}
|
|
338
404
|
return this.#readyPromise;
|
|
339
405
|
},
|
|
340
406
|
configurable: false,
|
|
@@ -590,19 +656,9 @@ export function createCoreFhevm<chain extends FhevmChain, runtime extends FhevmR
|
|
|
590
656
|
ownerToken: symbol,
|
|
591
657
|
parameters: CreateCoreFhevmParameters<chain, runtime, client>,
|
|
592
658
|
): Fhevm<chain, runtime, client> {
|
|
593
|
-
//
|
|
594
|
-
//
|
|
595
|
-
//
|
|
596
|
-
const fheEncryptionKey = parameters.options?.fheEncryptionKey;
|
|
597
|
-
if (fheEncryptionKey !== undefined) {
|
|
598
|
-
const relayerUrl = parameters.chain?.fhevm.relayerUrl;
|
|
599
|
-
globalFheEncryptionKeyCache.setBytes(
|
|
600
|
-
parameters.runtime,
|
|
601
|
-
relayerUrl ?? fheEncryptionKey.metadata.relayerUrl,
|
|
602
|
-
fheEncryptionKey,
|
|
603
|
-
);
|
|
604
|
-
}
|
|
605
|
-
|
|
659
|
+
// A caller-provided FheEncryptionKey is not written to the global cache here:
|
|
660
|
+
// the client keeps it privately and the key fetch caches it once it passes
|
|
661
|
+
// the KMSGeneration check (see ensureFheEncryptionKeyDownload).
|
|
606
662
|
return new CoreFhevmImpl(PRIVATE_TOKEN, ownerToken, parameters);
|
|
607
663
|
}
|
|
608
664
|
|
|
@@ -640,13 +696,47 @@ function extendCoreFhevm<T extends Fhevm<FhevmChain | undefined, FhevmRuntime, O
|
|
|
640
696
|
|
|
641
697
|
////////////////////////////////////////////////////////////////////////////////
|
|
642
698
|
|
|
643
|
-
function resolveOptions(options: FhevmOptions | undefined): ResolvedFhevmOptions {
|
|
699
|
+
function resolveOptions(options: FhevmOptions | undefined, ownerToken: symbol): ResolvedFhevmOptions {
|
|
700
|
+
// The native keyVerification client is wrapped like the host-chain one.
|
|
701
|
+
const keyVerification = options?.keyVerification;
|
|
644
702
|
return Object.freeze<ResolvedFhevmOptions>({
|
|
645
703
|
batchRpcCalls: options?.batchRpcCalls ?? false,
|
|
646
704
|
moduleVersions: cloneModuleVersions(options?.moduleVersions),
|
|
705
|
+
keyVerification:
|
|
706
|
+
keyVerification === undefined
|
|
707
|
+
? undefined
|
|
708
|
+
: Object.freeze({
|
|
709
|
+
chain: keyVerification.chain,
|
|
710
|
+
trustedClient: createTrustedClient(keyVerification.client, ownerToken),
|
|
711
|
+
}),
|
|
647
712
|
});
|
|
648
713
|
}
|
|
649
714
|
|
|
715
|
+
/**
|
|
716
|
+
* A provided key from another relayer can never be used by this client: fail
|
|
717
|
+
* at creation, before any KMSGeneration read or cache change. Exact string
|
|
718
|
+
* match, as the cache slot is keyed by the relayer URL.
|
|
719
|
+
*
|
|
720
|
+
* @throws {FhevmConfigError}
|
|
721
|
+
*/
|
|
722
|
+
function _assertProvidedFheEncryptionKeyRelayerUrl(
|
|
723
|
+
fheEncryptionKey: FheEncryptionKeyBytes | undefined,
|
|
724
|
+
chain: FhevmChain | undefined,
|
|
725
|
+
): void {
|
|
726
|
+
if (fheEncryptionKey === undefined || chain === undefined) {
|
|
727
|
+
return;
|
|
728
|
+
}
|
|
729
|
+
const actual = fheEncryptionKey.metadata.relayerUrl;
|
|
730
|
+
const expected = chain.fhevm.relayerUrl;
|
|
731
|
+
if (actual !== expected) {
|
|
732
|
+
throw new FhevmConfigError({
|
|
733
|
+
message:
|
|
734
|
+
`'options.fheEncryptionKey' comes from relayer "${actual}", but the client uses relayer "${expected}". ` +
|
|
735
|
+
'The FheEncryptionKey must originate from the same relayer.',
|
|
736
|
+
});
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
|
|
650
740
|
/**
|
|
651
741
|
* Standard prologue that **every public API action must run first**, before it
|
|
652
742
|
* touches the runtime or reads any resolved version.
|
|
@@ -656,7 +746,8 @@ function resolveOptions(options: FhevmOptions | undefined): ResolvedFhevmOptions
|
|
|
656
746
|
*
|
|
657
747
|
* 1. **Lazy, idempotent init** — `await fhevm.ready`. Init is lazy and shared:
|
|
658
748
|
* the first public call triggers it and every later `ready` awaits the same
|
|
659
|
-
* in-flight promise, so this is safe regardless of prior
|
|
749
|
+
* in-flight or resolved promise, so this is safe regardless of prior
|
|
750
|
+
* `init()`/action calls. A failed init is not kept: the next call retries.
|
|
660
751
|
* 2. **Resolve the frozen context** — the on-chain-resolved version snapshot
|
|
661
752
|
* (protocol / PubKey-CRS / TFHE / TKMS / host-contract versions) is resolved
|
|
662
753
|
* exactly once during init (via `ensureFrozenContext`) and stored on the
|
|
@@ -748,3 +839,50 @@ export function getRelayerFeaturesPromise(fhevm: unknown): Promise<RelayerFeatur
|
|
|
748
839
|
}
|
|
749
840
|
|
|
750
841
|
////////////////////////////////////////////////////////////////////////////////
|
|
842
|
+
|
|
843
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
844
|
+
|
|
845
|
+
/**
|
|
846
|
+
* The caller-provided key / CRS bytes (`options.fheEncryptionKey`), until they
|
|
847
|
+
* are released by {@link releaseProvidedFheEncryptionKey}.
|
|
848
|
+
*/
|
|
849
|
+
export function getProvidedFheEncryptionKey(
|
|
850
|
+
fhevm: FhevmBase<FhevmChain | undefined, FhevmRuntime, OptionalNativeClient>,
|
|
851
|
+
): FheEncryptionKeyBytes | undefined {
|
|
852
|
+
const f = asCoreFhevm(fhevm) as CoreFhevm & {
|
|
853
|
+
readonly [GET_PROVIDED_FHE_ENCRYPTION_KEY]: GetProvidedFheEncryptionKeyFn;
|
|
854
|
+
};
|
|
855
|
+
return f[GET_PROVIDED_FHE_ENCRYPTION_KEY]();
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
/**
|
|
859
|
+
* Drops the client's reference to the caller-provided key / CRS bytes once
|
|
860
|
+
* checked:
|
|
861
|
+
* - passed (no `error`): the global cache holds them from then on; a later
|
|
862
|
+
* fetch, after a cache eviction, downloads the active key from the relayer;
|
|
863
|
+
* - failed (`error`): the client keeps only the error, returned by
|
|
864
|
+
* {@link getProvidedFheEncryptionKeyError}; every later fetch throws it.
|
|
865
|
+
*/
|
|
866
|
+
export function releaseProvidedFheEncryptionKey(
|
|
867
|
+
fhevm: FhevmBase<FhevmChain | undefined, FhevmRuntime, OptionalNativeClient>,
|
|
868
|
+
fheEncryptionKey: FheEncryptionKeyBytes,
|
|
869
|
+
error?: FheEncryptionKeyVerificationError,
|
|
870
|
+
): void {
|
|
871
|
+
const f = asCoreFhevm(fhevm) as CoreFhevm & {
|
|
872
|
+
readonly [RELEASE_PROVIDED_FHE_ENCRYPTION_KEY]: ReleaseProvidedFheEncryptionKeyFn;
|
|
873
|
+
};
|
|
874
|
+
f[RELEASE_PROVIDED_FHE_ENCRYPTION_KEY](fheEncryptionKey, error);
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
/**
|
|
878
|
+
* The error of the caller-provided key / CRS bytes that failed the check, once
|
|
879
|
+
* released by {@link releaseProvidedFheEncryptionKey}; `undefined` otherwise.
|
|
880
|
+
*/
|
|
881
|
+
export function getProvidedFheEncryptionKeyError(
|
|
882
|
+
fhevm: FhevmBase<FhevmChain | undefined, FhevmRuntime, OptionalNativeClient>,
|
|
883
|
+
): FheEncryptionKeyVerificationError | undefined {
|
|
884
|
+
const f = asCoreFhevm(fhevm) as CoreFhevm & {
|
|
885
|
+
readonly [GET_PROVIDED_FHE_ENCRYPTION_KEY_ERROR]: GetProvidedFheEncryptionKeyErrorFn;
|
|
886
|
+
};
|
|
887
|
+
return f[GET_PROVIDED_FHE_ENCRYPTION_KEY_ERROR]();
|
|
888
|
+
}
|
|
@@ -8,30 +8,59 @@ import type {
|
|
|
8
8
|
TfheVersion,
|
|
9
9
|
TkmsVersion,
|
|
10
10
|
} from './moduleVersions.js';
|
|
11
|
+
import type { TrustedClient } from '../modules/ethereum/types.js';
|
|
11
12
|
|
|
12
13
|
////////////////////////////////////////////////////////////////////////////////
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Options shared by every client. `client` is the adapter's native client
|
|
17
|
+
* type (viem `PublicClient`, ethers `ContractRunner`), the one taken by
|
|
18
|
+
* `keyVerification`.
|
|
19
|
+
*/
|
|
20
|
+
export type FhevmBaseOptions<client extends NativeClient = NativeClient> = {
|
|
15
21
|
readonly batchRpcCalls?: boolean | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Required to fetch the FHE public key and CRS (encryption,
|
|
24
|
+
* `fetchFheEncryptionKeyBytes`) when the host chain is not Ethereum. Applies
|
|
25
|
+
* to every client, as every client can fetch them and every fetch is
|
|
26
|
+
* verified.
|
|
27
|
+
*/
|
|
28
|
+
readonly keyVerification?: FhevmKeyVerification<client> | undefined;
|
|
16
29
|
};
|
|
17
30
|
|
|
18
|
-
export type FhevmEncryptOptions = FhevmBaseOptions & {
|
|
31
|
+
export type FhevmEncryptOptions<client extends NativeClient = NativeClient> = FhevmBaseOptions<client> & {
|
|
19
32
|
readonly fheEncryptionKey?: FheEncryptionKeyBytes | undefined;
|
|
20
33
|
readonly moduleVersions?: FhevmEncryptModuleVersions | undefined;
|
|
21
34
|
};
|
|
22
35
|
|
|
23
|
-
export type FhevmDecryptOptions = FhevmBaseOptions & {
|
|
36
|
+
export type FhevmDecryptOptions<client extends NativeClient = NativeClient> = FhevmBaseOptions<client> & {
|
|
24
37
|
readonly moduleVersions?: FhevmDecryptModuleVersions | undefined;
|
|
25
38
|
};
|
|
26
39
|
|
|
27
|
-
export type FhevmOptions = FhevmBaseOptions & {
|
|
40
|
+
export type FhevmOptions<client extends NativeClient = NativeClient> = FhevmBaseOptions<client> & {
|
|
28
41
|
readonly fheEncryptionKey?: FheEncryptionKeyBytes | undefined;
|
|
29
42
|
readonly moduleVersions?: FhevmModuleVersions | undefined;
|
|
30
43
|
};
|
|
31
44
|
|
|
45
|
+
/**
|
|
46
|
+
* An Ethereum chain definition (one that defines `kmsGeneration`) and a client
|
|
47
|
+
* connected to it. Used only to read `KMSGeneration` when the host chain is
|
|
48
|
+
* not Ethereum; every other read goes through the host-chain client.
|
|
49
|
+
*/
|
|
50
|
+
export type FhevmKeyVerification<client extends NativeClient = NativeClient> = {
|
|
51
|
+
readonly chain: FhevmChain;
|
|
52
|
+
readonly client: client;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export type ResolvedFhevmKeyVerification = {
|
|
56
|
+
readonly chain: FhevmChain;
|
|
57
|
+
readonly trustedClient: TrustedClient;
|
|
58
|
+
};
|
|
59
|
+
|
|
32
60
|
export type ResolvedFhevmOptions = {
|
|
33
61
|
readonly batchRpcCalls: boolean;
|
|
34
62
|
readonly moduleVersions?: FhevmModuleVersions | undefined;
|
|
63
|
+
readonly keyVerification: ResolvedFhevmKeyVerification | undefined;
|
|
35
64
|
};
|
|
36
65
|
|
|
37
66
|
////////////////////////////////////////////////////////////////////////////////
|
package/core/types/fhevmChain.ts
CHANGED
|
@@ -44,6 +44,12 @@ export type FhevmChainContracts = {
|
|
|
44
44
|
readonly inputVerifier: ChainContract;
|
|
45
45
|
readonly kmsVerifier: ChainContract;
|
|
46
46
|
readonly protocolConfig?: ChainContract | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* KMSGeneration stores the digests of the FHE public key and CRS generated by
|
|
49
|
+
* the KMS nodes. It exists only on Ethereum: set it in Ethereum chain
|
|
50
|
+
* definitions only. Its presence marks the host chain as Ethereum.
|
|
51
|
+
*/
|
|
52
|
+
readonly kmsGeneration?: ChainContract | undefined;
|
|
47
53
|
};
|
|
48
54
|
|
|
49
55
|
export type FhevmGatewayChain = {
|
|
@@ -78,6 +84,7 @@ type ResolvedFhevmChainContracts = {
|
|
|
78
84
|
readonly inputVerifier: ResolvedChainContract;
|
|
79
85
|
readonly kmsVerifier: ResolvedChainContract;
|
|
80
86
|
readonly protocolConfig?: ResolvedChainContract | undefined;
|
|
87
|
+
readonly kmsGeneration?: ResolvedChainContract | undefined;
|
|
81
88
|
};
|
|
82
89
|
|
|
83
90
|
type ResolvedFhevmGatewayChain = {
|
|
@@ -6,6 +6,8 @@ export type HostContractNameMap = {
|
|
|
6
6
|
readonly HCULimit: 'HCULimit';
|
|
7
7
|
readonly InputVerifier: 'InputVerifier';
|
|
8
8
|
readonly KMSVerifier: 'KMSVerifier';
|
|
9
|
+
// Ethereum only: stores the FHE public key and CRS digests.
|
|
10
|
+
readonly KMSGeneration: 'KMSGeneration';
|
|
9
11
|
readonly ProtocolConfig: 'ProtocolConfig';
|
|
10
12
|
};
|
|
11
13
|
|
package/core/types/index.ts
CHANGED
|
@@ -3,4 +3,5 @@ export type { TypedValue } from './primitives.js';
|
|
|
3
3
|
export type { EncryptedValue, EncryptedValueLike } from './encryptedTypes.js';
|
|
4
4
|
export type { Eip712Like } from './kms.js';
|
|
5
5
|
export type { FhevmEncryptClient, FhevmDecryptClient } from './fhevmClient.js';
|
|
6
|
+
export type { FhevmKeyVerification } from './coreFhevmClient.js';
|
|
6
7
|
export { asEncryptedValue, isEncryptedValue } from '../handle/EncryptedValue.js';
|
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
} from './primitives.js';
|
|
13
13
|
import type { ZkProof } from './zkProof-p.js';
|
|
14
14
|
import type { WithEncrypt } from './coreFhevmRuntime.js';
|
|
15
|
+
import type { FhevmBase, OptionalNativeClient } from './coreFhevmClient.js';
|
|
15
16
|
import type { FhevmChain } from './fhevmChain.js';
|
|
16
17
|
import type { FhevmClientFrozenContext } from './fhevmClientFrozenContext-p.js';
|
|
17
18
|
|
|
@@ -27,7 +28,7 @@ export interface ZkProofBuilder {
|
|
|
27
28
|
addTypedValue(typedValue: TypedValue): this;
|
|
28
29
|
getBits(): EncryptionBits[];
|
|
29
30
|
build(
|
|
30
|
-
context:
|
|
31
|
+
context: FhevmBase<FhevmChain, WithEncrypt, OptionalNativeClient>,
|
|
31
32
|
parameters: {
|
|
32
33
|
readonly contractAddress: string;
|
|
33
34
|
readonly userAddress: string;
|
|
@@ -16,7 +16,7 @@ export function createFhevmCleartextBaseClient<
|
|
|
16
16
|
>(parameters: {
|
|
17
17
|
readonly provider: provider;
|
|
18
18
|
readonly chain: chain;
|
|
19
|
-
readonly options?: FhevmOptions | undefined;
|
|
19
|
+
readonly options?: FhevmOptions<EthersT.ContractRunner> | undefined;
|
|
20
20
|
}): FhevmBaseClient<chain, FhevmRuntime, provider> {
|
|
21
21
|
const c = createCoreFhevm(PRIVATE_ETHERS_TOKEN, {
|
|
22
22
|
chain: parameters.chain,
|
|
@@ -15,7 +15,7 @@ export function createFhevmCleartextClient<
|
|
|
15
15
|
>(parameters: {
|
|
16
16
|
readonly provider: provider;
|
|
17
17
|
readonly chain: chain;
|
|
18
|
-
readonly options?: FhevmOptions | undefined;
|
|
18
|
+
readonly options?: FhevmOptions<EthersT.ContractRunner> | undefined;
|
|
19
19
|
}): FhevmClient<chain, WithAll, provider> {
|
|
20
20
|
const c = createFhevmCleartextBaseClient(parameters);
|
|
21
21
|
|
|
@@ -14,7 +14,7 @@ export function createFhevmCleartextDecryptClient<
|
|
|
14
14
|
>(parameters: {
|
|
15
15
|
readonly provider: provider;
|
|
16
16
|
readonly chain: chain;
|
|
17
|
-
readonly options?: FhevmDecryptOptions | undefined;
|
|
17
|
+
readonly options?: FhevmDecryptOptions<EthersT.ContractRunner> | undefined;
|
|
18
18
|
}): FhevmDecryptClient<chain, WithDecrypt, provider> {
|
|
19
19
|
const c = createFhevmCleartextBaseClient(parameters);
|
|
20
20
|
return c.extend(decryptActions);
|
|
@@ -14,7 +14,7 @@ export function createFhevmCleartextEncryptClient<
|
|
|
14
14
|
>(parameters: {
|
|
15
15
|
readonly provider: provider;
|
|
16
16
|
readonly chain: chain;
|
|
17
|
-
readonly options?: FhevmEncryptOptions | undefined;
|
|
17
|
+
readonly options?: FhevmEncryptOptions<EthersT.ContractRunner> | undefined;
|
|
18
18
|
}): FhevmEncryptClient<chain, WithEncrypt, provider> {
|
|
19
19
|
const c = createFhevmCleartextBaseClient(parameters);
|
|
20
20
|
|
|
@@ -13,7 +13,7 @@ import { getEthersRuntime } from '../internal/runtime.js';
|
|
|
13
13
|
export function createFhevmBaseClient<chain extends FhevmChain, provider extends EthersT.ContractRunner>(parameters: {
|
|
14
14
|
readonly provider: provider;
|
|
15
15
|
readonly chain: chain;
|
|
16
|
-
readonly options?: FhevmOptions | undefined;
|
|
16
|
+
readonly options?: FhevmOptions<EthersT.ContractRunner> | undefined;
|
|
17
17
|
}): FhevmBaseClient<chain, FhevmRuntime, provider> {
|
|
18
18
|
const c = createCoreFhevm(PRIVATE_ETHERS_TOKEN, {
|
|
19
19
|
chain: parameters.chain,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ethers as EthersT } from 'ethers';
|
|
2
2
|
import type { FhevmChain } from '../../core/types/fhevmChain.js';
|
|
3
3
|
import type { WithAll } from '../../core/types/coreFhevmRuntime.js';
|
|
4
|
-
import type { FhevmOptions } from '../../core/types/coreFhevmClient.js';
|
|
5
4
|
import type { FhevmClient } from '../../core/types/fhevmClient.js';
|
|
5
|
+
import type { FhevmOptions } from '../../core/types/coreFhevmClient.js';
|
|
6
6
|
import { createFhevmBaseClient } from './createFhevmBaseClient.js';
|
|
7
7
|
import { encryptActions } from './decorators/encrypt.js';
|
|
8
8
|
import { decryptActions } from './decorators/decrypt.js';
|
|
@@ -12,7 +12,7 @@ import { decryptActions } from './decorators/decrypt.js';
|
|
|
12
12
|
export function createFhevmClient<chain extends FhevmChain, provider extends EthersT.ContractRunner>(parameters: {
|
|
13
13
|
readonly provider: provider;
|
|
14
14
|
readonly chain: chain;
|
|
15
|
-
readonly options?: FhevmOptions | undefined;
|
|
15
|
+
readonly options?: FhevmOptions<EthersT.ContractRunner> | undefined;
|
|
16
16
|
}): FhevmClient<chain, WithAll, provider> {
|
|
17
17
|
const c = createFhevmBaseClient(parameters);
|
|
18
18
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ethers as EthersT } from 'ethers';
|
|
2
2
|
import type { FhevmChain } from '../../core/types/fhevmChain.js';
|
|
3
3
|
import type { WithDecrypt } from '../../core/types/coreFhevmRuntime.js';
|
|
4
|
-
import type { FhevmDecryptOptions } from '../../core/types/coreFhevmClient.js';
|
|
5
4
|
import type { FhevmDecryptClient } from '../../core/types/fhevmClient.js';
|
|
5
|
+
import type { FhevmDecryptOptions } from '../../core/types/coreFhevmClient.js';
|
|
6
6
|
import { createFhevmBaseClient } from './createFhevmBaseClient.js';
|
|
7
7
|
import { decryptActions } from './decorators/decrypt.js';
|
|
8
8
|
|
|
@@ -14,8 +14,12 @@ export function createFhevmDecryptClient<
|
|
|
14
14
|
>(parameters: {
|
|
15
15
|
readonly provider: provider;
|
|
16
16
|
readonly chain: chain;
|
|
17
|
-
readonly options?: FhevmDecryptOptions | undefined;
|
|
17
|
+
readonly options?: FhevmDecryptOptions<EthersT.ContractRunner> | undefined;
|
|
18
18
|
}): FhevmDecryptClient<chain, WithDecrypt, provider> {
|
|
19
|
-
const c = createFhevmBaseClient(
|
|
19
|
+
const c = createFhevmBaseClient({
|
|
20
|
+
...parameters,
|
|
21
|
+
// Decrypt clients never use the key: do not keep a copy of it.
|
|
22
|
+
options: parameters.options === undefined ? undefined : { ...parameters.options, fheEncryptionKey: undefined },
|
|
23
|
+
});
|
|
20
24
|
return c.extend(decryptActions);
|
|
21
25
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ethers as EthersT } from 'ethers';
|
|
2
2
|
import type { FhevmChain } from '../../core/types/fhevmChain.js';
|
|
3
3
|
import type { WithEncrypt } from '../../core/types/coreFhevmRuntime.js';
|
|
4
|
-
import type { FhevmEncryptOptions } from '../../core/types/coreFhevmClient.js';
|
|
5
4
|
import type { FhevmEncryptClient } from '../../core/types/fhevmClient.js';
|
|
5
|
+
import type { FhevmEncryptOptions } from '../../core/types/coreFhevmClient.js';
|
|
6
6
|
import { createFhevmBaseClient } from './createFhevmBaseClient.js';
|
|
7
7
|
import { encryptActions } from './decorators/encrypt.js';
|
|
8
8
|
|
|
@@ -14,7 +14,7 @@ export function createFhevmEncryptClient<
|
|
|
14
14
|
>(parameters: {
|
|
15
15
|
readonly provider: provider;
|
|
16
16
|
readonly chain: chain;
|
|
17
|
-
readonly options?: FhevmEncryptOptions | undefined;
|
|
17
|
+
readonly options?: FhevmEncryptOptions<EthersT.ContractRunner> | undefined;
|
|
18
18
|
}): FhevmEncryptClient<chain, WithEncrypt, provider> {
|
|
19
19
|
const c = createFhevmBaseClient(parameters);
|
|
20
20
|
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@ export function createFhevmCleartextBaseClient<
|
|
|
16
16
|
>(parameters: {
|
|
17
17
|
readonly publicClient: publicClient;
|
|
18
18
|
readonly chain: chain;
|
|
19
|
-
readonly options?: FhevmOptions | undefined;
|
|
19
|
+
readonly options?: FhevmOptions<PublicClient> | undefined;
|
|
20
20
|
}): FhevmBaseClient<chain, FhevmRuntime, publicClient> {
|
|
21
21
|
const c = createCoreFhevm(PRIVATE_VIEM_TOKEN, {
|
|
22
22
|
chain: parameters.chain,
|
|
@@ -12,7 +12,7 @@ import { decryptActions } from './decorators/decrypt.js';
|
|
|
12
12
|
export function createFhevmCleartextClient<chain extends FhevmChain, publicClient extends PublicClient>(parameters: {
|
|
13
13
|
readonly publicClient: publicClient;
|
|
14
14
|
readonly chain: chain;
|
|
15
|
-
readonly options?: FhevmOptions | undefined;
|
|
15
|
+
readonly options?: FhevmOptions<PublicClient> | undefined;
|
|
16
16
|
}): FhevmClient<chain, WithAll, publicClient> {
|
|
17
17
|
const c = createFhevmCleartextBaseClient(parameters);
|
|
18
18
|
|
|
@@ -14,7 +14,7 @@ export function createFhevmCleartextDecryptClient<
|
|
|
14
14
|
>(parameters: {
|
|
15
15
|
readonly publicClient: publicClient;
|
|
16
16
|
readonly chain: chain;
|
|
17
|
-
readonly options?: FhevmDecryptOptions | undefined;
|
|
17
|
+
readonly options?: FhevmDecryptOptions<PublicClient> | undefined;
|
|
18
18
|
}): FhevmDecryptClient<chain, WithDecrypt, publicClient> {
|
|
19
19
|
const c = createFhevmCleartextBaseClient(parameters);
|
|
20
20
|
return c.extend(decryptActions);
|
|
@@ -14,7 +14,7 @@ export function createFhevmCleartextEncryptClient<
|
|
|
14
14
|
>(parameters: {
|
|
15
15
|
readonly publicClient: publicClient;
|
|
16
16
|
readonly chain: chain;
|
|
17
|
-
readonly options?: FhevmEncryptOptions | undefined;
|
|
17
|
+
readonly options?: FhevmEncryptOptions<PublicClient> | undefined;
|
|
18
18
|
}): FhevmEncryptClient<chain, WithEncrypt, publicClient> {
|
|
19
19
|
const c = createFhevmCleartextBaseClient(parameters);
|
|
20
20
|
|
|
@@ -13,7 +13,7 @@ import { baseActions } from '../../core/clients/decorators/base.js';
|
|
|
13
13
|
export function createFhevmBaseClient<chain extends FhevmChain, publicClient extends PublicClient>(parameters: {
|
|
14
14
|
readonly publicClient: publicClient;
|
|
15
15
|
readonly chain: chain;
|
|
16
|
-
readonly options?: FhevmOptions | undefined;
|
|
16
|
+
readonly options?: FhevmOptions<PublicClient> | undefined;
|
|
17
17
|
}): FhevmBaseClient<chain, FhevmRuntime, publicClient> {
|
|
18
18
|
const c = createCoreFhevm(PRIVATE_VIEM_TOKEN, {
|
|
19
19
|
chain: parameters.chain,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { PublicClient } from 'viem';
|
|
2
2
|
import type { FhevmChain } from '../../core/types/fhevmChain.js';
|
|
3
3
|
import type { WithAll } from '../../core/types/coreFhevmRuntime.js';
|
|
4
|
-
import type { FhevmOptions } from '../../core/types/coreFhevmClient.js';
|
|
5
4
|
import type { FhevmClient } from '../../core/types/fhevmClient.js';
|
|
5
|
+
import type { FhevmOptions } from '../../core/types/coreFhevmClient.js';
|
|
6
6
|
import { createFhevmBaseClient } from './createFhevmBaseClient.js';
|
|
7
7
|
import { encryptActions } from './decorators/encrypt.js';
|
|
8
8
|
import { decryptActions } from './decorators/decrypt.js';
|
|
@@ -12,7 +12,7 @@ import { decryptActions } from './decorators/decrypt.js';
|
|
|
12
12
|
export function createFhevmClient<chain extends FhevmChain, publicClient extends PublicClient>(parameters: {
|
|
13
13
|
readonly publicClient: publicClient;
|
|
14
14
|
readonly chain: chain;
|
|
15
|
-
readonly options?: FhevmOptions | undefined;
|
|
15
|
+
readonly options?: FhevmOptions<PublicClient> | undefined;
|
|
16
16
|
}): FhevmClient<chain, WithAll, publicClient> {
|
|
17
17
|
const c = createFhevmBaseClient(parameters);
|
|
18
18
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { PublicClient } from 'viem';
|
|
2
2
|
import type { FhevmChain } from '../../core/types/fhevmChain.js';
|
|
3
3
|
import type { WithDecrypt } from '../../core/types/coreFhevmRuntime.js';
|
|
4
|
-
import type { FhevmDecryptOptions } from '../../core/types/coreFhevmClient.js';
|
|
5
4
|
import type { FhevmDecryptClient } from '../../core/types/fhevmClient.js';
|
|
5
|
+
import type { FhevmDecryptOptions } from '../../core/types/coreFhevmClient.js';
|
|
6
6
|
import { createFhevmBaseClient } from './createFhevmBaseClient.js';
|
|
7
7
|
import { decryptActions } from './decorators/decrypt.js';
|
|
8
8
|
|
|
@@ -11,8 +11,12 @@ import { decryptActions } from './decorators/decrypt.js';
|
|
|
11
11
|
export function createFhevmDecryptClient<chain extends FhevmChain, publicClient extends PublicClient>(parameters: {
|
|
12
12
|
readonly publicClient: publicClient;
|
|
13
13
|
readonly chain: chain;
|
|
14
|
-
readonly options?: FhevmDecryptOptions | undefined;
|
|
14
|
+
readonly options?: FhevmDecryptOptions<PublicClient> | undefined;
|
|
15
15
|
}): FhevmDecryptClient<chain, WithDecrypt, publicClient> {
|
|
16
|
-
const c = createFhevmBaseClient(
|
|
16
|
+
const c = createFhevmBaseClient({
|
|
17
|
+
...parameters,
|
|
18
|
+
// Decrypt clients never use the key: do not keep a copy of it.
|
|
19
|
+
options: parameters.options === undefined ? undefined : { ...parameters.options, fheEncryptionKey: undefined },
|
|
20
|
+
});
|
|
17
21
|
return c.extend(decryptActions);
|
|
18
22
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { PublicClient } from 'viem';
|
|
2
2
|
import type { FhevmChain } from '../../core/types/fhevmChain.js';
|
|
3
3
|
import type { WithEncrypt } from '../../core/types/coreFhevmRuntime.js';
|
|
4
|
-
import type { FhevmEncryptOptions } from '../../core/types/coreFhevmClient.js';
|
|
5
4
|
import type { FhevmEncryptClient } from '../../core/types/fhevmClient.js';
|
|
5
|
+
import type { FhevmEncryptOptions } from '../../core/types/coreFhevmClient.js';
|
|
6
6
|
import { createFhevmBaseClient } from './createFhevmBaseClient.js';
|
|
7
7
|
import { encryptActions } from './decorators/encrypt.js';
|
|
8
8
|
|
|
@@ -11,7 +11,7 @@ import { encryptActions } from './decorators/encrypt.js';
|
|
|
11
11
|
export function createFhevmEncryptClient<chain extends FhevmChain, publicClient extends PublicClient>(parameters: {
|
|
12
12
|
readonly publicClient: publicClient;
|
|
13
13
|
readonly chain: chain;
|
|
14
|
-
readonly options?: FhevmEncryptOptions | undefined;
|
|
14
|
+
readonly options?: FhevmEncryptOptions<PublicClient> | undefined;
|
|
15
15
|
}): FhevmEncryptClient<chain, WithEncrypt, publicClient> {
|
|
16
16
|
const c = createFhevmBaseClient(parameters);
|
|
17
17
|
|