@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,13 +1,12 @@
1
1
  import { Account, Chain, PublicClient, Transport, WalletClient } from 'viem';
2
2
  import { AllowanceVoucherWithSig } from '../advancedacl/types.js';
3
3
  import { AttestedComputeOP } from '../attestedcompute/types.js';
4
- import { DecryptionAttestation } from '../attesteddecrypt/index.js';
4
+ import { DecryptionAttestation, EncryptedDecryptionAttestation } from '../attesteddecrypt/index.js';
5
5
  import { Address, HexString } from '../binary.js';
6
- import { EciesScheme, Encryptor, PlaintextOf, SupportedFheType } from '../encryption/index.js';
6
+ import { EciesScheme, Encryptor, SupportedFheType } from '../encryption/index.js';
7
7
  import { lightningDeployments } from '../generated/lightning.js';
8
8
  import { localNodeLightningConfig } from '../generated/local-node.js';
9
9
  import { LocalNodeEnv } from '../local/index.js';
10
- import type { Reencryptor } from '../reencryption/index.js';
11
10
  import { BackoffConfig } from '../retry.js';
12
11
  import { Secp256k1Keypair } from './ecies.js';
13
12
  type TupleToUnion<T> = T extends readonly unknown[] ? T[number] : never;
@@ -31,22 +30,28 @@ export type DeploymentSlice = {
31
30
  export type CustomConfig = {
32
31
  executorAddress: string;
33
32
  chainId: number;
34
- covalidatorUrl: string;
33
+ covalidatorUrls: string[];
34
+ signers?: Address[];
35
35
  hostChainRpcUrl?: string;
36
36
  senderPrivateKey?: HexString;
37
37
  };
38
38
  export type CustomDeployment = DeploymentSlice & CustomConfig;
39
+ type LocalNodeEnvFileSource = {
40
+ filePath: string;
41
+ };
39
42
  /**
40
43
  * The Lightning class provides a convenient way to interact with the Inco Lightning contract by binding to a specific
41
44
  * deployment.
42
45
  */
43
46
  export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
44
47
  private readonly _deployment;
45
- readonly covalidatorUrl: string;
48
+ readonly covalidatorUrls: string[];
49
+ readonly signers: Address[];
50
+ readonly threshold: number;
46
51
  readonly executorAddress: Address;
47
52
  readonly chainId: bigint;
48
53
  private readonly ephemeralKeypair;
49
- private readonly kmsClient;
54
+ private readonly kmsQuorumClient;
50
55
  private constructor();
51
56
  /**
52
57
  * Get a Lightning instance bound to the latest Lightning deployment for the Base Sepolia testnet.
@@ -73,7 +78,7 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
73
78
  *
74
79
  * @param filePath the path to the file containing the environment variables in dotenv format
75
80
  */
76
- static localNodeFromEnv(filePath?: string): Promise<Lightning<CustomDeployment>>;
81
+ static localNodeFromEnv(source?: string | Buffer | LocalNodeEnvFileSource): Promise<Lightning<CustomDeployment>>;
77
82
  /**
78
83
  * Get a Lightning deployment by name or executor address on a particular chain.
79
84
  *
@@ -102,7 +107,7 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
102
107
  * will not be compatible with the new version.
103
108
  *
104
109
  * @param pepper the pepper to use to filter the deployments
105
- * @param chainId the chainId to use to filter the deployments
110
+ * @param chain the chain to use to filter the deployments
106
111
  */
107
112
  static latest<P extends Pepper>(pepper: P, chainId: ChainId): Promise<Lightning<Deployment>>;
108
113
  get deployment(): T;
@@ -115,13 +120,11 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
115
120
  */
116
121
  encrypt<T extends SupportedNativeType>(value: T, { accountAddress, dappAddress }: EncryptionContext, encryptor: Encryptor<EciesScheme>): Promise<HexString>;
117
122
  /**
118
- * Obtain a reencryptor for a particular Externally Owned Account (EOA) to request decrypted values.
119
- * The account associated with the walletClient must have permissions to decrypt the handle or ciphertext passed
120
- * to the reencryptor function.
123
+ * Get the encryptor for a specific ECIES public key.
121
124
  *
122
- * @param walletClient the wallet client to use for signing the reencrypt request.
125
+ * @param eciesPubkey the ECIES public key to use for encryption
126
+ * @returns an Encryptor instance configured for the specified ECIES public key
123
127
  */
124
- getReencryptor(walletClient: WalletClient<Transport, Chain, Account>): Promise<Reencryptor<EciesScheme>>;
125
128
  getEncryptor(eciesPubkey: HexString): Encryptor<EciesScheme>;
126
129
  /**
127
130
  * Grants a session key allowance voucher for secure reencryption operations.
@@ -147,24 +150,6 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
147
150
  * ```
148
151
  */
149
152
  grantSessionKeyAllowanceVoucher(walletClient: WalletClient<Transport, Chain, Account>, granteeAddress: string, expiresAt: Date, sessionVerifierAddress: string): Promise<AllowanceVoucherWithSig>;
150
- /**
151
- * Creates a session key reencryptor for secure data reencryption operations.
152
- *
153
- * This method returns a reencryptor instance that can be used to perform reencryption
154
- * operations using session keys. The reencryptor is configured with the provided
155
- * allowance voucher and ephemeral keypair for secure communication.
156
- *
157
- * @param allowanceVoucherWithSig - The signed allowance voucher obtained from grantSessionKeyAllowanceVoucher
158
- * @param ephemeralKeypair - The ephemeral keypair used for secure communication with the KMS make sure it has allowance to voucher
159
- * @returns A reencryptor instance configured for session key operations
160
- *
161
- * @example
162
- * ```typescript
163
- * const reencryptor = await lightning.getSessionKeyRencryptor(voucher, ephemeralKeypair);
164
- * const decryptedValue = await reencryptor({handle: resultHandle});
165
- * ```
166
- */
167
- getSessionKeyRencryptor(allowanceVoucherWithSig: AllowanceVoucherWithSig, ephemeralKeypair: Secp256k1Keypair): Promise<(<T_1 extends SupportedFheType>({ handle, }: import("../reencryption/types.js").ReencryptFnArgs<EciesScheme, T_1>) => Promise<PlaintextOf<1, 0 | 5 | 7 | 8>>)>;
168
153
  /**
169
154
  * Updates the active session nonce for the given wallet client.
170
155
  *
@@ -176,35 +161,68 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
176
161
  */
177
162
  updateActiveVouchersSessionNonce(walletClient: WalletClient<Transport, Chain, Account>): Promise<HexString>;
178
163
  /**
179
- * Get an attested decryptor for the given wallet client.
164
+ * Requests attested decrypts signed by the covalidator using a wallet client.
180
165
  *
181
- * @param walletClient - The wallet client used for signing the attested decrypt request
182
- * @param handles - The handles to decrypt
183
- * @param backoffConfig - The backoff configuration for the attested decrypt request
184
- * @returns The decryption attestations
166
+ * @param walletClient Wallet used to sign the EIP-712 request.
167
+ * @param handles 32-byte handles to decrypt.
168
+ * @param backoffConfig Optional retry configuration.
185
169
  *
186
- * @example
187
- * ```typescript
188
- * const response = await lightning.attestedDecrypt(walletClient, [handle1, handle2]);
189
- * const { plaintext, covalidatorSignature } = response[0];
170
+ * @example Plaintext results
171
+ * ```ts
172
+ * const attestations = await lightning.attestedDecrypt(walletClient, [handle]);
173
+ * console.log(attestations[0].plaintext.value);
174
+ * ```
175
+ *
176
+ * @example Reencrypt for a delegate
177
+ * ```ts
178
+ * const encrypted = await lightning.attestedDecrypt(walletClient, [handle], delegatePubKey);
179
+ * console.log(encrypted[0].encryptedPlaintext.ciphertext.value);
180
+ * ```
181
+ *
182
+ * @example Reencrypt and decrypt locally
183
+ * ```ts
184
+ * const decrypted = await lightning.attestedDecrypt(
185
+ * walletClient,
186
+ * [handle],
187
+ * keypair.encodePublicKey(),
188
+ * keypair,
189
+ * );
190
+ * console.log(decrypted[0].plaintext.value);
190
191
  * ```
191
192
  */
192
193
  attestedDecrypt(walletClient: WalletClient<Transport, Chain, Account>, handles: HexString[], backoffConfig?: Partial<BackoffConfig>): Promise<Array<DecryptionAttestation<EciesScheme, SupportedFheType>>>;
194
+ attestedDecrypt(walletClient: WalletClient<Transport, Chain, Account>, handles: HexString[], reencryptPubKey: Uint8Array, backoffConfig?: Partial<BackoffConfig>): Promise<Array<EncryptedDecryptionAttestation<EciesScheme, SupportedFheType>>>;
195
+ attestedDecrypt(walletClient: WalletClient<Transport, Chain, Account>, handles: HexString[], reencryptPubKey: Uint8Array, reencryptKeypair: Secp256k1Keypair, backoffConfig?: Partial<BackoffConfig>): Promise<Array<DecryptionAttestation<EciesScheme, SupportedFheType>>>;
193
196
  /**
194
- * @notice Attested decryption using a session key.
195
- * @dev This method is used when you want to perform attested decryption
196
- * via an ephemeral session key and an allowance voucher. The session
197
- * key setup is typically faster and more flexible than using a wallet.
197
+ * Requests attested decrypts using a voucher-backed session key.
198
198
  *
199
- * @param ephemeralKeypair The ephemeral Secp256k1 keypair used for secure communication.
200
- * @param allowanceVoucherWithSig The signed allowance voucher, obtained from
201
- * `grantSessionKeyAllowanceVoucher`, proving the session key's decryption rights.
202
- * @param handles The encrypted handles to be decrypted.
203
- * @param backoffConfig Optional configuration for retry and backoff strategy.
199
+ * @param ephemeralKeypair Session keypair matching the voucher grantee.
200
+ * @param allowanceVoucherWithSig Signed allowance voucher.
201
+ * @param handles Handles to decrypt.
202
+ * @param options Optional reencryption/backoff configuration.
204
203
  *
205
- * @returns A promise that resolves to an array of decryption attestations.
204
+ * @example Plaintext results
205
+ * ```ts
206
+ * const attestations = await lightning.attestedDecryptWithVoucher(
207
+ * ephemeralKeypair,
208
+ * voucher,
209
+ * [handle],
210
+ * );
211
+ * ```
212
+ *
213
+ * @example Reencrypt for a delegate
214
+ * ```ts
215
+ * const encrypted = await lightning.attestedDecryptWithVoucher(
216
+ * ephemeralKeypair,
217
+ * voucher,
218
+ * [handle],
219
+ * { reencryptPubKey: delegateKeypair.encodePublicKey() },
220
+ * );
221
+ * ```
206
222
  */
207
- attestedDecrypt(ephemeralKeypair: Secp256k1Keypair, allowanceVoucherWithSig: AllowanceVoucherWithSig, handles: HexString[], backoffConfig?: Partial<BackoffConfig>): Promise<Array<DecryptionAttestation<EciesScheme, SupportedFheType>>>;
223
+ attestedDecryptWithVoucher(ephemeralKeypair: Secp256k1Keypair, allowanceVoucherWithSig: AllowanceVoucherWithSig, handles: HexString[], backoffConfig?: Partial<BackoffConfig>): Promise<Array<DecryptionAttestation<EciesScheme, SupportedFheType>>>;
224
+ attestedDecryptWithVoucher(ephemeralKeypair: Secp256k1Keypair, allowanceVoucherWithSig: AllowanceVoucherWithSig, handles: HexString[], reencryptPubKey: Uint8Array, backoffConfig?: Partial<BackoffConfig>): Promise<Array<EncryptedDecryptionAttestation<EciesScheme, SupportedFheType>>>;
225
+ attestedDecryptWithVoucher(ephemeralKeypair: Secp256k1Keypair, allowanceVoucherWithSig: AllowanceVoucherWithSig, handles: HexString[], reencryptPubKey: Uint8Array, reencryptKeypair: Secp256k1Keypair, backoffConfig?: Partial<BackoffConfig>): Promise<Array<DecryptionAttestation<EciesScheme, SupportedFheType>>>;
208
226
  /**
209
227
  * Get an attested compute for the given wallet client.
210
228
  *
@@ -227,22 +245,20 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
227
245
  */
228
246
  attestedCompute(walletClient: WalletClient<Transport, Chain, Account>, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, backoffConfig?: Partial<BackoffConfig>): Promise<DecryptionAttestation<EciesScheme, SupportedFheType>>;
229
247
  /**
230
- * @notice Attested compute using a session key.
231
- * @dev This method is used when you want to perform attested compute
232
- * via an ephemeral session key and an allowance voucher. The session
233
- * key setup is typically faster and more flexible than using a wallet.
234
- *
235
- * @param ephemeralKeypair The ephemeral Secp256k1 keypair used for secure communication.
236
- * @param lhsHandle The handle to compute on
237
- * @param op The operation to perform
238
- * @param rhsPlaintext The plaintext to compute with
239
- * @param allowanceVoucherWithSig The signed allowance voucher, obtained from
240
- * `grantSessionKeyAllowanceVoucher`, proving the session key's compute rights.
241
- * @param backoffConfig Optional configuration for retry and backoff strategy.
248
+ * Performs attested compute via a voucher-backed session key.
242
249
  *
243
- * @returns A promise that resolves to a compute attestation.
250
+ * @example
251
+ * ```ts
252
+ * const attestation = await lightning.attestedComputeWithVoucher(
253
+ * ephemeralKeypair,
254
+ * voucher,
255
+ * lhsHandle,
256
+ * AttestedComputeSupportedOps.Eq,
257
+ * true,
258
+ * );
259
+ * ```
244
260
  */
245
- attestedCompute(ephemeralKeypair: Secp256k1Keypair, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, allowanceVoucherWithSig: AllowanceVoucherWithSig, backoffConfig?: Partial<BackoffConfig>): Promise<DecryptionAttestation<EciesScheme, SupportedFheType>>;
261
+ attestedComputeWithVoucher(ephemeralKeypair: Secp256k1Keypair, allowanceVoucherWithSig: AllowanceVoucherWithSig, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, backoffConfig?: Partial<BackoffConfig>): Promise<DecryptionAttestation<EciesScheme, SupportedFheType>>;
246
262
  /**
247
263
  * Get an decryption of publicly revealed handles.
248
264
  *
@@ -260,10 +276,14 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
260
276
  /**
261
277
  * Get the GRPC endpoint for the covalidator that services this deployment.
262
278
  */
263
- static getCovalidatorUrl(deployment: DeploymentSlice & {
279
+ static getCovalidatorUrls(deployment: DeploymentSlice & {
264
280
  pepper: string;
265
- }): string;
281
+ }, threshold: number): string[];
266
282
  private static isIdByName;
267
283
  private static plaintextFromValue;
284
+ private static getContractThresholdAndSigners;
285
+ private static getThresholdAndSigners;
286
+ private static supportsThresholdRetrieval;
287
+ private static getDefaultThresholdAndSigners;
268
288
  }
