@inco/js 0.6.9 → 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.
Files changed (105) hide show
  1. package/README.md +8 -8
  2. package/dist/cjs/advancedacl/session-key.d.ts +39 -26
  3. package/dist/cjs/advancedacl/session-key.js +53 -136
  4. package/dist/cjs/attestedcompute/attested-compute.d.ts +6 -6
  5. package/dist/cjs/attestedcompute/attested-compute.js +5 -35
  6. package/dist/cjs/attesteddecrypt/attested-decrypt.d.ts +36 -21
  7. package/dist/cjs/attesteddecrypt/attested-decrypt.js +107 -108
  8. package/dist/cjs/attesteddecrypt/types.d.ts +4 -4
  9. package/dist/cjs/generated/es/inco/covalidator/compute/v1/types_pb.d.ts +15 -1
  10. package/dist/cjs/generated/es/inco/covalidator/compute/v1/types_pb.js +1 -1
  11. package/dist/cjs/generated/es/inco/kms/lite/v1/kms_service_pb.d.ts +13 -5
  12. package/dist/cjs/generated/es/inco/kms/lite/v1/kms_service_pb.js +3 -4
  13. package/dist/cjs/generated/lightning.d.ts +40 -0
  14. package/dist/cjs/generated/lightning.js +43 -1
  15. package/dist/cjs/generated/local-node.d.ts +11 -7
  16. package/dist/cjs/generated/local-node.js +28 -8
  17. package/dist/cjs/kms/client.d.ts +8 -4
  18. package/dist/cjs/kms/client.js +9 -4
  19. package/dist/cjs/kms/quorumClient.d.ts +58 -0
  20. package/dist/cjs/kms/quorumClient.js +378 -0
  21. package/dist/cjs/kms/thresholdPromises.d.ts +7 -0
  22. package/dist/cjs/kms/thresholdPromises.js +52 -0
  23. package/dist/cjs/lite/index.d.ts +0 -1
  24. package/dist/cjs/lite/index.js +1 -2
  25. package/dist/cjs/lite/lightning.d.ts +87 -67
  26. package/dist/cjs/lite/lightning.js +231 -100
  27. package/dist/cjs/local/local-node.d.ts +1 -2
  28. package/dist/cjs/local/local-node.js +2 -3
  29. package/dist/cjs/test/mocks.d.ts +3 -0
  30. package/dist/cjs/test/mocks.js +19 -1
  31. package/dist/esm/advancedacl/session-key.d.ts +39 -26
  32. package/dist/esm/advancedacl/session-key.js +44 -126
  33. package/dist/esm/attestedcompute/attested-compute.d.ts +6 -6
  34. package/dist/esm/attestedcompute/attested-compute.js +6 -36
  35. package/dist/esm/attesteddecrypt/attested-decrypt.d.ts +36 -21
  36. package/dist/esm/attesteddecrypt/attested-decrypt.js +106 -108
  37. package/dist/esm/attesteddecrypt/types.d.ts +4 -4
  38. package/dist/esm/generated/es/inco/covalidator/compute/v1/types_pb.d.ts +15 -1
  39. package/dist/esm/generated/es/inco/covalidator/compute/v1/types_pb.js +1 -1
  40. package/dist/esm/generated/es/inco/kms/lite/v1/kms_service_pb.d.ts +13 -5
  41. package/dist/esm/generated/es/inco/kms/lite/v1/kms_service_pb.js +2 -3
  42. package/dist/esm/generated/lightning.d.ts +40 -0
  43. package/dist/esm/generated/lightning.js +43 -1
  44. package/dist/esm/generated/local-node.d.ts +11 -7
  45. package/dist/esm/generated/local-node.js +28 -8
  46. package/dist/esm/kms/client.d.ts +8 -4
  47. package/dist/esm/kms/client.js +8 -4
  48. package/dist/esm/kms/quorumClient.d.ts +58 -0
  49. package/dist/esm/kms/quorumClient.js +374 -0
  50. package/dist/esm/kms/thresholdPromises.d.ts +7 -0
  51. package/dist/esm/kms/thresholdPromises.js +49 -0
  52. package/dist/esm/lite/index.d.ts +0 -1
  53. package/dist/esm/lite/index.js +1 -2
  54. package/dist/esm/lite/lightning.d.ts +87 -67
  55. package/dist/esm/lite/lightning.js +234 -103
  56. package/dist/esm/local/local-node.d.ts +1 -2
  57. package/dist/esm/local/local-node.js +2 -3
  58. package/dist/esm/test/mocks.d.ts +3 -0
  59. package/dist/esm/test/mocks.js +17 -1
  60. package/dist/types/advancedacl/session-key.d.ts +39 -26
  61. package/dist/types/attestedcompute/attested-compute.d.ts +6 -6
  62. package/dist/types/attesteddecrypt/attested-decrypt.d.ts +36 -21
  63. package/dist/types/attesteddecrypt/types.d.ts +4 -4
  64. package/dist/types/generated/es/inco/covalidator/compute/v1/types_pb.d.ts +15 -1
  65. package/dist/types/generated/es/inco/kms/lite/v1/kms_service_pb.d.ts +13 -5
  66. package/dist/types/generated/lightning.d.ts +40 -0
  67. package/dist/types/generated/local-node.d.ts +11 -7
  68. package/dist/types/kms/client.d.ts +8 -4
  69. package/dist/types/kms/quorumClient.d.ts +58 -0
  70. package/dist/types/kms/thresholdPromises.d.ts +7 -0
  71. package/dist/types/lite/index.d.ts +0 -1
  72. package/dist/types/lite/lightning.d.ts +87 -67
  73. package/dist/types/local/local-node.d.ts +1 -2
  74. package/dist/types/test/mocks.d.ts +3 -0
  75. package/package.json +2 -2
  76. package/dist/cjs/attestedreveal/attested-reveal.d.ts +0 -21
  77. package/dist/cjs/attestedreveal/attested-reveal.js +0 -69
  78. package/dist/cjs/attestedreveal/index.d.ts +0 -1
  79. package/dist/cjs/attestedreveal/index.js +0 -18
  80. package/dist/cjs/attestedreveal/types.d.ts +0 -7
  81. package/dist/cjs/attestedreveal/types.js +0 -16
  82. package/dist/cjs/generated/es/cosmos_proto/cosmos_pb.d.ts +0 -174
  83. package/dist/cjs/generated/es/cosmos_proto/cosmos_pb.js +0 -118
  84. package/dist/cjs/generated/es/inco/fhe/v1/types_pb.d.ts +0 -419
  85. package/dist/cjs/generated/es/inco/fhe/v1/types_pb.js +0 -136
  86. package/dist/cjs/lite/reencrypt.d.ts +0 -21
  87. package/dist/cjs/lite/reencrypt.js +0 -141
  88. package/dist/esm/attestedreveal/attested-reveal.d.ts +0 -21
  89. package/dist/esm/attestedreveal/attested-reveal.js +0 -66
  90. package/dist/esm/attestedreveal/index.d.ts +0 -1
  91. package/dist/esm/attestedreveal/index.js +0 -2
  92. package/dist/esm/attestedreveal/types.d.ts +0 -7
  93. package/dist/esm/attestedreveal/types.js +0 -12
  94. package/dist/esm/generated/es/cosmos_proto/cosmos_pb.d.ts +0 -174
  95. package/dist/esm/generated/es/cosmos_proto/cosmos_pb.js +0 -115
  96. package/dist/esm/generated/es/inco/fhe/v1/types_pb.d.ts +0 -419
  97. package/dist/esm/generated/es/inco/fhe/v1/types_pb.js +0 -133
  98. package/dist/esm/lite/reencrypt.d.ts +0 -21
  99. package/dist/esm/lite/reencrypt.js +0 -131
  100. package/dist/types/attestedreveal/attested-reveal.d.ts +0 -21
  101. package/dist/types/attestedreveal/index.d.ts +0 -1
  102. package/dist/types/attestedreveal/types.d.ts +0 -7
  103. package/dist/types/generated/es/cosmos_proto/cosmos_pb.d.ts +0 -174
  104. package/dist/types/generated/es/inco/fhe/v1/types_pb.d.ts +0 -419
  105. package/dist/types/lite/reencrypt.d.ts +0 -21
