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