@fhevm/sdk 0.13.2-1 → 0.14.0-12
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/_version.js.map +1 -1
- package/_cjs/core/actions/base/canUseUnifiedDecryptionPermit.js +11 -0
- package/_cjs/core/actions/base/canUseUnifiedDecryptionPermit.js.map +1 -0
- package/_cjs/core/actions/base/createUnsignedUnifiedDecryptionPermitEip712.js +0 -4
- package/_cjs/core/actions/base/createUnsignedUnifiedDecryptionPermitEip712.js.map +1 -1
- package/_cjs/core/actions/base/index.js +7 -1
- package/_cjs/core/actions/base/index.js.map +1 -1
- package/_cjs/core/actions/base/signUnifiedDecryptionPermit.js +10 -0
- package/_cjs/core/actions/base/signUnifiedDecryptionPermit.js.map +1 -0
- package/_cjs/core/actions/host/resolveChainId.js +3 -1
- package/_cjs/core/actions/host/resolveChainId.js.map +1 -1
- package/_cjs/core/clients/decorators/base.js +2 -0
- package/_cjs/core/clients/decorators/base.js.map +1 -1
- package/_cjs/core/errors/Erc1271Error.js +48 -0
- package/_cjs/core/errors/Erc1271Error.js.map +1 -0
- package/_cjs/core/frozenContext/fhevmClientFrozenContext-p.js.map +1 -1
- package/_cjs/core/frozenContext/resolveFhevmClientFrozenContext-p.js +11 -1
- package/_cjs/core/frozenContext/resolveFhevmClientFrozenContext-p.js.map +1 -1
- package/_cjs/core/host-contracts/readKmsSignersContext-p.js +0 -7
- package/_cjs/core/host-contracts/readKmsSignersContext-p.js.map +1 -1
- package/_cjs/core/key/FheEncryptionKeyCache-p.js +3 -0
- package/_cjs/core/key/FheEncryptionKeyCache-p.js.map +1 -1
- package/_cjs/core/key/fetchFheEncryptionKey.js +13 -1
- package/_cjs/core/key/fetchFheEncryptionKey.js.map +1 -1
- package/_cjs/core/kms/SignedDecryptionPermit-p.js +1 -27
- package/_cjs/core/kms/SignedDecryptionPermit-p.js.map +1 -1
- package/_cjs/core/kms/SignedDecryptionPermitV2-p.js +22 -14
- package/_cjs/core/kms/SignedDecryptionPermitV2-p.js.map +1 -1
- package/_cjs/core/kms/decryptValuesFromPairs.js +5 -14
- package/_cjs/core/kms/decryptValuesFromPairs.js.map +1 -1
- package/_cjs/core/kms/fetchKmsSigncryptedSharesV2-p.js +8 -0
- package/_cjs/core/kms/fetchKmsSigncryptedSharesV2-p.js.map +1 -1
- package/_cjs/core/modules/decrypt/module/api-p.js +1 -1
- package/_cjs/core/modules/decrypt/module/api-p.js.map +1 -1
- package/_cjs/core/modules/decrypt/module/init-p.js +7 -1
- package/_cjs/core/modules/decrypt/module/init-p.js.map +1 -1
- package/_cjs/core/modules/encrypt/module/init-p.js +14 -2
- package/_cjs/core/modules/encrypt/module/init-p.js.map +1 -1
- package/_cjs/core/modules/relayer/cleartext/mock.js +5 -0
- package/_cjs/core/modules/relayer/cleartext/mock.js.map +1 -1
- package/_cjs/core/modules/relayer/module/RelayerAsyncRequest.js +20 -0
- package/_cjs/core/modules/relayer/module/RelayerAsyncRequest.js.map +1 -1
- package/_cjs/core/modules/relayer/module/fetchCoprocessorSignatures.js +1 -0
- package/_cjs/core/modules/relayer/module/fetchCoprocessorSignatures.js.map +1 -1
- package/_cjs/core/modules/relayer/module/fetchDelegatedUserDecryptV1.js +1 -0
- package/_cjs/core/modules/relayer/module/fetchDelegatedUserDecryptV1.js.map +1 -1
- package/_cjs/core/modules/relayer/module/fetchFeatures.js +35 -0
- package/_cjs/core/modules/relayer/module/fetchFeatures.js.map +1 -0
- package/_cjs/core/modules/relayer/module/fetchPublicDecrypt.js +1 -0
- package/_cjs/core/modules/relayer/module/fetchPublicDecrypt.js.map +1 -1
- package/_cjs/core/modules/relayer/module/fetchUserDecryptV1.js +1 -0
- package/_cjs/core/modules/relayer/module/fetchUserDecryptV1.js.map +1 -1
- package/_cjs/core/modules/relayer/module/fetchUserDecryptV2.js +1 -0
- package/_cjs/core/modules/relayer/module/fetchUserDecryptV2.js.map +1 -1
- package/_cjs/core/modules/relayer/module/index.js +2 -0
- package/_cjs/core/modules/relayer/module/index.js.map +1 -1
- package/_cjs/core/relayerFeatures/ensureRelayerFeatures-p.js +25 -0
- package/_cjs/core/relayerFeatures/ensureRelayerFeatures-p.js.map +1 -0
- package/_cjs/core/relayerFeatures/resolveRelayerFeatures-p.js +7 -0
- package/_cjs/core/relayerFeatures/resolveRelayerFeatures-p.js.map +1 -0
- package/_cjs/core/runtime/CoreFhevm-p.js +58 -2
- package/_cjs/core/runtime/CoreFhevm-p.js.map +1 -1
- package/_cjs/core/runtime/HyperWasmSolver-p.js +44 -4
- package/_cjs/core/runtime/HyperWasmSolver-p.js.map +1 -1
- package/_cjs/core/runtime/ProtocolVersionResolver-p.js +10 -4
- package/_cjs/core/runtime/ProtocolVersionResolver-p.js.map +1 -1
- package/_cjs/core/runtime/initFhevmDecryptRuntime-p.js +1 -1
- package/_cjs/core/runtime/initFhevmDecryptRuntime-p.js.map +1 -1
- package/_cjs/core/runtime/initFhevmRuntime-p.js +1 -1
- package/_cjs/core/runtime/initFhevmRuntime-p.js.map +1 -1
- package/_cjs/core/runtime/sdkProtocolApiVersion.js +1 -1
- package/_cjs/core/runtime/sdkProtocolApiVersion.js.map +1 -1
- package/_cjs/core/utils-p/decrypt/verifyErc1271UserDecrypt-p.js +73 -0
- package/_cjs/core/utils-p/decrypt/verifyErc1271UserDecrypt-p.js.map +1 -0
- package/_cjs/ethers/internal/ethereum-ct.js +2 -11
- package/_cjs/ethers/internal/ethereum-ct.js.map +1 -1
- package/_cjs/ethers/internal/ethereum.js +33 -0
- package/_cjs/ethers/internal/ethereum.js.map +1 -1
- package/_cjs/ethers/internal/utils.js +17 -0
- package/_cjs/ethers/internal/utils.js.map +1 -1
- package/_cjs/viem/internal/ethereum-ct.js +2 -8
- package/_cjs/viem/internal/ethereum-ct.js.map +1 -1
- package/_cjs/viem/internal/ethereum.js +34 -4
- package/_cjs/viem/internal/ethereum.js.map +1 -1
- package/_cjs/wasm/tfhe/loadTfheLib.js.map +1 -1
- package/_cjs/wasm/tkms/KmsLibApi.d.ts +1 -1
- package/_cjs/wasm/tkms/loadKmsLib.js +13 -4
- package/_cjs/wasm/tkms/loadKmsLib.js.map +3 -3
- package/_cjs/wasm/tkms/v0.14.0-1/kms_lib.d.ts +598 -0
- package/_cjs/wasm/tkms/v0.14.0-1/kms_lib.js +1887 -0
- package/_cjs/wasm/tkms/v0.14.0-1/kms_lib.js.map +7 -0
- package/_cjs/wasm/tkms/v0.14.0-1/kms_lib_bg.wasm +0 -0
- package/_cjs/wasm/tkms/v0.14.0-1/kms_lib_bg.wasm.base64.d.ts +3 -0
- package/_cjs/wasm/tkms/v0.14.0-1/kms_lib_bg.wasm.base64.js +35 -0
- package/_cjs/wasm/tkms/v0.14.0-1/kms_lib_bg.wasm.base64.js.map +7 -0
- package/_esm/core/_version.js +1 -1
- package/_esm/core/_version.js.map +1 -1
- package/_esm/core/actions/base/canUseUnifiedDecryptionPermit.js +21 -0
- package/_esm/core/actions/base/canUseUnifiedDecryptionPermit.js.map +1 -0
- package/_esm/core/actions/base/createUnsignedUnifiedDecryptionPermitEip712.js +0 -4
- package/_esm/core/actions/base/createUnsignedUnifiedDecryptionPermitEip712.js.map +1 -1
- package/_esm/core/actions/base/index.js +9 -2
- package/_esm/core/actions/base/index.js.map +1 -1
- package/_esm/core/actions/base/signUnifiedDecryptionPermit.js +7 -0
- package/_esm/core/actions/base/signUnifiedDecryptionPermit.js.map +1 -0
- package/_esm/core/actions/host/resolveChainId.js +3 -1
- package/_esm/core/actions/host/resolveChainId.js.map +1 -1
- package/_esm/core/clients/decorators/base.js +2 -0
- package/_esm/core/clients/decorators/base.js.map +1 -1
- package/_esm/core/errors/Erc1271Error.js +45 -0
- package/_esm/core/errors/Erc1271Error.js.map +1 -0
- package/_esm/core/frozenContext/fhevmClientFrozenContext-p.js.map +1 -1
- package/_esm/core/frozenContext/resolveFhevmClientFrozenContext-p.js +12 -1
- package/_esm/core/frozenContext/resolveFhevmClientFrozenContext-p.js.map +1 -1
- package/_esm/core/host-contracts/readKmsSignersContext-p.js +9 -40
- package/_esm/core/host-contracts/readKmsSignersContext-p.js.map +1 -1
- package/_esm/core/key/FheEncryptionKeyCache-p.js +3 -0
- package/_esm/core/key/FheEncryptionKeyCache-p.js.map +1 -1
- package/_esm/core/key/fetchFheEncryptionKey.js +13 -1
- package/_esm/core/key/fetchFheEncryptionKey.js.map +1 -1
- package/_esm/core/kms/SignedDecryptionPermit-p.js +6 -47
- package/_esm/core/kms/SignedDecryptionPermit-p.js.map +1 -1
- package/_esm/core/kms/SignedDecryptionPermitV2-p.js +35 -21
- package/_esm/core/kms/SignedDecryptionPermitV2-p.js.map +1 -1
- package/_esm/core/kms/decryptValuesFromPairs.js +14 -32
- package/_esm/core/kms/decryptValuesFromPairs.js.map +1 -1
- package/_esm/core/kms/fetchKmsSigncryptedSharesV2-p.js +11 -0
- package/_esm/core/kms/fetchKmsSigncryptedSharesV2-p.js.map +1 -1
- package/_esm/core/modules/decrypt/module/api-p.js +5 -3
- package/_esm/core/modules/decrypt/module/api-p.js.map +1 -1
- package/_esm/core/modules/decrypt/module/init-p.js +7 -1
- package/_esm/core/modules/decrypt/module/init-p.js.map +1 -1
- package/_esm/core/modules/encrypt/module/init-p.js +14 -2
- package/_esm/core/modules/encrypt/module/init-p.js.map +1 -1
- package/_esm/core/modules/relayer/cleartext/mock.js +5 -0
- package/_esm/core/modules/relayer/cleartext/mock.js.map +1 -1
- package/_esm/core/modules/relayer/module/RelayerAsyncRequest.js +20 -0
- package/_esm/core/modules/relayer/module/RelayerAsyncRequest.js.map +1 -1
- package/_esm/core/modules/relayer/module/fetchCoprocessorSignatures.js +1 -0
- package/_esm/core/modules/relayer/module/fetchCoprocessorSignatures.js.map +1 -1
- package/_esm/core/modules/relayer/module/fetchDelegatedUserDecryptV1.js +1 -0
- package/_esm/core/modules/relayer/module/fetchDelegatedUserDecryptV1.js.map +1 -1
- package/_esm/core/modules/relayer/module/fetchFeatures.js +68 -0
- package/_esm/core/modules/relayer/module/fetchFeatures.js.map +1 -0
- package/_esm/core/modules/relayer/module/fetchPublicDecrypt.js +1 -0
- package/_esm/core/modules/relayer/module/fetchPublicDecrypt.js.map +1 -1
- package/_esm/core/modules/relayer/module/fetchUserDecryptV1.js +1 -0
- package/_esm/core/modules/relayer/module/fetchUserDecryptV1.js.map +1 -1
- package/_esm/core/modules/relayer/module/fetchUserDecryptV2.js +1 -0
- package/_esm/core/modules/relayer/module/fetchUserDecryptV2.js.map +1 -1
- package/_esm/core/modules/relayer/module/index.js +2 -0
- package/_esm/core/modules/relayer/module/index.js.map +1 -1
- package/_esm/core/relayerFeatures/ensureRelayerFeatures-p.js +61 -0
- package/_esm/core/relayerFeatures/ensureRelayerFeatures-p.js.map +1 -0
- package/_esm/core/relayerFeatures/resolveRelayerFeatures-p.js +15 -0
- package/_esm/core/relayerFeatures/resolveRelayerFeatures-p.js.map +1 -0
- package/_esm/core/runtime/CoreFhevm-p.js +61 -2
- package/_esm/core/runtime/CoreFhevm-p.js.map +1 -1
- package/_esm/core/runtime/HyperWasmSolver-p.js +51 -6
- package/_esm/core/runtime/HyperWasmSolver-p.js.map +1 -1
- package/_esm/core/runtime/ProtocolVersionResolver-p.js +10 -4
- package/_esm/core/runtime/ProtocolVersionResolver-p.js.map +1 -1
- package/_esm/core/runtime/initFhevmDecryptRuntime-p.js +1 -1
- package/_esm/core/runtime/initFhevmDecryptRuntime-p.js.map +1 -1
- package/_esm/core/runtime/initFhevmRuntime-p.js +1 -1
- package/_esm/core/runtime/initFhevmRuntime-p.js.map +1 -1
- package/_esm/core/runtime/sdkProtocolApiVersion.js +8 -9
- package/_esm/core/runtime/sdkProtocolApiVersion.js.map +1 -1
- package/_esm/core/utils-p/decrypt/verifyErc1271UserDecrypt-p.js +118 -0
- package/_esm/core/utils-p/decrypt/verifyErc1271UserDecrypt-p.js.map +1 -0
- package/_esm/ethers/internal/ethereum-ct.js +4 -13
- package/_esm/ethers/internal/ethereum-ct.js.map +1 -1
- package/_esm/ethers/internal/ethereum.js +45 -2
- package/_esm/ethers/internal/ethereum.js.map +1 -1
- package/_esm/ethers/internal/utils.js +20 -0
- package/_esm/ethers/internal/utils.js.map +1 -1
- package/_esm/viem/internal/ethereum-ct.js +5 -11
- package/_esm/viem/internal/ethereum-ct.js.map +1 -1
- package/_esm/viem/internal/ethereum.js +37 -0
- package/_esm/viem/internal/ethereum.js.map +1 -1
- package/_esm/wasm/tkms/KmsLibApi.d.ts +1 -1
- package/_esm/wasm/tkms/loadKmsLib.js +11 -2
- package/_esm/wasm/tkms/v0.14.0-1/kms_lib.d.ts +598 -0
- package/_esm/wasm/tkms/v0.14.0-1/kms_lib.js +2055 -0
- package/_esm/wasm/tkms/v0.14.0-1/kms_lib_bg.wasm +0 -0
- package/_esm/wasm/tkms/v0.14.0-1/kms_lib_bg.wasm.base64.d.ts +3 -0
- package/_esm/wasm/tkms/v0.14.0-1/kms_lib_bg.wasm.base64.js +7 -0
- package/_types/core/_version.d.ts.map +1 -1
- package/_types/core/actions/base/canUseUnifiedDecryptionPermit.d.ts +23 -0
- package/_types/core/actions/base/canUseUnifiedDecryptionPermit.d.ts.map +1 -0
- package/_types/core/actions/base/createUnsignedUnifiedDecryptionPermitEip712.d.ts.map +1 -1
- package/_types/core/actions/base/index.d.ts +3 -0
- package/_types/core/actions/base/index.d.ts.map +1 -1
- package/_types/core/actions/base/signUnifiedDecryptionPermit.d.ts +17 -0
- package/_types/core/actions/base/signUnifiedDecryptionPermit.d.ts.map +1 -0
- package/_types/core/actions/host/resolveChainId.d.ts.map +1 -1
- package/_types/core/clients/decorators/base.d.ts +14 -0
- package/_types/core/clients/decorators/base.d.ts.map +1 -1
- package/_types/core/errors/Erc1271Error.d.ts +46 -0
- package/_types/core/errors/Erc1271Error.d.ts.map +1 -0
- package/_types/core/frozenContext/fhevmClientFrozenContext-p.d.ts.map +1 -1
- package/_types/core/frozenContext/resolveFhevmClientFrozenContext-p.d.ts.map +1 -1
- package/_types/core/host-contracts/readKmsSignersContext-p.d.ts +9 -14
- package/_types/core/host-contracts/readKmsSignersContext-p.d.ts.map +1 -1
- package/_types/core/key/FheEncryptionKeyCache-p.d.ts.map +1 -1
- package/_types/core/key/fetchFheEncryptionKey.d.ts.map +1 -1
- package/_types/core/kms/SignedDecryptionPermit-p.d.ts.map +1 -1
- package/_types/core/kms/SignedDecryptionPermitV2-p.d.ts.map +1 -1
- package/_types/core/kms/decryptValuesFromPairs.d.ts.map +1 -1
- package/_types/core/kms/fetchKmsSigncryptedSharesV2-p.d.ts.map +1 -1
- package/_types/core/modules/decrypt/module/api-p.d.ts.map +1 -1
- package/_types/core/modules/decrypt/module/init-p.d.ts.map +1 -1
- package/_types/core/modules/encrypt/module/init-p.d.ts.map +1 -1
- package/_types/core/modules/ethereum/types.d.ts +47 -2
- package/_types/core/modules/ethereum/types.d.ts.map +1 -1
- package/_types/core/modules/relayer/cleartext/mock.d.ts.map +1 -1
- package/_types/core/modules/relayer/module/RelayerAsyncRequest.d.ts +3 -0
- package/_types/core/modules/relayer/module/RelayerAsyncRequest.d.ts.map +1 -1
- package/_types/core/modules/relayer/module/fetchCoprocessorSignatures.d.ts.map +1 -1
- package/_types/core/modules/relayer/module/fetchDelegatedUserDecryptV1.d.ts.map +1 -1
- package/_types/core/modules/relayer/module/fetchFeatures.d.ts +26 -0
- package/_types/core/modules/relayer/module/fetchFeatures.d.ts.map +1 -0
- package/_types/core/modules/relayer/module/fetchPublicDecrypt.d.ts.map +1 -1
- package/_types/core/modules/relayer/module/fetchUserDecryptV1.d.ts.map +1 -1
- package/_types/core/modules/relayer/module/fetchUserDecryptV2.d.ts.map +1 -1
- package/_types/core/modules/relayer/module/index.d.ts.map +1 -1
- package/_types/core/modules/relayer/types.d.ts +14 -2
- package/_types/core/modules/relayer/types.d.ts.map +1 -1
- package/_types/core/relayerFeatures/ensureRelayerFeatures-p.d.ts +55 -0
- package/_types/core/relayerFeatures/ensureRelayerFeatures-p.d.ts.map +1 -0
- package/_types/core/relayerFeatures/resolveRelayerFeatures-p.d.ts +39 -0
- package/_types/core/relayerFeatures/resolveRelayerFeatures-p.d.ts.map +1 -0
- package/_types/core/runtime/CoreFhevm-p.d.ts +5 -0
- package/_types/core/runtime/CoreFhevm-p.d.ts.map +1 -1
- package/_types/core/runtime/HyperWasmSolver-p.d.ts +1 -0
- package/_types/core/runtime/HyperWasmSolver-p.d.ts.map +1 -1
- package/_types/core/runtime/ProtocolVersionResolver-p.d.ts.map +1 -1
- package/_types/core/runtime/sdkProtocolApiVersion.d.ts +7 -8
- package/_types/core/runtime/sdkProtocolApiVersion.d.ts.map +1 -1
- package/_types/core/types/kms-p.d.ts +2 -2
- package/_types/core/types/kms-p.d.ts.map +1 -1
- package/_types/core/types/relayer-p.d.ts +1 -1
- package/_types/core/types/relayer-p.d.ts.map +1 -1
- package/_types/core/types/signedDecryptionPermit.d.ts +10 -3
- package/_types/core/types/signedDecryptionPermit.d.ts.map +1 -1
- package/_types/core/utils-p/decrypt/verifyErc1271UserDecrypt-p.d.ts +49 -0
- package/_types/core/utils-p/decrypt/verifyErc1271UserDecrypt-p.d.ts.map +1 -0
- package/_types/ethers/internal/ethereum-ct.d.ts.map +1 -1
- package/_types/ethers/internal/ethereum.d.ts +3 -1
- package/_types/ethers/internal/ethereum.d.ts.map +1 -1
- package/_types/ethers/internal/utils.d.ts +5 -0
- package/_types/ethers/internal/utils.d.ts.map +1 -1
- package/_types/viem/internal/ethereum-ct.d.ts.map +1 -1
- package/_types/viem/internal/ethereum.d.ts +3 -1
- package/_types/viem/internal/ethereum.d.ts.map +1 -1
- package/_types/wasm/tkms/KmsLibApi.d.ts +1 -1
- package/_types/wasm/tkms/v0.14.0-1/kms_lib.d.ts +598 -0
- package/_types/wasm/tkms/v0.14.0-1/kms_lib_bg.wasm.base64.d.ts +3 -0
- package/core/_version.ts +1 -1
- package/core/actions/base/canUseUnifiedDecryptionPermit.ts +38 -0
- package/core/actions/base/createUnsignedUnifiedDecryptionPermitEip712.ts +0 -6
- package/core/actions/base/index.ts +24 -2
- package/core/actions/base/signUnifiedDecryptionPermit.ts +27 -0
- package/core/actions/host/resolveChainId.ts +3 -1
- package/core/clients/decorators/base.ts +21 -0
- package/core/errors/Erc1271Error.ts +85 -0
- package/core/frozenContext/fhevmClientFrozenContext-p.ts +1 -0
- package/core/frozenContext/resolveFhevmClientFrozenContext-p.ts +21 -8
- package/core/host-contracts/readKmsSignersContext-p.ts +9 -45
- package/core/key/FheEncryptionKeyCache-p.ts +6 -0
- package/core/key/fetchFheEncryptionKey.ts +17 -1
- package/core/kms/SignedDecryptionPermit-p.ts +6 -60
- package/core/kms/SignedDecryptionPermitV2-p.ts +54 -41
- package/core/kms/decryptValuesFromPairs.ts +14 -33
- package/core/kms/fetchKmsSigncryptedSharesV2-p.ts +15 -0
- package/core/modules/decrypt/module/api-p.ts +5 -3
- package/core/modules/decrypt/module/init-p.ts +6 -1
- package/core/modules/encrypt/module/init-p.ts +15 -2
- package/core/modules/ethereum/types.ts +55 -1
- package/core/modules/relayer/cleartext/mock.ts +11 -0
- package/core/modules/relayer/module/RelayerAsyncRequest.ts +55 -0
- package/core/modules/relayer/module/fetchCoprocessorSignatures.ts +1 -0
- package/core/modules/relayer/module/fetchDelegatedUserDecryptV1.ts +1 -0
- package/core/modules/relayer/module/fetchFeatures.ts +75 -0
- package/core/modules/relayer/module/fetchPublicDecrypt.ts +1 -0
- package/core/modules/relayer/module/fetchUserDecryptV1.ts +1 -0
- package/core/modules/relayer/module/fetchUserDecryptV2.ts +1 -0
- package/core/modules/relayer/module/index.ts +2 -0
- package/core/modules/relayer/types.ts +26 -2
- package/core/relayerFeatures/ensureRelayerFeatures-p.ts +84 -0
- package/core/relayerFeatures/resolveRelayerFeatures-p.ts +47 -0
- package/core/runtime/CoreFhevm-p.ts +71 -0
- package/core/runtime/HyperWasmSolver-p.ts +57 -8
- package/core/runtime/ProtocolVersionResolver-p.ts +12 -4
- package/core/runtime/initFhevmDecryptRuntime-p.ts +1 -1
- package/core/runtime/initFhevmRuntime-p.ts +1 -1
- package/core/runtime/sdkProtocolApiVersion.ts +8 -9
- package/core/types/kms-p.ts +2 -2
- package/core/types/relayer-p.ts +4 -2
- package/core/types/signedDecryptionPermit.ts +10 -3
- package/core/utils-p/decrypt/verifyErc1271UserDecrypt-p.ts +164 -0
- package/ethers/internal/ethereum-ct.ts +5 -15
- package/ethers/internal/ethereum.ts +58 -3
- package/ethers/internal/utils.ts +27 -0
- package/package.json +2 -2
- package/viem/internal/ethereum-ct.ts +6 -14
- package/viem/internal/ethereum.ts +48 -1
- package/wasm/tkms/KmsLibApi.d.ts +1 -1
- package/wasm/tkms/loadKmsLib.js +11 -2
- package/wasm/tkms/v0.14.0-1/kms_lib.d.ts +598 -0
- package/wasm/tkms/v0.14.0-1/kms_lib.js +2055 -0
- package/wasm/tkms/v0.14.0-1/kms_lib_bg.wasm +0 -0
- package/wasm/tkms/v0.14.0-1/kms_lib_bg.wasm.base64.d.ts +3 -0
- package/wasm/tkms/v0.14.0-1/kms_lib_bg.wasm.base64.js +7 -0
- package/_cjs/core/utils-p/decrypt/verifyKmsUserDecryptEip712V2.js +0 -30
- package/_cjs/core/utils-p/decrypt/verifyKmsUserDecryptEip712V2.js.map +0 -1
- package/_esm/core/utils-p/decrypt/verifyKmsUserDecryptEip712V2.js +0 -27
- package/_esm/core/utils-p/decrypt/verifyKmsUserDecryptEip712V2.js.map +0 -1
- package/_types/core/utils-p/decrypt/verifyKmsUserDecryptEip712V2.d.ts +0 -14
- package/_types/core/utils-p/decrypt/verifyKmsUserDecryptEip712V2.d.ts.map +0 -1
- package/core/utils-p/decrypt/verifyKmsUserDecryptEip712V2.ts +0 -43
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { FetchFeaturesParameters, FetchFeaturesReturnType, RelayerClientWithRuntime } from '../types.js';
|
|
2
|
+
import { RelayerResponseErrorBase } from '../../../errors/RelayerResponseErrorBase.js';
|
|
3
|
+
import { RelayerAsyncRequest } from './RelayerAsyncRequest.js';
|
|
4
|
+
import { buildRelayerUrlString, validateRelayerBaseUrl } from './relayerUrl.js';
|
|
5
|
+
|
|
6
|
+
//////////////////////////////////////////////////////////////////////////////
|
|
7
|
+
// fetchFeatures
|
|
8
|
+
//////////////////////////////////////////////////////////////////////////////
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Probes whether the relayer exposes the unified user-decrypt route, and reports it as
|
|
12
|
+
* `relayerSupportsV3UserDecryptRoute`.
|
|
13
|
+
*
|
|
14
|
+
* There is no dedicated feature endpoint, so we detect the route by POSTing an **empty probe
|
|
15
|
+
* payload** to `v3/user-decrypt` and reading the outcome. Routing is path-based, so the body never
|
|
16
|
+
* decides existence:
|
|
17
|
+
*
|
|
18
|
+
* - **Route absent** → a user-decrypt POST does not expect a 404, so the request layer surfaces it
|
|
19
|
+
* as `status: 404` → `relayerSupportsV3UserDecryptRoute: false`.
|
|
20
|
+
* - **Route present** → the relayer answers the (invalid) probe with a 400 (or 429 / 5xx). Any such
|
|
21
|
+
* response proves the endpoint exists → `relayerSupportsV3UserDecryptRoute: true`.
|
|
22
|
+
* - **Auth rejected (401 / 403)** → the key is missing, bad, or expired (or an edge proxy blocked
|
|
23
|
+
* the request). That is not a capability answer, so we **fail loudly** (rethrow) rather than guess.
|
|
24
|
+
* `ensureRelayerFeatures` clears its in-flight promise on this rejection, so a retry with a valid
|
|
25
|
+
* key resolves cleanly.
|
|
26
|
+
*
|
|
27
|
+
* `options.auth` is forwarded so the probe can authenticate against relayers that require a key
|
|
28
|
+
* (e.g. mainnet); the resulting capability is itself auth-independent.
|
|
29
|
+
*
|
|
30
|
+
* Any non-response failure (network, DNS, timeout) is likewise rethrown so the caller fails loudly
|
|
31
|
+
* and retries instead of caching a wrong answer.
|
|
32
|
+
*/
|
|
33
|
+
export async function fetchFeatures(
|
|
34
|
+
relayerClient: RelayerClientWithRuntime,
|
|
35
|
+
parameters: FetchFeaturesParameters,
|
|
36
|
+
): Promise<FetchFeaturesReturnType> {
|
|
37
|
+
const { options } = parameters;
|
|
38
|
+
|
|
39
|
+
const hasAuth: boolean = options?.auth !== undefined;
|
|
40
|
+
const relayerBaseUrl: URL = validateRelayerBaseUrl(relayerClient.chain.fhevm.relayerUrl, hasAuth);
|
|
41
|
+
const url = buildRelayerUrlString(relayerBaseUrl, 'v3/user-decrypt');
|
|
42
|
+
|
|
43
|
+
const request = new RelayerAsyncRequest({
|
|
44
|
+
relayerOperation: 'USER_DECRYPT',
|
|
45
|
+
url,
|
|
46
|
+
// Deliberately-empty probe: a present route rejects it with a 400 (proving it exists); an absent
|
|
47
|
+
// route 404s. We never expect this request to succeed.
|
|
48
|
+
payload: {},
|
|
49
|
+
options,
|
|
50
|
+
// Do not use a logger here: this is a low-level probe.
|
|
51
|
+
// logger: relayerClient.runtime.config.logger,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
await request.run();
|
|
56
|
+
// Not expected from an empty payload — but if the route accepts it, it certainly exists.
|
|
57
|
+
return { relayerSupportsV3UserDecryptRoute: true };
|
|
58
|
+
} catch (error) {
|
|
59
|
+
if (error instanceof RelayerResponseErrorBase) {
|
|
60
|
+
if (error.status === 404) {
|
|
61
|
+
// RelayerResponseStatusError(404)
|
|
62
|
+
return { relayerSupportsV3UserDecryptRoute: false };
|
|
63
|
+
}
|
|
64
|
+
// Auth rejected (missing / bad / expired key) or edge-blocked → fail loudly instead of
|
|
65
|
+
// reporting a capability: the caller supplied a key we could not authenticate with.
|
|
66
|
+
if (error.status === 401 || error.status === 403) {
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
// Any other relayer response (400 rejects the empty probe, 429, 5xx) proves the route exists.
|
|
70
|
+
return { relayerSupportsV3UserDecryptRoute: true };
|
|
71
|
+
}
|
|
72
|
+
// Non-response failure (network / timeout): can't determine support — fail loudly.
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -5,6 +5,7 @@ import { fetchPublicDecrypt } from './fetchPublicDecrypt.js';
|
|
|
5
5
|
import { fetchFheEncryptionKeyBytes } from './fetchFheEncryptionKeyBytes.js';
|
|
6
6
|
import { fetchFheEncryptionKeySource } from './fetchFheEncryptionKeySource.js';
|
|
7
7
|
import { fetchUserDecrypt } from './fetchUserDecrypt.js';
|
|
8
|
+
import { fetchFeatures } from './fetchFeatures.js';
|
|
8
9
|
|
|
9
10
|
////////////////////////////////////////////////////////////////////////////////
|
|
10
11
|
// relayerModule
|
|
@@ -19,6 +20,7 @@ export const relayerModule: RelayerModuleFactory = () => {
|
|
|
19
20
|
fetchPublicDecrypt,
|
|
20
21
|
fetchUserDecrypt,
|
|
21
22
|
fetchDelegatedUserDecrypt,
|
|
23
|
+
fetchFeatures,
|
|
22
24
|
}),
|
|
23
25
|
});
|
|
24
26
|
};
|
|
@@ -19,6 +19,7 @@ import type { Handle, InputHandle } from '../../types/encryptedTypes-p.js';
|
|
|
19
19
|
import type { FhevmChain } from '../../types/fhevmChain.js';
|
|
20
20
|
import type { FhevmRuntime } from '../../types/coreFhevmRuntime.js';
|
|
21
21
|
import type { FhevmClientFrozenContext } from '../../types/fhevmClientFrozenContext-p.js';
|
|
22
|
+
import type { Auth } from '../../types/auth.js';
|
|
22
23
|
|
|
23
24
|
////////////////////////////////////////////////////////////////////////////////
|
|
24
25
|
//
|
|
@@ -152,7 +153,8 @@ export type FetchUserDecryptParametersV2 = {
|
|
|
152
153
|
}>;
|
|
153
154
|
readonly kmsDecryptEip712Signer: ChecksummedAddress;
|
|
154
155
|
readonly kmsDecryptEip712Message: KmsUserDecryptEip712V2Message;
|
|
155
|
-
|
|
156
|
+
// Variable length: 65-byte EOA, ERC-1271 blob, or empty `0x`.
|
|
157
|
+
readonly kmsDecryptEip712Signature: BytesHex;
|
|
156
158
|
};
|
|
157
159
|
readonly fhevmContext: FhevmClientFrozenContext;
|
|
158
160
|
readonly options?: RelayerUserDecryptOptions | undefined;
|
|
@@ -197,6 +199,27 @@ export type FetchDelegatedUserDecryptModuleFunction = {
|
|
|
197
199
|
): Promise<FetchDelegatedUserDecryptReturnType>;
|
|
198
200
|
};
|
|
199
201
|
|
|
202
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
203
|
+
// 6. fetchFeatures
|
|
204
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
205
|
+
|
|
206
|
+
export type FetchFeaturesParameters = {
|
|
207
|
+
readonly options?:
|
|
208
|
+
| {
|
|
209
|
+
readonly auth?: Auth | undefined;
|
|
210
|
+
}
|
|
211
|
+
| undefined;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
export type FetchFeaturesReturnType = { readonly relayerSupportsV3UserDecryptRoute: boolean };
|
|
215
|
+
|
|
216
|
+
export type FetchFeaturesModuleFunction = {
|
|
217
|
+
fetchFeatures(
|
|
218
|
+
relayerClient: RelayerClientWithRuntime,
|
|
219
|
+
parameters: FetchFeaturesParameters,
|
|
220
|
+
): Promise<FetchFeaturesReturnType>;
|
|
221
|
+
};
|
|
222
|
+
|
|
200
223
|
////////////////////////////////////////////////////////////////////////////////
|
|
201
224
|
// RelayerModule
|
|
202
225
|
////////////////////////////////////////////////////////////////////////////////
|
|
@@ -207,7 +230,8 @@ export type RelayerModule = Prettify<
|
|
|
207
230
|
FetchCoprocessorSignaturesModuleFunction &
|
|
208
231
|
FetchUserDecryptModuleFunction &
|
|
209
232
|
FetchPublicDecryptModuleFunction &
|
|
210
|
-
FetchDelegatedUserDecryptModuleFunction
|
|
233
|
+
FetchDelegatedUserDecryptModuleFunction &
|
|
234
|
+
FetchFeaturesModuleFunction
|
|
211
235
|
>;
|
|
212
236
|
|
|
213
237
|
// Relayer is a base module. It does not take any runtime argument
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { Auth } from '../types/auth.js';
|
|
2
|
+
import type { FhevmChain } from '../types/fhevmChain.js';
|
|
3
|
+
import type { FhevmRuntime } from '../types/coreFhevmRuntime.js';
|
|
4
|
+
import {
|
|
5
|
+
getRelayerFeatures,
|
|
6
|
+
getRelayerFeaturesPromise,
|
|
7
|
+
setRelayerFeatures,
|
|
8
|
+
setRelayerFeaturesPromise,
|
|
9
|
+
} from '../runtime/CoreFhevm-p.js';
|
|
10
|
+
import { resolveRelayerFeatures, type RelayerFeatures } from './resolveRelayerFeatures-p.js';
|
|
11
|
+
|
|
12
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
13
|
+
|
|
14
|
+
type Context = {
|
|
15
|
+
readonly runtime: FhevmRuntime;
|
|
16
|
+
readonly chain: FhevmChain;
|
|
17
|
+
readonly client: NonNullable<object>;
|
|
18
|
+
readonly options: { readonly batchRpcCalls: boolean };
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Resolves the client's relayer feature list **exactly once** and returns it, deduping concurrent
|
|
25
|
+
* callers onto a single in-flight fetch. The relayer-service sibling of `ensureFrozenContext`.
|
|
26
|
+
*
|
|
27
|
+
* ### Why this lives beside the frozen context, not inside it
|
|
28
|
+
*
|
|
29
|
+
* The frozen context is the *version basis*, resolved at `init()` from pure chain reads with **no
|
|
30
|
+
* inputs**. Relayer features are a *service capability*, fetched over HTTP and — critically —
|
|
31
|
+
* requiring an `Auth` that only arrives with a public action call, never at `init()`. So they
|
|
32
|
+
* cannot share the frozen context's resolution point, and they are resolved **lazily** here: at the
|
|
33
|
+
* first relayer action that carries an `Auth`.
|
|
34
|
+
*
|
|
35
|
+
* ### Auth is used only on the first resolution
|
|
36
|
+
*
|
|
37
|
+
* The result is Auth-independent (a deployment capability — see {@link RelayerFeatures}). The first
|
|
38
|
+
* caller's `auth` authorizes the one discovery request; the result is then pinned on the client and
|
|
39
|
+
* every later caller — regardless of its own `auth` — reads the same snapshot. This is what keeps a
|
|
40
|
+
* single per-client cache correct while avoiding dynamic drift.
|
|
41
|
+
*
|
|
42
|
+
* ### Lifecycle — promise while resolving, data afterwards (mirrors `ensureFrozenContext`)
|
|
43
|
+
*
|
|
44
|
+
* - Already stored on the client → return it immediately (no re-fetch).
|
|
45
|
+
* - Otherwise resolve once; on success store it (`setRelayerFeatures`) so later reads are
|
|
46
|
+
* synchronous, and drop the transient promise.
|
|
47
|
+
* - The transient promise is cleared once resolution settles either way (`.finally`), so a first
|
|
48
|
+
* attempt that fails — e.g. an auth-less call to an auth-required endpoint — does not poison later
|
|
49
|
+
* auth'd calls: the next caller retries, and the first success wins.
|
|
50
|
+
*
|
|
51
|
+
* All state lives on the client instance (`getRelayerFeatures` / `getRelayerFeaturesPromise`), so it
|
|
52
|
+
* is scoped to the client's lifecycle and safe to use per-request in a server component.
|
|
53
|
+
*
|
|
54
|
+
* NOTE: this depends on the client-instance accessors `getRelayerFeatures` / `setRelayerFeatures` /
|
|
55
|
+
* `getRelayerFeaturesPromise` / `setRelayerFeaturesPromise` being added to `CoreFhevm-p.ts`, exactly
|
|
56
|
+
* parallel to the frozen-context slot (`#frozenContext` / `#frozenContextPromise` + their symbols).
|
|
57
|
+
* Wiring those into `CoreFhevm-p.ts` is intentionally out of scope of this folder.
|
|
58
|
+
*
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
export async function ensureRelayerFeatures(
|
|
62
|
+
fhevm: Context,
|
|
63
|
+
parameters: { readonly auth?: Auth | undefined },
|
|
64
|
+
): Promise<RelayerFeatures> {
|
|
65
|
+
const existing = getRelayerFeatures(fhevm);
|
|
66
|
+
if (existing !== undefined) {
|
|
67
|
+
return existing;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let pending = getRelayerFeaturesPromise(fhevm);
|
|
71
|
+
if (pending === undefined) {
|
|
72
|
+
pending = resolveRelayerFeatures(fhevm, parameters)
|
|
73
|
+
.then((relayerFeatures) => {
|
|
74
|
+
setRelayerFeatures(fhevm, relayerFeatures);
|
|
75
|
+
return relayerFeatures;
|
|
76
|
+
})
|
|
77
|
+
.finally(() => {
|
|
78
|
+
setRelayerFeaturesPromise(fhevm, undefined);
|
|
79
|
+
});
|
|
80
|
+
setRelayerFeaturesPromise(fhevm, pending);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return pending;
|
|
84
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Auth } from '../types/auth.js';
|
|
2
|
+
import type { FhevmChain } from '../types/fhevmChain.js';
|
|
3
|
+
import type { FetchFeaturesReturnType } from '../modules/relayer/types.js';
|
|
4
|
+
import type { FhevmRuntime } from '../types/coreFhevmRuntime.js';
|
|
5
|
+
|
|
6
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
7
|
+
|
|
8
|
+
type Context = {
|
|
9
|
+
readonly runtime: FhevmRuntime;
|
|
10
|
+
readonly chain: FhevmChain;
|
|
11
|
+
readonly client: NonNullable<object>;
|
|
12
|
+
readonly options: { readonly batchRpcCalls: boolean };
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The relayer capability snapshot a client resolves **once** and then pins for its lifetime
|
|
19
|
+
* (currently just `relayerSupportsV3UserDecryptRoute`). It is the relayer-service analogue of the
|
|
20
|
+
* frozen context's version basis — but a *different category*: fetched over HTTP from the relayer,
|
|
21
|
+
* not derived from chain reads, so it lives beside {@link FhevmClientFrozenContext}, never inside it.
|
|
22
|
+
*
|
|
23
|
+
* **Auth-independent.** The feature list is a property of the relayer *deployment*, identical for
|
|
24
|
+
* every caller; an `Auth` (optional API key) is only needed to *reach* the discovery endpoint, and
|
|
25
|
+
* never changes the result. This is precisely what makes a single per-client resolution correct —
|
|
26
|
+
* were features per-caller, a per-client cache would be a correctness bug.
|
|
27
|
+
*/
|
|
28
|
+
export type RelayerFeatures = FetchFeaturesReturnType;
|
|
29
|
+
|
|
30
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Resolves the relayer feature list via the relayer module's `fetchFeatures`.
|
|
34
|
+
*
|
|
35
|
+
* Unlike `resolveFhevmClientFrozenContext` (pure chain reads, no inputs), this is a network call to
|
|
36
|
+
* the relayer whose discovery endpoint requires an `Auth`. The `auth` is threaded through purely to
|
|
37
|
+
* authorize the request; the returned {@link RelayerFeatures} does not depend on it (see the type
|
|
38
|
+
* doc above), so the caller is free to resolve once and reuse across callers with different auths.
|
|
39
|
+
*
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
export async function resolveRelayerFeatures(
|
|
43
|
+
fhevm: Context,
|
|
44
|
+
parameters: { readonly auth?: Auth | undefined },
|
|
45
|
+
): Promise<RelayerFeatures> {
|
|
46
|
+
return await fhevm.runtime.relayer.fetchFeatures(fhevm, { options: { auth: parameters.auth } });
|
|
47
|
+
}
|
|
@@ -15,6 +15,7 @@ import type { FhevmRuntime, WithModule, WithModuleMap } from '../types/coreFhevm
|
|
|
15
15
|
import type { FhevmClientFrozenContext } from '../types/fhevmClientFrozenContext-p.js';
|
|
16
16
|
import type { TfheVersion } from '../../wasm/tfhe/TfheApi.js';
|
|
17
17
|
import type { TkmsVersion } from '../../wasm/tkms/KmsLibApi.js';
|
|
18
|
+
import type { RelayerFeatures } from '../relayerFeatures/resolveRelayerFeatures-p.js';
|
|
18
19
|
import { InvalidTypeError } from '../base/errors/InvalidTypeError.js';
|
|
19
20
|
import { verifyTrustedValue } from '../base/trustedValue.js';
|
|
20
21
|
import { uid } from '../base/uid.js';
|
|
@@ -31,6 +32,10 @@ const GET_FROZEN_CONTEXT = Symbol('CoreFhevmHostClient.getFrozenContext');
|
|
|
31
32
|
const SET_FROZEN_CONTEXT = Symbol('CoreFhevmHostClient.setFrozenContext');
|
|
32
33
|
const GET_FROZEN_CONTEXT_PROMISE = Symbol('CoreFhevmHostClient.getFrozenContextPromise');
|
|
33
34
|
const SET_FROZEN_CONTEXT_PROMISE = Symbol('CoreFhevmHostClient.setFrozenContextPromise');
|
|
35
|
+
const GET_RELAYER_FEATURES = Symbol('CoreFhevmHostClient.getRelayerFeatures');
|
|
36
|
+
const SET_RELAYER_FEATURES = Symbol('CoreFhevmHostClient.setRelayerFeatures');
|
|
37
|
+
const GET_RELAYER_FEATURES_PROMISE = Symbol('CoreFhevmHostClient.getRelayerFeaturesPromise');
|
|
38
|
+
const SET_RELAYER_FEATURES_PROMISE = Symbol('CoreFhevmHostClient.setRelayerFeaturesPromise');
|
|
34
39
|
|
|
35
40
|
const UNRESOLVED_FHEVM_CONTEXT_MESSAGE = 'Fhevm context has not been resolved. Await client.ready before.';
|
|
36
41
|
|
|
@@ -38,6 +43,10 @@ type GetFrozenContextFn = () => FhevmClientFrozenContext | undefined;
|
|
|
38
43
|
type SetFrozenContextFn = (frozenContext: FhevmClientFrozenContext) => void;
|
|
39
44
|
type GetFrozenContextPromiseFn = () => Promise<FhevmClientFrozenContext> | undefined;
|
|
40
45
|
type SetFrozenContextPromiseFn = (frozenContextPromise: Promise<FhevmClientFrozenContext> | undefined) => void;
|
|
46
|
+
type GetRelayerFeaturesFn = () => RelayerFeatures | undefined;
|
|
47
|
+
type SetRelayerFeaturesFn = (relayerFeatures: RelayerFeatures) => void;
|
|
48
|
+
type GetRelayerFeaturesPromiseFn = () => Promise<RelayerFeatures> | undefined;
|
|
49
|
+
type SetRelayerFeaturesPromiseFn = (relayerFeaturesPromise: Promise<RelayerFeatures> | undefined) => void;
|
|
41
50
|
|
|
42
51
|
////////////////////////////////////////////////////////////////////////////////
|
|
43
52
|
// CoreFhevmImpl
|
|
@@ -52,6 +61,8 @@ class CoreFhevmImpl<
|
|
|
52
61
|
readonly #uid: string;
|
|
53
62
|
#frozenContext: FhevmClientFrozenContext | undefined;
|
|
54
63
|
#frozenContextPromise: Promise<FhevmClientFrozenContext> | undefined;
|
|
64
|
+
#relayerFeatures: RelayerFeatures | undefined;
|
|
65
|
+
#relayerFeaturesPromise: Promise<RelayerFeatures> | undefined;
|
|
55
66
|
readonly #runtime: runtime;
|
|
56
67
|
readonly #trustedClient: TrustedClient<client> | undefined;
|
|
57
68
|
readonly #chain: chain | undefined;
|
|
@@ -95,6 +106,8 @@ class CoreFhevmImpl<
|
|
|
95
106
|
this.#uid = uid();
|
|
96
107
|
this.#frozenContext = undefined;
|
|
97
108
|
this.#frozenContextPromise = undefined;
|
|
109
|
+
this.#relayerFeatures = undefined;
|
|
110
|
+
this.#relayerFeaturesPromise = undefined;
|
|
98
111
|
this.#trustedClient =
|
|
99
112
|
parameters.client !== undefined ? createTrustedClient(parameters.client, ownerToken) : undefined;
|
|
100
113
|
this.#chain = parameters.chain;
|
|
@@ -274,6 +287,38 @@ class CoreFhevmImpl<
|
|
|
274
287
|
enumerable: false,
|
|
275
288
|
writable: false,
|
|
276
289
|
},
|
|
290
|
+
[GET_RELAYER_FEATURES]: {
|
|
291
|
+
value: (): RelayerFeatures | undefined => this.#relayerFeatures,
|
|
292
|
+
configurable: false,
|
|
293
|
+
enumerable: false,
|
|
294
|
+
writable: false,
|
|
295
|
+
},
|
|
296
|
+
[SET_RELAYER_FEATURES]: {
|
|
297
|
+
// Plain overwrite: relayer features are resolved once (Auth-independent) and pinned.
|
|
298
|
+
value: (relayerFeatures: RelayerFeatures): void => {
|
|
299
|
+
this.#relayerFeatures = relayerFeatures;
|
|
300
|
+
},
|
|
301
|
+
configurable: false,
|
|
302
|
+
enumerable: false,
|
|
303
|
+
writable: false,
|
|
304
|
+
},
|
|
305
|
+
[GET_RELAYER_FEATURES_PROMISE]: {
|
|
306
|
+
value: (): Promise<RelayerFeatures> | undefined => this.#relayerFeaturesPromise,
|
|
307
|
+
configurable: false,
|
|
308
|
+
enumerable: false,
|
|
309
|
+
writable: false,
|
|
310
|
+
},
|
|
311
|
+
[SET_RELAYER_FEATURES_PROMISE]: {
|
|
312
|
+
// Transient: holds the single in-flight fetch so concurrent callers dedupe
|
|
313
|
+
// onto one promise; cleared once it settles (the resolved features are kept
|
|
314
|
+
// as data in #relayerFeatures).
|
|
315
|
+
value: (relayerFeaturesPromise: Promise<RelayerFeatures> | undefined): void => {
|
|
316
|
+
this.#relayerFeaturesPromise = relayerFeaturesPromise;
|
|
317
|
+
},
|
|
318
|
+
configurable: false,
|
|
319
|
+
enumerable: false,
|
|
320
|
+
writable: false,
|
|
321
|
+
},
|
|
277
322
|
extend: {
|
|
278
323
|
value: (actionsFactory: (client: typeof this) => FhevmExtension) =>
|
|
279
324
|
extendCoreFhevm(this, actionsFactory, (fn) => {
|
|
@@ -676,4 +721,30 @@ export function getFrozenContextPromise(fhevm: unknown): Promise<FhevmClientFroz
|
|
|
676
721
|
return f[GET_FROZEN_CONTEXT_PROMISE]();
|
|
677
722
|
}
|
|
678
723
|
|
|
724
|
+
// `fhevm` is typed `unknown` (like the getters): relayer features are resolved lazily from within
|
|
725
|
+
// internal `context`-typed decrypt helpers that carry a minimal client shape, not a full `FhevmBase`.
|
|
726
|
+
// `asCoreFhevm` validates at runtime that it is a genuine SDK client.
|
|
727
|
+
export function setRelayerFeatures(fhevm: unknown, relayerFeatures: RelayerFeatures): void {
|
|
728
|
+
const f = asCoreFhevm(fhevm) as CoreFhevm & { readonly [SET_RELAYER_FEATURES]: SetRelayerFeaturesFn };
|
|
729
|
+
f[SET_RELAYER_FEATURES](relayerFeatures);
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
export function getRelayerFeatures(fhevm: unknown): RelayerFeatures | undefined {
|
|
733
|
+
const f = asCoreFhevm(fhevm) as CoreFhevm & { readonly [GET_RELAYER_FEATURES]: GetRelayerFeaturesFn };
|
|
734
|
+
return f[GET_RELAYER_FEATURES]();
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
export function setRelayerFeaturesPromise(
|
|
738
|
+
fhevm: unknown,
|
|
739
|
+
relayerFeaturesPromise: Promise<RelayerFeatures> | undefined,
|
|
740
|
+
): void {
|
|
741
|
+
const f = asCoreFhevm(fhevm) as CoreFhevm & { readonly [SET_RELAYER_FEATURES_PROMISE]: SetRelayerFeaturesPromiseFn };
|
|
742
|
+
f[SET_RELAYER_FEATURES_PROMISE](relayerFeaturesPromise);
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
export function getRelayerFeaturesPromise(fhevm: unknown): Promise<RelayerFeatures> | undefined {
|
|
746
|
+
const f = asCoreFhevm(fhevm) as CoreFhevm & { readonly [GET_RELAYER_FEATURES_PROMISE]: GetRelayerFeaturesPromiseFn };
|
|
747
|
+
return f[GET_RELAYER_FEATURES_PROMISE]();
|
|
748
|
+
}
|
|
749
|
+
|
|
679
750
|
////////////////////////////////////////////////////////////////////////////////
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ModuleVersionCompatibilityCheck, TfheVersion, TkmsVersion } from '../types/moduleVersions.js';
|
|
2
2
|
import type { FhevmRuntime } from '../types/coreFhevmRuntime.js';
|
|
3
3
|
import type { FhevmProtocolContext, ResolvedFhevmOptions, VersionResolution } from '../types/coreFhevmClient.js';
|
|
4
|
-
import type { SemverRange } from '../base/semver.js';
|
|
4
|
+
import type { SemverInterval, SemverRange } from '../base/semver.js';
|
|
5
5
|
import type { Logger } from '../types/logger.js';
|
|
6
6
|
import { semverComparatorImpliesRange } from '../base/semver.js';
|
|
7
7
|
|
|
@@ -22,7 +22,7 @@ type WasmModuleKey = keyof WasmModuleVersionByKey;
|
|
|
22
22
|
type WasmModuleVersion<K extends WasmModuleKey> = WasmModuleVersionByKey[K];
|
|
23
23
|
|
|
24
24
|
type WasmCompatibilityRule = {
|
|
25
|
-
readonly protocol:
|
|
25
|
+
readonly protocol: SemverInterval;
|
|
26
26
|
readonly pubKeyCrs: SemverRange;
|
|
27
27
|
readonly tfhe: {
|
|
28
28
|
readonly canonical: TfheVersion;
|
|
@@ -69,7 +69,7 @@ const HYPER_WASM_SOLVER_CONFIG = {
|
|
|
69
69
|
compatibilityRules: [
|
|
70
70
|
{
|
|
71
71
|
// protocol.version <= 0.12.x
|
|
72
|
-
protocol: { version: '0.13.0', comparator: 'lt' },
|
|
72
|
+
protocol: { upperBound: { version: '0.13.0', comparator: 'lt' } },
|
|
73
73
|
// pubKeyCrs.version <= 1.5.x (ex: mainnet 1.4.0-alpha.3)
|
|
74
74
|
pubKeyCrs: { version: '1.6.0', comparator: 'lt' },
|
|
75
75
|
tfhe: {
|
|
@@ -82,8 +82,11 @@ const HYPER_WASM_SOLVER_CONFIG = {
|
|
|
82
82
|
},
|
|
83
83
|
},
|
|
84
84
|
{
|
|
85
|
-
// protocol.version
|
|
86
|
-
protocol: {
|
|
85
|
+
// 0.13.0 <= protocol.version < 0.14.0
|
|
86
|
+
protocol: {
|
|
87
|
+
lowerBound: { version: '0.13.0', comparator: 'ge' },
|
|
88
|
+
upperBound: { version: '0.14.0', comparator: 'lt' },
|
|
89
|
+
},
|
|
87
90
|
// pubKeyCrs.version <= 1.5.x (ex: mainnet 1.4.0-alpha.3)
|
|
88
91
|
pubKeyCrs: { version: '1.6.0', comparator: 'lt' },
|
|
89
92
|
tfhe: {
|
|
@@ -96,8 +99,11 @@ const HYPER_WASM_SOLVER_CONFIG = {
|
|
|
96
99
|
},
|
|
97
100
|
},
|
|
98
101
|
{
|
|
99
|
-
// protocol.version
|
|
100
|
-
protocol: {
|
|
102
|
+
// 0.13.0 <= protocol.version < 0.14.0
|
|
103
|
+
protocol: {
|
|
104
|
+
lowerBound: { version: '0.13.0', comparator: 'ge' },
|
|
105
|
+
upperBound: { version: '0.14.0', comparator: 'lt' },
|
|
106
|
+
},
|
|
101
107
|
// pubKeyCrs.version >= 1.6.0 (ex: localstack_v13)
|
|
102
108
|
pubKeyCrs: { version: '1.6.0', comparator: 'ge' },
|
|
103
109
|
tfhe: {
|
|
@@ -109,6 +115,34 @@ const HYPER_WASM_SOLVER_CONFIG = {
|
|
|
109
115
|
compatible: ['0.13.10', '0.13.20-0'],
|
|
110
116
|
},
|
|
111
117
|
},
|
|
118
|
+
{
|
|
119
|
+
// protocol.version >= 0.14.0
|
|
120
|
+
protocol: { lowerBound: { version: '0.14.0', comparator: 'ge' } },
|
|
121
|
+
// pubKeyCrs.version <= 1.5.x (ex: mainnet 1.4.0-alpha.3)
|
|
122
|
+
pubKeyCrs: { version: '1.6.0', comparator: 'lt' },
|
|
123
|
+
tfhe: {
|
|
124
|
+
canonical: '1.6.2',
|
|
125
|
+
compatible: ['1.5.3', '1.6.2'],
|
|
126
|
+
},
|
|
127
|
+
kms: {
|
|
128
|
+
canonical: '0.14.0-1',
|
|
129
|
+
compatible: ['0.13.10', '0.13.20-0', '0.14.0-1'],
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
// protocol.version >= 0.14.0
|
|
134
|
+
protocol: { lowerBound: { version: '0.14.0', comparator: 'ge' } },
|
|
135
|
+
// pubKeyCrs.version >= 1.6.0 (ex: localstack_v13)
|
|
136
|
+
pubKeyCrs: { version: '1.6.0', comparator: 'ge' },
|
|
137
|
+
tfhe: {
|
|
138
|
+
canonical: '1.6.2',
|
|
139
|
+
compatible: ['1.6.2'],
|
|
140
|
+
},
|
|
141
|
+
kms: {
|
|
142
|
+
canonical: '0.14.0-1',
|
|
143
|
+
compatible: ['0.13.10', '0.13.20-0', '0.14.0-1'],
|
|
144
|
+
},
|
|
145
|
+
},
|
|
112
146
|
],
|
|
113
147
|
} as const satisfies HyperWasmSolverConfig;
|
|
114
148
|
|
|
@@ -203,6 +237,7 @@ export function hyperWasmResolveTfheModuleVersion(
|
|
|
203
237
|
* `protocolVersion = eq:0.12.0, pubKeyCrsVersion = eq:1.5.4` -> `'0.13.10'`.
|
|
204
238
|
* `protocolVersion = eq:0.13.0, pubKeyCrsVersion = eq:1.4.0-alpha.3` -> `'0.13.20-0'`.
|
|
205
239
|
* `protocolVersion = eq:0.13.0, pubKeyCrsVersion = eq:1.6.1` -> `'0.13.20-0'`.
|
|
240
|
+
* `protocolVersion = eq:0.14.0, pubKeyCrsVersion = eq:1.6.1` -> `'0.14.0-1'`.
|
|
206
241
|
*/
|
|
207
242
|
export function hyperWasmResolveTkmsModuleVersion(
|
|
208
243
|
parameters: ResolveParameters,
|
|
@@ -295,7 +330,7 @@ function _resolveWasmCompatibilityRule(
|
|
|
295
330
|
function _findWasmCompatibilityRules(protocolContext: FhevmProtocolContext): WasmCompatibilityRule[] {
|
|
296
331
|
return WASM_COMPATIBILITY_RULES.filter(
|
|
297
332
|
(entry) =>
|
|
298
|
-
|
|
333
|
+
_versionResolutionImpliesInterval(protocolContext.protocolVersion, entry.protocol) &&
|
|
299
334
|
_versionResolutionImpliesRange(protocolContext.pubKeyCrsVersion, entry.pubKeyCrs),
|
|
300
335
|
);
|
|
301
336
|
}
|
|
@@ -304,6 +339,19 @@ function _versionResolutionImpliesRange(versionResolution: VersionResolution<str
|
|
|
304
339
|
return semverComparatorImpliesRange(versionResolution.version, versionResolution.comparator, range);
|
|
305
340
|
}
|
|
306
341
|
|
|
342
|
+
function _versionResolutionImpliesInterval(
|
|
343
|
+
versionResolution: VersionResolution<string>,
|
|
344
|
+
interval: SemverInterval,
|
|
345
|
+
): boolean {
|
|
346
|
+
if (interval.lowerBound !== undefined && !_versionResolutionImpliesRange(versionResolution, interval.lowerBound)) {
|
|
347
|
+
return false;
|
|
348
|
+
}
|
|
349
|
+
if (interval.upperBound !== undefined && !_versionResolutionImpliesRange(versionResolution, interval.upperBound)) {
|
|
350
|
+
return false;
|
|
351
|
+
}
|
|
352
|
+
return true;
|
|
353
|
+
}
|
|
354
|
+
|
|
307
355
|
function _resolveModuleVersionCompatibilityCheck(
|
|
308
356
|
checkCompatibility: ModuleVersionCompatibilityCheck | undefined,
|
|
309
357
|
): ModuleVersionCompatibilityCheck {
|
|
@@ -348,6 +396,7 @@ function _handleModuleVersionCompatibilityPolicy(
|
|
|
348
396
|
const resolvedCheckCompatibility = _resolveModuleVersionCompatibilityCheck(checkCompatibility);
|
|
349
397
|
switch (resolvedCheckCompatibility) {
|
|
350
398
|
case 'throw':
|
|
399
|
+
logger?.error?.(message, undefined);
|
|
351
400
|
throw new Error(message);
|
|
352
401
|
case 'warn':
|
|
353
402
|
logger?.warn?.(message);
|
|
@@ -23,12 +23,20 @@ export type ResolveProtocolContextParameters = ResolveProtocolVersionParameters;
|
|
|
23
23
|
export async function resolveProtocolContext(
|
|
24
24
|
parameters: ResolveProtocolContextParameters,
|
|
25
25
|
): Promise<FhevmProtocolContext> {
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
try {
|
|
27
|
+
const aclAddress = addressToChecksummedAddress(asAddress(parameters.chain.fhevm.contracts.acl.address));
|
|
28
|
+
const aclVersion = await getHostContractVersion(parameters, { address: aclAddress });
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
assertIsHostContractVersionOf(aclVersion, 'ACL');
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
return protocolContextFromAclVersion(parameters.chain, aclVersion);
|
|
33
|
+
} catch (e) {
|
|
34
|
+
parameters.runtime.config.logger?.error?.(
|
|
35
|
+
`Failed to resolve protocol context for chain ${parameters.chain.id} (ACL address=${parameters.chain.fhevm.contracts.acl.address}).`,
|
|
36
|
+
e,
|
|
37
|
+
);
|
|
38
|
+
throw e;
|
|
39
|
+
}
|
|
32
40
|
}
|
|
33
41
|
|
|
34
42
|
export async function resolveProtocolVersion(
|
|
@@ -5,5 +5,5 @@ import { decryptModule } from '../modules/decrypt/module/index.js';
|
|
|
5
5
|
export async function initFhevmDecryptRuntime(runtime: FhevmRuntime, ownerToken: symbol): Promise<void> {
|
|
6
6
|
verifyFhevmRuntime(runtime, ownerToken);
|
|
7
7
|
const decryptRuntime = runtime.extend(decryptModule);
|
|
8
|
-
await decryptRuntime.decrypt.initTkmsModule({ tkmsVersion: '0.
|
|
8
|
+
await decryptRuntime.decrypt.initTkmsModule({ tkmsVersion: '0.14.0-1' });
|
|
9
9
|
}
|
|
@@ -7,7 +7,7 @@ export async function initFhevmRuntime(runtime: FhevmRuntime, ownerToken: symbol
|
|
|
7
7
|
verifyFhevmRuntime(runtime, ownerToken);
|
|
8
8
|
const fullRuntime = runtime.extend(decryptModule).extend(encryptModule);
|
|
9
9
|
await Promise.all([
|
|
10
|
-
fullRuntime.decrypt.initTkmsModule({ tkmsVersion: '0.
|
|
10
|
+
fullRuntime.decrypt.initTkmsModule({ tkmsVersion: '0.14.0-1' }),
|
|
11
11
|
fullRuntime.encrypt.initTfheModule({ tfheVersion: '1.6.2' }),
|
|
12
12
|
]);
|
|
13
13
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The FHEVM protocol API version this SDK is using (currently `0.
|
|
2
|
+
* The FHEVM protocol API version this SDK is using (currently `0.14.0`).
|
|
3
3
|
*
|
|
4
4
|
* This is a static compile-time constant, distinct from the *dynamic*
|
|
5
5
|
* on-chain protocol version reported by `resolveProtocolVersion()` /
|
|
@@ -7,16 +7,15 @@
|
|
|
7
7
|
*
|
|
8
8
|
* ## Supported protocol versions
|
|
9
9
|
*
|
|
10
|
-
* This SDK natively supports FHEVM protocol **v11, v12, and
|
|
11
|
-
* each of their on-chain APIs and encodes requests accordingly.
|
|
10
|
+
* This SDK natively supports FHEVM protocol **v11, v12, v13, and v14** — it
|
|
11
|
+
* knows each of their on-chain APIs and encodes requests accordingly.
|
|
12
12
|
*
|
|
13
|
-
* It is also **guaranteed to work on
|
|
13
|
+
* It is also **guaranteed to work on v15 and later**: the FHEVM protocol
|
|
14
14
|
* guarantees backward compatibility, so a chain running a newer protocol
|
|
15
|
-
* version still accepts the
|
|
16
|
-
* SDK keeps using its
|
|
17
|
-
* not yet know about
|
|
18
|
-
* permits, which this SDK does not emit).
|
|
15
|
+
* version still accepts the v14 API this SDK speaks. Against such a chain the
|
|
16
|
+
* SDK keeps using its v14 API — it does not opt into any v15+ feature it does
|
|
17
|
+
* not yet know about.
|
|
19
18
|
*/
|
|
20
19
|
export const SDK_PROTOCOL_API_MAJOR_VERSION: number = 0;
|
|
21
|
-
export const SDK_PROTOCOL_API_MINOR_VERSION: number =
|
|
20
|
+
export const SDK_PROTOCOL_API_MINOR_VERSION: number = 14;
|
|
22
21
|
export const SDK_PROTOCOL_API_PATCH_VERSION: number = 0;
|
package/core/types/kms-p.ts
CHANGED
|
@@ -3,7 +3,6 @@ import type { Handle } from './encryptedTypes-p.js';
|
|
|
3
3
|
import type { KmsEip712Domain } from './kms.js';
|
|
4
4
|
import type { KmsSignersContext } from './kmsSignersContext.js';
|
|
5
5
|
import type {
|
|
6
|
-
Bytes65Hex,
|
|
7
6
|
Bytes65HexNo0x,
|
|
8
7
|
BytesHex,
|
|
9
8
|
BytesHexNo0x,
|
|
@@ -16,7 +15,8 @@ export interface KmsSigncryptedSharesMetadata {
|
|
|
16
15
|
readonly kmsSignersContext: KmsSignersContext;
|
|
17
16
|
readonly eip712ExtraData: BytesHex;
|
|
18
17
|
readonly eip712Domain: KmsEip712Domain;
|
|
19
|
-
|
|
18
|
+
// Variable length: 65-byte EOA, ERC-1271 blob, or empty `0x`.
|
|
19
|
+
readonly eip712Signature: BytesHex;
|
|
20
20
|
readonly eip712SignerAddress: ChecksummedAddress;
|
|
21
21
|
readonly handles: readonly Handle[];
|
|
22
22
|
readonly tkmsVersion: TkmsVersion;
|