@@ -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 { KmsService, Secp256k1Keypair } from '../lite/index.js';
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,42 +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
- /**
33
- * The sessionKeyReencryptor function is a reencryptor that uses a session key
34
- * to reencrypt data.
35
- *
36
- */
37
- 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>>)>;
38
25
  export declare function updateActiveVouchersSessionNonce(incoLiteAddress: Address, sharerWalletClient: WalletClient<Transport, Chain, Account>): Promise<`0x${string}`>;
39
26
  export interface SessionKeyAttestedComputeArgs {
40
27
  chainId: SupportedChainId;
41
28
  ephemeralKeypair: Secp256k1Keypair;
42
- kmsConnectRpcEndpointOrClient: string | Client<typeof KmsService>;
29
+ kmsQuorumClient: KmsQuorumClient;
43
30
  allowanceVoucherWithSig: AllowanceVoucherWithSig;
44
31
  lhsHandle: HexString;
45
32
  op: AttestedComputeOP;
46
33
  rhsPlaintext: bigint | boolean;
47
34
  backoffConfig?: Partial<BackoffConfig> | undefined;
48
35
  }
49
- export declare function sessionKeyAttestedCompute<T extends SupportedFheType>({ lhsHandle, op, rhsPlaintext, backoffConfig, chainId, kmsConnectRpcEndpointOrClient, ephemeralKeypair, allowanceVoucherWithSig, }: SessionKeyAttestedComputeArgs): Promise<{
50
- handle: HexString;
51
- plaintext: import("../encryption/encryption.js").PlaintextOf<1, T>;
52
- covalidatorSignature: Uint8Array<ArrayBufferLike>;
53
- }>;
36
+ export declare function sessionKeyAttestedCompute<T extends SupportedFheType>({ lhsHandle, op, rhsPlaintext, backoffConfig, chainId, kmsQuorumClient, ephemeralKeypair, allowanceVoucherWithSig, }: SessionKeyAttestedComputeArgs): Promise<DecryptionAttestation<EciesScheme, SupportedFheType>>;
54
37
  export interface SessionKeyAttestedDecryptArgs {
55
38
  chainId: SupportedChainId;
56
39
  ephemeralKeypair: Secp256k1Keypair;
57
- kmsConnectRpcEndpointOrClient: string | Client<typeof KmsService>;
40
+ kmsQuorumClient: KmsQuorumClient;
58
41
  allowanceVoucherWithSig: AllowanceVoucherWithSig;
59
42
  handles: HexString[];
60
43
  backoffConfig?: Partial<BackoffConfig> | undefined;
61
- reencryptPubKey?: Uint8Array;
62
- reencryptKeypair?: Secp256k1Keypair;
44
+ reencryptPubKey?: Uint8Array | undefined;
45
+ reencryptKeypair?: Secp256k1Keypair | undefined;
63
46
  }
