@inco/js 0.3.1 → 0.3.2

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 (31) hide show
  1. package/dist/cjs/attestedcompute/attested-compute.d.ts +14 -16
  2. package/dist/cjs/attestedcompute/attested-compute.js +56 -71
  3. package/dist/cjs/attesteddecrypt/attested-decrypt.d.ts +18 -19
  4. package/dist/cjs/attesteddecrypt/attested-decrypt.js +50 -60
  5. package/dist/cjs/attesteddecrypt/index.d.ts +0 -1
  6. package/dist/cjs/attesteddecrypt/index.js +1 -2
  7. package/dist/cjs/lite/attested-compute.d.ts +1 -2
  8. package/dist/cjs/lite/attested-compute.js +1 -4
  9. package/dist/cjs/lite/attested-decrypt.d.ts +1 -2
  10. package/dist/cjs/lite/attested-decrypt.js +1 -4
  11. package/dist/cjs/lite/lightning.d.ts +41 -2
  12. package/dist/cjs/lite/lightning.js +57 -1
  13. package/dist/esm/attestedcompute/attested-compute.d.ts +14 -16
  14. package/dist/esm/attestedcompute/attested-compute.js +55 -70
  15. package/dist/esm/attesteddecrypt/attested-decrypt.d.ts +18 -19
  16. package/dist/esm/attesteddecrypt/attested-decrypt.js +49 -59
  17. package/dist/esm/attesteddecrypt/index.d.ts +0 -1
  18. package/dist/esm/attesteddecrypt/index.js +1 -2
  19. package/dist/esm/lite/attested-compute.d.ts +1 -2
  20. package/dist/esm/lite/attested-compute.js +2 -3
  21. package/dist/esm/lite/attested-decrypt.d.ts +1 -2
  22. package/dist/esm/lite/attested-decrypt.js +2 -3
  23. package/dist/esm/lite/lightning.d.ts +41 -2
  24. package/dist/esm/lite/lightning.js +57 -1
  25. package/dist/types/attestedcompute/attested-compute.d.ts +14 -16
  26. package/dist/types/attesteddecrypt/attested-decrypt.d.ts +18 -19
  27. package/dist/types/attesteddecrypt/index.d.ts +0 -1
  28. package/dist/types/lite/attested-compute.d.ts +1 -2
  29. package/dist/types/lite/attested-decrypt.d.ts +1 -2
  30. package/dist/types/lite/lightning.d.ts +41 -2
  31. package/package.json +1 -1
@@ -1,8 +1,11 @@
1
1
  import type { Account, Chain, Transport, WalletClient } from 'viem';
2
+ import { DecryptionAttestation } from '../attesteddecrypt/types.js';
3
+ import { HexString } from '../binary.js';
2
4
  import { SupportedChainId } from '../chain.js';
3
- import { EciesScheme } from '../encryption/encryption.js';
5
+ import { EciesScheme, SupportedFheType } from '../encryption/encryption.js';
4
6
  import type { KmsClient } from '../kms/client.js';
5
- import { AttestedCompute } from './types.js';
7
+ import type { BackoffConfig } from '../retry.js';
8
+ import { AttestedComputeOP } from './types.js';
6
9
  /**
7
10
  * Arguments for creating an attested compute.
8
11
  */