269
289
  export {};
@@ -4,13 +4,12 @@ export declare const LocalNodeEnv: Schema.Struct<{
4
4
  STATE_DUMP: typeof Schema.String;
5
5
  EXECUTOR_ADDRESS: Schema.brand<Schema.filter<Schema.TemplateLiteral<`0x${string}`>>, "Address">;
6
6
  ECIES_PUBLIC_KEY: Schema.TemplateLiteral<`0x${string}`>;
7
- CALLBACK_ADDRESS: Schema.TemplateLiteral<`0x${string}`>;
8
7
  SENDER_ADDRESS: Schema.brand<Schema.filter<Schema.TemplateLiteral<`0x${string}`>>, "Address">;
9
8
  SENDER_PRIVATE_KEY: Schema.TemplateLiteral<`0x${string}`>;
9
+ EIP712_SIGNER_ADDRESS: Schema.optional<Schema.TemplateLiteral<`0x${string}`>>;
10
10
  PEPPER: typeof Schema.String;
11
11
  COVALIDATOR_ECIES_PRIVATE_KEY: Schema.TemplateLiteral<`0x${string}`>;
12
12
  COVALIDATOR_EIP712_PRIVATE_SIGNING_KEY: Schema.TemplateLiteral<`0x${string}`>;
13
- COVALIDATOR_CALLBACK_PRIVATE_KEY: Schema.TemplateLiteral<`0x${string}`>;
14
13
  COVALIDATOR_ACL_ADDR: Schema.brand<Schema.filter<Schema.TemplateLiteral<`0x${string}`>>, "Address">;
15
14
  COVALIDATOR_INCO_EXECUTOR_ADDR: Schema.brand<Schema.filter<Schema.TemplateLiteral<`0x${string}`>>, "Address">;
16
15
  COVALIDATOR_DECRYPTION_HANDLER_ADDR: Schema.brand<Schema.filter<Schema.TemplateLiteral<`0x${string}`>>, "Address">;
@@ -1,6 +1,7 @@
1
1
  import { Account, Chain, Transport, WalletClient } from 'viem';
2
2
  import { vi } from 'vitest';
3
3
  import { KmsClient } from '../kms/client.js';
4
+ import { KmsQuorumClient } from '../kms/quorumClient.js';
4
5
  interface MinimalKmsClient {
5
6
  attestedCompute: ReturnType<typeof vi.fn>;
6
7
  attestedDecrypt: ReturnType<typeof vi.fn>;
@@ -8,5 +9,7 @@ interface MinimalKmsClient {
8
9
  reencrypt: ReturnType<typeof vi.fn>;
9
10
  }
10
11
  export declare function createMockKmsClient(): MinimalKmsClient & KmsClient;
12
+ export declare function createMockQuorumClient(): KmsQuorumClient;
13
+ export declare function setupMockInQuorumClient(quorumClient: KmsQuorumClient, mockKmsClient: MinimalKmsClient & KmsClient): void;
11
14
  export declare function createTestWalletClient(): WalletClient<Transport, Chain, Account>;
12
15
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inco/js",
3
- "version": "0.6.9",
3
+ "version": "0.7.0",
4
4
  "repository": "https://github.com/Inco-fhevm/inco-monorepo",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -105,7 +105,7 @@
105
105
  "@vitest/coverage-istanbul": "3.1.1",
106
106
  "@wagmi/cli": "^2.2.0",
107
107
  "eslint": "^9.30.1",
108
- "eslint-plugin-import": "^2.32.0",
108
+ "eslint-plugin-require-extensions": "^0.1.3",
109
109
  "ts-proto": "^2.6.1",
110
110
  "typescript": "^5.7.3",
111
111
  "vitest": "^3.0.4"
@@ -1,21 +0,0 @@
1
- import { DecryptionAttestation } from '../attesteddecrypt/types.js';
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 type { BackoffConfig } from '../retry.js';
7
- /**
8
- * Just like attestedDecrypt, attestedReveal multiple revealed handles in a single attested request.
9
- * Returns an array of attestations aligned with the response ordering.
10
- * Handles must be revealed ahead of time using the .reveal() on-chain call.
11
- *
12
- * @param args - The arguments for creating the attested reveal function
13
- * @returns A function that can reveal handles and return an attestation
14
- * @throws {AttestedRevealError} If the creation fails
15
- */
16
- export declare function attestedReveal({ handles, backoffConfig, chainId, kmsConnectRpcEndpointOrClient, }: {
17
- handles: HexString[];
18
- backoffConfig?: Partial<BackoffConfig> | undefined;
19
- chainId: SupportedChainId;
20
- kmsConnectRpcEndpointOrClient?: string | KmsClient;
21
- }): Promise<Array<DecryptionAttestation<EciesScheme, SupportedFheType>>>;
@@ -1,69 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.attestedReveal = attestedReveal;
4
- const protobuf_1 = require("@bufbuild/protobuf");
5
- const binary_js_1 = require("../binary.js");
6
- const chain_js_1 = require("../chain.js");
7
- const encryption_js_1 = require("../encryption/encryption.js");
8
- const kms_service_pb_js_1 = require("../generated/es/inco/kms/lite/v1/kms_service_pb.js");
9
- const handle_js_1 = require("../handle.js");
10
- const client_js_1 = require("../kms/client.js");
11
- const retry_js_1 = require("../retry.js");
12
- const types_js_1 = require("./types.js");
13
- /**
14
- * Validates a handle format.
15
- * @param handle - The handle to validate
16
- * @throws {AttestedRevealError} If the handle format is invalid
17
- */
18
- function validateHandle(handle) {
19
- if (!handle.startsWith('0x') || handle.length !== 2 + 2 * 32) {
20
- throw new types_js_1.AttestedRevealError('Invalid handle format: must be a 32-byte hex string with 0x prefix');
21
- }
22
- }
23
- /**
24
- * Just like attestedDecrypt, attestedReveal multiple revealed handles in a single attested request.
25
- * Returns an array of attestations aligned with the response ordering.
26
- * Handles must be revealed ahead of time using the .reveal() on-chain call.
27
- *
28
- * @param args - The arguments for creating the attested reveal function
29
- * @returns A function that can reveal handles and return an attestation
30
- * @throws {AttestedRevealError} If the creation fails
31
- */
32
- async function attestedReveal({ handles, backoffConfig, chainId, kmsConnectRpcEndpointOrClient, }) {
33
- try {
34
- handles.forEach(validateHandle);
35
- const kmsClient = (0, client_js_1.getKmsClient)(kmsConnectRpcEndpointOrClient ||
36
- (0, client_js_1.defaultCovalidatorGrpc)((0, chain_js_1.getSupportedChain)(chainId)));
37
- const attestedRevealRequest = (0, protobuf_1.create)(kms_service_pb_js_1.AttestedRevealRequestSchema, {
38
- handles: handles,
39
- });
40
- const response = await (0, retry_js_1.retryWithBackoff)(async () => {
41
- return await kmsClient.attestedReveal(attestedRevealRequest);
42
- }, backoffConfig);
43
- if (response.decryptionAttestations.length !== handles.length) {
44
- throw new types_js_1.AttestedRevealError(`Expected ${handles.length} decryption attestations in response, got ${response.decryptionAttestations.length}`);
45
- }
46
- const results = response.decryptionAttestations.map((att) => {
47
- if (att.value === undefined) {
48
- throw new types_js_1.AttestedRevealError('No value in attestation');
49
- }
50
- const plaintext = att.value.value;
51
- const h = att.handle;
52
- const handleType = (0, handle_js_1.getHandleType)(h);
53
- const bigIntValue = (0, binary_js_1.bytesToBigInt)(plaintext.value);
54
- return {
55
- handle: h,
56
- plaintext: (0, encryption_js_1.bigintToPlaintext)(encryption_js_1.encryptionSchemes.ecies, handleType, bigIntValue),
57
- covalidatorSignature: att.signature,
58
- };
59
- });
60
- return results;
61
- }
62
- catch (error) {
63
- if (error instanceof types_js_1.AttestedRevealError) {
64
- throw error;
65
- }
66
- throw new types_js_1.AttestedRevealError('Failed to reveal handles', error);
67
- }
68
- }
69
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXR0ZXN0ZWQtcmV2ZWFsLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2F0dGVzdGVkcmV2ZWFsL2F0dGVzdGVkLXJldmVhbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQTRDQSx3Q0E4REM7QUExR0QsaURBQTRDO0FBRTVDLDRDQUF3RDtBQUN4RCwwQ0FBa0U7QUFDbEUsK0RBS3FDO0FBQ3JDLDBGQUk0RDtBQUM1RCw0Q0FBNkM7QUFFN0MsZ0RBQXdFO0FBRXhFLDBDQUErQztBQUMvQyx5Q0FBaUQ7QUFFakQ7Ozs7R0FJRztBQUNILFNBQVMsY0FBYyxDQUFDLE1BQWM7SUFDcEMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxVQUFVLENBQUMsSUFBSSxDQUFDLElBQUksTUFBTSxDQUFDLE1BQU0sS0FBSyxDQUFDLEdBQUcsQ0FBQyxHQUFHLEVBQUUsRUFBRSxDQUFDO1FBQzdELE1BQU0sSUFBSSw4QkFBbUIsQ0FDM0Isb0VBQW9FLENBQ3JFLENBQUM7SUFDSixDQUFDO0FBQ0gsQ0FBQztBQUVEOzs7Ozs7OztHQVFHO0FBQ0ksS0FBSyxVQUFVLGNBQWMsQ0FBQyxFQUNuQyxPQUFPLEVBQ1AsYUFBYSxFQUNiLE9BQU8sRUFDUCw2QkFBNkIsR0FNOUI7SUFDQyxJQUFJLENBQUM7UUFDSCxPQUFPLENBQUMsT0FBTyxDQUFDLGNBQWMsQ0FBQyxDQUFDO1FBQ2hDLE1BQU0sU0FBUyxHQUFHLElBQUEsd0JBQVksRUFDNUIsNkJBQTZCO1lBQzNCLElBQUEsa0NBQXNCLEVBQUMsSUFBQSw0QkFBaUIsRUFBQyxPQUFPLENBQUMsQ0FBQyxDQUNyRCxDQUFDO1FBRUYsTUFBTSxxQkFBcUIsR0FBMEIsSUFBQSxpQkFBTSxFQUN6RCwrQ0FBMkIsRUFDM0I7WUFDRSxPQUFPLEVBQUUsT0FBTztTQUNqQixDQUNGLENBQUM7UUFFRixNQUFNLFFBQVEsR0FBRyxNQUFNLElBQUEsMkJBQWdCLEVBQUMsS0FBSyxJQUFJLEVBQUU7WUFDakQsT0FBTyxNQUFNLFNBQVMsQ0FBQyxjQUFjLENBQUMscUJBQXFCLENBQUMsQ0FBQztRQUMvRCxDQUFDLEVBQUUsYUFBYSxDQUFDLENBQUM7UUFFbEIsSUFBSSxRQUFRLENBQUMsc0JBQXNCLENBQUMsTUFBTSxLQUFLLE9BQU8sQ0FBQyxNQUFNLEVBQUUsQ0FBQztZQUM5RCxNQUFNLElBQUksOEJBQW1CLENBQzNCLFlBQVksT0FBTyxDQUFDLE1BQU0sNkNBQTZDLFFBQVEsQ0FBQyxzQkFBc0IsQ0FBQyxNQUFNLEVBQUUsQ0FDaEgsQ0FBQztRQUNKLENBQUM7UUFFRCxNQUFNLE9BQU8sR0FDWCxRQUFRLENBQUMsc0JBQXNCLENBQUMsR0FBRyxDQUFDLENBQUMsR0FBRyxFQUFFLEVBQUU7WUFDMUMsSUFBSSxHQUFHLENBQUMsS0FBSyxLQUFLLFNBQVMsRUFBRSxDQUFDO2dCQUM1QixNQUFNLElBQUksOEJBQW1CLENBQUMseUJBQXlCLENBQUMsQ0FBQztZQUMzRCxDQUFDO1lBQ0QsTUFBTSxTQUFTLEdBQUcsR0FBRyxDQUFDLEtBQUssQ0FBQyxLQUFrQixDQUFDO1lBQy9DLE1BQU0sQ0FBQyxHQUFHLEdBQUcsQ0FBQyxNQUFtQixDQUFDO1lBQ2xDLE1BQU0sVUFBVSxHQUFHLElBQUEseUJBQWEsRUFBQyxDQUFDLENBQUMsQ0FBQztZQUNwQyxNQUFNLFdBQVcsR0FBRyxJQUFBLHlCQUFhLEVBQUMsU0FBUyxDQUFDLEtBQUssQ0FBQyxDQUFDO1lBQ25ELE9BQU87Z0JBQ0wsTUFBTSxFQUFFLENBQUM7Z0JBQ1QsU0FBUyxFQUFFLElBQUEsaUNBQWlCLEVBQzFCLGlDQUFpQixDQUFDLEtBQUssRUFDdkIsVUFBOEIsRUFDOUIsV0FBVyxDQUNaO2dCQUNELG9CQUFvQixFQUFFLEdBQUcsQ0FBQyxTQUFTO2FBQ3BDLENBQUM7UUFDSixDQUFDLENBQUMsQ0FBQztRQUVMLE9BQU8sT0FBTyxDQUFDO0lBQ2pCLENBQUM7SUFBQyxPQUFPLEtBQUssRUFBRSxDQUFDO1FBQ2YsSUFBSSxLQUFLLFlBQVksOEJBQW1CLEVBQUUsQ0FBQztZQUN6QyxNQUFNLEtBQUssQ0FBQztRQUNkLENBQUM7UUFDRCxNQUFNLElBQUksOEJBQW1CLENBQUMsMEJBQTBCLEVBQUUsS0FBSyxDQUFDLENBQUM7SUFDbkUsQ0FBQztBQUNILENBQUMifQ==
@@ -1 +0,0 @@
1
- export * from './types.js';
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./types.js"), exports);
18
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvYXR0ZXN0ZWRyZXZlYWwvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLDZDQUEyQiJ9
@@ -1,7 +0,0 @@
1
- /**
2
- * Custom error class for attested reveal operations.
3
- */
4
- export declare class AttestedRevealError extends Error {
5
- readonly cause?: unknown | undefined;
6
- constructor(message: string, cause?: unknown | undefined);
7
- }
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AttestedRevealError = void 0;
4
- /**
5
- * Custom error class for attested reveal operations.
6
- */
7
- class AttestedRevealError extends Error {
8
- cause;
9
- constructor(message, cause) {
10
- super(message);
11
- this.cause = cause;
12
- this.name = 'AttestedRevealError';
13
- }
14
- }
15
- exports.AttestedRevealError = AttestedRevealError;
16
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvYXR0ZXN0ZWRyZXZlYWwvdHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUE7O0dBRUc7QUFDSCxNQUFhLG1CQUFvQixTQUFRLEtBQUs7SUFHMUI7SUFGbEIsWUFDRSxPQUFlLEVBQ0MsS0FBZTtRQUUvQixLQUFLLENBQUMsT0FBTyxDQUFDLENBQUM7UUFGQyxVQUFLLEdBQUwsS0FBSyxDQUFVO1FBRy9CLElBQUksQ0FBQyxJQUFJLEdBQUcscUJBQXFCLENBQUM7SUFDcEMsQ0FBQztDQUNGO0FBUkQsa0RBUUMifQ==
@@ -1,174 +0,0 @@
1
- import type { GenEnum, GenExtension, GenFile, GenMessage } from "@bufbuild/protobuf/codegenv2";
2
- import type { FieldOptions, FileOptions, MessageOptions, MethodOptions } from "@bufbuild/protobuf/wkt";
3
- import type { Message } from "@bufbuild/protobuf";
4
- /**
5
- * Describes the file cosmos_proto/cosmos.proto.
6
- */
7
- export declare const file_cosmos_proto_cosmos: GenFile;
8
- /**
9
- * InterfaceDescriptor describes an interface type to be used with
10
- * accepts_interface and implements_interface and declared by declare_interface.
11
- *
12
- * @generated from message cosmos_proto.InterfaceDescriptor
13
- */
14
- export type InterfaceDescriptor = Message<"cosmos_proto.InterfaceDescriptor"> & {
15
- /**
16
- * name is the name of the interface. It should be a short-name (without
17
- * a period) such that the fully qualified name of the interface will be
18
- * package.name, ex. for the package a.b and interface named C, the
19
- * fully-qualified name will be a.b.C.
20
- *
21
- * @generated from field: string name = 1;
22
- */
23
- name: string;
24
- /**
25
- * description is a human-readable description of the interface and its
26
- * purpose.
27
- *
28
- * @generated from field: string description = 2;
29
- */
30
- description: string;
31
- };
32
- /**
33
- * Describes the message cosmos_proto.InterfaceDescriptor.
34
- * Use `create(InterfaceDescriptorSchema)` to create a new message.
35
- */
36
- export declare const InterfaceDescriptorSchema: GenMessage<InterfaceDescriptor>;
37
- /**
38
- * ScalarDescriptor describes an scalar type to be used with
39
- * the scalar field option and declared by declare_scalar.
40
- * Scalars extend simple protobuf built-in types with additional
41
- * syntax and semantics, for instance to represent big integers.
42
- * Scalars should ideally define an encoding such that there is only one
43
- * valid syntactical representation for a given semantic meaning,
44
- * i.e. the encoding should be deterministic.
45
- *
46
- * @generated from message cosmos_proto.ScalarDescriptor
47
- */
48
- export type ScalarDescriptor = Message<"cosmos_proto.ScalarDescriptor"> & {
49
- /**
50
- * name is the name of the scalar. It should be a short-name (without
51
- * a period) such that the fully qualified name of the scalar will be
52
- * package.name, ex. for the package a.b and scalar named C, the
53
- * fully-qualified name will be a.b.C.
54
- *
55
- * @generated from field: string name = 1;
56
- */
57
- name: string;
58
- /**
59
- * description is a human-readable description of the scalar and its
60
- * encoding format. For instance a big integer or decimal scalar should
61
- * specify precisely the expected encoding format.
62
- *
63
- * @generated from field: string description = 2;
64
- */
65
- description: string;
66
- /**
67
- * field_type is the type of field with which this scalar can be used.
68
- * Scalars can be used with one and only one type of field so that
69
- * encoding standards and simple and clear. Currently only string and
70
- * bytes fields are supported for scalars.
71
- *
72
- * @generated from field: repeated cosmos_proto.ScalarType field_type = 3;
73
- */
74
- fieldType: ScalarType[];
75
- };
76
- /**
77
- * Describes the message cosmos_proto.ScalarDescriptor.
78
- * Use `create(ScalarDescriptorSchema)` to create a new message.
79
- */
80
- export declare const ScalarDescriptorSchema: GenMessage<ScalarDescriptor>;
81
- /**
82
- * @generated from enum cosmos_proto.ScalarType
83
- */
84
- export declare enum ScalarType {
85
- /**
86
- * @generated from enum value: SCALAR_TYPE_UNSPECIFIED = 0;
87
- */
88
- UNSPECIFIED = 0,
89
- /**
90
- * @generated from enum value: SCALAR_TYPE_STRING = 1;
91
- */
92
- STRING = 1,
93
- /**
94
- * @generated from enum value: SCALAR_TYPE_BYTES = 2;
95
- */
96
- BYTES = 2
97
- }
98
- /**
99
- * Describes the enum cosmos_proto.ScalarType.
100
- */
101
- export declare const ScalarTypeSchema: GenEnum<ScalarType>;
102
- /**
103
- * method_added_in is used to indicate from which version the method was added.
104
- *
105
- * @generated from extension: string method_added_in = 93001;
106
- */
107
- export declare const method_added_in: GenExtension<MethodOptions, string>;
108
- /**
109
- * implements_interface is used to indicate the type name of the interface
110
- * that a message implements so that it can be used in google.protobuf.Any
111
- * fields that accept that interface. A message can implement multiple
112
- * interfaces. Interfaces should be declared using a declare_interface
113
- * file option.
114
- *
115
- * @generated from extension: repeated string implements_interface = 93001;
116
- */
117
- export declare const implements_interface: GenExtension<MessageOptions, string[]>;
118
- /**
119
- * message_added_in is used to indicate from which version the message was added.
120
- *
121
- * @generated from extension: string message_added_in = 93002;
122
- */
123
- export declare const message_added_in: GenExtension<MessageOptions, string>;
124
- /**
125
- * accepts_interface is used to annotate that a google.protobuf.Any
126
- * field accepts messages that implement the specified interface.
127
- * Interfaces should be declared using a declare_interface file option.
128
- *
129
- * @generated from extension: string accepts_interface = 93001;
130
- */
131
- export declare const accepts_interface: GenExtension<FieldOptions, string>;
132
- /**
133
- * scalar is used to indicate that this field follows the formatting defined
134
- * by the named scalar which should be declared with declare_scalar. Code
135
- * generators may choose to use this information to map this field to a
136
- * language-specific type representing the scalar.
137
- *
138
- * @generated from extension: string scalar = 93002;
139
- */
140
- export declare const scalar: GenExtension<FieldOptions, string>;
141
- /**
142
- * field_added_in is used to indicate from which version the field was added.
143
- *
144
- * @generated from extension: string field_added_in = 93003;
145
- */
146
- export declare const field_added_in: GenExtension<FieldOptions, string>;
147
- /**
148
- * declare_interface declares an interface type to be used with
149
- * accepts_interface and implements_interface. Interface names are
150
- * expected to follow the following convention such that their declaration
151
- * can be discovered by tools: for a given interface type a.b.C, it is
152
- * expected that the declaration will be found in a protobuf file named
153
- * a/b/interfaces.proto in the file descriptor set.
154
- *
155
- * @generated from extension: repeated cosmos_proto.InterfaceDescriptor declare_interface = 793021;
156
- */
157
- export declare const declare_interface: GenExtension<FileOptions, InterfaceDescriptor[]>;
158
- /**
159
- * declare_scalar declares a scalar type to be used with
160
- * the scalar field option. Scalar names are
161
- * expected to follow the following convention such that their declaration
162
- * can be discovered by tools: for a given scalar type a.b.C, it is
163
- * expected that the declaration will be found in a protobuf file named
164
- * a/b/scalars.proto in the file descriptor set.
165
- *
166
- * @generated from extension: repeated cosmos_proto.ScalarDescriptor declare_scalar = 793022;
167
- */
168
- export declare const declare_scalar: GenExtension<FileOptions, ScalarDescriptor[]>;
169
- /**
170
- * file_added_in is used to indicate from which the version the file was added.
171
- *
172
- * @generated from extension: string file_added_in = 793023;
173
- */
174
- export declare const file_added_in: GenExtension<FileOptions, string>;