64
- export declare function sessionKeyAttestedDecrypt({ chainId, kmsConnectRpcEndpointOrClient, handles, ephemeralKeypair, allowanceVoucherWithSig, backoffConfig, reencryptPubKey, reencryptKeypair, }: SessionKeyAttestedDecryptArgs): Promise<Array<DecryptionAttestation<EciesScheme, SupportedFheType>>>;
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 type { KmsClient } from '../kms/client.js';
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 = "0.1.0";
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 connect RPC endpoint or client instance */
18
- kmsConnectRpcEndpointOrClient?: string | KmsClient;
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, kmsConnectRpcEndpointOrClient, chainId, }: {
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
- kmsConnectRpcEndpointOrClient?: string | KmsClient;
36
+ kmsQuorumClient: KmsQuorumClient;
37
37
  chainId: SupportedChainId;
38
38
  }): Promise<DecryptionAttestation<EciesScheme, T>>;
@@ -1,30 +1,38 @@
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 type { KmsClient } from '../kms/client.js';
6
- import { Secp256k1Keypair } from '../lite/ecies.js';
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';
7
7
  import type { BackoffConfig } from '../retry.js';
8
- import { DecryptionAttestation, EncryptedDecryptionAttestation } from './types.js';
8
+ import { type DecryptionAttestation, type EncryptedDecryptionAttestation } from './types.js';
9
9
  export declare const ATTESTED_DECRYPT_DOMAIN_NAME = "IncoAttestedDecrypt";
