@fhevm/sdk 1.1.0-alpha.6 → 1.1.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/_cjs/core/_version.js +1 -1
- package/_cjs/core/actions/base/index.js +1 -17
- package/_cjs/core/actions/base/index.js.map +1 -1
- package/_cjs/core/actions/base/signDecryptionPermit.js +0 -3
- package/_cjs/core/actions/base/signDecryptionPermit.js.map +1 -1
- package/_cjs/core/actions/chain/index.js +1 -13
- package/_cjs/core/actions/chain/index.js.map +1 -1
- package/_cjs/core/actions/chain/parseSignedDecryptionPermit.js.map +1 -1
- package/_cjs/core/actions/chain/serializeSignedDecryptionPermit.js.map +1 -1
- package/_cjs/core/actions/decrypt/canDecryptValue.js.map +1 -1
- package/_cjs/core/actions/decrypt/canDecryptValues.js.map +1 -1
- package/_cjs/core/actions/decrypt/canDecryptValuesFromPairs.js.map +1 -1
- package/_cjs/core/actions/decrypt/decryptValue.js +1 -0
- package/_cjs/core/actions/decrypt/decryptValue.js.map +1 -1
- package/_cjs/core/actions/decrypt/decryptValues.js +2 -0
- package/_cjs/core/actions/decrypt/decryptValues.js.map +1 -1
- package/_cjs/core/actions/decrypt/decryptValuesFromPairs.js +2 -0
- package/_cjs/core/actions/decrypt/decryptValuesFromPairs.js.map +1 -1
- package/_cjs/core/actions/decrypt/index.js +1 -3
- package/_cjs/core/actions/decrypt/index.js.map +1 -1
- package/_cjs/core/actions/encrypt/encryptValue.js +2 -1
- package/_cjs/core/actions/encrypt/encryptValue.js.map +1 -1
- package/_cjs/core/actions/encrypt/encryptValues.js +2 -1
- package/_cjs/core/actions/encrypt/encryptValues.js.map +1 -1
- package/_cjs/core/actions/encrypt/generateZkProof.js +2 -1
- package/_cjs/core/actions/encrypt/generateZkProof.js.map +1 -1
- package/_cjs/core/actions/host/index.js +1 -9
- package/_cjs/core/actions/host/index.js.map +1 -1
- package/_cjs/core/actions/host/readKmsVerifierContractData.js +1 -1
- package/_cjs/core/actions/host/readKmsVerifierContractData.js.map +1 -1
- package/_cjs/core/base/cachedFetch.js +2 -1
- package/_cjs/core/base/cachedFetch.js.map +1 -1
- package/_cjs/core/base/uint.js +7 -0
- package/_cjs/core/base/uint.js.map +1 -1
- package/_cjs/core/clients/decorators/base.js +1 -1
- package/_cjs/core/clients/decorators/base.js.map +1 -1
- package/_cjs/core/handle/FheType.js +4 -0
- package/_cjs/core/handle/FheType.js.map +1 -1
- package/_cjs/core/host-contracts/HostContractVersion-p.js +4 -0
- package/_cjs/core/host-contracts/HostContractVersion-p.js.map +1 -1
- package/_cjs/core/host-contracts/KmsSignersContext-p.js +15 -25
- package/_cjs/core/host-contracts/KmsSignersContext-p.js.map +1 -1
- package/_cjs/core/host-contracts/canDecryptValuesFromPairs.js +4 -1
- package/_cjs/core/host-contracts/canDecryptValuesFromPairs.js.map +1 -1
- package/_cjs/core/host-contracts/getCoprocessorContextSignersAndThreshold-p.js +1 -1
- package/_cjs/core/host-contracts/getCoprocessorContextSignersAndThreshold-p.js.map +1 -1
- package/_cjs/core/host-contracts/getCurrentKmsContextAndEpoch-p.js +1 -1
- package/_cjs/core/host-contracts/getCurrentKmsContextAndEpoch-p.js.map +1 -1
- package/_cjs/core/host-contracts/getCurrentKmsContextId-p.js +1 -1
- package/_cjs/core/host-contracts/getCurrentKmsContextId-p.js.map +1 -1
- package/_cjs/core/host-contracts/getKmsContextSignersAndThreshold-p.js +1 -1
- package/_cjs/core/host-contracts/getKmsContextSignersAndThreshold-p.js.map +1 -1
- package/_cjs/core/host-contracts/getKmsContextSignersAndThresholdFromExtraData-p.js +7 -6
- package/_cjs/core/host-contracts/getKmsContextSignersAndThresholdFromExtraData-p.js.map +1 -1
- package/_cjs/core/host-contracts/readKmsSignersContext-p.js +54 -66
- package/_cjs/core/host-contracts/readKmsSignersContext-p.js.map +1 -1
- package/_cjs/core/kms/KmsSigncryptedShares-p.js +40 -4
- package/_cjs/core/kms/KmsSigncryptedShares-p.js.map +1 -1
- package/_cjs/core/kms/PublicDecryptionProof-p.js +8 -7
- package/_cjs/core/kms/PublicDecryptionProof-p.js.map +1 -1
- package/_cjs/core/kms/SignedDecryptionPermit-p.js +33 -199
- package/_cjs/core/kms/SignedDecryptionPermit-p.js.map +1 -1
- package/_cjs/core/kms/SignedDecryptionPermitV1-p.js +204 -0
- package/_cjs/core/kms/SignedDecryptionPermitV1-p.js.map +1 -0
- package/_cjs/core/kms/SignedDecryptionPermitV2-p.js +172 -0
- package/_cjs/core/kms/SignedDecryptionPermitV2-p.js.map +1 -0
- package/_cjs/core/kms/{createKmsDelegatedUserDecryptEip712.js → createKmsDelegatedUserDecryptEip712V1.js} +12 -13
- package/_cjs/core/kms/createKmsDelegatedUserDecryptEip712V1.js.map +1 -0
- package/_cjs/core/kms/{createKmsUserDecryptEip712.js → createKmsUserDecryptEip712V1.js} +22 -21
- package/_cjs/core/kms/createKmsUserDecryptEip712V1.js.map +1 -0
- package/_cjs/core/kms/createKmsUserDecryptEip712V2.js +4 -5
- package/_cjs/core/kms/createKmsUserDecryptEip712V2.js.map +1 -1
- package/_cjs/core/kms/decryptValuesFromPairs.js +18 -2
- package/_cjs/core/kms/decryptValuesFromPairs.js.map +1 -1
- package/_cjs/core/kms/{fetchKmsSigncryptedShares-p.js → fetchKmsSigncryptedSharesV1-p.js} +19 -9
- package/_cjs/core/kms/fetchKmsSigncryptedSharesV1-p.js.map +1 -0
- package/_cjs/core/kms/fetchKmsSigncryptedSharesV2-p.js +95 -0
- package/_cjs/core/kms/fetchKmsSigncryptedSharesV2-p.js.map +1 -0
- package/_cjs/core/kms/{kmsDelegatedUserDecryptEip712Types.js → kmsDelegatedUserDecryptEip712V1Types.js} +8 -8
- package/_cjs/core/kms/kmsDelegatedUserDecryptEip712V1Types.js.map +1 -0
- package/_cjs/core/kms/kmsExtraData-p.js +234 -0
- package/_cjs/core/kms/kmsExtraData-p.js.map +1 -0
- package/_cjs/core/kms/{kmsUserDecryptEip712Types.js → kmsUserDecryptEip712V1Types.js} +8 -8
- package/_cjs/core/kms/kmsUserDecryptEip712V1Types.js.map +1 -0
- package/_cjs/core/kms/kmsUserDecryptEip712V2Types.js.map +1 -1
- package/_cjs/core/kms/publicDecrypt.js +5 -5
- package/_cjs/core/kms/publicDecrypt.js.map +1 -1
- package/_cjs/core/kms/utils.js +0 -19
- package/_cjs/core/kms/utils.js.map +1 -1
- package/_cjs/core/kms/verifyKmsPublicDecryptEip712-p.js +6 -5
- package/_cjs/core/kms/verifyKmsPublicDecryptEip712-p.js.map +1 -1
- package/_cjs/core/modules/decrypt/mock.js +6 -6
- package/_cjs/core/modules/decrypt/mock.js.map +1 -1
- package/_cjs/core/modules/decrypt/module/api-p.js +12 -12
- package/_cjs/core/modules/decrypt/module/api-p.js.map +1 -1
- package/_cjs/core/modules/decrypt/module/init-p.js +6 -7
- package/_cjs/core/modules/decrypt/module/init-p.js.map +1 -1
- package/_cjs/core/modules/encrypt/module/init-p.js +12 -11
- package/_cjs/core/modules/encrypt/module/init-p.js.map +1 -1
- package/_cjs/core/modules/relayer/cleartext/fetchCoprocessorSignatures.js +53 -3
- package/_cjs/core/modules/relayer/cleartext/fetchCoprocessorSignatures.js.map +1 -1
- package/_cjs/core/modules/relayer/cleartext/{fetchDelegatedUserDecrypt.js → fetchDelegatedUserDecryptV1.js} +67 -21
- package/_cjs/core/modules/relayer/cleartext/fetchDelegatedUserDecryptV1.js.map +1 -0
- package/_cjs/core/modules/relayer/cleartext/fetchPublicDecrypt.js +64 -7
- package/_cjs/core/modules/relayer/cleartext/fetchPublicDecrypt.js.map +1 -1
- package/_cjs/core/modules/relayer/cleartext/fetchUserDecrypt.js +9 -108
- package/_cjs/core/modules/relayer/cleartext/fetchUserDecrypt.js.map +1 -1
- package/_cjs/core/modules/relayer/cleartext/fetchUserDecryptV1.js +163 -0
- package/_cjs/core/modules/relayer/cleartext/fetchUserDecryptV1.js.map +1 -0
- package/_cjs/core/modules/relayer/cleartext/fetchUserDecryptV2.js +7 -0
- package/_cjs/core/modules/relayer/cleartext/fetchUserDecryptV2.js.map +1 -0
- package/_cjs/core/modules/relayer/cleartext/forgeFhevmV1.js +83 -0
- package/_cjs/core/modules/relayer/cleartext/forgeFhevmV1.js.map +1 -0
- package/_cjs/core/modules/relayer/cleartext/mock.js +2 -2
- package/_cjs/core/modules/relayer/cleartext/mock.js.map +1 -1
- package/_cjs/core/modules/relayer/cleartext/signers.js +14 -0
- package/_cjs/core/modules/relayer/cleartext/signers.js.map +1 -1
- package/_cjs/core/modules/relayer/module/{fetchDelegatedUserDecrypt.js → fetchDelegatedUserDecryptV1.js} +1 -1
- package/_cjs/core/modules/relayer/module/fetchDelegatedUserDecryptV1.js.map +1 -0
- package/_cjs/core/modules/relayer/module/fetchPublicDecrypt.js +1 -1
- package/_cjs/core/modules/relayer/module/fetchUserDecrypt.js +11 -45
- package/_cjs/core/modules/relayer/module/fetchUserDecrypt.js.map +1 -1
- package/_cjs/core/modules/relayer/module/fetchUserDecryptV1.js +52 -0
- package/_cjs/core/modules/relayer/module/fetchUserDecryptV1.js.map +1 -0
- package/_cjs/core/modules/relayer/module/fetchUserDecryptV2.js +54 -0
- package/_cjs/core/modules/relayer/module/fetchUserDecryptV2.js.map +1 -0
- package/_cjs/core/modules/relayer/module/guards/RelayerResponseFailed.js +10 -2
- package/_cjs/core/modules/relayer/module/guards/RelayerResponseFailed.js.map +1 -1
- package/_cjs/core/modules/relayer/module/guards/api-errors/RelayerApiError400NoDetails.js +5 -2
- package/_cjs/core/modules/relayer/module/guards/api-errors/RelayerApiError400NoDetails.js.map +1 -1
- package/_cjs/core/modules/relayer/module/guards/api-errors/RelayerApiError503.js +2 -0
- package/_cjs/core/modules/relayer/module/guards/api-errors/RelayerApiError503.js.map +1 -1
- package/_cjs/core/modules/relayer/module/index.js +2 -2
- package/_cjs/core/modules/relayer/module/index.js.map +1 -1
- package/_cjs/core/runtime/HyperWasmSolver-p.js +1 -6
- package/_cjs/core/runtime/HyperWasmSolver-p.js.map +1 -1
- package/_cjs/core/utils-p/decrypt/{verifyKmsDelegatedUserDecryptEip712.js → verifyKmsDelegatedUserDecryptEip712V1.js} +5 -5
- package/_cjs/core/utils-p/decrypt/verifyKmsDelegatedUserDecryptEip712V1.js.map +1 -0
- package/_cjs/core/utils-p/decrypt/{verifyKmsUserDecryptEip712.js → verifyKmsUserDecryptEip712V1.js} +5 -5
- package/_cjs/core/utils-p/decrypt/verifyKmsUserDecryptEip712V1.js.map +1 -0
- package/_cjs/core/utils-p/decrypt/verifyKmsUserDecryptEip712V2.js +30 -0
- package/_cjs/core/utils-p/decrypt/verifyKmsUserDecryptEip712V2.js.map +1 -0
- package/_cjs/ethers/internal/ethereum-ct.js +11 -0
- package/_cjs/ethers/internal/ethereum-ct.js.map +1 -1
- package/_cjs/ethers/internal/runtime-ct.js +9 -7
- package/_cjs/ethers/internal/runtime-ct.js.map +1 -1
- package/_cjs/viem/internal/ethereum-ct.js +8 -0
- package/_cjs/viem/internal/ethereum-ct.js.map +1 -1
- package/_cjs/viem/internal/runtime-ct.js +9 -7
- package/_cjs/viem/internal/runtime-ct.js.map +1 -1
- package/_cjs/wasm/tfhe/loadTfheLib.js.map +1 -1
- package/_cjs/wasm/tkms/loadKmsLib.js.map +1 -1
- package/_esm/core/_version.js +1 -1
- package/_esm/core/actions/base/index.js +0 -8
- package/_esm/core/actions/base/index.js.map +1 -1
- package/_esm/core/actions/base/signDecryptionPermit.js +0 -6
- package/_esm/core/actions/base/signDecryptionPermit.js.map +1 -1
- package/_esm/core/actions/chain/index.js +0 -6
- package/_esm/core/actions/chain/index.js.map +1 -1
- package/_esm/core/actions/chain/parseSignedDecryptionPermit.js.map +1 -1
- package/_esm/core/actions/chain/serializeSignedDecryptionPermit.js.map +1 -1
- package/_esm/core/actions/decrypt/canDecryptValue.js +40 -0
- package/_esm/core/actions/decrypt/canDecryptValue.js.map +1 -1
- package/_esm/core/actions/decrypt/canDecryptValues.js +1 -0
- package/_esm/core/actions/decrypt/canDecryptValues.js.map +1 -1
- package/_esm/core/actions/decrypt/canDecryptValuesFromPairs.js +1 -0
- package/_esm/core/actions/decrypt/canDecryptValuesFromPairs.js.map +1 -1
- package/_esm/core/actions/decrypt/decryptValue.js +1 -0
- package/_esm/core/actions/decrypt/decryptValue.js.map +1 -1
- package/_esm/core/actions/decrypt/decryptValues.js +2 -0
- package/_esm/core/actions/decrypt/decryptValues.js.map +1 -1
- package/_esm/core/actions/decrypt/decryptValuesFromPairs.js +2 -0
- package/_esm/core/actions/decrypt/decryptValuesFromPairs.js.map +1 -1
- package/_esm/core/actions/decrypt/index.js +0 -1
- package/_esm/core/actions/decrypt/index.js.map +1 -1
- package/_esm/core/actions/encrypt/encryptValue.js +2 -1
- package/_esm/core/actions/encrypt/encryptValue.js.map +1 -1
- package/_esm/core/actions/encrypt/encryptValues.js +2 -1
- package/_esm/core/actions/encrypt/encryptValues.js.map +1 -1
- package/_esm/core/actions/encrypt/generateZkProof.js +2 -1
- package/_esm/core/actions/encrypt/generateZkProof.js.map +1 -1
- package/_esm/core/actions/host/index.js +0 -4
- package/_esm/core/actions/host/index.js.map +1 -1
- package/_esm/core/actions/host/readKmsVerifierContractData.js +2 -2
- package/_esm/core/actions/host/readKmsVerifierContractData.js.map +1 -1
- package/_esm/core/base/cachedFetch.js +1 -0
- package/_esm/core/base/cachedFetch.js.map +1 -1
- package/_esm/core/base/uint.js +7 -0
- package/_esm/core/base/uint.js.map +1 -1
- package/_esm/core/clients/decorators/base.js +2 -4
- package/_esm/core/clients/decorators/base.js.map +1 -1
- package/_esm/core/coprocessor/coprocessorEip712Types.js +2 -2
- package/_esm/core/handle/FheType.js +10 -0
- package/_esm/core/handle/FheType.js.map +1 -1
- package/_esm/core/host-contracts/HostContractVersion-p.js +6 -0
- package/_esm/core/host-contracts/HostContractVersion-p.js.map +1 -1
- package/_esm/core/host-contracts/KmsSignersContext-p.js +16 -25
- package/_esm/core/host-contracts/KmsSignersContext-p.js.map +1 -1
- package/_esm/core/host-contracts/canDecryptValuesFromPairs.js +5 -2
- package/_esm/core/host-contracts/canDecryptValuesFromPairs.js.map +1 -1
- package/_esm/core/host-contracts/getCoprocessorContextSignersAndThreshold-p.js +2 -2
- package/_esm/core/host-contracts/getCoprocessorContextSignersAndThreshold-p.js.map +1 -1
- package/_esm/core/host-contracts/getCurrentKmsContextAndEpoch-p.js +2 -2
- package/_esm/core/host-contracts/getCurrentKmsContextAndEpoch-p.js.map +1 -1
- package/_esm/core/host-contracts/getCurrentKmsContextId-p.js +2 -2
- package/_esm/core/host-contracts/getCurrentKmsContextId-p.js.map +1 -1
- package/_esm/core/host-contracts/getKmsContextSignersAndThreshold-p.js +2 -2
- package/_esm/core/host-contracts/getKmsContextSignersAndThreshold-p.js.map +1 -1
- package/_esm/core/host-contracts/getKmsContextSignersAndThresholdFromExtraData-p.js +6 -5
- package/_esm/core/host-contracts/getKmsContextSignersAndThresholdFromExtraData-p.js.map +1 -1
- package/_esm/core/host-contracts/readKmsSignersContext-p.js +132 -68
- package/_esm/core/host-contracts/readKmsSignersContext-p.js.map +1 -1
- package/_esm/core/kms/KmsSigncryptedShares-p.js +70 -4
- package/_esm/core/kms/KmsSigncryptedShares-p.js.map +1 -1
- package/_esm/core/kms/PublicDecryptionProof-p.js +8 -7
- package/_esm/core/kms/PublicDecryptionProof-p.js.map +1 -1
- package/_esm/core/kms/SignedDecryptionPermit-p.js +48 -245
- package/_esm/core/kms/SignedDecryptionPermit-p.js.map +1 -1
- package/_esm/core/kms/SignedDecryptionPermitV1-p.js +228 -0
- package/_esm/core/kms/SignedDecryptionPermitV1-p.js.map +1 -0
- package/_esm/core/kms/SignedDecryptionPermitV2-p.js +192 -0
- package/_esm/core/kms/SignedDecryptionPermitV2-p.js.map +1 -0
- package/_esm/core/kms/{createKmsDelegatedUserDecryptEip712.js → createKmsDelegatedUserDecryptEip712V1.js} +11 -12
- package/_esm/core/kms/createKmsDelegatedUserDecryptEip712V1.js.map +1 -0
- package/_esm/core/kms/createKmsPublicDecryptEip712.js +1 -1
- package/_esm/core/kms/{createKmsUserDecryptEip712.js → createKmsUserDecryptEip712V1.js} +23 -22
- package/_esm/core/kms/createKmsUserDecryptEip712V1.js.map +1 -0
- package/_esm/core/kms/createKmsUserDecryptEip712V2.js +4 -5
- package/_esm/core/kms/createKmsUserDecryptEip712V2.js.map +1 -1
- package/_esm/core/kms/decryptValuesFromPairs.js +18 -2
- package/_esm/core/kms/decryptValuesFromPairs.js.map +1 -1
- package/_esm/core/kms/{fetchKmsSigncryptedShares-p.js → fetchKmsSigncryptedSharesV1-p.js} +49 -15
- package/_esm/core/kms/fetchKmsSigncryptedSharesV1-p.js.map +1 -0
- package/_esm/core/kms/fetchKmsSigncryptedSharesV2-p.js +119 -0
- package/_esm/core/kms/fetchKmsSigncryptedSharesV2-p.js.map +1 -0
- package/_esm/core/kms/{kmsDelegatedUserDecryptEip712Types.js → kmsDelegatedUserDecryptEip712V1Types.js} +9 -8
- package/_esm/core/kms/kmsDelegatedUserDecryptEip712V1Types.js.map +1 -0
- package/_esm/core/kms/kmsExtraData-p.js +298 -0
- package/_esm/core/kms/kmsExtraData-p.js.map +1 -0
- package/_esm/core/kms/kmsPublicDecryptEip712Types.js +1 -1
- package/_esm/core/kms/{kmsUserDecryptEip712Types.js → kmsUserDecryptEip712V1Types.js} +9 -8
- package/_esm/core/kms/kmsUserDecryptEip712V1Types.js.map +1 -0
- package/_esm/core/kms/kmsUserDecryptEip712V2Types.js +2 -1
- package/_esm/core/kms/kmsUserDecryptEip712V2Types.js.map +1 -1
- package/_esm/core/kms/publicDecrypt.js +6 -6
- package/_esm/core/kms/publicDecrypt.js.map +1 -1
- package/_esm/core/kms/utils.js +0 -18
- package/_esm/core/kms/utils.js.map +1 -1
- package/_esm/core/kms/verifyKmsPublicDecryptEip712-p.js +7 -6
- package/_esm/core/kms/verifyKmsPublicDecryptEip712-p.js.map +1 -1
- package/_esm/core/modules/decrypt/mock.js +6 -6
- package/_esm/core/modules/decrypt/mock.js.map +1 -1
- package/_esm/core/modules/decrypt/module/api-p.js +13 -13
- package/_esm/core/modules/decrypt/module/api-p.js.map +1 -1
- package/_esm/core/modules/decrypt/module/init-p.js +7 -7
- package/_esm/core/modules/decrypt/module/init-p.js.map +1 -1
- package/_esm/core/modules/encrypt/module/init-p.js +13 -11
- package/_esm/core/modules/encrypt/module/init-p.js.map +1 -1
- package/_esm/core/modules/relayer/cleartext/fetchCoprocessorSignatures.js +69 -12
- package/_esm/core/modules/relayer/cleartext/fetchCoprocessorSignatures.js.map +1 -1
- package/_esm/core/modules/relayer/cleartext/{fetchDelegatedUserDecrypt.js → fetchDelegatedUserDecryptV1.js} +76 -22
- package/_esm/core/modules/relayer/cleartext/fetchDelegatedUserDecryptV1.js.map +1 -0
- package/_esm/core/modules/relayer/cleartext/fetchPublicDecrypt.js +80 -7
- package/_esm/core/modules/relayer/cleartext/fetchPublicDecrypt.js.map +1 -1
- package/_esm/core/modules/relayer/cleartext/fetchUserDecrypt.js +13 -114
- package/_esm/core/modules/relayer/cleartext/fetchUserDecrypt.js.map +1 -1
- package/_esm/core/modules/relayer/cleartext/fetchUserDecryptV1.js +173 -0
- package/_esm/core/modules/relayer/cleartext/fetchUserDecryptV1.js.map +1 -0
- package/_esm/core/modules/relayer/cleartext/fetchUserDecryptV2.js +6 -0
- package/_esm/core/modules/relayer/cleartext/fetchUserDecryptV2.js.map +1 -0
- package/_esm/core/modules/relayer/cleartext/forgeFhevmV1.js +140 -0
- package/_esm/core/modules/relayer/cleartext/forgeFhevmV1.js.map +1 -0
- package/_esm/core/modules/relayer/cleartext/mock.js +1 -1
- package/_esm/core/modules/relayer/cleartext/mock.js.map +1 -1
- package/_esm/core/modules/relayer/cleartext/signers.js +26 -0
- package/_esm/core/modules/relayer/cleartext/signers.js.map +1 -1
- package/_esm/core/modules/relayer/module/{fetchDelegatedUserDecrypt.js → fetchDelegatedUserDecryptV1.js} +1 -1
- package/_esm/core/modules/relayer/module/fetchDelegatedUserDecryptV1.js.map +1 -0
- package/_esm/core/modules/relayer/module/fetchPublicDecrypt.js +1 -1
- package/_esm/core/modules/relayer/module/fetchUserDecrypt.js +11 -46
- package/_esm/core/modules/relayer/module/fetchUserDecrypt.js.map +1 -1
- package/_esm/core/modules/relayer/module/fetchUserDecryptV1.js +53 -0
- package/_esm/core/modules/relayer/module/fetchUserDecryptV1.js.map +1 -0
- package/_esm/core/modules/relayer/module/fetchUserDecryptV2.js +56 -0
- package/_esm/core/modules/relayer/module/fetchUserDecryptV2.js.map +1 -0
- package/_esm/core/modules/relayer/module/guards/RelayerResponseFailed.js +10 -2
- package/_esm/core/modules/relayer/module/guards/RelayerResponseFailed.js.map +1 -1
- package/_esm/core/modules/relayer/module/guards/api-errors/RelayerApiError400NoDetails.js +6 -3
- package/_esm/core/modules/relayer/module/guards/api-errors/RelayerApiError400NoDetails.js.map +1 -1
- package/_esm/core/modules/relayer/module/guards/api-errors/RelayerApiError503.js +2 -0
- package/_esm/core/modules/relayer/module/guards/api-errors/RelayerApiError503.js.map +1 -1
- package/_esm/core/modules/relayer/module/index.js +1 -1
- package/_esm/core/modules/relayer/module/index.js.map +1 -1
- package/_esm/core/runtime/HyperWasmSolver-p.js +1 -6
- package/_esm/core/runtime/HyperWasmSolver-p.js.map +1 -1
- package/_esm/core/utils-p/decrypt/{verifyKmsDelegatedUserDecryptEip712.js → verifyKmsDelegatedUserDecryptEip712V1.js} +5 -5
- package/_esm/core/utils-p/decrypt/verifyKmsDelegatedUserDecryptEip712V1.js.map +1 -0
- package/_esm/core/utils-p/decrypt/{verifyKmsUserDecryptEip712.js → verifyKmsUserDecryptEip712V1.js} +5 -5
- package/_esm/core/utils-p/decrypt/verifyKmsUserDecryptEip712V1.js.map +1 -0
- package/_esm/core/utils-p/decrypt/verifyKmsUserDecryptEip712V2.js +27 -0
- package/_esm/core/utils-p/decrypt/verifyKmsUserDecryptEip712V2.js.map +1 -0
- package/_esm/ethers/internal/ethereum-ct.js +12 -1
- package/_esm/ethers/internal/ethereum-ct.js.map +1 -1
- package/_esm/ethers/internal/runtime-ct.js +9 -7
- package/_esm/ethers/internal/runtime-ct.js.map +1 -1
- package/_esm/viem/internal/ethereum-ct.js +10 -2
- package/_esm/viem/internal/ethereum-ct.js.map +1 -1
- package/_esm/viem/internal/runtime-ct.js +9 -7
- package/_esm/viem/internal/runtime-ct.js.map +1 -1
- package/_types/core/actions/base/index.d.ts +0 -8
- package/_types/core/actions/base/index.d.ts.map +1 -1
- package/_types/core/actions/base/signDecryptionPermit.d.ts +4 -5
- package/_types/core/actions/base/signDecryptionPermit.d.ts.map +1 -1
- package/_types/core/actions/chain/index.d.ts +1 -7
- package/_types/core/actions/chain/index.d.ts.map +1 -1
- package/_types/core/actions/chain/parseSignedDecryptionPermit.d.ts +1 -0
- package/_types/core/actions/chain/parseSignedDecryptionPermit.d.ts.map +1 -1
- package/_types/core/actions/chain/serializeSignedDecryptionPermit.d.ts +3 -2
- package/_types/core/actions/chain/serializeSignedDecryptionPermit.d.ts.map +1 -1
- package/_types/core/actions/decrypt/canDecryptValue.d.ts +3 -4
- package/_types/core/actions/decrypt/canDecryptValue.d.ts.map +1 -1
- package/_types/core/actions/decrypt/canDecryptValues.d.ts +3 -4
- package/_types/core/actions/decrypt/canDecryptValues.d.ts.map +1 -1
- package/_types/core/actions/decrypt/canDecryptValuesFromPairs.d.ts +3 -4
- package/_types/core/actions/decrypt/canDecryptValuesFromPairs.d.ts.map +1 -1
- package/_types/core/actions/decrypt/decryptValue.d.ts.map +1 -1
- package/_types/core/actions/decrypt/decryptValues.d.ts.map +1 -1
- package/_types/core/actions/decrypt/decryptValuesFromPairs.d.ts.map +1 -1
- package/_types/core/actions/decrypt/index.d.ts +0 -1
- package/_types/core/actions/decrypt/index.d.ts.map +1 -1
- package/_types/core/actions/encrypt/encryptValue.d.ts.map +1 -1
- package/_types/core/actions/encrypt/encryptValues.d.ts.map +1 -1
- package/_types/core/actions/encrypt/generateZkProof.d.ts.map +1 -1
- package/_types/core/actions/host/index.d.ts +0 -4
- package/_types/core/actions/host/index.d.ts.map +1 -1
- package/_types/core/base/cachedFetch.d.ts +1 -0
- package/_types/core/base/cachedFetch.d.ts.map +1 -1
- package/_types/core/base/uint.d.ts +2 -1
- package/_types/core/base/uint.d.ts.map +1 -1
- package/_types/core/clients/decorators/base.d.ts +12 -23
- package/_types/core/clients/decorators/base.d.ts.map +1 -1
- package/_types/core/handle/FheType.d.ts +8 -0
- package/_types/core/handle/FheType.d.ts.map +1 -1
- package/_types/core/host-contracts/HostContractVersion-p.d.ts +8 -0
- package/_types/core/host-contracts/HostContractVersion-p.d.ts.map +1 -1
- package/_types/core/host-contracts/KmsSignersContext-p.d.ts +3 -2
- package/_types/core/host-contracts/KmsSignersContext-p.d.ts.map +1 -1
- package/_types/core/host-contracts/canDecryptValuesFromPairs.d.ts +2 -2
- package/_types/core/host-contracts/canDecryptValuesFromPairs.d.ts.map +1 -1
- package/_types/core/host-contracts/getKmsContextSignersAndThresholdFromExtraData-p.d.ts +3 -2
- package/_types/core/host-contracts/getKmsContextSignersAndThresholdFromExtraData-p.d.ts.map +1 -1
- package/_types/core/host-contracts/readKmsSignersContext-p.d.ts +43 -26
- package/_types/core/host-contracts/readKmsSignersContext-p.d.ts.map +1 -1
- package/_types/core/kms/KmsSigncryptedShares-p.d.ts +18 -0
- package/_types/core/kms/KmsSigncryptedShares-p.d.ts.map +1 -1
- package/_types/core/kms/PublicDecryptionProof-p.d.ts +1 -1
- package/_types/core/kms/PublicDecryptionProof-p.d.ts.map +1 -1
- package/_types/core/kms/SignedDecryptionPermit-p.d.ts +15 -29
- package/_types/core/kms/SignedDecryptionPermit-p.d.ts.map +1 -1
- package/_types/core/kms/SignedDecryptionPermitV1-p.d.ts +7 -0
- package/_types/core/kms/SignedDecryptionPermitV1-p.d.ts.map +1 -0
- package/_types/core/kms/SignedDecryptionPermitV2-p.d.ts +7 -0
- package/_types/core/kms/SignedDecryptionPermitV2-p.d.ts.map +1 -0
- package/_types/core/kms/createKmsDelegatedUserDecryptEip712V1.d.ts +16 -0
- package/_types/core/kms/createKmsDelegatedUserDecryptEip712V1.d.ts.map +1 -0
- package/_types/core/kms/createKmsUserDecryptEip712V1.d.ts +27 -0
- package/_types/core/kms/createKmsUserDecryptEip712V1.d.ts.map +1 -0
- package/_types/core/kms/createKmsUserDecryptEip712V2.d.ts +3 -2
- package/_types/core/kms/createKmsUserDecryptEip712V2.d.ts.map +1 -1
- package/_types/core/kms/decryptValuesFromPairs.d.ts +4 -11
- package/_types/core/kms/decryptValuesFromPairs.d.ts.map +1 -1
- package/_types/core/kms/{fetchKmsSigncryptedShares-p.d.ts → fetchKmsSigncryptedSharesV1-p.d.ts} +10 -12
- package/_types/core/kms/fetchKmsSigncryptedSharesV1-p.d.ts.map +1 -0
- package/_types/core/kms/fetchKmsSigncryptedSharesV2-p.d.ts +28 -0
- package/_types/core/kms/fetchKmsSigncryptedSharesV2-p.d.ts.map +1 -0
- package/_types/core/kms/kmsDelegatedUserDecryptEip712V1Types.d.ts +3 -0
- package/_types/core/kms/kmsDelegatedUserDecryptEip712V1Types.d.ts.map +1 -0
- package/_types/core/kms/kmsExtraData-p.d.ts +66 -0
- package/_types/core/kms/kmsExtraData-p.d.ts.map +1 -0
- package/_types/core/kms/kmsUserDecryptEip712V1Types.d.ts +3 -0
- package/_types/core/kms/kmsUserDecryptEip712V1Types.d.ts.map +1 -0
- package/_types/core/kms/kmsUserDecryptEip712V2Types.d.ts.map +1 -1
- package/_types/core/kms/publicDecrypt.d.ts.map +1 -1
- package/_types/core/kms/utils.d.ts +0 -4
- package/_types/core/kms/utils.d.ts.map +1 -1
- package/_types/core/kms/verifyKmsPublicDecryptEip712-p.d.ts +1 -1
- package/_types/core/kms/verifyKmsPublicDecryptEip712-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-ct.d.ts +20 -2
- package/_types/core/modules/ethereum/types-ct.d.ts.map +1 -1
- package/_types/core/modules/relayer/cleartext/fetchCoprocessorSignatures.d.ts.map +1 -1
- package/_types/core/modules/relayer/cleartext/{fetchDelegatedUserDecrypt.d.ts → fetchDelegatedUserDecryptV1.d.ts} +1 -1
- package/_types/core/modules/relayer/cleartext/fetchDelegatedUserDecryptV1.d.ts.map +1 -0
- package/_types/core/modules/relayer/cleartext/fetchPublicDecrypt.d.ts.map +1 -1
- package/_types/core/modules/relayer/cleartext/fetchUserDecrypt.d.ts.map +1 -1
- package/_types/core/modules/relayer/cleartext/fetchUserDecryptV1.d.ts +3 -0
- package/_types/core/modules/relayer/cleartext/fetchUserDecryptV1.d.ts.map +1 -0
- package/_types/core/modules/relayer/cleartext/fetchUserDecryptV2.d.ts +3 -0
- package/_types/core/modules/relayer/cleartext/fetchUserDecryptV2.d.ts.map +1 -0
- package/_types/core/modules/relayer/cleartext/forgeFhevmV1.d.ts +29 -0
- package/_types/core/modules/relayer/cleartext/forgeFhevmV1.d.ts.map +1 -0
- package/_types/core/modules/relayer/cleartext/signers.d.ts +1 -0
- package/_types/core/modules/relayer/cleartext/signers.d.ts.map +1 -1
- package/_types/core/modules/relayer/module/{fetchDelegatedUserDecrypt.d.ts → fetchDelegatedUserDecryptV1.d.ts} +1 -1
- package/_types/core/modules/relayer/module/fetchDelegatedUserDecryptV1.d.ts.map +1 -0
- package/_types/core/modules/relayer/module/fetchUserDecrypt.d.ts.map +1 -1
- package/_types/core/modules/relayer/module/fetchUserDecryptV1.d.ts +3 -0
- package/_types/core/modules/relayer/module/fetchUserDecryptV1.d.ts.map +1 -0
- package/_types/core/modules/relayer/module/fetchUserDecryptV2.d.ts +3 -0
- package/_types/core/modules/relayer/module/fetchUserDecryptV2.d.ts.map +1 -0
- package/_types/core/modules/relayer/module/guards/RelayerResponseFailed.d.ts.map +1 -1
- package/_types/core/modules/relayer/module/guards/api-errors/RelayerApiError400NoDetails.d.ts +1 -1
- package/_types/core/modules/relayer/module/guards/api-errors/RelayerApiError400NoDetails.d.ts.map +1 -1
- package/_types/core/modules/relayer/module/guards/api-errors/RelayerApiError503.d.ts.map +1 -1
- package/_types/core/modules/relayer/types.d.ts +18 -5
- package/_types/core/modules/relayer/types.d.ts.map +1 -1
- package/_types/core/types/kms-p.d.ts +7 -1
- package/_types/core/types/kms-p.d.ts.map +1 -1
- package/_types/core/types/kms.d.ts +18 -19
- package/_types/core/types/kms.d.ts.map +1 -1
- package/_types/core/types/logger.d.ts +3 -3
- package/_types/core/types/logger.d.ts.map +1 -1
- package/_types/core/types/record-p.d.ts +2 -1
- package/_types/core/types/record-p.d.ts.map +1 -1
- package/_types/core/types/relayer-p.d.ts +27 -5
- package/_types/core/types/relayer-p.d.ts.map +1 -1
- package/_types/core/types/signedDecryptionPermit.d.ts +37 -26
- package/_types/core/types/signedDecryptionPermit.d.ts.map +1 -1
- package/_types/core/utils-p/decrypt/verifyKmsDelegatedUserDecryptEip712V1.d.ts +14 -0
- package/_types/core/utils-p/decrypt/verifyKmsDelegatedUserDecryptEip712V1.d.ts.map +1 -0
- package/_types/core/utils-p/decrypt/verifyKmsUserDecryptEip712V1.d.ts +14 -0
- package/_types/core/utils-p/decrypt/verifyKmsUserDecryptEip712V1.d.ts.map +1 -0
- package/_types/core/utils-p/decrypt/verifyKmsUserDecryptEip712V2.d.ts +14 -0
- package/_types/core/utils-p/decrypt/verifyKmsUserDecryptEip712V2.d.ts.map +1 -0
- package/_types/core/utils-p/runtime/recoverSigners.d.ts +2 -2
- package/_types/ethers/internal/ethereum-ct.d.ts.map +1 -1
- package/_types/ethers/internal/runtime-ct.d.ts.map +1 -1
- package/_types/viem/internal/ethereum-ct.d.ts.map +1 -1
- package/_types/viem/internal/runtime-ct.d.ts.map +1 -1
- package/core/_version.ts +1 -1
- package/core/actions/base/index.ts +0 -42
- package/core/actions/base/signDecryptionPermit.ts +3 -31
- package/core/actions/chain/index.ts +0 -28
- package/core/actions/chain/parseSignedDecryptionPermit.ts +1 -0
- package/core/actions/chain/serializeSignedDecryptionPermit.ts +3 -2
- package/core/actions/decrypt/canDecryptValue.ts +2 -16
- package/core/actions/decrypt/canDecryptValues.ts +2 -16
- package/core/actions/decrypt/canDecryptValuesFromPairs.ts +2 -16
- package/core/actions/decrypt/decryptValue.ts +2 -1
- package/core/actions/decrypt/decryptValues.ts +3 -1
- package/core/actions/decrypt/decryptValuesFromPairs.ts +3 -1
- package/core/actions/decrypt/index.ts +0 -6
- package/core/actions/encrypt/encryptValue.ts +4 -1
- package/core/actions/encrypt/encryptValues.ts +5 -1
- package/core/actions/encrypt/generateZkProof.ts +2 -1
- package/core/actions/host/index.ts +0 -20
- package/core/actions/host/readKmsVerifierContractData.ts +2 -2
- package/core/base/cachedFetch.ts +1 -0
- package/core/base/uint.ts +18 -1
- package/core/clients/decorators/base.ts +13 -37
- package/core/coprocessor/coprocessorEip712Types.ts +2 -2
- package/core/handle/FheType.ts +11 -0
- package/core/host-contracts/HostContractVersion-p.ts +12 -0
- package/core/host-contracts/KmsSignersContext-p.ts +29 -36
- package/core/host-contracts/canDecryptValuesFromPairs.ts +7 -7
- package/core/host-contracts/getCoprocessorContextSignersAndThreshold-p.ts +2 -2
- package/core/host-contracts/getCurrentKmsContextAndEpoch-p.ts +2 -2
- package/core/host-contracts/getCurrentKmsContextId-p.ts +2 -2
- package/core/host-contracts/getKmsContextSignersAndThreshold-p.ts +3 -2
- package/core/host-contracts/getKmsContextSignersAndThresholdFromExtraData-p.ts +10 -7
- package/core/host-contracts/readKmsSignersContext-p.ts +156 -115
- package/core/kms/KmsSigncryptedShares-p.ts +87 -4
- package/core/kms/PublicDecryptionProof-p.ts +11 -9
- package/core/kms/SignedDecryptionPermit-p.ts +67 -357
- package/core/kms/SignedDecryptionPermitV1-p.ts +308 -0
- package/core/kms/SignedDecryptionPermitV2-p.ts +275 -0
- package/core/kms/{createKmsDelegatedUserDecryptEip712.ts → createKmsDelegatedUserDecryptEip712V1.ts} +21 -21
- package/core/kms/createKmsPublicDecryptEip712.ts +1 -1
- package/core/kms/{createKmsUserDecryptEip712.ts → createKmsUserDecryptEip712V1.ts} +35 -31
- package/core/kms/createKmsUserDecryptEip712V2.ts +7 -7
- package/core/kms/decryptValuesFromPairs.ts +34 -22
- package/core/kms/{fetchKmsSigncryptedShares-p.ts → fetchKmsSigncryptedSharesV1-p.ts} +62 -45
- package/core/kms/fetchKmsSigncryptedSharesV2-p.ts +176 -0
- package/core/kms/{kmsDelegatedUserDecryptEip712Types.ts → kmsDelegatedUserDecryptEip712V1Types.ts} +9 -8
- package/core/kms/kmsExtraData-p.ts +374 -0
- package/core/kms/kmsPublicDecryptEip712Types.ts +1 -1
- package/core/kms/{kmsUserDecryptEip712Types.ts → kmsUserDecryptEip712V1Types.ts} +9 -8
- package/core/kms/kmsUserDecryptEip712V2Types.ts +2 -1
- package/core/kms/publicDecrypt.ts +10 -9
- package/core/kms/utils.ts +0 -32
- package/core/kms/verifyKmsPublicDecryptEip712-p.ts +10 -8
- package/core/modules/decrypt/mock.ts +6 -6
- package/core/modules/decrypt/module/api-p.ts +15 -15
- package/core/modules/decrypt/module/init-p.ts +7 -7
- package/core/modules/encrypt/module/init-p.ts +16 -11
- package/core/modules/ethereum/types-ct.ts +25 -2
- package/core/modules/relayer/cleartext/fetchCoprocessorSignatures.ts +98 -15
- package/core/modules/relayer/cleartext/{fetchDelegatedUserDecrypt.ts → fetchDelegatedUserDecryptV1.ts} +115 -27
- package/core/modules/relayer/cleartext/fetchPublicDecrypt.ts +115 -9
- package/core/modules/relayer/cleartext/fetchUserDecrypt.ts +23 -131
- package/core/modules/relayer/cleartext/fetchUserDecryptV1.ts +229 -0
- package/core/modules/relayer/cleartext/fetchUserDecryptV2.ts +11 -0
- package/core/modules/relayer/cleartext/forgeFhevmV1.ts +185 -0
- package/core/modules/relayer/cleartext/mock.ts +1 -1
- package/core/modules/relayer/cleartext/signers.ts +35 -0
- package/core/modules/relayer/module/fetchPublicDecrypt.ts +1 -1
- package/core/modules/relayer/module/fetchUserDecrypt.ts +20 -56
- package/core/modules/relayer/module/fetchUserDecryptV1.ts +69 -0
- package/core/modules/relayer/module/fetchUserDecryptV2.ts +71 -0
- package/core/modules/relayer/module/guards/RelayerResponseFailed.ts +10 -2
- package/core/modules/relayer/module/guards/api-errors/RelayerApiError400NoDetails.ts +6 -3
- package/core/modules/relayer/module/guards/api-errors/RelayerApiError503.ts +2 -0
- package/core/modules/relayer/module/index.ts +1 -1
- package/core/modules/relayer/types.ts +24 -5
- package/core/runtime/HyperWasmSolver-p.ts +1 -5
- package/core/types/kms-p.ts +16 -1
- package/core/types/kms.ts +40 -28
- package/core/types/logger.ts +3 -3
- package/core/types/record-p.ts +2 -1
- package/core/types/relayer-p.ts +48 -5
- package/core/types/signedDecryptionPermit.ts +47 -26
- package/core/utils-p/decrypt/{verifyKmsDelegatedUserDecryptEip712.ts → verifyKmsDelegatedUserDecryptEip712V1.ts} +9 -9
- package/core/utils-p/decrypt/{verifyKmsUserDecryptEip712.ts → verifyKmsUserDecryptEip712V1.ts} +9 -9
- package/core/utils-p/decrypt/verifyKmsUserDecryptEip712V2.ts +43 -0
- package/core/utils-p/runtime/recoverSigners.ts +2 -2
- package/ethers/internal/ethereum-ct.ts +15 -1
- package/ethers/internal/runtime-ct.ts +9 -7
- package/package.json +1 -1
- package/viem/internal/ethereum-ct.ts +14 -2
- package/viem/internal/runtime-ct.ts +9 -7
- package/_cjs/core/actions/base/createVerifiedInputProofFromRawBytes.js +0 -10
- package/_cjs/core/actions/base/createVerifiedInputProofFromRawBytes.js.map +0 -1
- package/_cjs/core/actions/base/fetchKmsSigncryptedShares.js +0 -19
- package/_cjs/core/actions/base/fetchKmsSigncryptedShares.js.map +0 -1
- package/_cjs/core/actions/base/fetchVerifiedInputProof.js +0 -11
- package/_cjs/core/actions/base/fetchVerifiedInputProof.js.map +0 -1
- package/_cjs/core/actions/base/readKmsSignersContext.js +0 -11
- package/_cjs/core/actions/base/readKmsSignersContext.js.map +0 -1
- package/_cjs/core/actions/base/verifyHandlesCoprocessorSignatures.js +0 -31
- package/_cjs/core/actions/base/verifyHandlesCoprocessorSignatures.js.map +0 -1
- package/_cjs/core/actions/base/verifyInputProof.js +0 -24
- package/_cjs/core/actions/base/verifyInputProof.js.map +0 -1
- package/_cjs/core/actions/base/verifyZkProofCoprocessorSignatures.js +0 -17
- package/_cjs/core/actions/base/verifyZkProofCoprocessorSignatures.js.map +0 -1
- package/_cjs/core/actions/chain/createCoprocessorEip712Domain.js +0 -11
- package/_cjs/core/actions/chain/createCoprocessorEip712Domain.js.map +0 -1
- package/_cjs/core/actions/chain/createKmsDelegatedUserDecryptEip712.js +0 -17
- package/_cjs/core/actions/chain/createKmsDelegatedUserDecryptEip712.js.map +0 -1
- package/_cjs/core/actions/chain/createKmsEip712Domain.js +0 -11
- package/_cjs/core/actions/chain/createKmsEip712Domain.js.map +0 -1
- package/_cjs/core/actions/chain/createKmsUserDecryptEip712.js +0 -16
- package/_cjs/core/actions/chain/createKmsUserDecryptEip712.js.map +0 -1
- package/_cjs/core/actions/chain/verifyKmsDelegatedUserDecryptEip712.js +0 -8
- package/_cjs/core/actions/chain/verifyKmsDelegatedUserDecryptEip712.js.map +0 -1
- package/_cjs/core/actions/chain/verifyKmsUserDecryptEip712.js +0 -8
- package/_cjs/core/actions/chain/verifyKmsUserDecryptEip712.js.map +0 -1
- package/_cjs/core/actions/decrypt/decryptKmsSigncryptedShares.js +0 -13
- package/_cjs/core/actions/decrypt/decryptKmsSigncryptedShares.js.map +0 -1
- package/_cjs/core/kms/createKmsDelegatedUserDecryptEip712.js.map +0 -1
- package/_cjs/core/kms/createKmsUserDecryptEip712.js.map +0 -1
- package/_cjs/core/kms/fetchKmsSigncryptedShares-p.js.map +0 -1
- package/_cjs/core/kms/kmsDelegatedUserDecryptEip712Types.js.map +0 -1
- package/_cjs/core/kms/kmsExtraData.js +0 -82
- package/_cjs/core/kms/kmsExtraData.js.map +0 -1
- package/_cjs/core/kms/kmsUserDecryptEip712Types.js.map +0 -1
- package/_cjs/core/modules/relayer/cleartext/fetchDelegatedUserDecrypt.js.map +0 -1
- package/_cjs/core/modules/relayer/module/fetchDelegatedUserDecrypt.js.map +0 -1
- package/_cjs/core/utils-p/decrypt/verifyKmsDelegatedUserDecryptEip712.js.map +0 -1
- package/_cjs/core/utils-p/decrypt/verifyKmsUserDecryptEip712.js.map +0 -1
- package/_esm/core/actions/base/createVerifiedInputProofFromRawBytes.js +0 -7
- package/_esm/core/actions/base/createVerifiedInputProofFromRawBytes.js.map +0 -1
- package/_esm/core/actions/base/fetchKmsSigncryptedShares.js +0 -17
- package/_esm/core/actions/base/fetchKmsSigncryptedShares.js.map +0 -1
- package/_esm/core/actions/base/fetchVerifiedInputProof.js +0 -8
- package/_esm/core/actions/base/fetchVerifiedInputProof.js.map +0 -1
- package/_esm/core/actions/base/readKmsSignersContext.js +0 -10
- package/_esm/core/actions/base/readKmsSignersContext.js.map +0 -1
- package/_esm/core/actions/base/verifyHandlesCoprocessorSignatures.js +0 -35
- package/_esm/core/actions/base/verifyHandlesCoprocessorSignatures.js.map +0 -1
- package/_esm/core/actions/base/verifyInputProof.js +0 -22
- package/_esm/core/actions/base/verifyInputProof.js.map +0 -1
- package/_esm/core/actions/base/verifyZkProofCoprocessorSignatures.js +0 -14
- package/_esm/core/actions/base/verifyZkProofCoprocessorSignatures.js.map +0 -1
- package/_esm/core/actions/chain/createCoprocessorEip712Domain.js +0 -8
- package/_esm/core/actions/chain/createCoprocessorEip712Domain.js.map +0 -1
- package/_esm/core/actions/chain/createKmsDelegatedUserDecryptEip712.js +0 -15
- package/_esm/core/actions/chain/createKmsDelegatedUserDecryptEip712.js.map +0 -1
- package/_esm/core/actions/chain/createKmsEip712Domain.js +0 -8
- package/_esm/core/actions/chain/createKmsEip712Domain.js.map +0 -1
- package/_esm/core/actions/chain/createKmsUserDecryptEip712.js +0 -14
- package/_esm/core/actions/chain/createKmsUserDecryptEip712.js.map +0 -1
- package/_esm/core/actions/chain/verifyKmsDelegatedUserDecryptEip712.js +0 -5
- package/_esm/core/actions/chain/verifyKmsDelegatedUserDecryptEip712.js.map +0 -1
- package/_esm/core/actions/chain/verifyKmsUserDecryptEip712.js +0 -5
- package/_esm/core/actions/chain/verifyKmsUserDecryptEip712.js.map +0 -1
- package/_esm/core/actions/decrypt/decryptKmsSigncryptedShares.js +0 -11
- package/_esm/core/actions/decrypt/decryptKmsSigncryptedShares.js.map +0 -1
- package/_esm/core/kms/createKmsDelegatedUserDecryptEip712.js.map +0 -1
- package/_esm/core/kms/createKmsUserDecryptEip712.js.map +0 -1
- package/_esm/core/kms/fetchKmsSigncryptedShares-p.js.map +0 -1
- package/_esm/core/kms/kmsDelegatedUserDecryptEip712Types.js.map +0 -1
- package/_esm/core/kms/kmsExtraData.js +0 -99
- package/_esm/core/kms/kmsExtraData.js.map +0 -1
- package/_esm/core/kms/kmsUserDecryptEip712Types.js.map +0 -1
- package/_esm/core/modules/relayer/cleartext/fetchDelegatedUserDecrypt.js.map +0 -1
- package/_esm/core/modules/relayer/module/fetchDelegatedUserDecrypt.js.map +0 -1
- package/_esm/core/utils-p/decrypt/verifyKmsDelegatedUserDecryptEip712.js.map +0 -1
- package/_esm/core/utils-p/decrypt/verifyKmsUserDecryptEip712.js.map +0 -1
- package/_types/core/actions/base/createVerifiedInputProofFromRawBytes.d.ts +0 -14
- package/_types/core/actions/base/createVerifiedInputProofFromRawBytes.d.ts.map +0 -1
- package/_types/core/actions/base/fetchKmsSigncryptedShares.d.ts +0 -41
- package/_types/core/actions/base/fetchKmsSigncryptedShares.d.ts.map +0 -1
- package/_types/core/actions/base/fetchVerifiedInputProof.d.ts +0 -14
- package/_types/core/actions/base/fetchVerifiedInputProof.d.ts.map +0 -1
- package/_types/core/actions/base/readKmsSignersContext.d.ts +0 -6
- package/_types/core/actions/base/readKmsSignersContext.d.ts.map +0 -1
- package/_types/core/actions/base/verifyHandlesCoprocessorSignatures.d.ts +0 -14
- package/_types/core/actions/base/verifyHandlesCoprocessorSignatures.d.ts.map +0 -1
- package/_types/core/actions/base/verifyInputProof.d.ts +0 -14
- package/_types/core/actions/base/verifyInputProof.d.ts.map +0 -1
- package/_types/core/actions/base/verifyZkProofCoprocessorSignatures.d.ts +0 -11
- package/_types/core/actions/base/verifyZkProofCoprocessorSignatures.d.ts.map +0 -1
- package/_types/core/actions/chain/createCoprocessorEip712Domain.d.ts +0 -7
- package/_types/core/actions/chain/createCoprocessorEip712Domain.d.ts.map +0 -1
- package/_types/core/actions/chain/createKmsDelegatedUserDecryptEip712.d.ts +0 -15
- package/_types/core/actions/chain/createKmsDelegatedUserDecryptEip712.d.ts.map +0 -1
- package/_types/core/actions/chain/createKmsEip712Domain.d.ts +0 -7
- package/_types/core/actions/chain/createKmsEip712Domain.d.ts.map +0 -1
- package/_types/core/actions/chain/createKmsUserDecryptEip712.d.ts +0 -14
- package/_types/core/actions/chain/createKmsUserDecryptEip712.d.ts.map +0 -1
- package/_types/core/actions/chain/verifyKmsDelegatedUserDecryptEip712.d.ts +0 -7
- package/_types/core/actions/chain/verifyKmsDelegatedUserDecryptEip712.d.ts.map +0 -1
- package/_types/core/actions/chain/verifyKmsUserDecryptEip712.d.ts +0 -7
- package/_types/core/actions/chain/verifyKmsUserDecryptEip712.d.ts.map +0 -1
- package/_types/core/actions/decrypt/decryptKmsSigncryptedShares.d.ts +0 -13
- package/_types/core/actions/decrypt/decryptKmsSigncryptedShares.d.ts.map +0 -1
- package/_types/core/kms/createKmsDelegatedUserDecryptEip712.d.ts +0 -15
- package/_types/core/kms/createKmsDelegatedUserDecryptEip712.d.ts.map +0 -1
- package/_types/core/kms/createKmsUserDecryptEip712.d.ts +0 -26
- package/_types/core/kms/createKmsUserDecryptEip712.d.ts.map +0 -1
- package/_types/core/kms/fetchKmsSigncryptedShares-p.d.ts.map +0 -1
- package/_types/core/kms/kmsDelegatedUserDecryptEip712Types.d.ts +0 -3
- package/_types/core/kms/kmsDelegatedUserDecryptEip712Types.d.ts.map +0 -1
- package/_types/core/kms/kmsExtraData.d.ts +0 -25
- package/_types/core/kms/kmsExtraData.d.ts.map +0 -1
- package/_types/core/kms/kmsUserDecryptEip712Types.d.ts +0 -3
- package/_types/core/kms/kmsUserDecryptEip712Types.d.ts.map +0 -1
- package/_types/core/modules/relayer/cleartext/fetchDelegatedUserDecrypt.d.ts.map +0 -1
- package/_types/core/modules/relayer/module/fetchDelegatedUserDecrypt.d.ts.map +0 -1
- package/_types/core/utils-p/decrypt/verifyKmsDelegatedUserDecryptEip712.d.ts +0 -14
- package/_types/core/utils-p/decrypt/verifyKmsDelegatedUserDecryptEip712.d.ts.map +0 -1
- package/_types/core/utils-p/decrypt/verifyKmsUserDecryptEip712.d.ts +0 -14
- package/_types/core/utils-p/decrypt/verifyKmsUserDecryptEip712.d.ts.map +0 -1
- package/core/actions/base/createVerifiedInputProofFromRawBytes.ts +0 -24
- package/core/actions/base/fetchKmsSigncryptedShares.ts +0 -83
- package/core/actions/base/fetchVerifiedInputProof.ts +0 -25
- package/core/actions/base/readKmsSignersContext.ts +0 -20
- package/core/actions/base/verifyHandlesCoprocessorSignatures.ts +0 -60
- package/core/actions/base/verifyInputProof.ts +0 -45
- package/core/actions/base/verifyZkProofCoprocessorSignatures.ts +0 -32
- package/core/actions/chain/createCoprocessorEip712Domain.ts +0 -16
- package/core/actions/chain/createKmsDelegatedUserDecryptEip712.ts +0 -36
- package/core/actions/chain/createKmsEip712Domain.ts +0 -16
- package/core/actions/chain/createKmsUserDecryptEip712.ts +0 -34
- package/core/actions/chain/verifyKmsDelegatedUserDecryptEip712.ts +0 -16
- package/core/actions/chain/verifyKmsUserDecryptEip712.ts +0 -16
- package/core/actions/decrypt/decryptKmsSigncryptedShares.ts +0 -34
- package/core/kms/kmsExtraData.ts +0 -127
- /package/core/modules/relayer/module/{fetchDelegatedUserDecrypt.ts → fetchDelegatedUserDecryptV1.ts} +0 -0
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import type { SignedDecryptionPermit, SignedDecryptionPermitV1 } from '../types/signedDecryptionPermit.js';
|
|
2
|
+
import type { KmsDelegatedUserDecryptEip712V1, KmsUserDecryptEip712V1 } from '../types/kms.js';
|
|
3
|
+
import type { Bytes65Hex, BytesHex, ChecksummedAddress, Uint8Number, UintNumber } from '../types/primitives.js';
|
|
4
|
+
import type { FhevmChain } from '../types/fhevmChain.js';
|
|
5
|
+
import type { FhevmRuntime } from '../types/coreFhevmRuntime.js';
|
|
6
|
+
import type { SignDecryptionPermitContext, SignDecryptionPermitParameters } from './SignedDecryptionPermit-p.js';
|
|
7
|
+
import type { KmsExtraData } from '../types/kms-p.js';
|
|
8
|
+
import { verifyKmsUserDecryptEip712V1 } from '../utils-p/decrypt/verifyKmsUserDecryptEip712V1.js';
|
|
9
|
+
import { verifyKmsDelegatedUserDecryptEip712V1 } from '../utils-p/decrypt/verifyKmsDelegatedUserDecryptEip712V1.js';
|
|
10
|
+
import { assertRecordNonNullableProperty } from '../base/record.js';
|
|
11
|
+
import { assertRecordBytes65HexProperty } from '../base/bytes.js';
|
|
12
|
+
import { addressToChecksummedAddress, assertIsAddress, assertRecordAddressProperty } from '../base/address.js';
|
|
13
|
+
import { assertIsKmsUserDecryptEip712V1, createKmsUserDecryptEip712V1 } from './createKmsUserDecryptEip712V1.js';
|
|
14
|
+
import {
|
|
15
|
+
assertIsKmsDelegatedUserDecryptEip712V1,
|
|
16
|
+
createKmsDelegatedUserDecryptEip712V1,
|
|
17
|
+
} from './createKmsDelegatedUserDecryptEip712V1.js';
|
|
18
|
+
import { assertRecordStringProperty } from '../base/string.js';
|
|
19
|
+
import { assertIsTransportKeyPair, type TransportKeyPair } from './TransportKeyPair-p.js';
|
|
20
|
+
import { readCurrentKmsSignersContext } from '../host-contracts/readKmsSignersContext-p.js';
|
|
21
|
+
import { kmsSignersContextToExtraData } from '../host-contracts/KmsSignersContext-p.js';
|
|
22
|
+
|
|
23
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
24
|
+
|
|
25
|
+
const PRIVATE_TOKEN = Symbol('SignedDecryptionPermitV1.token');
|
|
26
|
+
const MAX_USER_DECRYPT_DURATION_DAYS = 365 as UintNumber;
|
|
27
|
+
const MAX_USER_DECRYPT_CONTRACT_ADDRESSES = 10 as Uint8Number;
|
|
28
|
+
|
|
29
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
30
|
+
|
|
31
|
+
function assertKmsEip712V1DeadlineValidity(
|
|
32
|
+
{
|
|
33
|
+
startTimestamp,
|
|
34
|
+
durationDays,
|
|
35
|
+
}: {
|
|
36
|
+
startTimestamp: bigint | number | string;
|
|
37
|
+
durationDays: bigint | number | string;
|
|
38
|
+
},
|
|
39
|
+
maxDurationDays: UintNumber,
|
|
40
|
+
): void {
|
|
41
|
+
if (durationDays === 0) {
|
|
42
|
+
throw Error('durationDays is zero');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const durationDaysBigInt = BigInt(durationDays);
|
|
46
|
+
if (durationDaysBigInt > BigInt(maxDurationDays)) {
|
|
47
|
+
throw Error(`durationDays is above max duration of ${maxDurationDays}`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const startTimestampBigInt = BigInt(startTimestamp);
|
|
51
|
+
|
|
52
|
+
const currentTimestamp = BigInt(Math.floor(Date.now() / 1000));
|
|
53
|
+
if (startTimestampBigInt > currentTimestamp) {
|
|
54
|
+
throw Error('startTimestamp is set in the future');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const durationInSeconds = durationDaysBigInt * BigInt(24 * 60 * 60);
|
|
58
|
+
if (startTimestampBigInt + durationInSeconds < currentTimestamp) {
|
|
59
|
+
throw Error('request has expired');
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Private implementation of {@link SignedDecryptionPermit}.
|
|
65
|
+
* Immutable by design — all fields are stored as private properties
|
|
66
|
+
* and exposed via readonly getters. Instances are only created through
|
|
67
|
+
* SDK-internal factory functions that guarantee the signature has been verified.
|
|
68
|
+
*
|
|
69
|
+
* **Invariant:** Every instance of this class has a verified signature.
|
|
70
|
+
* Construction is only possible through factory functions that validate the
|
|
71
|
+
* signature against the on-chain verifier before returning. If the EIP-712
|
|
72
|
+
* format has changed (e.g. loading a permit serialized by an older SDK version),
|
|
73
|
+
* verification will fail and construction will throw.
|
|
74
|
+
*
|
|
75
|
+
* As a consequence, any code within the SDK that receives a
|
|
76
|
+
* `SignedDecryptionPermit` (verified via `instanceof`) can safely trust
|
|
77
|
+
* its contents without re-verification.
|
|
78
|
+
*/
|
|
79
|
+
class SignedDecryptionPermitV1Impl implements SignedDecryptionPermitV1 {
|
|
80
|
+
readonly #eip712: KmsUserDecryptEip712V1 | KmsDelegatedUserDecryptEip712V1;
|
|
81
|
+
readonly #signature: Bytes65Hex;
|
|
82
|
+
readonly #signerAddress: ChecksummedAddress;
|
|
83
|
+
|
|
84
|
+
constructor(
|
|
85
|
+
privateToken: symbol,
|
|
86
|
+
parameters: {
|
|
87
|
+
readonly eip712: KmsUserDecryptEip712V1 | KmsDelegatedUserDecryptEip712V1;
|
|
88
|
+
readonly signature: Bytes65Hex;
|
|
89
|
+
readonly signerAddress: ChecksummedAddress;
|
|
90
|
+
},
|
|
91
|
+
) {
|
|
92
|
+
if (privateToken !== PRIVATE_TOKEN) {
|
|
93
|
+
throw new Error('Unauthorized');
|
|
94
|
+
}
|
|
95
|
+
this.#eip712 = parameters.eip712;
|
|
96
|
+
this.#signature = parameters.signature;
|
|
97
|
+
this.#signerAddress = parameters.signerAddress;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public get eip712(): KmsUserDecryptEip712V1 | KmsDelegatedUserDecryptEip712V1 {
|
|
101
|
+
return this.#eip712;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
public get signature(): Bytes65Hex {
|
|
105
|
+
return this.#signature;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public get signerAddress(): ChecksummedAddress {
|
|
109
|
+
return this.#signerAddress;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
public readonly version = 1 as const;
|
|
113
|
+
|
|
114
|
+
public assertNotExpired(): void {
|
|
115
|
+
assertKmsEip712V1DeadlineValidity(this.#eip712.message, MAX_USER_DECRYPT_DURATION_DAYS);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
public get transportPublicKey(): BytesHex {
|
|
119
|
+
return this.#eip712.message.publicKey;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
public get encryptedDataOwnerAddress(): ChecksummedAddress {
|
|
123
|
+
if (this.eip712.primaryType === 'DelegatedUserDecryptRequestVerification') {
|
|
124
|
+
return this.eip712.message.delegatorAddress;
|
|
125
|
+
}
|
|
126
|
+
return this.signerAddress;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
public get isDelegated(): boolean {
|
|
130
|
+
return this.eip712.primaryType === 'DelegatedUserDecryptRequestVerification';
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
135
|
+
|
|
136
|
+
Object.freeze(SignedDecryptionPermitV1Impl);
|
|
137
|
+
Object.freeze(SignedDecryptionPermitV1Impl.prototype);
|
|
138
|
+
|
|
139
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
140
|
+
|
|
141
|
+
export function isSignedDecryptionPermitV1(value: unknown): value is SignedDecryptionPermitV1 {
|
|
142
|
+
return value instanceof SignedDecryptionPermitV1Impl;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
146
|
+
// _createSignedDecryptionPermitV1
|
|
147
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
148
|
+
|
|
149
|
+
async function _createSignedDecryptionPermitV1(
|
|
150
|
+
context: { readonly chain: FhevmChain; readonly runtime: FhevmRuntime },
|
|
151
|
+
parameters: {
|
|
152
|
+
readonly signerAddress: ChecksummedAddress;
|
|
153
|
+
readonly eip712: KmsUserDecryptEip712V1 | KmsDelegatedUserDecryptEip712V1;
|
|
154
|
+
readonly signature: Bytes65Hex;
|
|
155
|
+
},
|
|
156
|
+
): Promise<SignedDecryptionPermit> {
|
|
157
|
+
const { signerAddress, eip712, signature } = parameters;
|
|
158
|
+
|
|
159
|
+
if (eip712.message.contractAddresses.length === 0) {
|
|
160
|
+
throw Error('contractAddresses is empty');
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (eip712.message.contractAddresses.length > MAX_USER_DECRYPT_CONTRACT_ADDRESSES) {
|
|
164
|
+
throw Error(`contractAddresses max length of ${MAX_USER_DECRYPT_CONTRACT_ADDRESSES} exceeded`);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (Number(eip712.message.durationDays) > MAX_USER_DECRYPT_DURATION_DAYS) {
|
|
168
|
+
throw Error(`durationDays is above max duration of ${MAX_USER_DECRYPT_DURATION_DAYS}`);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (eip712.primaryType === 'UserDecryptRequestVerification') {
|
|
172
|
+
await verifyKmsUserDecryptEip712V1(context, {
|
|
173
|
+
signer: signerAddress,
|
|
174
|
+
message: eip712.message,
|
|
175
|
+
signature,
|
|
176
|
+
});
|
|
177
|
+
return new SignedDecryptionPermitV1Impl(PRIVATE_TOKEN, parameters);
|
|
178
|
+
} else {
|
|
179
|
+
await verifyKmsDelegatedUserDecryptEip712V1(context, {
|
|
180
|
+
signer: signerAddress,
|
|
181
|
+
message: eip712.message,
|
|
182
|
+
signature,
|
|
183
|
+
});
|
|
184
|
+
return new SignedDecryptionPermitV1Impl(PRIVATE_TOKEN, parameters);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
189
|
+
// signDecryptionPermitV1
|
|
190
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
191
|
+
|
|
192
|
+
export async function signDecryptionPermitV1(
|
|
193
|
+
context: SignDecryptionPermitContext,
|
|
194
|
+
parameters: SignDecryptionPermitParameters,
|
|
195
|
+
): Promise<SignedDecryptionPermit> {
|
|
196
|
+
const kmsSignersContext = await readCurrentKmsSignersContext(context, {
|
|
197
|
+
kmsVerifierAddress: context.chain.fhevm.contracts.kmsVerifier.address as ChecksummedAddress,
|
|
198
|
+
protocolConfigAddress: context.chain.fhevm.contracts.protocolConfig?.address as ChecksummedAddress | undefined,
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
const extraData: KmsExtraData = kmsSignersContextToExtraData(kmsSignersContext);
|
|
202
|
+
|
|
203
|
+
const {
|
|
204
|
+
contractAddresses,
|
|
205
|
+
startTimestamp,
|
|
206
|
+
durationSeconds,
|
|
207
|
+
signerAddress: signerAddressArg,
|
|
208
|
+
transportKeyPair: transportKeyPair,
|
|
209
|
+
signer,
|
|
210
|
+
delegatorAddress,
|
|
211
|
+
} = parameters;
|
|
212
|
+
|
|
213
|
+
if (durationSeconds % 86_400 !== 0) {
|
|
214
|
+
throw new Error(`Protocol v13 requires durationSeconds to be a whole number of days, got ${durationSeconds}`);
|
|
215
|
+
}
|
|
216
|
+
const durationDays = durationSeconds / 86_400;
|
|
217
|
+
|
|
218
|
+
assertIsTransportKeyPair(transportKeyPair, {});
|
|
219
|
+
assertIsAddress(signerAddressArg, {});
|
|
220
|
+
|
|
221
|
+
if (delegatorAddress !== undefined) {
|
|
222
|
+
assertIsAddress(delegatorAddress, {});
|
|
223
|
+
if (signerAddressArg.toLowerCase() === delegatorAddress.toLowerCase()) {
|
|
224
|
+
throw new Error(
|
|
225
|
+
'signerAddress and delegatorAddress must be different. ' +
|
|
226
|
+
'Use a non-delegated permit to decrypt your own values.',
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const signerAddress = addressToChecksummedAddress(signerAddressArg);
|
|
232
|
+
|
|
233
|
+
const commonMessage = {
|
|
234
|
+
verifyingContractAddressDecryption: context.chain.fhevm.gateway.contracts.decryption.address as ChecksummedAddress,
|
|
235
|
+
chainId: context.chain.id,
|
|
236
|
+
contractAddresses,
|
|
237
|
+
durationDays,
|
|
238
|
+
startTimestamp,
|
|
239
|
+
extraData,
|
|
240
|
+
publicKey: transportKeyPair.publicKey,
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
const eip712 =
|
|
244
|
+
delegatorAddress !== undefined
|
|
245
|
+
? createKmsDelegatedUserDecryptEip712V1({
|
|
246
|
+
...commonMessage,
|
|
247
|
+
delegatorAddress,
|
|
248
|
+
})
|
|
249
|
+
: createKmsUserDecryptEip712V1(commonMessage);
|
|
250
|
+
|
|
251
|
+
const signature = await context.runtime.ethereum.signTypedData(signer, {
|
|
252
|
+
account: signerAddress,
|
|
253
|
+
...eip712,
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
return await _createSignedDecryptionPermitV1(context, {
|
|
257
|
+
signature,
|
|
258
|
+
signerAddress,
|
|
259
|
+
eip712,
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
264
|
+
// parseSignedDecryptionPermitV1
|
|
265
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
266
|
+
|
|
267
|
+
export async function parseSignedDecryptionPermitV1(
|
|
268
|
+
context: SignDecryptionPermitContext,
|
|
269
|
+
transportKeyPair: TransportKeyPair,
|
|
270
|
+
permit: unknown,
|
|
271
|
+
): Promise<SignedDecryptionPermit> {
|
|
272
|
+
assertIsTransportKeyPair(transportKeyPair, {});
|
|
273
|
+
|
|
274
|
+
const permitName = 'permit';
|
|
275
|
+
const options = {};
|
|
276
|
+
|
|
277
|
+
assertRecordNonNullableProperty(permit, 'eip712', permitName, options);
|
|
278
|
+
assertRecordBytes65HexProperty(permit, 'signature', permitName, options);
|
|
279
|
+
assertRecordAddressProperty(permit, 'signerAddress', permitName, options);
|
|
280
|
+
|
|
281
|
+
const eip712 = permit.eip712;
|
|
282
|
+
assertRecordStringProperty(eip712, 'primaryType', `${permitName}.eip712`, options);
|
|
283
|
+
const primaryType = (eip712 as Record<string, unknown>).primaryType;
|
|
284
|
+
|
|
285
|
+
const signerAddress = addressToChecksummedAddress(permit.signerAddress);
|
|
286
|
+
|
|
287
|
+
if (primaryType === 'UserDecryptRequestVerification') {
|
|
288
|
+
assertIsKmsUserDecryptEip712V1(eip712, `${permitName}.eip712`, options);
|
|
289
|
+
if (eip712.message.publicKey.toLowerCase() !== transportKeyPair.publicKey.toLowerCase()) {
|
|
290
|
+
throw new Error(
|
|
291
|
+
"The permit's publicKey does not match the TransportKeyPair's publicKey. " +
|
|
292
|
+
'Ensure the permit was signed with the same key pair.',
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
return await _createSignedDecryptionPermitV1(context, { signature: permit.signature, eip712, signerAddress });
|
|
296
|
+
} else if (primaryType === 'DelegatedUserDecryptRequestVerification') {
|
|
297
|
+
assertIsKmsDelegatedUserDecryptEip712V1(eip712, `${permitName}.eip712`, options);
|
|
298
|
+
if (eip712.message.publicKey.toLowerCase() !== transportKeyPair.publicKey.toLowerCase()) {
|
|
299
|
+
throw new Error(
|
|
300
|
+
"The permit's publicKey does not match the TransportKeyPair's publicKey. " +
|
|
301
|
+
'Ensure the permit was signed with the same key pair.',
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
return await _createSignedDecryptionPermitV1(context, { signature: permit.signature, eip712, signerAddress });
|
|
305
|
+
} else {
|
|
306
|
+
throw new Error(`Unknown permit primaryType: ${primaryType}`);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import type { SignedDecryptionPermit, SignedDecryptionPermitV2 } from '../types/signedDecryptionPermit.js';
|
|
2
|
+
import type { KmsUserDecryptEip712V2 } from '../types/kms.js';
|
|
3
|
+
import type { Bytes65Hex, BytesHex, ChecksummedAddress, Uint8Number } from '../types/primitives.js';
|
|
4
|
+
import type { FhevmChain } from '../types/fhevmChain.js';
|
|
5
|
+
import type { FhevmRuntime } from '../types/coreFhevmRuntime.js';
|
|
6
|
+
import type { SignDecryptionPermitContext, SignDecryptionPermitParameters } from './SignedDecryptionPermit-p.js';
|
|
7
|
+
import type { KmsExtraData } from '../types/kms-p.js';
|
|
8
|
+
import { assertRecordNonNullableProperty } from '../base/record.js';
|
|
9
|
+
import { assertRecordBytes65HexProperty } from '../base/bytes.js';
|
|
10
|
+
import { addressToChecksummedAddress, assertIsAddress, assertRecordAddressProperty } from '../base/address.js';
|
|
11
|
+
import { assertRecordStringProperty } from '../base/string.js';
|
|
12
|
+
import { assertIsTransportKeyPair, type TransportKeyPair } from './TransportKeyPair-p.js';
|
|
13
|
+
import { readCurrentKmsSignersContext } from '../host-contracts/readKmsSignersContext-p.js';
|
|
14
|
+
import { kmsSignersContextToExtraData } from '../host-contracts/KmsSignersContext-p.js';
|
|
15
|
+
import { assertIsKmsUserDecryptEip712V2, createKmsUserDecryptEip712V2 } from './createKmsUserDecryptEip712V2.js';
|
|
16
|
+
import { verifyKmsUserDecryptEip712V2 } from '../utils-p/decrypt/verifyKmsUserDecryptEip712V2.js';
|
|
17
|
+
import { assert } from '../base/errors/InternalError.js';
|
|
18
|
+
import { EXTRA_DATA_V2 } from './kmsExtraData-p.js';
|
|
19
|
+
|
|
20
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
21
|
+
|
|
22
|
+
const PRIVATE_TOKEN = Symbol('SignedDecryptionPermitV2.token');
|
|
23
|
+
const MAX_USER_DECRYPT_CONTRACT_ADDRESSES = 10 as Uint8Number;
|
|
24
|
+
|
|
25
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
26
|
+
|
|
27
|
+
function assertKmsEip712V2DeadlineValidity({
|
|
28
|
+
startTimestamp,
|
|
29
|
+
durationSeconds,
|
|
30
|
+
}: {
|
|
31
|
+
startTimestamp: bigint | number | string;
|
|
32
|
+
durationSeconds: bigint | number | string;
|
|
33
|
+
}): void {
|
|
34
|
+
if (durationSeconds === 0) {
|
|
35
|
+
throw Error('durationSeconds is zero');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const durationSecBigInt = BigInt(durationSeconds);
|
|
39
|
+
const startTimestampBigInt = BigInt(startTimestamp);
|
|
40
|
+
|
|
41
|
+
const currentTimestamp = BigInt(Math.floor(Date.now() / 1000));
|
|
42
|
+
if (startTimestampBigInt > currentTimestamp) {
|
|
43
|
+
throw Error('startTimestamp is set in the future');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (startTimestampBigInt + durationSecBigInt < currentTimestamp) {
|
|
47
|
+
throw Error('request has expired');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
52
|
+
// SignedDecryptionPermitV2Impl
|
|
53
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
54
|
+
|
|
55
|
+
class SignedDecryptionPermitV2Impl implements SignedDecryptionPermitV2 {
|
|
56
|
+
readonly #eip712: KmsUserDecryptEip712V2;
|
|
57
|
+
readonly #signature: Bytes65Hex;
|
|
58
|
+
readonly #signerAddress: ChecksummedAddress;
|
|
59
|
+
readonly #delegatorAddress: ChecksummedAddress | undefined;
|
|
60
|
+
|
|
61
|
+
constructor(
|
|
62
|
+
privateToken: symbol,
|
|
63
|
+
parameters: {
|
|
64
|
+
readonly eip712: KmsUserDecryptEip712V2;
|
|
65
|
+
readonly signature: Bytes65Hex;
|
|
66
|
+
readonly signerAddress: ChecksummedAddress;
|
|
67
|
+
readonly delegatorAddress?: ChecksummedAddress | undefined;
|
|
68
|
+
},
|
|
69
|
+
) {
|
|
70
|
+
if (privateToken !== PRIVATE_TOKEN) {
|
|
71
|
+
throw new Error('Unauthorized');
|
|
72
|
+
}
|
|
73
|
+
this.#eip712 = parameters.eip712;
|
|
74
|
+
this.#signature = parameters.signature;
|
|
75
|
+
this.#signerAddress = parameters.signerAddress;
|
|
76
|
+
this.#delegatorAddress = parameters.delegatorAddress;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public get eip712(): KmsUserDecryptEip712V2 {
|
|
80
|
+
return this.#eip712;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
public get signature(): Bytes65Hex {
|
|
84
|
+
return this.#signature;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
public get signerAddress(): ChecksummedAddress {
|
|
88
|
+
return this.#signerAddress;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
public readonly version = 2 as const;
|
|
92
|
+
|
|
93
|
+
public get encryptedDataOwnerAddress(): ChecksummedAddress {
|
|
94
|
+
return this.#delegatorAddress ?? this.#signerAddress;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
public get isDelegated(): boolean {
|
|
98
|
+
return this.#delegatorAddress !== undefined;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
public get transportPublicKey(): BytesHex {
|
|
102
|
+
return this.#eip712.message.publicKey;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
public assertNotExpired(): void {
|
|
106
|
+
const { startTimestamp, durationSeconds } = this.#eip712.message;
|
|
107
|
+
assertKmsEip712V2DeadlineValidity({ startTimestamp, durationSeconds });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
112
|
+
|
|
113
|
+
Object.freeze(SignedDecryptionPermitV2Impl);
|
|
114
|
+
Object.freeze(SignedDecryptionPermitV2Impl.prototype);
|
|
115
|
+
|
|
116
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
117
|
+
|
|
118
|
+
export function isSignedDecryptionPermitV2(value: unknown): value is SignedDecryptionPermitV2 {
|
|
119
|
+
return value instanceof SignedDecryptionPermitV2Impl;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
123
|
+
// _createSignedDecryptionPermitV2
|
|
124
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
125
|
+
|
|
126
|
+
async function _createSignedDecryptionPermitV2(
|
|
127
|
+
context: { readonly chain: FhevmChain; readonly runtime: FhevmRuntime },
|
|
128
|
+
parameters: {
|
|
129
|
+
readonly signerAddress: ChecksummedAddress;
|
|
130
|
+
readonly eip712: KmsUserDecryptEip712V2;
|
|
131
|
+
readonly signature: Bytes65Hex;
|
|
132
|
+
readonly delegatorAddress?: ChecksummedAddress | undefined;
|
|
133
|
+
},
|
|
134
|
+
): Promise<SignedDecryptionPermitV2> {
|
|
135
|
+
const { signerAddress, eip712, signature } = parameters;
|
|
136
|
+
|
|
137
|
+
if (eip712.message.allowedContracts.length > MAX_USER_DECRYPT_CONTRACT_ADDRESSES) {
|
|
138
|
+
throw Error(`allowedContracts max length of ${MAX_USER_DECRYPT_CONTRACT_ADDRESSES} exceeded`);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
await verifyKmsUserDecryptEip712V2(context, { signer: signerAddress, message: eip712.message, signature });
|
|
142
|
+
|
|
143
|
+
return new SignedDecryptionPermitV2Impl(PRIVATE_TOKEN, parameters);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
147
|
+
// signDecryptionPermitV2
|
|
148
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
149
|
+
|
|
150
|
+
export async function signDecryptionPermitV2(
|
|
151
|
+
context: SignDecryptionPermitContext,
|
|
152
|
+
parameters: SignDecryptionPermitParameters,
|
|
153
|
+
): Promise<SignedDecryptionPermit> {
|
|
154
|
+
const kmsSignersContext = await readCurrentKmsSignersContext(context, {
|
|
155
|
+
kmsVerifierAddress: context.chain.fhevm.contracts.kmsVerifier.address as ChecksummedAddress,
|
|
156
|
+
protocolConfigAddress: context.chain.fhevm.contracts.protocolConfig?.address as ChecksummedAddress | undefined,
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
const extraData: KmsExtraData = kmsSignersContextToExtraData(kmsSignersContext);
|
|
160
|
+
|
|
161
|
+
// For debug purpose only:
|
|
162
|
+
// -----------------------
|
|
163
|
+
// In theory, it should not be possible to produce a unified eip712 (protocol v14+)
|
|
164
|
+
// with an extraData coming from an old protocol v11/12/13
|
|
165
|
+
assert(
|
|
166
|
+
extraData.version >= EXTRA_DATA_V2,
|
|
167
|
+
`signDecryptionPermitV2 error: Invalid extraData version extraData=${extraData.toBytesHex()}`,
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
const {
|
|
171
|
+
contractAddresses,
|
|
172
|
+
startTimestamp,
|
|
173
|
+
durationSeconds: durationSecondsParam,
|
|
174
|
+
signerAddress: signerAddressArg,
|
|
175
|
+
transportKeyPair: transportKeyPair,
|
|
176
|
+
signer,
|
|
177
|
+
delegatorAddress: delegatorAddressArg,
|
|
178
|
+
} = parameters;
|
|
179
|
+
|
|
180
|
+
if (durationSecondsParam <= 0) {
|
|
181
|
+
throw new RangeError(`durationSeconds must be positive, got ${durationSecondsParam}`);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const MAX_DURATION_SECONDS = 604_800n; // 7 days in seconds
|
|
185
|
+
const durationSeconds = BigInt(durationSecondsParam);
|
|
186
|
+
|
|
187
|
+
// RFC-016: warn when permissive mode (allowedContracts=[]) is combined with a long-lived permit —
|
|
188
|
+
// a stolen signature can decrypt anything the user owns until it expires or is invalidated.
|
|
189
|
+
if (contractAddresses.length === 0 && durationSeconds > MAX_DURATION_SECONDS) {
|
|
190
|
+
const msg = `permissive mode (allowedContracts=[]) with durationSeconds ${durationSeconds} exceeds the recommended maximum of ${MAX_DURATION_SECONDS}s — consider using a shorter window or app-bounded allowedContracts`;
|
|
191
|
+
const logger = context.runtime.config.logger;
|
|
192
|
+
logger?.warn?.(msg);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
assertIsTransportKeyPair(transportKeyPair, {});
|
|
196
|
+
assertIsAddress(signerAddressArg, {});
|
|
197
|
+
|
|
198
|
+
const signerAddress = addressToChecksummedAddress(signerAddressArg);
|
|
199
|
+
|
|
200
|
+
let delegatorAddress: ChecksummedAddress | undefined;
|
|
201
|
+
if (delegatorAddressArg !== undefined) {
|
|
202
|
+
assertIsAddress(delegatorAddressArg, {});
|
|
203
|
+
delegatorAddress = addressToChecksummedAddress(delegatorAddressArg);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// RFC-016: round startTimestamp down to the nearest minute. This absorbs small clock skew
|
|
207
|
+
// and prevents a future-dated startTimestamp from bypassing signature invalidation
|
|
208
|
+
// (a future start would survive an invalidateDecryptionSignaturesBefore(block.timestamp) call).
|
|
209
|
+
const roundedStartTimestamp = Math.floor(startTimestamp / 60) * 60;
|
|
210
|
+
|
|
211
|
+
const commonMessage = {
|
|
212
|
+
verifyingContractAddressDecryption: context.chain.fhevm.gateway.contracts.decryption.address as ChecksummedAddress,
|
|
213
|
+
chainId: context.chain.id,
|
|
214
|
+
userAddress: signerAddress, // identity asserting authorization
|
|
215
|
+
allowedContracts: contractAddresses, // [] = permissive, [...] = specific
|
|
216
|
+
durationSeconds,
|
|
217
|
+
startTimestamp: roundedStartTimestamp,
|
|
218
|
+
extraData,
|
|
219
|
+
publicKey: transportKeyPair.publicKey,
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
const eip712 = createKmsUserDecryptEip712V2(commonMessage);
|
|
223
|
+
|
|
224
|
+
const signature = await context.runtime.ethereum.signTypedData(signer, {
|
|
225
|
+
account: signerAddress,
|
|
226
|
+
...eip712,
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
return await _createSignedDecryptionPermitV2(context, {
|
|
230
|
+
signature,
|
|
231
|
+
signerAddress,
|
|
232
|
+
eip712,
|
|
233
|
+
delegatorAddress,
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
238
|
+
// parseSignedDecryptionPermitV2
|
|
239
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
240
|
+
|
|
241
|
+
export async function parseSignedDecryptionPermitV2(
|
|
242
|
+
context: SignDecryptionPermitContext,
|
|
243
|
+
transportKeyPair: TransportKeyPair,
|
|
244
|
+
permit: unknown,
|
|
245
|
+
): Promise<SignedDecryptionPermitV2> {
|
|
246
|
+
assertIsTransportKeyPair(transportKeyPair, {});
|
|
247
|
+
|
|
248
|
+
const permitName = 'permit';
|
|
249
|
+
const options = {};
|
|
250
|
+
|
|
251
|
+
assertRecordNonNullableProperty(permit, 'eip712', permitName, options);
|
|
252
|
+
assertRecordBytes65HexProperty(permit, 'signature', permitName, options);
|
|
253
|
+
assertRecordAddressProperty(permit, 'signerAddress', permitName, options);
|
|
254
|
+
|
|
255
|
+
const eip712 = permit.eip712;
|
|
256
|
+
assertRecordStringProperty(eip712, 'primaryType', `${permitName}.eip712`, options);
|
|
257
|
+
const primaryType = (eip712 as Record<string, unknown>).primaryType;
|
|
258
|
+
|
|
259
|
+
if (primaryType !== 'UserDecryptRequestVerification') {
|
|
260
|
+
throw new Error(`Expected primaryType 'UserDecryptRequestVerification' for V2 permit, got: ${primaryType}`);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
assertIsKmsUserDecryptEip712V2(eip712, `${permitName}.eip712`, options);
|
|
264
|
+
|
|
265
|
+
const signerAddress = addressToChecksummedAddress(permit.signerAddress);
|
|
266
|
+
|
|
267
|
+
if (eip712.message.publicKey.toLowerCase() !== transportKeyPair.publicKey.toLowerCase()) {
|
|
268
|
+
throw new Error(
|
|
269
|
+
"The permit's publicKey does not match the TransportKeyPair's publicKey. " +
|
|
270
|
+
'Ensure the permit was signed with the same key pair.',
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
return await _createSignedDecryptionPermitV2(context, { signature: permit.signature, eip712, signerAddress });
|
|
275
|
+
}
|