@inco/js 0.6.8 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/dist/cjs/advancedacl/session-key.d.ts +39 -19
- package/dist/cjs/advancedacl/session-key.js +59 -108
- package/dist/cjs/attestedcompute/attested-compute.d.ts +6 -6
- package/dist/cjs/attestedcompute/attested-compute.js +5 -28
- package/dist/cjs/attesteddecrypt/attested-decrypt.d.ts +68 -16
- package/dist/cjs/attesteddecrypt/attested-decrypt.js +108 -66
- package/dist/cjs/attesteddecrypt/types.d.ts +8 -3
- package/dist/cjs/attesteddecrypt/types.js +1 -1
- package/dist/cjs/encryption/encryption.d.ts +8 -10
- package/dist/cjs/encryption/encryption.js +6 -6
- package/dist/cjs/generated/abis/add-two.d.ts +1 -1
- package/dist/cjs/generated/abis/add-two.js +1 -1
- package/dist/cjs/generated/abis/lightning-preview.d.ts +40 -0
- package/dist/cjs/generated/abis/lightning-preview.js +29 -1
- package/dist/cjs/generated/abis/lightning.d.ts +1 -1
- package/dist/cjs/generated/abis/lightning.js +1 -1
- package/dist/cjs/generated/abis/verifier.d.ts +126 -67
- package/dist/cjs/generated/abis/verifier.js +108 -54
- package/dist/cjs/generated/es/inco/covalidator/compute/v1/types_pb.d.ts +15 -1
- package/dist/cjs/generated/es/inco/covalidator/compute/v1/types_pb.js +1 -1
- package/dist/cjs/generated/es/inco/kms/lite/v1/kms_service_pb.d.ts +87 -132
- package/dist/cjs/generated/es/inco/kms/lite/v1/kms_service_pb.js +21 -27
- package/dist/cjs/generated/lightning.d.ts +40 -32
- package/dist/cjs/generated/lightning.js +43 -33
- package/dist/cjs/generated/local-node.d.ts +11 -11
- package/dist/cjs/generated/local-node.js +28 -12
- package/dist/cjs/kms/client.d.ts +8 -4
- package/dist/cjs/kms/client.js +9 -4
- package/dist/cjs/kms/quorumClient.d.ts +58 -0
- package/dist/cjs/kms/quorumClient.js +378 -0
- package/dist/cjs/kms/thresholdPromises.d.ts +7 -0
- package/dist/cjs/kms/thresholdPromises.js +52 -0
- package/dist/cjs/lite/deployments.d.ts +20 -2
- package/dist/cjs/lite/deployments.js +1 -1
- package/dist/cjs/lite/index.d.ts +1 -2
- package/dist/cjs/lite/index.js +1 -2
- package/dist/cjs/lite/lightning.d.ts +109 -77
- package/dist/cjs/lite/lightning.js +279 -112
- package/dist/cjs/local/local-node.d.ts +1 -2
- package/dist/cjs/local/local-node.js +2 -3
- package/dist/cjs/test/mocks.d.ts +15 -0
- package/dist/cjs/test/mocks.js +45 -0
- package/dist/cjs/viem.d.ts +1 -1
- package/dist/esm/advancedacl/session-key.d.ts +39 -19
- package/dist/esm/advancedacl/session-key.js +52 -100
- package/dist/esm/attestedcompute/attested-compute.d.ts +6 -6
- package/dist/esm/attestedcompute/attested-compute.js +6 -29
- package/dist/esm/attesteddecrypt/attested-decrypt.d.ts +68 -16
- package/dist/esm/attesteddecrypt/attested-decrypt.js +109 -68
- package/dist/esm/attesteddecrypt/types.d.ts +8 -3
- package/dist/esm/attesteddecrypt/types.js +1 -1
- package/dist/esm/encryption/encryption.d.ts +8 -10
- package/dist/esm/encryption/encryption.js +6 -6
- package/dist/esm/generated/abis/add-two.d.ts +1 -1
- package/dist/esm/generated/abis/add-two.js +1 -1
- package/dist/esm/generated/abis/lightning-preview.d.ts +40 -0
- package/dist/esm/generated/abis/lightning-preview.js +29 -1
- package/dist/esm/generated/abis/lightning.d.ts +1 -1
- package/dist/esm/generated/abis/lightning.js +1 -1
- package/dist/esm/generated/abis/verifier.d.ts +126 -67
- package/dist/esm/generated/abis/verifier.js +108 -54
- package/dist/esm/generated/es/inco/covalidator/compute/v1/types_pb.d.ts +15 -1
- package/dist/esm/generated/es/inco/covalidator/compute/v1/types_pb.js +1 -1
- package/dist/esm/generated/es/inco/kms/lite/v1/kms_service_pb.d.ts +87 -132
- package/dist/esm/generated/es/inco/kms/lite/v1/kms_service_pb.js +19 -25
- package/dist/esm/generated/lightning.d.ts +40 -32
- package/dist/esm/generated/lightning.js +43 -33
- package/dist/esm/generated/local-node.d.ts +11 -11
- package/dist/esm/generated/local-node.js +28 -12
- package/dist/esm/kms/client.d.ts +8 -4
- package/dist/esm/kms/client.js +8 -4
- package/dist/esm/kms/quorumClient.d.ts +58 -0
- package/dist/esm/kms/quorumClient.js +374 -0
- package/dist/esm/kms/thresholdPromises.d.ts +7 -0
- package/dist/esm/kms/thresholdPromises.js +49 -0
- package/dist/esm/lite/deployments.d.ts +20 -2
- package/dist/esm/lite/deployments.js +1 -1
- package/dist/esm/lite/index.d.ts +1 -2
- package/dist/esm/lite/index.js +1 -2
- package/dist/esm/lite/lightning.d.ts +109 -77
- package/dist/esm/lite/lightning.js +278 -111
- package/dist/esm/local/local-node.d.ts +1 -2
- package/dist/esm/local/local-node.js +2 -3
- package/dist/esm/test/mocks.d.ts +15 -0
- package/dist/esm/test/mocks.js +39 -0
- package/dist/esm/viem.d.ts +1 -1
- package/dist/types/advancedacl/session-key.d.ts +39 -19
- package/dist/types/attestedcompute/attested-compute.d.ts +6 -6
- package/dist/types/attesteddecrypt/attested-decrypt.d.ts +68 -16
- package/dist/types/attesteddecrypt/types.d.ts +8 -3
- package/dist/types/encryption/encryption.d.ts +8 -10
- package/dist/types/generated/abis/add-two.d.ts +1 -1
- package/dist/types/generated/abis/lightning-preview.d.ts +40 -0
- package/dist/types/generated/abis/lightning.d.ts +1 -1
- package/dist/types/generated/abis/verifier.d.ts +126 -67
- package/dist/types/generated/es/inco/covalidator/compute/v1/types_pb.d.ts +15 -1
- package/dist/types/generated/es/inco/kms/lite/v1/kms_service_pb.d.ts +87 -132
- package/dist/types/generated/lightning.d.ts +40 -32
- package/dist/types/generated/local-node.d.ts +11 -11
- package/dist/types/kms/client.d.ts +8 -4
- package/dist/types/kms/quorumClient.d.ts +58 -0
- package/dist/types/kms/thresholdPromises.d.ts +7 -0
- package/dist/types/lite/deployments.d.ts +20 -2
- package/dist/types/lite/index.d.ts +1 -2
- package/dist/types/lite/lightning.d.ts +109 -77
- package/dist/types/local/local-node.d.ts +1 -2
- package/dist/types/test/mocks.d.ts +15 -0
- package/dist/types/viem.d.ts +1 -1
- package/package.json +3 -3
- package/dist/cjs/attestedreveal/attested-reveal.d.ts +0 -21
- package/dist/cjs/attestedreveal/attested-reveal.js +0 -67
- package/dist/cjs/attestedreveal/index.d.ts +0 -1
- package/dist/cjs/attestedreveal/index.js +0 -18
- package/dist/cjs/attestedreveal/types.d.ts +0 -7
- package/dist/cjs/attestedreveal/types.js +0 -16
- package/dist/cjs/generated/es/cosmos_proto/cosmos_pb.d.ts +0 -174
- package/dist/cjs/generated/es/cosmos_proto/cosmos_pb.js +0 -118
- package/dist/cjs/generated/es/inco/fhe/v1/types_pb.d.ts +0 -419
- package/dist/cjs/generated/es/inco/fhe/v1/types_pb.js +0 -136
- package/dist/cjs/lite/reencrypt.d.ts +0 -23
- package/dist/cjs/lite/reencrypt.js +0 -131
- package/dist/esm/attestedreveal/attested-reveal.d.ts +0 -21
- package/dist/esm/attestedreveal/attested-reveal.js +0 -64
- package/dist/esm/attestedreveal/index.d.ts +0 -1
- package/dist/esm/attestedreveal/index.js +0 -2
- package/dist/esm/attestedreveal/types.d.ts +0 -7
- package/dist/esm/attestedreveal/types.js +0 -12
- package/dist/esm/generated/es/cosmos_proto/cosmos_pb.d.ts +0 -174
- package/dist/esm/generated/es/cosmos_proto/cosmos_pb.js +0 -115
- package/dist/esm/generated/es/inco/fhe/v1/types_pb.d.ts +0 -419
- package/dist/esm/generated/es/inco/fhe/v1/types_pb.js +0 -133
- package/dist/esm/lite/reencrypt.d.ts +0 -23
- package/dist/esm/lite/reencrypt.js +0 -122
- package/dist/types/attestedreveal/attested-reveal.d.ts +0 -21
- package/dist/types/attestedreveal/index.d.ts +0 -1
- package/dist/types/attestedreveal/types.d.ts +0 -7
- package/dist/types/generated/es/cosmos_proto/cosmos_pb.d.ts +0 -174
- package/dist/types/generated/es/inco/fhe/v1/types_pb.d.ts +0 -419
- package/dist/types/lite/reencrypt.d.ts +0 -23
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { createWalletClient, http, } from 'viem';
|
|
2
|
+
import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
|
|
3
|
+
import { sepolia } from 'viem/chains';
|
|
4
|
+
import { vi } from 'vitest';
|
|
5
|
+
import { DEFAULT_COVALIDATOR_SIGNER } from '../kms/client.js';
|
|
6
|
+
import { KmsQuorumClient } from '../kms/quorumClient.js';
|
|
7
|
+
// Create a mock that satisfies our minimal interface
|
|
8
|
+
export function createMockKmsClient() {
|
|
9
|
+
return {
|
|
10
|
+
attestedCompute: vi.fn(),
|
|
11
|
+
attestedDecrypt: vi.fn(),
|
|
12
|
+
key: vi.fn(),
|
|
13
|
+
reencrypt: vi.fn(),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
// Create a mock KmsQuorumClient from a mock KmsClient for testing
|
|
17
|
+
export function createMockQuorumClient() {
|
|
18
|
+
// Use the private constructor via type casting (similar to quorumClient.test.ts)
|
|
19
|
+
const AnyClass = KmsQuorumClient;
|
|
20
|
+
return new AnyClass([{ url: 'https://mock-kms', signer: DEFAULT_COVALIDATOR_SIGNER }], 1);
|
|
21
|
+
}
|
|
22
|
+
// Helper to set up the mock client inside the quorum client
|
|
23
|
+
export function setupMockInQuorumClient(quorumClient, mockKmsClient) {
|
|
24
|
+
// Access private kmss array and replace the client
|
|
25
|
+
const anyQuorumClient = quorumClient;
|
|
26
|
+
if (anyQuorumClient.kmss && anyQuorumClient.kmss.length > 0) {
|
|
27
|
+
anyQuorumClient.kmss[0].client = mockKmsClient;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// Create a real wallet client for testing
|
|
31
|
+
export function createTestWalletClient() {
|
|
32
|
+
const account = privateKeyToAccount(generatePrivateKey());
|
|
33
|
+
return createWalletClient({
|
|
34
|
+
chain: sepolia, // Arbitrary chain, not relevant to test
|
|
35
|
+
transport: http('UNUSED IN TEST'),
|
|
36
|
+
account,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9ja3MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvdGVzdC9tb2Nrcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBR0wsa0JBQWtCLEVBQ2xCLElBQUksR0FHTCxNQUFNLE1BQU0sQ0FBQztBQUNkLE9BQU8sRUFBRSxrQkFBa0IsRUFBRSxtQkFBbUIsRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUN4RSxPQUFPLEVBQUUsT0FBTyxFQUFFLE1BQU0sYUFBYSxDQUFDO0FBQ3RDLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSxRQUFRLENBQUM7QUFDNUIsT0FBTyxFQUFFLDBCQUEwQixFQUFhLE1BQU0sa0JBQWtCLENBQUM7QUFDekUsT0FBTyxFQUFFLGVBQWUsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBV3pELHFEQUFxRDtBQUNyRCxNQUFNLFVBQVUsbUJBQW1CO0lBQ2pDLE9BQU87UUFDTCxlQUFlLEVBQUUsRUFBRSxDQUFDLEVBQUUsRUFBRTtRQUN4QixlQUFlLEVBQUUsRUFBRSxDQUFDLEVBQUUsRUFBRTtRQUN4QixHQUFHLEVBQUUsRUFBRSxDQUFDLEVBQUUsRUFBRTtRQUNaLFNBQVMsRUFBRSxFQUFFLENBQUMsRUFBRSxFQUFFO0tBQ2EsQ0FBQztBQUNwQyxDQUFDO0FBRUQsa0VBQWtFO0FBQ2xFLE1BQU0sVUFBVSxzQkFBc0I7SUFDcEMsaUZBQWlGO0lBQ2pGLE1BQU0sUUFBUSxHQUFRLGVBQWUsQ0FBQztJQUN0QyxPQUFPLElBQUksUUFBUSxDQUNqQixDQUFDLEVBQUUsR0FBRyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sRUFBRSwwQkFBMEIsRUFBRSxDQUFDLEVBQ2pFLENBQUMsQ0FDRixDQUFDO0FBQ0osQ0FBQztBQUVELDREQUE0RDtBQUM1RCxNQUFNLFVBQVUsdUJBQXVCLENBQ3JDLFlBQTZCLEVBQzdCLGFBQTJDO0lBRTNDLG1EQUFtRDtJQUNuRCxNQUFNLGVBQWUsR0FBRyxZQUFtQixDQUFDO0lBQzVDLElBQUksZUFBZSxDQUFDLElBQUksSUFBSSxlQUFlLENBQUMsSUFBSSxDQUFDLE1BQU0sR0FBRyxDQUFDLEVBQUUsQ0FBQztRQUM1RCxlQUFlLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxDQUFDLE1BQU0sR0FBRyxhQUFhLENBQUM7SUFDakQsQ0FBQztBQUNILENBQUM7QUFFRCwwQ0FBMEM7QUFDMUMsTUFBTSxVQUFVLHNCQUFzQjtJQUtwQyxNQUFNLE9BQU8sR0FBRyxtQkFBbUIsQ0FBQyxrQkFBa0IsRUFBRSxDQUFDLENBQUM7SUFDMUQsT0FBTyxrQkFBa0IsQ0FBQztRQUN4QixLQUFLLEVBQUUsT0FBTyxFQUFFLHdDQUF3QztRQUN4RCxTQUFTLEVBQUUsSUFBSSxDQUFDLGdCQUFnQixDQUFDO1FBQ2pDLE9BQU87S0FDUixDQUFDLENBQUM7QUFDTCxDQUFDIn0=
|
package/dist/esm/viem.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export declare const chains: {
|
|
|
30
30
|
experimental_preconfirmationTime?: number | undefined | undefined;
|
|
31
31
|
rpcUrls: {
|
|
32
32
|
readonly default: {
|
|
33
|
-
readonly http: readonly ["https://
|
|
33
|
+
readonly http: readonly ["https://11155111.rpc.thirdweb.com"];
|
|
34
34
|
};
|
|
35
35
|
};
|
|
36
36
|
sourceId?: number | undefined | undefined;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import type { Client } from '@connectrpc/connect';
|
|
2
1
|
import { type Account, type Address, type Chain, type Hex, type Transport, type WalletClient } from 'viem';
|
|
3
|
-
import { DecryptionAttestation } from '../attesteddecrypt/index.js';
|
|
2
|
+
import { DecryptionAttestation, EncryptedDecryptionAttestation } from '../attesteddecrypt/index.js';
|
|
4
3
|
import { SupportedChainId } from '../chain.js';
|
|
5
4
|
import { type EciesScheme, SupportedFheType } from '../encryption/encryption.js';
|
|
6
5
|
import { HexString } from '../index.js';
|
|
7
|
-
import type {
|
|
8
|
-
import { type ReencryptFnArgs } from '../reencryption/index.js';
|
|
6
|
+
import type { Secp256k1Keypair } from '../lite/index.js';
|
|
9
7
|
import { BackoffConfig } from '../retry.js';
|
|
10
8
|
import type { AllowanceVoucher, AllowanceVoucherWithSig } from './types.js';
|
|
11
9
|
import { AttestedComputeOP } from '../attestedcompute/types.js';
|
|
10
|
+
import { KmsQuorumClient } from '../kms/quorumClient.js';
|
|
12
11
|
export interface Session {
|
|
13
12
|
decrypter: Address;
|
|
14
13
|
expiresAt: bigint;
|
|
@@ -23,35 +22,56 @@ export interface GrantSessionKeyArgs {
|
|
|
23
22
|
expiresAt: Date;
|
|
24
23
|
}
|
|
25
24
|
export declare function grantSessionKey({ chainId, incoLiteAddress, sessionVerifierContractAddress, granteeAddress, sharerWalletClient, expiresAt, }: GrantSessionKeyArgs): Promise<AllowanceVoucherWithSig>;
|
|
26
|
-
export interface SessionKeyReencryptorArgs {
|
|
27
|
-
chainId: bigint;
|
|
28
|
-
ephemeralKeypair: Secp256k1Keypair;
|
|
29
|
-
kmsConnectRpcEndpointOrClient: string | Client<typeof KmsService>;
|
|
30
|
-
allowanceVoucherWithSig: AllowanceVoucherWithSig;
|
|
31
|
-
}
|
|
32
|
-
export declare function sessionKeyReencryptor({ chainId, kmsConnectRpcEndpointOrClient, ephemeralKeypair, allowanceVoucherWithSig, }: SessionKeyReencryptorArgs): Promise<(<T extends SupportedFheType>({ handle, }: ReencryptFnArgs<EciesScheme, T>) => Promise<import("../encryption/encryption.js").PlaintextOf<1, 0 | 5 | 7 | 8>>)>;
|
|
33
25
|
export declare function updateActiveVouchersSessionNonce(incoLiteAddress: Address, sharerWalletClient: WalletClient<Transport, Chain, Account>): Promise<`0x${string}`>;
|
|
34
26
|
export interface SessionKeyAttestedComputeArgs {
|
|
35
27
|
chainId: SupportedChainId;
|
|
36
28
|
ephemeralKeypair: Secp256k1Keypair;
|
|
37
|
-
|
|
29
|
+
kmsQuorumClient: KmsQuorumClient;
|
|
38
30
|
allowanceVoucherWithSig: AllowanceVoucherWithSig;
|
|
39
31
|
lhsHandle: HexString;
|
|
40
32
|
op: AttestedComputeOP;
|
|
41
33
|
rhsPlaintext: bigint | boolean;
|
|
42
34
|
backoffConfig?: Partial<BackoffConfig> | undefined;
|
|
43
35
|
}
|
|
44
|
-
export declare function sessionKeyAttestedCompute<T extends SupportedFheType>({ lhsHandle, op, rhsPlaintext, backoffConfig, chainId,
|
|
45
|
-
handle: HexString;
|
|
46
|
-
plaintext: import("../encryption/encryption.js").PlaintextOf<1, T>;
|
|
47
|
-
covalidatorSignature: Uint8Array<ArrayBufferLike>;
|
|
48
|
-
}>;
|
|
36
|
+
export declare function sessionKeyAttestedCompute<T extends SupportedFheType>({ lhsHandle, op, rhsPlaintext, backoffConfig, chainId, kmsQuorumClient, ephemeralKeypair, allowanceVoucherWithSig, }: SessionKeyAttestedComputeArgs): Promise<DecryptionAttestation<EciesScheme, SupportedFheType>>;
|
|
49
37
|
export interface SessionKeyAttestedDecryptArgs {
|
|
50
38
|
chainId: SupportedChainId;
|
|
51
39
|
ephemeralKeypair: Secp256k1Keypair;
|
|
52
|
-
|
|
40
|
+
kmsQuorumClient: KmsQuorumClient;
|
|
53
41
|
allowanceVoucherWithSig: AllowanceVoucherWithSig;
|
|
54
42
|
handles: HexString[];
|
|
55
43
|
backoffConfig?: Partial<BackoffConfig> | undefined;
|
|
44
|
+
reencryptPubKey?: Uint8Array | undefined;
|
|
45
|
+
reencryptKeypair?: Secp256k1Keypair | undefined;
|
|
56
46
|
}
|
|
57
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Performs attested decrypts using a voucher-backed session key.
|
|
49
|
+
*
|
|
50
|
+
* @example Plaintext results
|
|
51
|
+
* ```ts
|
|
52
|
+
* const attestations = await sessionKeyAttestedDecrypt({
|
|
53
|
+
* chainId,
|
|
54
|
+
* kmsConnectRpcEndpointOrClient: covalidatorUrl,
|
|
55
|
+
* allowanceVoucherWithSig: voucher,
|
|
56
|
+
* ephemeralKeypair,
|
|
57
|
+
* handles,
|
|
58
|
+
* });
|
|
59
|
+
* console.log(attestations[0].plaintext.value);
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @example Encrypted results
|
|
63
|
+
* ```ts
|
|
64
|
+
* const encryptedResults = await sessionKeyAttestedDecrypt({
|
|
65
|
+
* chainId,
|
|
66
|
+
* kmsConnectRpcEndpointOrClient: covalidatorUrl,
|
|
67
|
+
* allowanceVoucherWithSig: voucher,
|
|
68
|
+
* ephemeralKeypair,
|
|
69
|
+
* handles,
|
|
70
|
+
* reencryptPubKey: recipientPubKey,
|
|
71
|
+
* });
|
|
72
|
+
* console.log(
|
|
73
|
+
* encryptedResults[0].encryptedPlaintext.ciphertext.value,
|
|
74
|
+
* );
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export declare function sessionKeyAttestedDecrypt({ chainId, kmsQuorumClient, handles, ephemeralKeypair, allowanceVoucherWithSig, backoffConfig, reencryptPubKey, reencryptKeypair, }: SessionKeyAttestedDecryptArgs): Promise<Array<DecryptionAttestation<EciesScheme, SupportedFheType> | EncryptedDecryptionAttestation<EciesScheme, SupportedFheType>>>;
|
|
@@ -3,19 +3,19 @@ import { DecryptionAttestation } from '../attesteddecrypt/types.js';
|
|
|
3
3
|
import { HexString } from '../binary.js';
|
|
4
4
|
import { SupportedChainId } from '../chain.js';
|
|
5
5
|
import { EciesScheme, SupportedFheType } from '../encryption/encryption.js';
|
|
6
|
-
import
|
|
6
|
+
import { KmsQuorumClient } from '../kms/quorumClient.js';
|
|
7
7
|
import type { BackoffConfig } from '../retry.js';
|
|
8
8
|
import { AttestedComputeOP } from './types.js';
|
|
9
9
|
export declare const ATTESTED_COMPUTE_DOMAIN_NAME = "IncoAttestedCompute";
|
|
10
|
-
export declare const ATTESTED_COMPUTE_DOMAIN_VERSION = "
|
|
10
|
+
export declare const ATTESTED_COMPUTE_DOMAIN_VERSION = "1";
|
|
11
11
|
/**
|
|
12
12
|
* Arguments for creating an attested compute.
|
|
13
13
|
*/
|
|
14
14
|
export interface IncoLiteAttestedComputeArgs {
|
|
15
15
|
/** The wallet used to interact with the blockchain and sign the compute request */
|
|
16
16
|
walletClient: WalletClient<Transport, Chain, Account>;
|
|
17
|
-
/** The KMS
|
|
18
|
-
|
|
17
|
+
/** The KMS quorum client instance */
|
|
18
|
+
kmsQuorumClient: KmsQuorumClient;
|
|
19
19
|
/** The chain ID to use */
|
|
20
20
|
chainId: SupportedChainId;
|
|
21
21
|
}
|
|
@@ -27,12 +27,12 @@ export interface IncoLiteAttestedComputeArgs {
|
|
|
27
27
|
*
|
|
28
28
|
* @todo Support multiple operations in a single request.
|
|
29
29
|
*/
|
|
30
|
-
export declare function attestedCompute<T extends SupportedFheType>({ lhsHandle, op, rhsPlaintext, backoffConfig, walletClient,
|
|
30
|
+
export declare function attestedCompute<T extends SupportedFheType>({ lhsHandle, op, rhsPlaintext, backoffConfig, walletClient, kmsQuorumClient, chainId, }: {
|
|
31
31
|
lhsHandle: HexString;
|
|
32
32
|
op: AttestedComputeOP;
|
|
33
33
|
rhsPlaintext: bigint | boolean;
|
|
34
34
|
backoffConfig?: Partial<BackoffConfig> | undefined;
|
|
35
35
|
walletClient: WalletClient<Transport, Chain, Account>;
|
|
36
|
-
|
|
36
|
+
kmsQuorumClient: KmsQuorumClient;
|
|
37
37
|
chainId: SupportedChainId;
|
|
38
38
|
}): Promise<DecryptionAttestation<EciesScheme, T>>;
|
|
@@ -1,29 +1,72 @@
|
|
|
1
1
|
import type { Account, Chain, Transport, WalletClient } from 'viem';
|
|
2
|
-
import { HexString } from '../binary.js';
|
|
3
|
-
import { SupportedChainId } from '../chain.js';
|
|
4
|
-
import { EciesScheme, SupportedFheType } from '../encryption/encryption.js';
|
|
5
|
-
import
|
|
2
|
+
import { type HexString } from '../binary.js';
|
|
3
|
+
import { type SupportedChainId } from '../chain.js';
|
|
4
|
+
import { type EciesScheme, type SupportedFheType } from '../encryption/encryption.js';
|
|
5
|
+
import { KmsQuorumClient } from '../kms/quorumClient.js';
|
|
6
|
+
import type { Secp256k1Keypair } from '../lite/ecies.js';
|
|
6
7
|
import type { BackoffConfig } from '../retry.js';
|
|
7
|
-
import { DecryptionAttestation } from './types.js';
|
|
8
|
+
import { type DecryptionAttestation, type EncryptedDecryptionAttestation } from './types.js';
|
|
8
9
|
export declare const ATTESTED_DECRYPT_DOMAIN_NAME = "IncoAttestedDecrypt";
|
|
9
|
-
export declare const ATTESTED_DECRYPT_DOMAIN_VERSION = "
|
|
10
|
-
/**
|
|
11
|
-
* Validates a handle format.
|
|
12
|
-
* @param handle - The handle to validate
|
|
13
|
-
* @throws {AttestedDecryptError} If the handle format is invalid
|
|
14
|
-
*/
|
|
15
|
-
export declare function validateHandle(handle: HexString): void;
|
|
10
|
+
export declare const ATTESTED_DECRYPT_DOMAIN_VERSION = "1";
|
|
16
11
|
/**
|
|
17
12
|
* Arguments for creating an attested decrypt request.
|
|
18
13
|
*/
|
|
19
14
|
export interface IncoLiteAttestedDecryptorArgs {
|
|
20
15
|
/** The wallet used to interact with the blockchain and sign the decrypt request */
|
|
21
16
|
walletClient: WalletClient<Transport, Chain, Account>;
|
|
22
|
-
/** The KMS
|
|
23
|
-
|
|
17
|
+
/** The KMS quorum client instance */
|
|
18
|
+
kmsQuorumClient: KmsQuorumClient;
|
|
24
19
|
/** The chain ID to use */
|
|
25
20
|
chainId: SupportedChainId;
|
|
26
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Decrypt multiple handles in a single attested request without wallet authentication.
|
|
24
|
+
* Returns an array of attestations aligned with the response ordering.
|
|
25
|
+
*
|
|
26
|
+
* @param args - The arguments for creating the attested decrypt function
|
|
27
|
+
* @returns A function that can decrypt handles and return an attestation
|
|
28
|
+
* @throws {AttestedDecryptError} If the creation fails
|
|
29
|
+
*/
|
|
30
|
+
export declare function attestedDecrypt({ handles, backoffConfig, chainId, kmsQuorumClient, }: {
|
|
31
|
+
handles: HexString[];
|
|
32
|
+
backoffConfig?: Partial<BackoffConfig> | undefined;
|
|
33
|
+
chainId: SupportedChainId;
|
|
34
|
+
kmsQuorumClient: KmsQuorumClient;
|
|
35
|
+
}): Promise<Array<DecryptionAttestation<EciesScheme, SupportedFheType>>>;
|
|
36
|
+
/**
|
|
37
|
+
* Decrypt multiple handles in a single attested request.
|
|
38
|
+
* Returns an array of attestations aligned with the response ordering.
|
|
39
|
+
*
|
|
40
|
+
* @param args - The arguments for creating the attested decrypt function
|
|
41
|
+
* @returns A function that can decrypt handles and return an attestation
|
|
42
|
+
* @throws {AttestedDecryptError} If the creation fails
|
|
43
|
+
*/
|
|
44
|
+
export declare function attestedDecrypt({ handles, backoffConfig, walletClient, chainId, reencryptPubKey, reencryptKeypair, kmsQuorumClient, }: {
|
|
45
|
+
handles: HexString[];
|
|
46
|
+
backoffConfig?: Partial<BackoffConfig> | undefined;
|
|
47
|
+
walletClient: WalletClient<Transport, Chain, Account>;
|
|
48
|
+
chainId: SupportedChainId;
|
|
49
|
+
reencryptPubKey: Uint8Array;
|
|
50
|
+
reencryptKeypair: Secp256k1Keypair;
|
|
51
|
+
kmsQuorumClient: KmsQuorumClient;
|
|
52
|
+
}): Promise<Array<DecryptionAttestation<EciesScheme, SupportedFheType>>>;
|
|
53
|
+
/**
|
|
54
|
+
* Decrypt multiple handles in a single attested request.
|
|
55
|
+
* Returns an array of attestations aligned with the response ordering.
|
|
56
|
+
*
|
|
57
|
+
* @param args - The arguments for creating the attested decrypt function
|
|
58
|
+
* @returns A function that can decrypt handles and return an attestation
|
|
59
|
+
* @throws {AttestedDecryptError} If the creation fails
|
|
60
|
+
*/
|
|
61
|
+
export declare function attestedDecrypt({ handles, backoffConfig, walletClient, chainId, reencryptPubKey, kmsQuorumClient, }: {
|
|
62
|
+
handles: HexString[];
|
|
63
|
+
backoffConfig?: Partial<BackoffConfig> | undefined;
|
|
64
|
+
walletClient: WalletClient<Transport, Chain, Account>;
|
|
65
|
+
chainId: SupportedChainId;
|
|
66
|
+
reencryptPubKey: Uint8Array;
|
|
67
|
+
reencryptKeypair?: never;
|
|
68
|
+
kmsQuorumClient: KmsQuorumClient;
|
|
69
|
+
}): Promise<Array<EncryptedDecryptionAttestation<EciesScheme, SupportedFheType>>>;
|
|
27
70
|
/**
|
|
28
71
|
* Decrypt multiple handles in a single attested request.
|
|
29
72
|
* Returns an array of attestations aligned with the response ordering.
|
|
@@ -32,10 +75,19 @@ export interface IncoLiteAttestedDecryptorArgs {
|
|
|
32
75
|
* @returns A function that can decrypt handles and return an attestation
|
|
33
76
|
* @throws {AttestedDecryptError} If the creation fails
|
|
34
77
|
*/
|
|
35
|
-
export declare function attestedDecrypt({ handles, backoffConfig, walletClient, chainId,
|
|
78
|
+
export declare function attestedDecrypt({ handles, backoffConfig, walletClient, chainId, kmsQuorumClient, }: {
|
|
36
79
|
handles: HexString[];
|
|
37
80
|
backoffConfig?: Partial<BackoffConfig> | undefined;
|
|
38
81
|
walletClient: WalletClient<Transport, Chain, Account>;
|
|
39
82
|
chainId: SupportedChainId;
|
|
40
|
-
|
|
83
|
+
reencryptPubKey?: never;
|
|
84
|
+
reencryptKeypair?: never;
|
|
85
|
+
kmsQuorumClient: KmsQuorumClient;
|
|
41
86
|
}): Promise<Array<DecryptionAttestation<EciesScheme, SupportedFheType>>>;
|
|
87
|
+
export declare function decryptEncryptedAttestations(attestations: Array<DecryptionAttestation<EciesScheme, SupportedFheType> | EncryptedDecryptionAttestation<EciesScheme, SupportedFheType>>, reencryptKeypair: Secp256k1Keypair): Promise<Array<DecryptionAttestation<EciesScheme, SupportedFheType>>>;
|
|
88
|
+
/**
|
|
89
|
+
* Validates a handle format.
|
|
90
|
+
* @param handle - The handle to validate
|
|
91
|
+
* @throws {AttestedDecryptError} If the handle format is invalid
|
|
92
|
+
*/
|
|
93
|
+
export declare function validateHandle(handle: HexString): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { HexString } from '../binary.js';
|
|
2
|
-
import { EncryptionScheme, PlaintextOf, SupportedFheType } from '../encryption/encryption.js';
|
|
1
|
+
import type { HexString } from '../binary.js';
|
|
2
|
+
import type { EncryptionScheme, EncryptResultOf, PlaintextOf, SupportedFheType } from '../encryption/encryption.js';
|
|
3
3
|
import type { BackoffConfig } from '../retry.js';
|
|
4
4
|
/**
|
|
5
5
|
* Custom error class for attested decrypt operations.
|
|
@@ -11,7 +11,12 @@ export declare class AttestedDecryptError extends Error {
|
|
|
11
11
|
export type DecryptionAttestation<S extends EncryptionScheme, T extends SupportedFheType> = {
|
|
12
12
|
handle: HexString;
|
|
13
13
|
plaintext: PlaintextOf<S, T>;
|
|
14
|
-
|
|
14
|
+
covalidatorSignatures: Uint8Array[];
|
|
15
|
+
};
|
|
16
|
+
export type EncryptedDecryptionAttestation<S extends EncryptionScheme, T extends SupportedFheType> = {
|
|
17
|
+
handle: HexString;
|
|
18
|
+
encryptedPlaintext: EncryptResultOf<S, T>;
|
|
19
|
+
covalidatorSignatures: Uint8Array[];
|
|
15
20
|
};
|
|
16
21
|
export type AttestedDecryptor<S extends EncryptionScheme> = <T extends SupportedFheType>(args: AttestedDecryptFnArgs<S, T>) => Promise<DecryptionAttestation<S, T>>;
|
|
17
22
|
export type AttestedDecryptFnArgs<S extends EncryptionScheme, T extends SupportedFheType> = {
|
|
@@ -14,21 +14,19 @@ export type SupportedFheTypeName = typeof SupportedFheTypeName.Type;
|
|
|
14
14
|
export declare const SupportedFheType: Schema.SchemaClass<0 | 5 | 7 | 8, 0 | 5 | 7 | 8, never>;
|
|
15
15
|
export type SupportedFheType = typeof SupportedFheType.Type;
|
|
16
16
|
export declare const encryptionSchemes: {
|
|
17
|
-
readonly tfhe: 0;
|
|
18
17
|
readonly ecies: 1;
|
|
19
18
|
};
|
|
20
19
|
export declare function getEncryptionSchemeName(scheme: number): string;
|
|
21
20
|
export type EncryptionSchemes = typeof encryptionSchemes;
|
|
22
21
|
export type EciesScheme = EncryptionSchemes['ecies'];
|
|
23
|
-
export
|
|
24
|
-
export declare const EncryptionScheme: Schema.Literal<[0, 1]>;
|
|
22
|
+
export declare const EncryptionScheme: Schema.Literal<[1]>;
|
|
25
23
|
export type EncryptionScheme = typeof EncryptionScheme.Type;
|
|
26
24
|
type DistType<P, S extends EncryptionScheme, T extends SupportedFheType> = P extends any ? P & {
|
|
27
25
|
scheme: S;
|
|
28
26
|
type: T;
|
|
29
27
|
} : never;
|
|
30
28
|
export declare const Ciphertext: Schema.Struct<{
|
|
31
|
-
scheme: Schema.Literal<[
|
|
29
|
+
scheme: Schema.Literal<[1]>;
|
|
32
30
|
type: Schema.SchemaClass<0 | 5 | 7 | 8, 0 | 5 | 7 | 8, never>;
|
|
33
31
|
value: Schema.TemplateLiteral<`0x${string}`>;
|
|
34
32
|
}>;
|
|
@@ -36,7 +34,7 @@ export type Ciphertext = typeof Ciphertext.Type;
|
|
|
36
34
|
export type CiphertextOf<S extends EncryptionScheme, T extends SupportedFheType> = DistType<Ciphertext, S, T>;
|
|
37
35
|
export declare const CiphertextWithContext: Schema.Struct<{
|
|
38
36
|
ciphertext: Schema.Struct<{
|
|
39
|
-
scheme: Schema.Literal<[
|
|
37
|
+
scheme: Schema.Literal<[1]>;
|
|
40
38
|
type: Schema.SchemaClass<0 | 5 | 7 | 8, 0 | 5 | 7 | 8, never>;
|
|
41
39
|
value: Schema.TemplateLiteral<`0x${string}`>;
|
|
42
40
|
}>;
|
|
@@ -53,7 +51,7 @@ export type CiphertextWithContextOf<S extends EncryptionScheme, T extends Suppor
|
|
|
53
51
|
};
|
|
54
52
|
export declare const EncryptResult: Schema.Struct<{
|
|
55
53
|
ciphertext: Schema.Struct<{
|
|
56
|
-
scheme: Schema.Literal<[
|
|
54
|
+
scheme: Schema.Literal<[1]>;
|
|
57
55
|
type: Schema.SchemaClass<0 | 5 | 7 | 8, 0 | 5 | 7 | 8, never>;
|
|
58
56
|
value: Schema.TemplateLiteral<`0x${string}`>;
|
|
59
57
|
}>;
|
|
@@ -71,11 +69,11 @@ export type EncryptResultOf<S extends EncryptionScheme, T extends SupportedFheTy
|
|
|
71
69
|
ciphertext: CiphertextOf<S, T>;
|
|
72
70
|
};
|
|
73
71
|
export declare const Plaintext: Schema.Union<[Schema.Struct<{
|
|
74
|
-
scheme: Schema.Literal<[
|
|
72
|
+
scheme: Schema.Literal<[1]>;
|
|
75
73
|
type: Schema.Literal<[5, 7, 8]>;
|
|
76
74
|
value: typeof Schema.BigInt;
|
|
77
75
|
}>, Schema.Struct<{
|
|
78
|
-
scheme: Schema.Literal<[
|
|
76
|
+
scheme: Schema.Literal<[1]>;
|
|
79
77
|
type: Schema.Literal<[0]>;
|
|
80
78
|
value: typeof Schema.Boolean;
|
|
81
79
|
}>]>;
|
|
@@ -83,11 +81,11 @@ export type Plaintext = typeof Plaintext.Type;
|
|
|
83
81
|
export type PlaintextOf<S extends EncryptionScheme, T extends SupportedFheType> = DistType<Plaintext, S, T>;
|
|
84
82
|
export declare const PlaintextWithContext: Schema.Struct<{
|
|
85
83
|
plaintext: Schema.Union<[Schema.Struct<{
|
|
86
|
-
scheme: Schema.Literal<[
|
|
84
|
+
scheme: Schema.Literal<[1]>;
|
|
87
85
|
type: Schema.Literal<[5, 7, 8]>;
|
|
88
86
|
value: typeof Schema.BigInt;
|
|
89
87
|
}>, Schema.Struct<{
|
|
90
|
-
scheme: Schema.Literal<[
|
|
88
|
+
scheme: Schema.Literal<[1]>;
|
|
91
89
|
type: Schema.Literal<[0]>;
|
|
92
90
|
value: typeof Schema.Boolean;
|
|
93
91
|
}>]>;
|
|
@@ -44,7 +44,7 @@ export declare const addTwoAbi: readonly [{
|
|
|
44
44
|
readonly internalType: "bytes";
|
|
45
45
|
readonly type: "bytes";
|
|
46
46
|
}];
|
|
47
|
-
readonly name: "
|
|
47
|
+
readonly name: "addTwoEoa";
|
|
48
48
|
readonly outputs: readonly [{
|
|
49
49
|
readonly name: "result";
|
|
50
50
|
readonly internalType: "euint256";
|
|
@@ -1135,6 +1135,26 @@ export declare const iIncoLightningPreviewAbi: readonly [{
|
|
|
1135
1135
|
readonly type: "bytes32";
|
|
1136
1136
|
}];
|
|
1137
1137
|
readonly stateMutability: "nonpayable";
|
|
1138
|
+
}, {
|
|
1139
|
+
readonly type: "function";
|
|
1140
|
+
readonly inputs: readonly [];
|
|
1141
|
+
readonly name: "majorVersion";
|
|
1142
|
+
readonly outputs: readonly [{
|
|
1143
|
+
readonly name: "";
|
|
1144
|
+
readonly internalType: "uint8";
|
|
1145
|
+
readonly type: "uint8";
|
|
1146
|
+
}];
|
|
1147
|
+
readonly stateMutability: "view";
|
|
1148
|
+
}, {
|
|
1149
|
+
readonly type: "function";
|
|
1150
|
+
readonly inputs: readonly [];
|
|
1151
|
+
readonly name: "minorVersion";
|
|
1152
|
+
readonly outputs: readonly [{
|
|
1153
|
+
readonly name: "";
|
|
1154
|
+
readonly internalType: "uint8";
|
|
1155
|
+
readonly type: "uint8";
|
|
1156
|
+
}];
|
|
1157
|
+
readonly stateMutability: "view";
|
|
1138
1158
|
}, {
|
|
1139
1159
|
readonly type: "function";
|
|
1140
1160
|
readonly inputs: readonly [{
|
|
@@ -1229,6 +1249,16 @@ export declare const iIncoLightningPreviewAbi: readonly [{
|
|
|
1229
1249
|
readonly type: "bytes32";
|
|
1230
1250
|
}];
|
|
1231
1251
|
readonly stateMutability: "payable";
|
|
1252
|
+
}, {
|
|
1253
|
+
readonly type: "function";
|
|
1254
|
+
readonly inputs: readonly [];
|
|
1255
|
+
readonly name: "patchVersion";
|
|
1256
|
+
readonly outputs: readonly [{
|
|
1257
|
+
readonly name: "";
|
|
1258
|
+
readonly internalType: "uint8";
|
|
1259
|
+
readonly type: "uint8";
|
|
1260
|
+
}];
|
|
1261
|
+
readonly stateMutability: "view";
|
|
1232
1262
|
}, {
|
|
1233
1263
|
readonly type: "function";
|
|
1234
1264
|
readonly inputs: readonly [{
|
|
@@ -1247,6 +1277,16 @@ export declare const iIncoLightningPreviewAbi: readonly [{
|
|
|
1247
1277
|
readonly type: "bool";
|
|
1248
1278
|
}];
|
|
1249
1279
|
readonly stateMutability: "view";
|
|
1280
|
+
}, {
|
|
1281
|
+
readonly type: "function";
|
|
1282
|
+
readonly inputs: readonly [];
|
|
1283
|
+
readonly name: "salt";
|
|
1284
|
+
readonly outputs: readonly [{
|
|
1285
|
+
readonly name: "";
|
|
1286
|
+
readonly internalType: "bytes32";
|
|
1287
|
+
readonly type: "bytes32";
|
|
1288
|
+
}];
|
|
1289
|
+
readonly stateMutability: "view";
|
|
1250
1290
|
}];
|
|
1251
1291
|
export declare const voucherEip712CheckerAbi: readonly [{
|
|
1252
1292
|
readonly type: "function";
|
|
@@ -700,7 +700,7 @@ export declare const incoLightningAbi: readonly [{
|
|
|
700
700
|
readonly internalType: "bytes32";
|
|
701
701
|
readonly type: "bytes32";
|
|
702
702
|
}];
|
|
703
|
-
readonly stateMutability: "
|
|
703
|
+
readonly stateMutability: "pure";
|
|
704
704
|
}, {
|
|
705
705
|
readonly type: "function";
|
|
706
706
|
readonly inputs: readonly [];
|