@@ -21,18 +24,13 @@ export interface IncoLiteAttestedComputeArgs {
21
24
  * @throws {AttestedComputeError} If the creation fails
22
25
  *
23
26
  * @todo Support multiple operations in a single request.
24
- *
25
- * @example
26
- * ```typescript
27
- * const compute = await incoLiteAttestedCompute({
28
- * walletClient,
29
- * chainId: sepolia,
30
- * });
31
- * const decryptionAttestation = await compute({
32
- * lhsHandle: '0x...',
33
- * op: AttestedComputeSupportedOps.Eq,
34
- * rhsPlaintext: 1337n,
35
- * });
36
- * ```
37
27
  */
38
- export declare function incoLiteAttestedCompute({ kmsConnectRpcEndpointOrClient, chainId, walletClient, }: IncoLiteAttestedComputeArgs): AttestedCompute<EciesScheme>;
28
+ export declare function attestedCompute<T extends SupportedFheType>({ lhsHandle, op, rhsPlaintext, backoffConfig, walletClient, kmsConnectRpcEndpointOrClient, chainId, }: {
29
+ lhsHandle: HexString;
30
+ op: AttestedComputeOP;
31
+ rhsPlaintext: bigint | boolean;
32
+ backoffConfig?: Partial<BackoffConfig> | undefined;
33
+ walletClient: WalletClient<Transport, Chain, Account>;
34
+ kmsConnectRpcEndpointOrClient?: string | KmsClient;
35
+ chainId: SupportedChainId;
36
+ }): Promise<DecryptionAttestation<EciesScheme, T>>;
@@ -1,16 +1,18 @@
1
1
  import type { Account, Chain, Transport, WalletClient } from 'viem';
2
+ import { HexString } from '../binary.js';
2
3
  import { SupportedChainId } from '../chain.js';
3
- import { EciesScheme } from '../encryption/encryption.js';
4
+ import { EciesScheme, SupportedFheType } from '../encryption/encryption.js';
4
5
  import type { KmsClient } from '../kms/client.js';
5
- import { AttestedDecryptor } from './types.js';
6
+ import type { BackoffConfig } from '../retry.js';
7
+ import { DecryptionAttestation } from './types.js';
6
8
  /**
7
9
  * Validates a handle format.
8
10
  * @param handle - The handle to validate
9
11
  * @throws {AttestedDecryptError} If the handle format is invalid
10
12
  */
11
- export declare function validateHandle(handle: string): void;
13
+ export declare function validateHandle(handle: HexString): void;
12
14
  /**
13
- * Arguments for creating an attested decryptor.
15
+ * Arguments for creating an attested decrypt request.
14
16
  */
15
17
  export interface IncoLiteAttestedDecryptorArgs {
16
18
  /** The wallet used to interact with the blockchain and sign the decrypt request */
@@ -21,20 +23,17 @@ export interface IncoLiteAttestedDecryptorArgs {
21
23
  chainId: SupportedChainId;
22
24
  }
23
25
  /**
24
- * Creates an attested decryptor that can decrypt handles with an attached attestation from the covalidator.
25
- * @param args - The arguments for creating the decryptor
26
- * @returns A function that can decrypt handles using attestation
27
- * @throws {AttestedDecryptError} If the decryptor creation fails
26
+ * Decrypt multiple handles in a single attested request.
27
+ * Returns an array of attestations aligned with the response ordering.
28
28
  *
29
- * @todo Support multiple handles in a single request.
30
- *
31
- * @example
32
- * ```typescript
33
- * const decryptor = await incoLiteAttestedDecryptor({
34
- * walletClient,
35
- * chainId: sepolia,
36
- * });
37
- * const { plaintext, covalidatorSignature } = await decryptor({ handle: '0x...' });
38
- * ```
29
+ * @param args - The arguments for creating the attested decrypt function
30
+ * @returns A function that can decrypt handles and return an attestation
31
+ * @throws {AttestedDecryptError} If the creation fails
39
32
  */
40
- export declare function incoLiteAttestedDecryptor({ kmsConnectRpcEndpointOrClient, chainId, walletClient, }: IncoLiteAttestedDecryptorArgs): AttestedDecryptor<EciesScheme>;
33
+ export declare function attestedDecrypt({ handles, backoffConfig, walletClient, chainId, kmsConnectRpcEndpointOrClient, }: {
34
+ handles: HexString[];
35
+ backoffConfig?: Partial<BackoffConfig> | undefined;
36
+ walletClient: WalletClient<Transport, Chain, Account>;
37
+ chainId: SupportedChainId;
38
+ kmsConnectRpcEndpointOrClient?: string | KmsClient;
39
+ }): Promise<Array<DecryptionAttestation<EciesScheme, SupportedFheType>>>;
@@ -1,2 +1 @@
1
- export * from './attested-decrypt.js';
2
1
  export * from './types.js';
@@ -1,4 +1,3 @@
1
- import { type IncoLiteAttestedComputeArgs, incoLiteAttestedCompute } from '../attestedcompute/attested-compute.js';
1
+ import { type IncoLiteAttestedComputeArgs } from '../attestedcompute/attested-compute.js';
2
2
  import { type AttestedComputeSupportedOps } from '../attestedcompute/types.js';
3
- export { incoLiteAttestedCompute };
4
3
  export type { AttestedComputeSupportedOps, IncoLiteAttestedComputeArgs };
@@ -1,3 +1,2 @@
1
- import { type IncoLiteAttestedDecryptorArgs, incoLiteAttestedDecryptor } from '../attesteddecrypt/attested-decrypt.js';
2
- export { incoLiteAttestedDecryptor };
1
+ import { type IncoLiteAttestedDecryptorArgs } from '../attesteddecrypt/attested-decrypt.js';
3
2
  export type { IncoLiteAttestedDecryptorArgs };
@@ -1,11 +1,14 @@
1
1
  import { Account, Chain, Transport, WalletClient } from 'viem';
2
2
  import { AllowanceVoucherWithSig } from '../advancedacl/types.js';
3
+ import { AttestedComputeOP } from '../attestedcompute/types.js';
4
+ import { DecryptionAttestation } from '../attesteddecrypt/index.js';
3
5
  import { Address, HexString } from '../binary.js';
4
- import { EciesScheme, PlaintextOf } from '../encryption/index.js';
6
+ import { EciesScheme, PlaintextOf, SupportedFheType } from '../encryption/index.js';
5
7
  import { lightningDeployments } from '../generated/lightning.js';
6
8
  import { localNodeLightningConfig } from '../generated/local-node.js';
7
9
  import { LocalNodeEnv } from '../local/index.js';
8
10
  import type { Reencryptor } from '../reencryption/index.js';
11
+ import { BackoffConfig } from '../retry.js';
9
12
  import { Secp256k1Keypair } from './ecies.js';
10
13
  type TupleToUnion<T> = T extends readonly unknown[] ? T[number] : never;
11
14
  type Deployment = TupleToUnion<typeof lightningDeployments>;
@@ -163,7 +166,7 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
163
166
  * const decryptedValue = await reencryptor({handle: resultHandle});
164
167
  * ```
165
168
  */
166
- getSessionKeyRencryptor(allowanceVoucherWithSig: AllowanceVoucherWithSig, ephemeralKeypair: Secp256k1Keypair): Promise<(<T_1 extends import("../encryption/encryption.js").SupportedFheType>({ handle }: import("../reencryption/types.js").ReencryptFnArgs<EciesScheme, T_1>) => Promise<PlaintextOf<1, 0 | 5 | 7 | 8>>)>;
169
+ 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>>)>;
167
170
  /**
168
171
  * Updates the active session nonce for the given wallet client.
169
172
  *
@@ -174,6 +177,42 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
174
177
  * @returns The transaction hash of the updateActiveVouchersSessionNonce transaction
175
178
  */
176
179
  updateActiveVouchersSessionNonce(walletClient: WalletClient<Transport, Chain, Account>): Promise<HexString>;
180
+ /**
181
+ * Get an attested decryptor for the given wallet client.
182
+ *
183
+ * @param walletClient - The wallet client used for signing the attested decrypt request
184
+ * @param handles - The handles to decrypt
185
+ * @param backoffConfig - The backoff configuration for the attested decrypt request
186
+ * @returns The decryption attestations
187
+ *
188
+ * @example
189
+ * ```typescript
190
+ * const response = await lightning.attestedDecrypt(walletClient, [handle1, handle2]);
191
+ * const { plaintext, covalidatorSignature } = response[0];
192
+ * ```
193
+ */
194
+ attestedDecrypt(walletClient: WalletClient<Transport, Chain, Account>, handles: HexString[], backoffConfig?: Partial<BackoffConfig>): Promise<Array<DecryptionAttestation<EciesScheme, SupportedFheType>>>;
195
+ /**
196
+ * Get an attested compute for the given wallet client.
197
+ *
198
+ * @param walletClient - The wallet client used for signing the attested compute request
199
+ * @param lhsHandle - The handle to compute
200
+ * @param op - The operation to perform
201
+ * @param rhsPlaintext - The plaintext to compute with
202
+ * @param backoffConfig - The backoff configuration for the attested compute request
203
+ * @returns The decryption attestation
204
+ *
205
+ * @example
206
+ * ```typescript
207
+ * import { AttestedComputeSupportedOps } from '../lite/attested-compute.js';
208
+ * const lhsHandle = '0x...';
209
+ * const rhsPlaintext = 1337n;
210
+ * const op = AttestedComputeSupportedOps.Eq;
211
+ * const response = await lightning.attestedCompute(walletClient, lhsHandle, op, rhsPlaintext);
212
+ * const { plaintext, covalidatorSignature, handle } = response;
213
+ * ```
214
+ */
215
+ attestedCompute(walletClient: WalletClient<Transport, Chain, Account>, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, backoffConfig?: Partial<BackoffConfig>): Promise<DecryptionAttestation<EciesScheme, SupportedFheType>>;
177
216
  /**
178
217
  * Get the GRPC endpoint for the covalidator that services this deployment.
179
218
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inco/js",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "repository": "https://github.com/Inco-fhevm/inco-monorepo",
5
5
  "sideEffects": false,
6
6
  "scripts": {