@fhevm/sdk 1.0.0-alpha.4 → 1.0.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_cjs/core/_version.js +1 -1
- package/_cjs/core/actions/base/fetchEncryptedValues.js +18 -0
- package/_cjs/core/actions/base/fetchEncryptedValues.js.map +1 -0
- package/_cjs/core/actions/base/index.js +3 -1
- package/_cjs/core/actions/base/index.js.map +1 -1
- package/_cjs/core/actions/chain/createKmsDelegatedUserDecryptEip712.js.map +1 -1
- package/_cjs/core/actions/chain/createKmsUserDecryptEip712.js.map +1 -1
- package/_cjs/core/actions/chain/index.js +5 -5
- package/_cjs/core/actions/chain/parseSignedDecryptionPermit.js +2 -2
- package/_cjs/core/actions/chain/parseSignedDecryptionPermit.js.map +1 -1
- package/_cjs/core/actions/chain/parseTransportKeyPair.js +8 -0
- package/_cjs/core/actions/chain/parseTransportKeyPair.js.map +1 -0
- package/_cjs/core/actions/chain/serializeTransportKeyPair.js +8 -0
- package/_cjs/core/actions/chain/serializeTransportKeyPair.js.map +1 -0
- package/_cjs/core/actions/decrypt/generateTransportKeyPair.js +8 -0
- package/_cjs/core/actions/decrypt/generateTransportKeyPair.js.map +1 -0
- package/_cjs/core/actions/decrypt/index.js +3 -3
- package/_cjs/core/actions/decrypt/index.js.map +1 -1
- package/_cjs/core/base/address.js.map +1 -1
- package/_cjs/core/base/fetch.js +2 -2
- package/_cjs/core/base/fetch.js.map +1 -1
- package/_cjs/core/base/sign.js +12 -6
- package/_cjs/core/base/sign.js.map +1 -1
- package/_cjs/core/base/wasm.js +1 -1
- package/_cjs/core/base/wasm.js.map +1 -1
- package/_cjs/core/clients/decorators/base.js +4 -4
- package/_cjs/core/clients/decorators/decrypt.js +2 -2
- package/_cjs/core/coprocessor/ZkProof-p.js +2 -1
- package/_cjs/core/coprocessor/ZkProof-p.js.map +1 -1
- package/_cjs/core/handle/EncryptedValue.js +0 -4
- package/_cjs/core/handle/EncryptedValue.js.map +1 -1
- package/_cjs/core/handle/FheType.js.map +1 -1
- package/_cjs/core/host-contracts/canDecryptValuesFromPairs.js +3 -3
- package/_cjs/core/kms/SignedDecryptionPermit-p.js +10 -10
- package/_cjs/core/kms/SignedDecryptionPermit-p.js.map +1 -1
- package/_cjs/core/kms/{TransportKeypair-p.js → TransportKeyPair-p.js} +48 -48
- package/_cjs/core/kms/{TransportKeypair-p.js.map → TransportKeyPair-p.js.map} +1 -1
- package/_cjs/core/kms/decryptKmsSignedcryptedShares-p.js +3 -3
- package/_cjs/core/kms/decryptKmsSignedcryptedShares-p.js.map +1 -1
- package/_cjs/core/kms/decryptValuesFromPairs.js +2 -2
- package/_cjs/core/kms/decryptValuesFromPairs.js.map +1 -1
- package/_cjs/core/kms/index.js +0 -1
- package/_cjs/core/kms/kmsExtraData.js +7 -1
- package/_cjs/core/kms/kmsExtraData.js.map +1 -1
- package/_cjs/core/modules/decrypt/mock.js.map +1 -1
- package/_cjs/core/modules/decrypt/module/init-p.js +3 -7
- package/_cjs/core/modules/decrypt/module/init-p.js.map +1 -1
- package/_cjs/core/modules/encrypt/mock.js.map +1 -1
- package/_cjs/core/modules/encrypt/module/api-p.js.map +1 -1
- package/_cjs/core/modules/encrypt/module/index.js.map +1 -1
- package/_cjs/core/modules/encrypt/module/init-p.js +18 -13
- package/_cjs/core/modules/encrypt/module/init-p.js.map +1 -1
- package/_cjs/core/modules/relayer/module/RelayerAsyncRequest.js.map +1 -1
- package/_cjs/core/modules/relayer/module/fetchPublicDecrypt.js.map +1 -1
- package/_cjs/core/modules/relayer/module/fetchUserDecrypt.js.map +1 -1
- package/_cjs/core/modules/relayer/module/guards/RelayerErrorBody.js +27 -0
- package/_cjs/core/modules/relayer/module/guards/RelayerErrorBody.js.map +1 -0
- package/_cjs/core/types/index.js +4 -0
- package/_cjs/core/types/index.js.map +1 -1
- package/_cjs/core/utils-p/decrypt/assertPermitMatchesKeyPair.js +14 -0
- package/_cjs/core/utils-p/decrypt/assertPermitMatchesKeyPair.js.map +1 -0
- package/_cjs/core/utils-p/decrypt/verifyTkmsPublicKey.js +1 -1
- package/_cjs/core/utils-p/decrypt/verifyTkmsPublicKey.js.map +1 -1
- package/_esm/core/_version.js +1 -1
- package/_esm/core/actions/base/fetchEncryptedValues.js +16 -0
- package/_esm/core/actions/base/fetchEncryptedValues.js.map +1 -0
- package/_esm/core/actions/base/index.js +1 -0
- package/_esm/core/actions/base/index.js.map +1 -1
- package/_esm/core/actions/chain/createKmsDelegatedUserDecryptEip712.js.map +1 -1
- package/_esm/core/actions/chain/createKmsUserDecryptEip712.js.map +1 -1
- package/_esm/core/actions/chain/index.js +2 -2
- package/_esm/core/actions/chain/parseSignedDecryptionPermit.js +3 -3
- package/_esm/core/actions/chain/parseSignedDecryptionPermit.js.map +1 -1
- package/_esm/core/actions/chain/parseTransportKeyPair.js +5 -0
- package/_esm/core/actions/chain/parseTransportKeyPair.js.map +1 -0
- package/_esm/core/actions/chain/serializeTransportKeyPair.js +5 -0
- package/_esm/core/actions/chain/{serializeTransportKeypair.js.map → serializeTransportKeyPair.js.map} +1 -1
- package/_esm/core/actions/decrypt/generateTransportKeyPair.js +6 -0
- package/_esm/core/actions/decrypt/{generateTransportKeypair.js.map → generateTransportKeyPair.js.map} +1 -1
- package/_esm/core/actions/decrypt/index.js +3 -1
- package/_esm/core/actions/decrypt/index.js.map +1 -1
- package/_esm/core/base/address.js.map +1 -1
- package/_esm/core/base/fetch.js +2 -2
- package/_esm/core/base/fetch.js.map +1 -1
- package/_esm/core/base/sign.js +15 -8
- package/_esm/core/base/sign.js.map +1 -1
- package/_esm/core/base/wasm.js +1 -1
- package/_esm/core/base/wasm.js.map +1 -1
- package/_esm/core/clients/decorators/base.js +4 -4
- package/_esm/core/clients/decorators/decrypt.js +2 -2
- package/_esm/core/coprocessor/ZkProof-p.js +3 -2
- package/_esm/core/coprocessor/ZkProof-p.js.map +1 -1
- package/_esm/core/handle/EncryptedValue.js +0 -3
- package/_esm/core/handle/EncryptedValue.js.map +1 -1
- package/_esm/core/handle/FheType.js +10 -17
- package/_esm/core/handle/FheType.js.map +1 -1
- package/_esm/core/host-contracts/canDecryptValuesFromPairs.js +3 -3
- package/_esm/core/kms/SignedDecryptionPermit-p.js +10 -10
- package/_esm/core/kms/SignedDecryptionPermit-p.js.map +1 -1
- package/_esm/core/kms/{TransportKeypair-p.js → TransportKeyPair-p.js} +55 -55
- package/_esm/core/kms/{TransportKeypair-p.js.map → TransportKeyPair-p.js.map} +1 -1
- package/_esm/core/kms/decryptKmsSignedcryptedShares-p.js +4 -4
- package/_esm/core/kms/decryptKmsSignedcryptedShares-p.js.map +1 -1
- package/_esm/core/kms/decryptValuesFromPairs.js +2 -2
- package/_esm/core/kms/decryptValuesFromPairs.js.map +1 -1
- package/_esm/core/kms/kmsExtraData.js +7 -1
- package/_esm/core/kms/kmsExtraData.js.map +1 -1
- package/_esm/core/modules/decrypt/mock.js.map +1 -1
- package/_esm/core/modules/decrypt/module/init-p.js +13 -11
- package/_esm/core/modules/decrypt/module/init-p.js.map +1 -1
- package/_esm/core/modules/encrypt/mock.js.map +1 -1
- package/_esm/core/modules/encrypt/module/api-p.js.map +1 -1
- package/_esm/core/modules/encrypt/module/index.js.map +1 -1
- package/_esm/core/modules/encrypt/module/init-p.js +34 -17
- package/_esm/core/modules/encrypt/module/init-p.js.map +1 -1
- package/_esm/core/modules/relayer/module/RelayerAsyncRequest.js +13 -0
- package/_esm/core/modules/relayer/module/RelayerAsyncRequest.js.map +1 -1
- package/_esm/core/modules/relayer/module/fetchPublicDecrypt.js.map +1 -1
- package/_esm/core/modules/relayer/module/fetchUserDecrypt.js.map +1 -1
- package/_esm/core/modules/relayer/module/guards/RelayerErrorBody.js +24 -0
- package/_esm/core/modules/relayer/module/guards/RelayerErrorBody.js.map +1 -0
- package/_esm/core/types/index.js +1 -1
- package/_esm/core/types/index.js.map +1 -1
- package/_esm/core/utils-p/decrypt/assertPermitMatchesKeyPair.js +19 -0
- package/_esm/core/utils-p/decrypt/assertPermitMatchesKeyPair.js.map +1 -0
- package/_esm/core/utils-p/decrypt/verifyTkmsPublicKey.js +1 -1
- package/_esm/core/utils-p/decrypt/verifyTkmsPublicKey.js.map +1 -1
- package/_types/core/actions/base/fetchEncryptedValues.d.ts +16 -0
- package/_types/core/actions/base/fetchEncryptedValues.d.ts.map +1 -0
- package/_types/core/actions/base/index.d.ts +1 -0
- package/_types/core/actions/base/index.d.ts.map +1 -1
- package/_types/core/actions/chain/createKmsDelegatedUserDecryptEip712.d.ts.map +1 -1
- package/_types/core/actions/chain/createKmsUserDecryptEip712.d.ts.map +1 -1
- package/_types/core/actions/chain/index.d.ts +2 -2
- package/_types/core/actions/chain/parseSignedDecryptionPermit.d.ts +4 -4
- package/_types/core/actions/chain/parseSignedDecryptionPermit.d.ts.map +1 -1
- package/_types/core/actions/chain/{parseTransportKeypair.d.ts → parseTransportKeyPair.d.ts} +5 -5
- package/_types/core/actions/chain/{parseTransportKeypair.d.ts.map → parseTransportKeyPair.d.ts.map} +1 -1
- package/_types/core/actions/chain/{serializeTransportKeypair.d.ts → serializeTransportKeyPair.d.ts} +6 -6
- package/_types/core/actions/chain/{serializeTransportKeypair.d.ts.map → serializeTransportKeyPair.d.ts.map} +1 -1
- package/_types/core/actions/decrypt/canDecryptValue.d.ts +4 -4
- package/_types/core/actions/decrypt/canDecryptValues.d.ts +2 -2
- package/_types/core/actions/decrypt/canDecryptValuesFromPairs.d.ts +2 -2
- package/_types/core/actions/decrypt/decryptKmsSignedcryptedShares.d.ts +2 -2
- package/_types/core/actions/decrypt/decryptValue.d.ts +2 -2
- package/_types/core/actions/decrypt/decryptValues.d.ts +2 -2
- package/_types/core/actions/decrypt/decryptValuesFromPairs.d.ts +2 -2
- package/_types/core/actions/decrypt/{generateTransportKeypair.d.ts → generateTransportKeyPair.d.ts} +4 -4
- package/_types/core/actions/decrypt/{generateTransportKeypair.d.ts.map → generateTransportKeyPair.d.ts.map} +1 -1
- package/_types/core/actions/decrypt/index.d.ts +3 -1
- package/_types/core/actions/decrypt/index.d.ts.map +1 -1
- package/_types/core/base/address.d.ts.map +1 -1
- package/_types/core/base/sign.d.ts.map +1 -1
- package/_types/core/clients/decorators/base.d.ts +6 -6
- package/_types/core/clients/decorators/base.d.ts.map +1 -1
- package/_types/core/clients/decorators/decrypt.d.ts +2 -2
- package/_types/core/coprocessor/ZkProof-p.d.ts +2 -1
- package/_types/core/coprocessor/ZkProof-p.d.ts.map +1 -1
- package/_types/core/handle/EncryptedValue.d.ts +0 -1
- package/_types/core/handle/EncryptedValue.d.ts.map +1 -1
- package/_types/core/handle/FheType.d.ts +10 -17
- package/_types/core/handle/FheType.d.ts.map +1 -1
- package/_types/core/host-contracts/canDecryptValuesFromPairs.d.ts +2 -2
- package/_types/core/kms/SignedDecryptionPermit-p.d.ts +6 -6
- package/_types/core/kms/{TransportKeypair-p.d.ts → TransportKeyPair-p.d.ts} +23 -23
- package/_types/core/kms/{TransportKeypair-p.d.ts.map → TransportKeyPair-p.d.ts.map} +1 -1
- package/_types/core/kms/decryptKmsSignedcryptedShares-p.d.ts +2 -2
- package/_types/core/kms/decryptValuesFromPairs.d.ts +3 -3
- package/_types/core/kms/index.d.ts +1 -1
- package/_types/core/kms/index.d.ts.map +1 -1
- package/_types/core/kms/kmsExtraData.d.ts.map +1 -1
- package/_types/core/modules/decrypt/module/init-p.d.ts.map +1 -1
- package/_types/core/modules/encrypt/mock.d.ts +2 -2
- package/_types/core/modules/encrypt/mock.d.ts.map +1 -1
- package/_types/core/modules/encrypt/module/api-p.d.ts +2 -2
- package/_types/core/modules/encrypt/module/api-p.d.ts.map +1 -1
- package/_types/core/modules/encrypt/module/init-p.d.ts.map +1 -1
- package/_types/core/modules/encrypt/types.d.ts +2 -2
- package/_types/core/modules/encrypt/types.d.ts.map +1 -1
- package/_types/core/modules/relayer/module/RelayerAsyncRequest.d.ts.map +1 -1
- package/_types/core/modules/relayer/module/fetchUserDecrypt.d.ts.map +1 -1
- package/_types/core/modules/relayer/module/guards/RelayerErrorBody.d.ts +13 -0
- package/_types/core/modules/relayer/module/guards/RelayerErrorBody.d.ts.map +1 -0
- package/_types/core/types/index.d.ts +3 -0
- package/_types/core/types/index.d.ts.map +1 -1
- package/_types/core/types/signedDecryptionPermit.d.ts +1 -1
- package/_types/core/types/signedDecryptionPermit.d.ts.map +1 -1
- package/_types/core/utils-p/decrypt/assertPermitMatchesKeyPair.d.ts +12 -0
- package/_types/core/utils-p/decrypt/{assertPermitMatchesKeypair.d.ts.map → assertPermitMatchesKeyPair.d.ts.map} +1 -1
- package/core/_version.ts +1 -1
- package/core/actions/base/fetchEncryptedValues.ts +42 -0
- package/core/actions/base/index.ts +6 -0
- package/core/actions/chain/createKmsDelegatedUserDecryptEip712.ts +1 -2
- package/core/actions/chain/createKmsUserDecryptEip712.ts +1 -2
- package/core/actions/chain/index.ts +8 -8
- package/core/actions/chain/parseSignedDecryptionPermit.ts +6 -6
- package/core/actions/chain/{parseTransportKeypair.ts → parseTransportKeyPair.ts} +7 -7
- package/core/actions/chain/{serializeTransportKeypair.ts → serializeTransportKeyPair.ts} +10 -10
- package/core/actions/decrypt/canDecryptValue.ts +4 -4
- package/core/actions/decrypt/canDecryptValues.ts +2 -2
- package/core/actions/decrypt/canDecryptValuesFromPairs.ts +2 -2
- package/core/actions/decrypt/decryptKmsSignedcryptedShares.ts +2 -2
- package/core/actions/decrypt/decryptValue.ts +2 -2
- package/core/actions/decrypt/decryptValues.ts +2 -2
- package/core/actions/decrypt/decryptValuesFromPairs.ts +2 -2
- package/core/actions/decrypt/{generateTransportKeypair.ts → generateTransportKeyPair.ts} +7 -7
- package/core/actions/decrypt/index.ts +8 -4
- package/core/base/address.ts +2 -2
- package/core/base/fetch.ts +2 -2
- package/core/base/sign.ts +16 -8
- package/core/base/wasm.ts +1 -1
- package/core/clients/decorators/base.ts +18 -18
- package/core/clients/decorators/decrypt.ts +4 -4
- package/core/coprocessor/ZkProof-p.ts +6 -6
- package/core/handle/EncryptedValue.ts +0 -4
- package/core/handle/FheType.ts +10 -17
- package/core/host-contracts/canDecryptValuesFromPairs.ts +5 -5
- package/core/kms/SignedDecryptionPermit-p.ts +14 -14
- package/core/kms/{TransportKeypair-p.ts → TransportKeyPair-p.ts} +42 -42
- package/core/kms/decryptKmsSignedcryptedShares-p.ts +6 -6
- package/core/kms/decryptValuesFromPairs.ts +5 -5
- package/core/kms/index.ts +0 -1
- package/core/kms/kmsExtraData.ts +8 -1
- package/core/modules/decrypt/mock.ts +3 -3
- package/core/modules/decrypt/module/init-p.ts +13 -14
- package/core/modules/encrypt/mock.ts +4 -6
- package/core/modules/encrypt/module/api-p.ts +4 -6
- package/core/modules/encrypt/module/index.ts +2 -2
- package/core/modules/encrypt/module/init-p.ts +37 -21
- package/core/modules/encrypt/types.ts +2 -2
- package/core/modules/relayer/module/RelayerAsyncRequest.ts +14 -0
- package/core/modules/relayer/module/fetchPublicDecrypt.ts +2 -2
- package/core/modules/relayer/module/fetchUserDecrypt.ts +1 -2
- package/core/modules/relayer/module/guards/RelayerErrorBody.ts +33 -0
- package/core/types/index.ts +3 -0
- package/core/types/signedDecryptionPermit.ts +1 -1
- package/core/utils-p/decrypt/assertPermitMatchesKeyPair.ts +27 -0
- package/core/utils-p/decrypt/verifyTkmsPublicKey.ts +1 -1
- package/package.json +3 -2
- package/_cjs/core/actions/chain/parseTransportKeypair.js +0 -8
- package/_cjs/core/actions/chain/parseTransportKeypair.js.map +0 -1
- package/_cjs/core/actions/chain/serializeTransportKeypair.js +0 -8
- package/_cjs/core/actions/chain/serializeTransportKeypair.js.map +0 -1
- package/_cjs/core/actions/decrypt/generateTransportKeypair.js +0 -8
- package/_cjs/core/actions/decrypt/generateTransportKeypair.js.map +0 -1
- package/_cjs/core/utils-p/decrypt/assertPermitMatchesKeypair.js +0 -14
- package/_cjs/core/utils-p/decrypt/assertPermitMatchesKeypair.js.map +0 -1
- package/_esm/core/actions/chain/parseTransportKeypair.js +0 -5
- package/_esm/core/actions/chain/parseTransportKeypair.js.map +0 -1
- package/_esm/core/actions/chain/serializeTransportKeypair.js +0 -5
- package/_esm/core/actions/decrypt/generateTransportKeypair.js +0 -6
- package/_esm/core/utils-p/decrypt/assertPermitMatchesKeypair.js +0 -19
- package/_esm/core/utils-p/decrypt/assertPermitMatchesKeypair.js.map +0 -1
- package/_types/core/utils-p/decrypt/assertPermitMatchesKeypair.d.ts +0 -12
- package/core/utils-p/decrypt/assertPermitMatchesKeypair.ts +0 -27
- package/tsconfig.json +0 -9
- package/vitest.config.ts +0 -17
|
@@ -12,16 +12,16 @@ export {
|
|
|
12
12
|
} from './fetchFheEncryptionKeyBytes.js';
|
|
13
13
|
|
|
14
14
|
export {
|
|
15
|
-
type
|
|
16
|
-
type
|
|
17
|
-
|
|
18
|
-
} from './
|
|
15
|
+
type ParseTransportKeyPairParameters,
|
|
16
|
+
type ParseTransportKeyPairReturnType,
|
|
17
|
+
parseTransportKeyPair,
|
|
18
|
+
} from './parseTransportKeyPair.js';
|
|
19
19
|
|
|
20
20
|
export {
|
|
21
|
-
type
|
|
22
|
-
type
|
|
23
|
-
|
|
24
|
-
} from './
|
|
21
|
+
type SerializeTransportKeyPairParameters,
|
|
22
|
+
type SerializeTransportKeyPairReturnType,
|
|
23
|
+
serializeTransportKeyPair,
|
|
24
|
+
} from './serializeTransportKeyPair.js';
|
|
25
25
|
|
|
26
26
|
export {
|
|
27
27
|
type CreateKmsDelegatedUserDecryptEip712Parameters,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Fhevm } from '../../types/coreFhevmClient.js';
|
|
2
2
|
import type { FhevmChain } from '../../types/fhevmChain.js';
|
|
3
3
|
import type { SignedDecryptionPermit } from '../../types/signedDecryptionPermit.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { TransportKeyPair } from '../../kms/TransportKeyPair-p.js';
|
|
5
5
|
import type { KmsDecryptEip712Like } from '../../types/kms.js';
|
|
6
6
|
import { parseSignedDecryptionPermit as parseSignedDecryptionPermit_ } from '../../kms/SignedDecryptionPermit-p.js';
|
|
7
7
|
|
|
@@ -14,8 +14,8 @@ export type ParseSignedDecryptionPermitParameters = {
|
|
|
14
14
|
readonly signature: string;
|
|
15
15
|
readonly signerAddress: string;
|
|
16
16
|
};
|
|
17
|
-
/** The transport
|
|
18
|
-
readonly
|
|
17
|
+
/** The transport key pair that was used when signing the permit. */
|
|
18
|
+
readonly transportKeyPair: TransportKeyPair;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
export type ParseSignedDecryptionPermitReturnType = SignedDecryptionPermit;
|
|
@@ -24,7 +24,7 @@ export type ParseSignedDecryptionPermitReturnType = SignedDecryptionPermit;
|
|
|
24
24
|
* Parses and verifies a previously serialized signed decryption permit.
|
|
25
25
|
*
|
|
26
26
|
* Validates the EIP-712 structure, verifies the signature against the on-chain
|
|
27
|
-
* verifier, and checks the permit's public key matches the provided
|
|
27
|
+
* verifier, and checks the permit's public key matches the provided key pair.
|
|
28
28
|
*
|
|
29
29
|
* @throws If the permit is malformed, expired, or the signature is invalid.
|
|
30
30
|
*/
|
|
@@ -32,7 +32,7 @@ export async function parseSignedDecryptionPermit(
|
|
|
32
32
|
fhevm: Fhevm<FhevmChain>,
|
|
33
33
|
parameters: ParseSignedDecryptionPermitParameters,
|
|
34
34
|
): Promise<ParseSignedDecryptionPermitReturnType> {
|
|
35
|
-
const { serializedPermit,
|
|
35
|
+
const { serializedPermit, transportKeyPair: transportKeyPair } = parameters;
|
|
36
36
|
|
|
37
|
-
return parseSignedDecryptionPermit_(fhevm,
|
|
37
|
+
return parseSignedDecryptionPermit_(fhevm, transportKeyPair, serializedPermit);
|
|
38
38
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import type { Fhevm, OptionalNativeClient } from '../../types/coreFhevmClient.js';
|
|
2
2
|
import type { FhevmRuntime } from '../../types/coreFhevmRuntime.js';
|
|
3
3
|
import type { FhevmChain } from '../../types/fhevmChain.js';
|
|
4
|
-
import {
|
|
4
|
+
import { toTransportKeyPair, type TransportKeyPair } from '../../kms/TransportKeyPair-p.js';
|
|
5
5
|
|
|
6
6
|
////////////////////////////////////////////////////////////////////////////////
|
|
7
7
|
|
|
8
|
-
export type
|
|
8
|
+
export type ParseTransportKeyPairParameters = {
|
|
9
9
|
readonly publicKey: string;
|
|
10
10
|
readonly privateKey: string;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
export type
|
|
13
|
+
export type ParseTransportKeyPairReturnType = TransportKeyPair;
|
|
14
14
|
|
|
15
|
-
export async function
|
|
15
|
+
export async function parseTransportKeyPair(
|
|
16
16
|
fhevm: Fhevm<FhevmChain, FhevmRuntime, OptionalNativeClient>,
|
|
17
|
-
parameters:
|
|
18
|
-
): Promise<
|
|
19
|
-
return
|
|
17
|
+
parameters: ParseTransportKeyPairParameters,
|
|
18
|
+
): Promise<ParseTransportKeyPairReturnType> {
|
|
19
|
+
return toTransportKeyPair(fhevm, parameters);
|
|
20
20
|
}
|
|
@@ -3,24 +3,24 @@ import type { FhevmRuntime } from '../../types/coreFhevmRuntime.js';
|
|
|
3
3
|
import type { FhevmChain } from '../../types/fhevmChain.js';
|
|
4
4
|
import type { BytesHex } from '../../types/primitives.js';
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
type
|
|
8
|
-
} from '../../kms/
|
|
6
|
+
serializeTransportKeyPair as serializeTransportKeyPair_,
|
|
7
|
+
type TransportKeyPair,
|
|
8
|
+
} from '../../kms/TransportKeyPair-p.js';
|
|
9
9
|
|
|
10
10
|
////////////////////////////////////////////////////////////////////////////////
|
|
11
11
|
|
|
12
|
-
export type
|
|
13
|
-
readonly
|
|
12
|
+
export type SerializeTransportKeyPairParameters = {
|
|
13
|
+
readonly transportKeyPair: TransportKeyPair;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
export type
|
|
16
|
+
export type SerializeTransportKeyPairReturnType = {
|
|
17
17
|
publicKey: BytesHex;
|
|
18
18
|
privateKey: BytesHex;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
export function
|
|
21
|
+
export function serializeTransportKeyPair(
|
|
22
22
|
_fhevm: Fhevm<FhevmChain, FhevmRuntime, OptionalNativeClient>,
|
|
23
|
-
parameters:
|
|
24
|
-
):
|
|
25
|
-
return
|
|
23
|
+
parameters: SerializeTransportKeyPairParameters,
|
|
24
|
+
): SerializeTransportKeyPairReturnType {
|
|
25
|
+
return serializeTransportKeyPair_(parameters.transportKeyPair);
|
|
26
26
|
}
|
|
@@ -5,7 +5,7 @@ import type {
|
|
|
5
5
|
SignedDelegatedDecryptionPermit,
|
|
6
6
|
SignedSelfDecryptionPermit,
|
|
7
7
|
} from '../../types/signedDecryptionPermit.js';
|
|
8
|
-
import type {
|
|
8
|
+
import type { TransportKeyPair } from '../../kms/TransportKeyPair-p.js';
|
|
9
9
|
import type { EncryptedValueLike } from '../../types/encryptedTypes.js';
|
|
10
10
|
import { canDecryptValuesFromPairs as canDecryptValuesFromPairs_ } from '../../host-contracts/canDecryptValuesFromPairs.js';
|
|
11
11
|
import { addressToChecksummedAddress, assertIsAddress } from '../../base/address.js';
|
|
@@ -24,7 +24,7 @@ export type CanDecryptValueWithUserAddressParameters = CanDecryptValueParameters
|
|
|
24
24
|
|
|
25
25
|
export type CanDecryptValueWithPermitParameters = CanDecryptValueParametersBase & {
|
|
26
26
|
readonly signedPermit: SignedSelfDecryptionPermit | SignedDelegatedDecryptionPermit;
|
|
27
|
-
readonly
|
|
27
|
+
readonly transportKeyPair?: TransportKeyPair | undefined;
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
export type CanDecryptValueReturnType = {
|
|
@@ -54,9 +54,9 @@ export type CanDecryptValueReturnType = {
|
|
|
54
54
|
* - the current time is within the permit validity window
|
|
55
55
|
* - the permit is scoped to the requested `contractAddress`
|
|
56
56
|
*
|
|
57
|
-
* When both a `SignedDecryptionPermit` and an `
|
|
57
|
+
* When both a `SignedDecryptionPermit` and an `transportKeyPair` are provided,
|
|
58
58
|
* the function also checks that the permit is scoped to the corresponding
|
|
59
|
-
* `
|
|
59
|
+
* `transportKeyPair.publicKey`.
|
|
60
60
|
*
|
|
61
61
|
* A permit is scoped to:
|
|
62
62
|
* - a user
|
|
@@ -5,7 +5,7 @@ import type {
|
|
|
5
5
|
SignedDelegatedDecryptionPermit,
|
|
6
6
|
SignedSelfDecryptionPermit,
|
|
7
7
|
} from '../../types/signedDecryptionPermit.js';
|
|
8
|
-
import type {
|
|
8
|
+
import type { TransportKeyPair } from '../../kms/TransportKeyPair-p.js';
|
|
9
9
|
import type { EncryptedValueLike } from '../../types/encryptedTypes.js';
|
|
10
10
|
import { canDecryptValuesFromPairs as canDecryptValuesFromPairs_ } from '../../host-contracts/canDecryptValuesFromPairs.js';
|
|
11
11
|
import { addressToChecksummedAddress, assertIsAddress } from '../../base/address.js';
|
|
@@ -24,7 +24,7 @@ export type CanDecryptValuesWithUserAddressParameters = CanDecryptValuesParamete
|
|
|
24
24
|
|
|
25
25
|
export type CanDecryptValuesWithPermitParameters = CanDecryptValuesParametersBase & {
|
|
26
26
|
readonly signedPermit: SignedSelfDecryptionPermit | SignedDelegatedDecryptionPermit;
|
|
27
|
-
readonly
|
|
27
|
+
readonly transportKeyPair?: TransportKeyPair | undefined;
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
export type CanDecryptValuesReturnType = {
|
|
@@ -5,7 +5,7 @@ import type {
|
|
|
5
5
|
SignedDelegatedDecryptionPermit,
|
|
6
6
|
SignedSelfDecryptionPermit,
|
|
7
7
|
} from '../../types/signedDecryptionPermit.js';
|
|
8
|
-
import type {
|
|
8
|
+
import type { TransportKeyPair } from '../../kms/TransportKeyPair-p.js';
|
|
9
9
|
import type { EncryptedValueLike } from '../../types/encryptedTypes.js';
|
|
10
10
|
import { canDecryptValuesFromPairs as canDecryptValuesFromPairs_ } from '../../host-contracts/canDecryptValuesFromPairs.js';
|
|
11
11
|
import { addressToChecksummedAddress, assertIsAddress } from '../../base/address.js';
|
|
@@ -26,7 +26,7 @@ export type CanDecryptValuesFromPairsWithUserAddressParameters = CanDecryptValue
|
|
|
26
26
|
|
|
27
27
|
export type CanDecryptValuesFromPairsWithPermitParameters = CanDecryptValuesFromPairsParametersBase & {
|
|
28
28
|
readonly signedPermit: SignedSelfDecryptionPermit | SignedDelegatedDecryptionPermit;
|
|
29
|
-
readonly
|
|
29
|
+
readonly transportKeyPair?: TransportKeyPair | undefined;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
export type CanDecryptValuesFromPairsReturnType = {
|
|
@@ -2,7 +2,7 @@ import type { Fhevm } from '../../types/coreFhevmClient.js';
|
|
|
2
2
|
import type { FhevmChain } from '../../types/fhevmChain.js';
|
|
3
3
|
import type { WithDecrypt } from '../../types/coreFhevmRuntime.js';
|
|
4
4
|
import type { KmsSigncryptedShares } from '../../types/kms.js';
|
|
5
|
-
import type {
|
|
5
|
+
import type { TransportKeyPair } from '../../kms/TransportKeyPair-p.js';
|
|
6
6
|
import type { TypedValue } from '../../types/primitives.js';
|
|
7
7
|
import { decryptKmsSignedcryptedShares as decryptKmsSignedcryptedShares_ } from '../../kms/decryptKmsSignedcryptedShares-p.js';
|
|
8
8
|
import { clearValueToTypedValue } from '../../handle/ClearValue.js';
|
|
@@ -13,7 +13,7 @@ import { clearValueToTypedValue } from '../../handle/ClearValue.js';
|
|
|
13
13
|
|
|
14
14
|
export type DecryptKmsSignedcryptedSharesParameters = {
|
|
15
15
|
readonly kmsSigncryptedShares: KmsSigncryptedShares;
|
|
16
|
-
readonly
|
|
16
|
+
readonly transportKeyPair: TransportKeyPair;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export type DecryptKmsSignedcryptedSharesReturnType = readonly TypedValue[];
|
|
@@ -4,7 +4,7 @@ import type { FhevmChain } from '../../types/fhevmChain.js';
|
|
|
4
4
|
import type { RelayerDelegatedUserDecryptOptions, RelayerUserDecryptOptions } from '../../types/relayer.js';
|
|
5
5
|
import type { SignedDecryptionPermit } from '../../types/signedDecryptionPermit.js';
|
|
6
6
|
import type { WithDecrypt } from '../../types/coreFhevmRuntime.js';
|
|
7
|
-
import type {
|
|
7
|
+
import type { TransportKeyPair } from '../../kms/TransportKeyPair-p.js';
|
|
8
8
|
import type { EncryptedValueLike } from '../../types/encryptedTypes.js';
|
|
9
9
|
import { decryptValuesFromPairs as decryptValuesFromPairs_ } from '../../kms/decryptValuesFromPairs.js';
|
|
10
10
|
import { addressToChecksummedAddress, assertIsAddress } from '../../base/address.js';
|
|
@@ -15,7 +15,7 @@ import { toFhevmHandle } from '../../handle/FhevmHandle.js';
|
|
|
15
15
|
export type DecryptValueParameters = {
|
|
16
16
|
readonly encryptedValue: EncryptedValueLike;
|
|
17
17
|
readonly contractAddress: string;
|
|
18
|
-
readonly
|
|
18
|
+
readonly transportKeyPair: TransportKeyPair;
|
|
19
19
|
readonly signedPermit: SignedDecryptionPermit;
|
|
20
20
|
readonly options?: RelayerUserDecryptOptions | RelayerDelegatedUserDecryptOptions | undefined;
|
|
21
21
|
};
|
|
@@ -4,7 +4,7 @@ import type { FhevmChain } from '../../types/fhevmChain.js';
|
|
|
4
4
|
import type { RelayerDelegatedUserDecryptOptions, RelayerUserDecryptOptions } from '../../types/relayer.js';
|
|
5
5
|
import type { SignedDecryptionPermit } from '../../types/signedDecryptionPermit.js';
|
|
6
6
|
import type { WithDecrypt } from '../../types/coreFhevmRuntime.js';
|
|
7
|
-
import type {
|
|
7
|
+
import type { TransportKeyPair } from '../../kms/TransportKeyPair-p.js';
|
|
8
8
|
import type { EncryptedValueLike } from '../../types/encryptedTypes.js';
|
|
9
9
|
import { decryptValuesFromPairs as decryptValuesFromPairs_ } from '../../kms/decryptValuesFromPairs.js';
|
|
10
10
|
import { addressToChecksummedAddress, assertIsAddress } from '../../base/address.js';
|
|
@@ -15,7 +15,7 @@ import { toFhevmHandle } from '../../handle/FhevmHandle.js';
|
|
|
15
15
|
export type DecryptValuesParameters = {
|
|
16
16
|
readonly encryptedValues: readonly EncryptedValueLike[];
|
|
17
17
|
readonly contractAddress: string;
|
|
18
|
-
readonly
|
|
18
|
+
readonly transportKeyPair: TransportKeyPair;
|
|
19
19
|
readonly signedPermit: SignedDecryptionPermit;
|
|
20
20
|
readonly options?: RelayerUserDecryptOptions | RelayerDelegatedUserDecryptOptions | undefined;
|
|
21
21
|
};
|
|
@@ -4,7 +4,7 @@ import type { FhevmChain } from '../../types/fhevmChain.js';
|
|
|
4
4
|
import type { RelayerDelegatedUserDecryptOptions, RelayerUserDecryptOptions } from '../../types/relayer.js';
|
|
5
5
|
import type { SignedDecryptionPermit } from '../../types/signedDecryptionPermit.js';
|
|
6
6
|
import type { WithDecrypt } from '../../types/coreFhevmRuntime.js';
|
|
7
|
-
import type {
|
|
7
|
+
import type { TransportKeyPair } from '../../kms/TransportKeyPair-p.js';
|
|
8
8
|
import type { EncryptedValueLike } from '../../types/encryptedTypes.js';
|
|
9
9
|
import { decryptValuesFromPairs as decryptValuesFromPairs_ } from '../../kms/decryptValuesFromPairs.js';
|
|
10
10
|
import { addressToChecksummedAddress, assertIsAddress } from '../../base/address.js';
|
|
@@ -17,7 +17,7 @@ export type DecryptValuesFromPairsParameters = {
|
|
|
17
17
|
readonly encryptedValue: EncryptedValueLike;
|
|
18
18
|
readonly contractAddress: string;
|
|
19
19
|
}>;
|
|
20
|
-
readonly
|
|
20
|
+
readonly transportKeyPair: TransportKeyPair;
|
|
21
21
|
readonly signedPermit: SignedDecryptionPermit;
|
|
22
22
|
readonly options?: RelayerUserDecryptOptions | RelayerDelegatedUserDecryptOptions | undefined;
|
|
23
23
|
};
|
|
@@ -2,18 +2,18 @@ import type { Fhevm, OptionalNativeClient } from '../../types/coreFhevmClient.js
|
|
|
2
2
|
import type { WithDecrypt } from '../../types/coreFhevmRuntime.js';
|
|
3
3
|
import type { FhevmChain } from '../../types/fhevmChain.js';
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
type
|
|
7
|
-
} from '../../kms/
|
|
5
|
+
generateTransportKeyPair as generateTransportKeyPair_,
|
|
6
|
+
type TransportKeyPair,
|
|
7
|
+
} from '../../kms/TransportKeyPair-p.js';
|
|
8
8
|
|
|
9
9
|
////////////////////////////////////////////////////////////////////////////////
|
|
10
10
|
|
|
11
|
-
export type
|
|
11
|
+
export type GenerateTransportKeyPairReturnType = TransportKeyPair;
|
|
12
12
|
|
|
13
|
-
export async function
|
|
13
|
+
export async function generateTransportKeyPair(
|
|
14
14
|
fhevm: Fhevm<FhevmChain | undefined, WithDecrypt, OptionalNativeClient>,
|
|
15
|
-
): Promise<
|
|
16
|
-
return await
|
|
15
|
+
): Promise<GenerateTransportKeyPairReturnType> {
|
|
16
|
+
return await generateTransportKeyPair_(fhevm);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
////////////////////////////////////////////////////////////////////////////////
|
|
@@ -4,10 +4,7 @@ export type {
|
|
|
4
4
|
RelayerDelegatedUserDecryptProgressArgs,
|
|
5
5
|
} from '../../types/relayer.js';
|
|
6
6
|
|
|
7
|
-
export {
|
|
8
|
-
type GenerateTransportKeypairReturnType as GenerateE2eTransportKeypairReturnType,
|
|
9
|
-
generateTransportKeypair as generateE2eTransportKeypair,
|
|
10
|
-
} from './generateTransportKeypair.js';
|
|
7
|
+
export { type GenerateTransportKeyPairReturnType, generateTransportKeyPair } from './generateTransportKeyPair.js';
|
|
11
8
|
|
|
12
9
|
export {
|
|
13
10
|
type DecryptValuesFromPairsParameters,
|
|
@@ -45,3 +42,10 @@ export {
|
|
|
45
42
|
type CanDecryptValueReturnType,
|
|
46
43
|
canDecryptValue,
|
|
47
44
|
} from './canDecryptValue.js';
|
|
45
|
+
|
|
46
|
+
export { type TransportKeyPair } from '../../kms/TransportKeyPair-p.js';
|
|
47
|
+
|
|
48
|
+
export {
|
|
49
|
+
type SignDecryptionPermitParameters,
|
|
50
|
+
type SignDecryptionPermitReturnType,
|
|
51
|
+
} from '../base/signDecryptionPermit.js';
|
package/core/base/address.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Address, Bytes20,
|
|
1
|
+
import type { Address, Bytes20, ChecksummedAddress } from '../types/primitives.js';
|
|
2
2
|
import type {
|
|
3
3
|
RecordAddressPropertyType,
|
|
4
4
|
RecordChecksummedAddressArrayPropertyType,
|
|
@@ -117,7 +117,7 @@ export function isAddress(value: unknown): value is Address {
|
|
|
117
117
|
return false;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
const hexNo0x = remove0x(value)
|
|
120
|
+
const hexNo0x = remove0x(value);
|
|
121
121
|
const hexNo0xLowerCase = hexNo0x.toLowerCase();
|
|
122
122
|
|
|
123
123
|
if (hexNo0x === hexNo0xLowerCase) {
|
package/core/base/fetch.ts
CHANGED
|
@@ -219,8 +219,8 @@ export async function fetchWithRetry(
|
|
|
219
219
|
): Promise<Response> {
|
|
220
220
|
let lastError: unknown;
|
|
221
221
|
|
|
222
|
-
const retries = args.retries ?? 3;
|
|
223
|
-
const retryDelayMs = args.retryDelayMs ?? 1000;
|
|
222
|
+
const retries = Math.max(0, Math.min(1000, args.retries ?? 3));
|
|
223
|
+
const retryDelayMs = Math.max(100, args.retryDelayMs ?? 1000);
|
|
224
224
|
const { url, init } = args;
|
|
225
225
|
|
|
226
226
|
for (let attempt = 0; attempt <= retries; attempt++) {
|
package/core/base/sign.ts
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
import type { Address, Bytes65Hex, BytesHex, ChecksummedAddress } from '../types/primitives.js';
|
|
2
|
-
import { secp256k1 } from '@noble/curves/secp256k1';
|
|
2
|
+
import { secp256k1 } from '@noble/curves/secp256k1.js';
|
|
3
3
|
import { keccak_256 } from '@noble/hashes/sha3.js';
|
|
4
4
|
import { addressToChecksummedAddress } from './address.js';
|
|
5
|
-
import { bytesToHex } from './bytes.js';
|
|
5
|
+
import { bytesToHex, bytesToHexNo0x, hexToBytes } from './bytes.js';
|
|
6
6
|
|
|
7
7
|
export function sign({ hash, privateKey }: { readonly hash: BytesHex; readonly privateKey: BytesHex }): Bytes65Hex {
|
|
8
|
-
const sig = secp256k1.sign(hash
|
|
8
|
+
const sig = secp256k1.sign(hexToBytes(hash), hexToBytes(privateKey), {
|
|
9
|
+
prehash: false,
|
|
9
10
|
lowS: true,
|
|
10
11
|
extraEntropy: true,
|
|
12
|
+
format: 'recovered',
|
|
11
13
|
});
|
|
12
14
|
|
|
13
|
-
if (sig.
|
|
15
|
+
if (sig.length !== 65) {
|
|
16
|
+
throw new Error('Unexpected signature length');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// @noble/curves v2 'recovered' format: [recovery (1 byte)] || [r (32 bytes)] || [s (32 bytes)]
|
|
20
|
+
const recovery = sig[0];
|
|
21
|
+
if (recovery !== 0 && recovery !== 1) {
|
|
14
22
|
throw new Error('Unexpected signature recovery value');
|
|
15
23
|
}
|
|
16
24
|
|
|
17
|
-
const signatureHex = `0x${sig.
|
|
25
|
+
const signatureHex = `0x${bytesToHexNo0x(sig.subarray(1, 65))}${recovery === 0 ? '1b' : '1c'}` as BytesHex;
|
|
18
26
|
|
|
19
27
|
if (signatureHex.length !== 2 + 130) {
|
|
20
28
|
throw new Error('Unexpected signature length');
|
|
@@ -48,10 +56,10 @@ function _recoverPublicKey(parameters: { readonly hash: BytesHex; readonly signa
|
|
|
48
56
|
throw new Error(`Invalid v value: ${v}`);
|
|
49
57
|
}
|
|
50
58
|
|
|
51
|
-
const sig = secp256k1.Signature.
|
|
59
|
+
const sig = secp256k1.Signature.fromBytes(hexToBytes(compactHex), 'compact').addRecoveryBit(recoveryBit);
|
|
52
60
|
|
|
53
|
-
//
|
|
54
|
-
return sig.recoverPublicKey(hash
|
|
61
|
+
// toBytes(false) → uncompressed encoding: 0x04 || X (32) || Y (32) = 65 bytes.
|
|
62
|
+
return sig.recoverPublicKey(hexToBytes(hash)).toBytes(false);
|
|
55
63
|
}
|
|
56
64
|
|
|
57
65
|
function _keccak256(bytes: Uint8Array): Uint8Array {
|
package/core/base/wasm.ts
CHANGED
|
@@ -52,7 +52,7 @@ export async function isomorphicCompileWasm(wasmUrl: URL): Promise<WebAssembly.M
|
|
|
52
52
|
// ArrayBufferLike (includes SharedArrayBuffer), making it incompatible with
|
|
53
53
|
// BufferSource. At runtime Buffer is always backed by ArrayBuffer, so the
|
|
54
54
|
// cast at WebAssembly.compile is safe and avoids copying.
|
|
55
|
-
bytes =
|
|
55
|
+
bytes = await readFile(fileURLToPath(wasmUrl));
|
|
56
56
|
} else {
|
|
57
57
|
// fetch wasm
|
|
58
58
|
const res = await fetch(wasmUrl);
|
|
@@ -5,9 +5,9 @@ import type {
|
|
|
5
5
|
SignedDelegatedDecryptionPermit,
|
|
6
6
|
} from '../../types/signedDecryptionPermit.js';
|
|
7
7
|
import type {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from '../../actions/chain/
|
|
8
|
+
SerializeTransportKeyPairParameters,
|
|
9
|
+
SerializeTransportKeyPairReturnType,
|
|
10
|
+
} from '../../actions/chain/serializeTransportKeyPair.js';
|
|
11
11
|
import { assertIsFhevmBaseClient } from '../../runtime/CoreFhevm-p.js';
|
|
12
12
|
import {
|
|
13
13
|
signDecryptionPermit,
|
|
@@ -15,16 +15,16 @@ import {
|
|
|
15
15
|
type SignDelegatedDecryptionPermitParameters,
|
|
16
16
|
} from '../../actions/base/signDecryptionPermit.js';
|
|
17
17
|
import {
|
|
18
|
-
|
|
19
|
-
type
|
|
20
|
-
type
|
|
21
|
-
} from '../../actions/chain/
|
|
18
|
+
parseTransportKeyPair,
|
|
19
|
+
type ParseTransportKeyPairParameters,
|
|
20
|
+
type ParseTransportKeyPairReturnType,
|
|
21
|
+
} from '../../actions/chain/parseTransportKeyPair.js';
|
|
22
22
|
import {
|
|
23
23
|
fetchFheEncryptionKeyBytes,
|
|
24
24
|
type FetchFheEncryptionKeyBytesParameters,
|
|
25
25
|
type FetchFheEncryptionKeyBytesReturnType,
|
|
26
26
|
} from '../../actions/chain/fetchFheEncryptionKeyBytes.js';
|
|
27
|
-
import {
|
|
27
|
+
import { serializeTransportKeyPair } from '../../actions/chain/serializeTransportKeyPair.js';
|
|
28
28
|
import {
|
|
29
29
|
serializeSignedDecryptionPermit,
|
|
30
30
|
type SerializeSignedDecryptionPermitParameters,
|
|
@@ -147,14 +147,14 @@ export type BaseActions = {
|
|
|
147
147
|
*/
|
|
148
148
|
(parameters: SignDelegatedDecryptionPermitParameters): Promise<SignedDelegatedDecryptionPermit>;
|
|
149
149
|
};
|
|
150
|
-
/** Deserializes a previously serialized e2e transport
|
|
151
|
-
readonly
|
|
152
|
-
parameters:
|
|
153
|
-
) => Promise<
|
|
154
|
-
/** Serializes an e2e transport
|
|
155
|
-
readonly
|
|
156
|
-
parameters:
|
|
157
|
-
) =>
|
|
150
|
+
/** Deserializes a previously serialized e2e transport key pair back into a usable key pair. */
|
|
151
|
+
readonly parseTransportKeyPair: (
|
|
152
|
+
parameters: ParseTransportKeyPairParameters,
|
|
153
|
+
) => Promise<ParseTransportKeyPairReturnType>;
|
|
154
|
+
/** Serializes an e2e transport key pair to hex strings for storage. */
|
|
155
|
+
readonly serializeTransportKeyPair: (
|
|
156
|
+
parameters: SerializeTransportKeyPairParameters,
|
|
157
|
+
) => SerializeTransportKeyPairReturnType;
|
|
158
158
|
/** Serializes a signed decryption permit to a plain object for storage or transmission. */
|
|
159
159
|
readonly serializeSignedDecryptionPermit: (
|
|
160
160
|
parameters: SerializeSignedDecryptionPermitParameters,
|
|
@@ -183,8 +183,8 @@ function _baseActions(fhevm: Fhevm<FhevmChain>): BaseActions {
|
|
|
183
183
|
fhevm,
|
|
184
184
|
parameters as SignSelfDecryptionPermitParameters,
|
|
185
185
|
)) as BaseActions['signDecryptionPermit'],
|
|
186
|
-
|
|
187
|
-
|
|
186
|
+
parseTransportKeyPair: (parameters) => parseTransportKeyPair(fhevm, parameters),
|
|
187
|
+
serializeTransportKeyPair: (parameters) => serializeTransportKeyPair(fhevm, parameters),
|
|
188
188
|
serializeSignedDecryptionPermit: (parameters) => serializeSignedDecryptionPermit(fhevm, parameters),
|
|
189
189
|
parseSignedDecryptionPermit: (parameters) => parseSignedDecryptionPermit(fhevm, parameters),
|
|
190
190
|
fetchFheEncryptionKeyBytes: (parameters) => fetchFheEncryptionKeyBytes(fhevm, parameters),
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Fhevm, FhevmBase, FhevmExtension, OptionalNativeClient } from '../../types/coreFhevmClient.js';
|
|
2
2
|
import type { FhevmRuntime, WithDecrypt } from '../../types/coreFhevmRuntime.js';
|
|
3
3
|
import type { FhevmChain } from '../../types/fhevmChain.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { GenerateTransportKeyPairReturnType } from '../../actions/decrypt/generateTransportKeyPair.js';
|
|
5
5
|
import type { DecryptModuleFactory } from '../../modules/decrypt/types.js';
|
|
6
6
|
import { asFhevmClientWith, assertIsFhevmClientWith } from '../../runtime/CoreFhevm-p.js';
|
|
7
|
-
import {
|
|
7
|
+
import { generateTransportKeyPair } from '../../kms/TransportKeyPair-p.js';
|
|
8
8
|
import {
|
|
9
9
|
decryptValue,
|
|
10
10
|
type DecryptValueParameters,
|
|
@@ -30,7 +30,7 @@ export type DecryptActions = {
|
|
|
30
30
|
readonly decryptValuesFromPairs: (
|
|
31
31
|
parameters: DecryptValuesFromPairsParameters,
|
|
32
32
|
) => Promise<DecryptValuesFromPairsReturnType>;
|
|
33
|
-
readonly
|
|
33
|
+
readonly generateTransportKeyPair: () => Promise<GenerateTransportKeyPairReturnType>;
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
////////////////////////////////////////////////////////////////////////////////
|
|
@@ -42,7 +42,7 @@ function _decryptActions(fhevm: Fhevm<FhevmChain, WithDecrypt>): DecryptActions
|
|
|
42
42
|
decryptValue: (parameters) => decryptValue(fhevm, parameters),
|
|
43
43
|
decryptValues: (parameters) => decryptValues(fhevm, parameters),
|
|
44
44
|
decryptValuesFromPairs: (parameters) => decryptValuesFromPairs(fhevm, parameters),
|
|
45
|
-
|
|
45
|
+
generateTransportKeyPair: () => generateTransportKeyPair(fhevm),
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -6,7 +6,6 @@ import type {
|
|
|
6
6
|
Bytes32,
|
|
7
7
|
Uint64,
|
|
8
8
|
Bytes21Hex,
|
|
9
|
-
Uint8Number,
|
|
10
9
|
BytesHex,
|
|
11
10
|
} from '../types/primitives.js';
|
|
12
11
|
import type { ZkProofLike, ZkProof } from '../types/zkProof-p.js';
|
|
@@ -23,7 +22,7 @@ import {
|
|
|
23
22
|
import { bytes32ToHex, bytesToHexLarge, concatBytes, hexToBytes32, toBytes } from '../base/bytes.js';
|
|
24
23
|
import { assertIsUint64, assertIsUint8, asUint64BigInt, uint64ToBytes32 } from '../base/uint.js';
|
|
25
24
|
import { ZkProofError } from '../errors/ZkProofError.js';
|
|
26
|
-
import { assertIsEncryptionBitsArray, fheTypeIdFromEncryptionBits } from '../handle/FheType.js';
|
|
25
|
+
import { asEncryptionBits, assertIsEncryptionBitsArray, fheTypeIdFromEncryptionBits } from '../handle/FheType.js';
|
|
27
26
|
import { buildHandle } from '../handle/FhevmHandle.js';
|
|
28
27
|
import { keccak_256 } from '@noble/hashes/sha3.js';
|
|
29
28
|
import { InvalidTypeError } from '../base/errors/InvalidTypeError.js';
|
|
@@ -74,7 +73,7 @@ class ZkProofImpl implements ZkProof {
|
|
|
74
73
|
this.#userAddress = parameters.userAddress;
|
|
75
74
|
this.#ciphertextWithZkProof = parameters.ciphertextWithZkProof;
|
|
76
75
|
this.#encryptionBits = Object.freeze([...parameters.encryptionBits]);
|
|
77
|
-
this.#fheTypeIds = Object.freeze(this.#encryptionBits.map(fheTypeIdFromEncryptionBits));
|
|
76
|
+
this.#fheTypeIds = Object.freeze(this.#encryptionBits.map((w) => fheTypeIdFromEncryptionBits(asEncryptionBits(w))));
|
|
78
77
|
this.#extraData = parameters.extraData;
|
|
79
78
|
Object.freeze(this);
|
|
80
79
|
}
|
|
@@ -105,7 +104,7 @@ class ZkProofImpl implements ZkProof {
|
|
|
105
104
|
|
|
106
105
|
/** The ciphertext with Zk proof (guaranteed non-empty). Returns a copy. */
|
|
107
106
|
public get ciphertextWithZkProof(): Bytes {
|
|
108
|
-
return new Uint8Array(this.#ciphertextWithZkProof)
|
|
107
|
+
return new Uint8Array(this.#ciphertextWithZkProof);
|
|
109
108
|
}
|
|
110
109
|
|
|
111
110
|
/** The encryption bit sizes for each encrypted value in the proof. */
|
|
@@ -197,7 +196,7 @@ export function isZkProof(value: unknown): value is ZkProof {
|
|
|
197
196
|
|
|
198
197
|
export function assertIsZkProof(
|
|
199
198
|
value: unknown,
|
|
200
|
-
options: { subject?: string } & ErrorMetadataParams,
|
|
199
|
+
options: { readonly subject?: string; readonly metaMessages?: string[] | undefined } & ErrorMetadataParams,
|
|
201
200
|
): asserts value is ZkProof {
|
|
202
201
|
if (!isZkProof(value)) {
|
|
203
202
|
throw new InvalidTypeError(
|
|
@@ -205,6 +204,7 @@ export function assertIsZkProof(
|
|
|
205
204
|
subject: options.subject,
|
|
206
205
|
type: typeof value,
|
|
207
206
|
expectedType: 'ZkProof',
|
|
207
|
+
metaMessages: options.metaMessages,
|
|
208
208
|
},
|
|
209
209
|
options,
|
|
210
210
|
);
|
|
@@ -379,7 +379,7 @@ function _zkProofToInputHandles(
|
|
|
379
379
|
chainId: args.chainId,
|
|
380
380
|
fheTypeId,
|
|
381
381
|
...(options?.version !== undefined ? { version: options.version } : {}),
|
|
382
|
-
index: i
|
|
382
|
+
index: i,
|
|
383
383
|
}),
|
|
384
384
|
);
|
|
385
385
|
}
|
|
@@ -23,7 +23,3 @@ export function asEncryptedValue(value: unknown): EncryptedValue {
|
|
|
23
23
|
assertIsEncryptedValue(value);
|
|
24
24
|
return value;
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
export function toEncryptedValue(value: unknown): EncryptedValue {
|
|
28
|
-
return toFhevmHandle(value).bytes32Hex as unknown as EncryptedValue;
|
|
29
|
-
}
|