10
- export declare const ATTESTED_DECRYPT_DOMAIN_VERSION = "0.1.0";
11
- /**
12
- * Validates a handle format.
13
- * @param handle - The handle to validate
14
- * @throws {AttestedDecryptError} If the handle format is invalid
15
- */
16
- export declare function validateHandle(handle: HexString): void;
10
+ export declare const ATTESTED_DECRYPT_DOMAIN_VERSION = "1";
17
11
  /**
18
12
  * Arguments for creating an attested decrypt request.
19
13
  */
20
14
  export interface IncoLiteAttestedDecryptorArgs {
21
15
  /** The wallet used to interact with the blockchain and sign the decrypt request */
22
16
  walletClient: WalletClient<Transport, Chain, Account>;
23
- /** The KMS connect RPC endpoint or client instance */
24
- kmsConnectRpcEndpointOrClient?: string | KmsClient;
17
+ /** The KMS quorum client instance */
18
+ kmsQuorumClient: KmsQuorumClient;
25
19
  /** The chain ID to use */
26
20
  chainId: SupportedChainId;
27
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>>>;
28
36
  /**
29
37
  * Decrypt multiple handles in a single attested request.
30
38
  * Returns an array of attestations aligned with the response ordering.
@@ -33,14 +41,14 @@ export interface IncoLiteAttestedDecryptorArgs {
33
41
  * @returns A function that can decrypt handles and return an attestation
34
42
  * @throws {AttestedDecryptError} If the creation fails
35
43
  */
36
- export declare function attestedDecrypt({ handles, backoffConfig, walletClient, chainId, reencryptPubKey, reencryptKeypair, kmsConnectRpcEndpointOrClient, }: {
44
+ export declare function attestedDecrypt({ handles, backoffConfig, walletClient, chainId, reencryptPubKey, reencryptKeypair, kmsQuorumClient, }: {
37
45
  handles: HexString[];
38
46
  backoffConfig?: Partial<BackoffConfig> | undefined;
39
47
  walletClient: WalletClient<Transport, Chain, Account>;
40
48
  chainId: SupportedChainId;
41
49
  reencryptPubKey: Uint8Array;
42
50
  reencryptKeypair: Secp256k1Keypair;
43
- kmsConnectRpcEndpointOrClient?: string | KmsClient;
51
+ kmsQuorumClient: KmsQuorumClient;
44
52
  }): Promise<Array<DecryptionAttestation<EciesScheme, SupportedFheType>>>;
45
53
  /**
46
54
  * Decrypt multiple handles in a single attested request.
@@ -50,14 +58,14 @@ export declare function attestedDecrypt({ handles, backoffConfig, walletClient,
50
58
  * @returns A function that can decrypt handles and return an attestation
51
59
  * @throws {AttestedDecryptError} If the creation fails
52
60
  */
53
- export declare function attestedDecrypt({ handles, backoffConfig, walletClient, chainId, reencryptPubKey, kmsConnectRpcEndpointOrClient, }: {
61
+ export declare function attestedDecrypt({ handles, backoffConfig, walletClient, chainId, reencryptPubKey, kmsQuorumClient, }: {
54
62
  handles: HexString[];
55
63
  backoffConfig?: Partial<BackoffConfig> | undefined;
56
64
  walletClient: WalletClient<Transport, Chain, Account>;
57
65
  chainId: SupportedChainId;
58
66
  reencryptPubKey: Uint8Array;
59
67
  reencryptKeypair?: never;
60
- kmsConnectRpcEndpointOrClient?: string | KmsClient;
68
+ kmsQuorumClient: KmsQuorumClient;
61
69
  }): Promise<Array<EncryptedDecryptionAttestation<EciesScheme, SupportedFheType>>>;
62
70
  /**
63
71
  * Decrypt multiple handles in a single attested request.
@@ -67,12 +75,19 @@ export declare function attestedDecrypt({ handles, backoffConfig, walletClient,
67
75
  * @returns A function that can decrypt handles and return an attestation
68
76
  * @throws {AttestedDecryptError} If the creation fails
69
77
  */
70
- export declare function attestedDecrypt({ handles, backoffConfig, walletClient, chainId, kmsConnectRpcEndpointOrClient, }: {
78
+ export declare function attestedDecrypt({ handles, backoffConfig, walletClient, chainId, kmsQuorumClient, }: {
71
79
  handles: HexString[];
72
80
  backoffConfig?: Partial<BackoffConfig> | undefined;
73
81
  walletClient: WalletClient<Transport, Chain, Account>;
74
82
  chainId: SupportedChainId;
75
83
  reencryptPubKey?: never;
76
84
  reencryptKeypair?: never;
77
- kmsConnectRpcEndpointOrClient?: string | KmsClient;
85
+ kmsQuorumClient: KmsQuorumClient;
78
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, EncryptResultOf, 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,12 +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
- covalidatorSignature: Uint8Array;
14
+ covalidatorSignatures: Uint8Array[];
15
15
  };
16
16
  export type EncryptedDecryptionAttestation<S extends EncryptionScheme, T extends SupportedFheType> = {
17
17
  handle: HexString;
18
18
  encryptedPlaintext: EncryptResultOf<S, T>;
19
- covalidatorSignature: Uint8Array;
19
+ covalidatorSignatures: Uint8Array[];
20
20
  };
21
21
  export type AttestedDecryptor<S extends EncryptionScheme> = <T extends SupportedFheType>(args: AttestedDecryptFnArgs<S, T>) => Promise<DecryptionAttestation<S, T>>;
22
22
  export type AttestedDecryptFnArgs<S extends EncryptionScheme, T extends SupportedFheType> = {
@@ -118,7 +118,21 @@ export declare const AnyValueSchema: GenMessage<AnyValue>;
118
118
  */
119
119
  export type Scalar = Message<"inco.covalidator.compute.v1.Scalar"> & {
120
120
  /**
121
- * The type of the scalar
121
+ * The type of the scalar.
122
+ *
123
+ * The possible values are:
124
+ * Bool = 0
125
+ * Uint4 = 1
126
+ * Uint8 = 2
127
+ * Uint16 = 3
128
+ * Uint32 = 4
129
+ * Uint64 = 5
130
+ * Uint128 = 6
131
+ * Uint160 = 7
132
+ * Uint256 = 8
133
+ * Bytes64 = 9
134
+ * Bytes128 = 10
135
+ * Bytes256 = 11
122
136
  *
123
137
  * @generated from field: int32 type = 1;
124
138
  */
@@ -1,5 +1,4 @@
1
1
  import type { GenEnum, GenFile, GenMessage, GenService } from "@bufbuild/protobuf/codegenv2";
2
- import type { TypedCiphertext } from "../../../fhe/v1/types_pb";
3
2
  import type { ACLProof, ECIESKeyset, HandleWithProof } from "./types_pb";
4
3
  import type { Message } from "@bufbuild/protobuf";
5
4
  /**
@@ -88,7 +87,7 @@ export type AttestedDecryptRequest = Message<"inco.kms.lite.v1.AttestedDecryptRe
88
87
  * "primaryType": "AttestedDecryptRequest",
89
88
  * "domain": {
90
89
  * "name": "IncoAttestedDecrypt",
91
- * "version": "0.1.0",
90
+ * "version": "1",
92
91
  * "chainId": "<host_chain_id>",
93
92
  * },
94
93
  * "message": {
@@ -169,7 +168,7 @@ export type AttestedComputeRequest = Message<"inco.kms.lite.v1.AttestedComputeRe
169
168
  * "primaryType": "AttestedComputeRequest",
170
169
  * "domain": {
171
170
  * "name": "IncoAttestedCompute",
172
- * "version": "0.1.0",
171
+ * "version": "1",
173
172
  * "chainId": "<host_chain_id>",
174
173
  * },
175
174
  * "message": {
@@ -298,9 +297,18 @@ export declare const PlaintextSchema: GenMessage<Plaintext>;
298
297
  */
299
298
  export type Reencryption = Message<"inco.kms.lite.v1.Reencryption"> & {
300
299
  /**
301
- * @generated from field: inco.fhe.v1.TypedCiphertext user_ciphertext = 1;
300
+ * The ciphertext that was reencrypted to the user's public key.
301
+ *
302
+ * @generated from field: bytes user_ciphertext = 1;
302
303
  */
303
- userCiphertext?: TypedCiphertext;
304
+ userCiphertext: Uint8Array;
305
+ /**
306
+ * The handle of the ciphertext, encoded as a 0x-prefixed hex string, any case.
307
+ * TODO scalar declaration.
308
+ *
309
+ * @generated from field: string handle = 2;
310
+ */
311
+ handle: string;
304
312
  };
305
313
  /**
306
314
  * Describes the message inco.kms.lite.v1.Reencryption.
@@ -1,4 +1,44 @@
1
1
  export declare const lightningDeployments: readonly [{
2
+ readonly name: "incoLightningPreview_2_0_0__976644394";
3
+ readonly majorVersion: 2;
4
+ readonly deployer: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC";
5
+ readonly pepper: "alphanet";
6
+ readonly executorAddress: "0xc0d693DeEF0A91CE39208676b6da09B822abd199";
7
+ readonly salt: "0x8202d2d747784cb7d48868e44c42c4bf162a70bc000822f11f6e30f933e76d2a";
8
+ readonly chainId: 84532;
9
+ readonly chainName: "Base Sepolia";
10
+ readonly version: {
11
+ readonly major: 2;
12
+ readonly minor: 0;
13
+ readonly patch: 0;
14
+ readonly shortSalt: "976644394";
15
+ };
16
+ readonly blockNumber: 34459258;
17
+ readonly deployDate: "2025-12-02T14:46:46.026Z";
18
+ readonly commit: "v0.6.9-17-g217794f3-dirty";
19
+ readonly active: true;
20
+ readonly includesPreviewFeatures: true;
21
+ }, {
22
+ readonly name: "incoLightningPreview_1_1_0__725458969";
23
+ readonly majorVersion: 1;
24
+ readonly deployer: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC";
25
+ readonly pepper: "alphanet";
26
+ readonly executorAddress: "0x28676Cd3b10b03b2FDF105Ba280425b45a674F2A";
27
+ readonly salt: "0x8202d2d747784cb7d48868e44c42c4bf162a70bc004dfbe338c6966a22bcca19";
28
+ readonly chainId: 84532;
29
+ readonly chainName: "Base Sepolia";
30
+ readonly version: {
31
+ readonly major: 1;
32
+ readonly minor: 1;
33
+ readonly patch: 0;
34
+ readonly shortSalt: "725458969";
35
+ };
36
+ readonly blockNumber: 34456535;
37
+ readonly deployDate: "2025-12-02T13:16:00.594Z";
38
+ readonly commit: "v0.6.9-16-g428d1837-dirty";
39
+ readonly active: true;
40
+ readonly includesPreviewFeatures: true;
41
+ }, {
2
42
  readonly name: "incoLightningPreview_1_0_2__725458969";
3
43
  readonly majorVersion: 1;
4
44
  readonly deployer: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC";
@@ -2,28 +2,32 @@ export declare const localNodeLightningConfig: {
2
2
  readonly testnet: {
3
3
  readonly executorAddress: "0x63D8135aF4D393B1dB43B649010c8D3EE19FC9fd";
4
4
  readonly chainId: 31337;
5
- readonly covalidatorUrl: "http://localhost:50055";
5
+ readonly covalidatorUrls: readonly ["http://localhost:50055"];
6
+ readonly signers: readonly ["0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"];
6
7
  readonly hostChainRpcUrl: "http://localhost:8545";
7
8
  readonly senderPrivateKey: "0x78a25e2a0b5148290cc4d93ae12338dabd6ccd6dd98276514c4168dc4100df7c";
8
9
  };
9
10
  readonly devnet: {
10
11
  readonly executorAddress: "0x3473820DcAa71Af8157b93C7f2bf1c676A2A39A6";
11
12
  readonly chainId: 31337;
12
- readonly covalidatorUrl: "http://localhost:50055";
13
+ readonly covalidatorUrls: readonly ["http://localhost:50055"];
14
+ readonly signers: readonly ["0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"];
13
15
  readonly hostChainRpcUrl: "http://localhost:8545";
14
16
  readonly senderPrivateKey: "0x6f2539401f377d76bafd39b580e0f95b9bf7d39dec8fd3ada4abe41ad2ae1e18";
15
17
  };
16
18
  readonly alphanet: {
17
- readonly executorAddress: "0x28676Cd3b10b03b2FDF105Ba280425b45a674F2A";
19
+ readonly executorAddress: "0xc0d693DeEF0A91CE39208676b6da09B822abd199";
18
20
  readonly chainId: 31337;
19
- readonly covalidatorUrl: "http://localhost:50055";
21
+ readonly covalidatorUrls: readonly ["http://localhost:50055"];
22
+ readonly signers: readonly ["0x8E873085348a3406A07907E5d1465B9824bA07cd"];
20
23
  readonly hostChainRpcUrl: "http://localhost:8545";
21
- readonly senderPrivateKey: "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d";
24
+ readonly senderPrivateKey: "0x279c172cf3638a79642daa5f7666c600befde318550d7579cf96280920e318b6";
22
25
  };
23
26
  readonly scratch: {
24
- readonly executorAddress: "0x195ec7fDf68fD835b9F78d6eb13E280cC2e25fdD";
27
+ readonly executorAddress: "0x230b8fb0201E621Be3612ab7387d164f8AdC863f";
25
28
  readonly chainId: 31337;
26
- readonly covalidatorUrl: "http://localhost:50055";
29
+ readonly covalidatorUrls: readonly ["http://localhost:50055"];
30
+ readonly signers: readonly ["0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"];
27
31
  readonly hostChainRpcUrl: "http://127.0.0.1:8567";
28
32
  readonly senderPrivateKey: "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80";
29
33
  };
@@ -1,8 +1,12 @@
1
- import { Client } from '@connectrpc/connect';
2
- import { SupportedChain } from '../chain.js';
1
+ import { type Client } from '@connectrpc/connect';
2
+ import type { Address } from 'viem';
3
+ import type { SupportedChain } from '../chain.js';
3
4
  import { KmsService } from '../generated/es/inco/kms/lite/v1/kms_service_pb.js';
4
- export type KmsClient = Client<typeof KmsService>;
5
- export declare function getKmsClient(kmsConnectRpcEndpointOrClient: string | KmsClient): KmsClient;
5
+ export declare const DEFAULT_COVALIDATOR_SIGNER: Address;
6
+ export type KmsClient = Client<typeof KmsService> & {
7
+ signerAddress: Address;
8
+ };
9
+ export declare function getKmsClient(kmsConnectRpcEndpointOrClient: string | KmsClient, signerAddress: Address): KmsClient;
6
10
  export declare function defaultCovalidatorGrpc(chain: SupportedChain): string;
7
11
  export declare function lightningDevnetCovalidatorGrpc(chain: SupportedChain): string;
8
12
  export declare function lightningTestnetCovalidatorGrpc(chain: SupportedChain): string;
@@ -0,0 +1,58 @@
1
+ import type { Address } from 'viem';
2
+ import type { DecryptionAttestation, EncryptedDecryptionAttestation } from '../attesteddecrypt/types.js';
3
+ import type { EciesScheme, SupportedFheType } from '../encryption/encryption.js';
4
+ import type { AttestedComputeRequest, AttestedDecryptRequest, AttestedRevealRequest } from '../generated/es/inco/kms/lite/v1/kms_service_pb.js';
5
+ import type { BackoffConfig } from '../retry.js';
6
+ import { type KmsClient } from './client.js';
7
+ export declare class KmsQuorumClient {
8
+ private readonly kmss;
9
+ private readonly threshold;
10
+ private constructor();
11
+ private constructor();
12
+ /**
13
+ * Creates a KmsQuorumClient from an array of URLs.
14
+ * Requires signer addresses and threshold to be explicitly provided.
15
+ *
16
+ * @param urls - Array of KMS endpoint URLs
17
+ * @param signers - Array of signer addresses, must match the length of URLs
18
+ * @param threshold - Number of successful responses required (must be between 1 and urls.length)
19
+ * @throws {Error} If URLs array is empty, signers length doesn't match URLs length, or threshold is invalid
20
+ */
21
+ static fromUrls(urls: string[], signers: Address[], threshold: number): KmsQuorumClient;
22
+ /**
23
+ * Creates a KmsQuorumClient from an array of KmsClient instances.
24
+ * Each KmsClient must have a signerAddress property.
25
+ *
26
+ * @param kmsClients - Array of KMS client instances
27
+ * @param threshold - Number of successful responses required (must be between 1 and kmsClients.length)
28
+ * @throws {Error} If KMS clients array is empty or threshold is invalid
29
+ */
30
+ static fromKmsClients(kmsClients: KmsClient[], threshold: number): KmsQuorumClient;
31
+ attestedDecrypt(request: AttestedDecryptRequest, backoffConfig?: Partial<BackoffConfig>): Promise<(DecryptionAttestation<EciesScheme, SupportedFheType> | EncryptedDecryptionAttestation<EciesScheme, SupportedFheType>)[]>;
32
+ attestedCompute(request: AttestedComputeRequest, backoffConfig?: Partial<BackoffConfig>): Promise<DecryptionAttestation<EciesScheme, SupportedFheType>>;
33
+ attestedReveal(request: AttestedRevealRequest, backoffConfig?: Partial<BackoffConfig>): Promise<(DecryptionAttestation<EciesScheme, SupportedFheType> | EncryptedDecryptionAttestation<EciesScheme, SupportedFheType>)[]>;
34
+ /**
35
+ * Generic method to execute a KMS operation across all clients with retry and threshold logic.
36
+ * Returns results with both the response and signer address.
37
+ */
38
+ private executeKmsOperationWithThreshold;
39
+ /**
40
+ * Collects signatures from responses and sorts them by signer address (ascending).
41
+ * This is required by SignatureVerifier.
42
+ */
43
+ private collectAndSortSignatures;
44
+ /**
45
+ * Builds a plaintext attestation from a DecryptionAttestation proto message.
46
+ */
47
+ private buildPlaintextAttestation;
48
+ private buildAggregatedAttestations;
49
+ private buildAggregatedComputeAttestation;
50
+ private verifyResponseConsistency;
51
+ private verifyComputeResponseConsistency;
52
+ /**
53
+ * Verifies that two plaintext byte arrays are identical.
54
+ */
55
+ private verifyPlaintextBytesConsistency;
56
+ private verifyPlaintextConsistency;
57
+ private verifyCiphertextConsistency;
58
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Executes promises and returns results as soon as threshold is reached
3
+ * @param promises Array of promises to execute
4
+ * @param threshold Number of successful responses needed
5
+ * @returns Promise that resolves with threshold number of results
6
+ */
7
+ export declare function executeWithThreshold<T>(promises: Promise<T>[], threshold: number): Promise<T[]>;
@@ -7,4 +7,3 @@ export * from './deployments.js';
7
7
  export * from './ecies.js';
8
8
  export * from './hadu.js';
9
9
  export * from './lightning.js';
10
- export * from './reencrypt.js';