@inco/js 0.7.0 → 0.7.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.
- package/dist/cjs/advancedacl/session-key.d.ts +9 -3
- package/dist/cjs/advancedacl/session-key.js +18 -7
- package/dist/cjs/attestedcompute/attested-compute.d.ts +32 -4
- package/dist/cjs/attestedcompute/attested-compute.js +13 -13
- package/dist/cjs/attesteddecrypt/attested-decrypt.d.ts +12 -6
- package/dist/cjs/attesteddecrypt/attested-decrypt.js +40 -7
- package/dist/cjs/attesteddecrypt/types.d.ts +1 -0
- package/dist/cjs/generated/es/inco/kms/lite/v1/kms_service_pb.d.ts +28 -14
- package/dist/cjs/generated/es/inco/kms/lite/v1/kms_service_pb.js +2 -2
- package/dist/cjs/kms/quorumClient.d.ts +1 -1
- package/dist/cjs/kms/quorumClient.js +118 -17
- package/dist/cjs/lite/attested-compute.d.ts +2 -2
- package/dist/cjs/lite/attested-compute.js +3 -3
- package/dist/cjs/lite/attested-decrypt.d.ts +2 -2
- package/dist/cjs/lite/attested-decrypt.js +3 -3
- package/dist/cjs/lite/ecies.d.ts +2 -0
- package/dist/cjs/lite/ecies.js +5 -2
- package/dist/cjs/lite/lightning.d.ts +99 -23
- package/dist/cjs/lite/lightning.js +165 -86
- package/dist/cjs/test/mocks.js +4 -2
- package/dist/cjs/viem.d.ts +2 -4
- package/dist/cjs/viem.js +6 -2
- package/dist/esm/advancedacl/session-key.d.ts +9 -3
- package/dist/esm/advancedacl/session-key.js +20 -9
- package/dist/esm/attestedcompute/attested-compute.d.ts +32 -4
- package/dist/esm/attestedcompute/attested-compute.js +14 -14
- package/dist/esm/attesteddecrypt/attested-decrypt.d.ts +12 -6
- package/dist/esm/attesteddecrypt/attested-decrypt.js +39 -7
- package/dist/esm/attesteddecrypt/types.d.ts +1 -0
- package/dist/esm/generated/es/inco/kms/lite/v1/kms_service_pb.d.ts +28 -14
- package/dist/esm/generated/es/inco/kms/lite/v1/kms_service_pb.js +2 -2
- package/dist/esm/kms/quorumClient.d.ts +1 -1
- package/dist/esm/kms/quorumClient.js +118 -17
- package/dist/esm/lite/attested-compute.d.ts +2 -2
- package/dist/esm/lite/attested-compute.js +3 -3
- package/dist/esm/lite/attested-decrypt.d.ts +2 -2
- package/dist/esm/lite/attested-decrypt.js +3 -3
- package/dist/esm/lite/ecies.d.ts +2 -0
- package/dist/esm/lite/ecies.js +4 -2
- package/dist/esm/lite/lightning.d.ts +99 -23
- package/dist/esm/lite/lightning.js +166 -87
- package/dist/esm/test/mocks.js +4 -2
- package/dist/esm/viem.d.ts +2 -4
- package/dist/esm/viem.js +6 -2
- package/dist/types/advancedacl/session-key.d.ts +9 -3
- package/dist/types/attestedcompute/attested-compute.d.ts +32 -4
- package/dist/types/attesteddecrypt/attested-decrypt.d.ts +12 -6
- package/dist/types/attesteddecrypt/types.d.ts +1 -0
- package/dist/types/generated/es/inco/kms/lite/v1/kms_service_pb.d.ts +28 -14
- package/dist/types/kms/quorumClient.d.ts +1 -1
- package/dist/types/lite/attested-compute.d.ts +2 -2
- package/dist/types/lite/attested-decrypt.d.ts +2 -2
- package/dist/types/lite/ecies.d.ts +2 -0
- package/dist/types/lite/lightning.d.ts +99 -23
- package/dist/types/viem.d.ts +2 -4
- package/package.json +5 -2
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { Account, Chain, PublicClient, Transport, WalletClient } from 'viem';
|
|
1
|
+
import { Account, Chain, GetContractReturnType, PublicClient, Transport, WalletClient } from 'viem';
|
|
2
2
|
import { AllowanceVoucherWithSig } from '../advancedacl/types.js';
|
|
3
3
|
import { AttestedComputeOP } from '../attestedcompute/types.js';
|
|
4
4
|
import { DecryptionAttestation, EncryptedDecryptionAttestation } from '../attesteddecrypt/index.js';
|
|
5
5
|
import { Address, HexString } from '../binary.js';
|
|
6
|
-
import { EciesScheme,
|
|
6
|
+
import { EciesScheme, SupportedFheType } from '../encryption/index.js';
|
|
7
|
+
import { incoVerifierAbi } from '../generated/abis/verifier.js';
|
|
7
8
|
import { lightningDeployments } from '../generated/lightning.js';
|
|
8
9
|
import { localNodeLightningConfig } from '../generated/local-node.js';
|
|
10
|
+
import { FheType } from '../handle.js';
|
|
9
11
|
import { LocalNodeEnv } from '../local/index.js';
|
|
10
12
|
import { BackoffConfig } from '../retry.js';
|
|
11
13
|
import { Secp256k1Keypair } from './ecies.js';
|
|
@@ -22,6 +24,7 @@ export type SupportedNativeType = boolean | bigint | number;
|
|
|
22
24
|
export type EncryptionContext = {
|
|
23
25
|
accountAddress: string;
|
|
24
26
|
dappAddress: string;
|
|
27
|
+
handleType: FheType;
|
|
25
28
|
};
|
|
26
29
|
export type DeploymentSlice = {
|
|
27
30
|
executorAddress: string;
|
|
@@ -36,6 +39,11 @@ export type CustomConfig = {
|
|
|
36
39
|
senderPrivateKey?: HexString;
|
|
37
40
|
};
|
|
38
41
|
export type CustomDeployment = DeploymentSlice & CustomConfig;
|
|
42
|
+
export type IncoVerifierConfig = {
|
|
43
|
+
threshold: number;
|
|
44
|
+
signers: Address[];
|
|
45
|
+
eciesPubKey: HexString;
|
|
46
|
+
};
|
|
39
47
|
type LocalNodeEnvFileSource = {
|
|
40
48
|
filePath: string;
|
|
41
49
|
};
|
|
@@ -45,13 +53,15 @@ type LocalNodeEnvFileSource = {
|
|
|
45
53
|
*/
|
|
46
54
|
export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
|
|
47
55
|
private readonly _deployment;
|
|
48
|
-
readonly covalidatorUrls
|
|
49
|
-
readonly signers
|
|
50
|
-
readonly threshold
|
|
56
|
+
private readonly covalidatorUrls;
|
|
57
|
+
private readonly signers;
|
|
58
|
+
private readonly threshold;
|
|
59
|
+
private readonly eciesPubKey;
|
|
51
60
|
readonly executorAddress: Address;
|
|
52
61
|
readonly chainId: bigint;
|
|
53
62
|
private readonly ephemeralKeypair;
|
|
54
63
|
private readonly kmsQuorumClient;
|
|
64
|
+
private readonly encryptor;
|
|
55
65
|
private constructor();
|
|
56
66
|
/**
|
|
57
67
|
* Get a Lightning instance bound to the latest Lightning deployment for the Base Sepolia testnet.
|
|
@@ -92,7 +102,6 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
|
|
|
92
102
|
* additional fields past will be made available as part of the `deployment` property.
|
|
93
103
|
*/
|
|
94
104
|
static custom<T extends CustomConfig>(config: T): Promise<Lightning<DeploymentSlice & T>>;
|
|
95
|
-
static getEciesPublicKey(client: PublicClient, executorAddress: Address): Promise<HexString>;
|
|
96
105
|
/**
|
|
97
106
|
* Get the latest deployment for a given pepper, which usually denotes a family of deployments distinct from their
|
|
98
107
|
* version such as 'devnet', 'testnet', 'mainnet', etc.
|
|
@@ -117,15 +126,13 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
|
|
|
117
126
|
* @param value a boolean or numeric value to encrypt
|
|
118
127
|
* @param accountAddress the address of the account interacting with the dapp contract, normally an Externally Owned Account (EOA)
|
|
119
128
|
* @param dappAddress the address of the dapp contract that interacts with the Inco Lightning contract or library
|
|
129
|
+
* @param handleType (optional) the handle type to be used for encrypting the value - this is required in case of non-default handle types
|
|
130
|
+
* default handle types:
|
|
131
|
+
* - boolean -> handleTypes.ebool
|
|
132
|
+
* - number | bigint -> handleTypes.euint256
|
|
133
|
+
* @returns a promise that resolves to the encrypted value as a HexString
|
|
120
134
|
*/
|
|
121
|
-
encrypt<T extends SupportedNativeType>(value: T, { accountAddress, dappAddress }: EncryptionContext
|
|
122
|
-
/**
|
|
123
|
-
* Get the encryptor for a specific ECIES public key.
|
|
124
|
-
*
|
|
125
|
-
* @param eciesPubkey the ECIES public key to use for encryption
|
|
126
|
-
* @returns an Encryptor instance configured for the specified ECIES public key
|
|
127
|
-
*/
|
|
128
|
-
getEncryptor(eciesPubkey: HexString): Encryptor<EciesScheme>;
|
|
135
|
+
encrypt<T extends SupportedNativeType>(value: T, { accountAddress, dappAddress, handleType }: EncryptionContext): Promise<HexString>;
|
|
129
136
|
/**
|
|
130
137
|
* Grants a session key allowance voucher for secure reencryption operations.
|
|
131
138
|
*
|
|
@@ -198,6 +205,7 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
|
|
|
198
205
|
*
|
|
199
206
|
* @param ephemeralKeypair Session keypair matching the voucher grantee.
|
|
200
207
|
* @param allowanceVoucherWithSig Signed allowance voucher.
|
|
208
|
+
* @param ethClient - A public eth client or eth wallet client used for signing the attested decrypt request
|
|
201
209
|
* @param handles Handles to decrypt.
|
|
202
210
|
* @param options Optional reencryption/backoff configuration.
|
|
203
211
|
*
|
|
@@ -206,6 +214,7 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
|
|
|
206
214
|
* const attestations = await lightning.attestedDecryptWithVoucher(
|
|
207
215
|
* ephemeralKeypair,
|
|
208
216
|
* voucher,
|
|
217
|
+
* ethClient,
|
|
209
218
|
* [handle],
|
|
210
219
|
* );
|
|
211
220
|
* ```
|
|
@@ -215,14 +224,15 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
|
|
|
215
224
|
* const encrypted = await lightning.attestedDecryptWithVoucher(
|
|
216
225
|
* ephemeralKeypair,
|
|
217
226
|
* voucher,
|
|
227
|
+
* ethClient,
|
|
218
228
|
* [handle],
|
|
219
229
|
* { reencryptPubKey: delegateKeypair.encodePublicKey() },
|
|
220
230
|
* );
|
|
221
231
|
* ```
|
|
222
232
|
*/
|
|
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>>>;
|
|
233
|
+
attestedDecryptWithVoucher(ephemeralKeypair: Secp256k1Keypair, allowanceVoucherWithSig: AllowanceVoucherWithSig, ethClient: PublicClient<Transport, Chain> | WalletClient<Transport, Chain, Account>, handles: HexString[], backoffConfig?: Partial<BackoffConfig>): Promise<Array<DecryptionAttestation<EciesScheme, SupportedFheType>>>;
|
|
234
|
+
attestedDecryptWithVoucher(ephemeralKeypair: Secp256k1Keypair, allowanceVoucherWithSig: AllowanceVoucherWithSig, ethClient: PublicClient<Transport, Chain> | WalletClient<Transport, Chain, Account>, handles: HexString[], reencryptPubKey: Uint8Array, backoffConfig?: Partial<BackoffConfig>): Promise<Array<EncryptedDecryptionAttestation<EciesScheme, SupportedFheType>>>;
|
|
235
|
+
attestedDecryptWithVoucher(ephemeralKeypair: Secp256k1Keypair, allowanceVoucherWithSig: AllowanceVoucherWithSig, ethClient: PublicClient<Transport, Chain> | WalletClient<Transport, Chain, Account>, handles: HexString[], reencryptPubKey: Uint8Array, reencryptKeypair: Secp256k1Keypair, backoffConfig?: Partial<BackoffConfig>): Promise<Array<DecryptionAttestation<EciesScheme, SupportedFheType>>>;
|
|
226
236
|
/**
|
|
227
237
|
* Get an attested compute for the given wallet client.
|
|
228
238
|
*
|
|
@@ -233,7 +243,7 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
|
|
|
233
243
|
* @param backoffConfig - The backoff configuration for the attested compute request
|
|
234
244
|
* @returns The decryption attestation
|
|
235
245
|
*
|
|
236
|
-
* @example
|
|
246
|
+
* @example Plaintext result
|
|
237
247
|
* ```typescript
|
|
238
248
|
* import { AttestedComputeSupportedOps } from '../lite/attested-compute.js';
|
|
239
249
|
* const lhsHandle = '0x...';
|
|
@@ -242,23 +252,80 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
|
|
|
242
252
|
* const response = await lightning.attestedCompute(walletClient, lhsHandle, op, rhsPlaintext);
|
|
243
253
|
* const { plaintext, covalidatorSignature, handle } = response;
|
|
244
254
|
* ```
|
|
255
|
+
*
|
|
256
|
+
* @example Reencrypt for a delegate
|
|
257
|
+
* ```ts
|
|
258
|
+
* const encrypted = await lightning.attestedCompute(
|
|
259
|
+
* walletClient,
|
|
260
|
+
* lhsHandle,
|
|
261
|
+
* op,
|
|
262
|
+
* rhsPlaintext,
|
|
263
|
+
* delegatePubKey,
|
|
264
|
+
* );
|
|
265
|
+
* console.log(encrypted.encryptedPlaintext.ciphertext.value);
|
|
266
|
+
* ```
|
|
267
|
+
*
|
|
268
|
+
* @example Reencrypt and decrypt locally
|
|
269
|
+
* ```ts
|
|
270
|
+
* const decrypted = await lightning.attestedCompute(
|
|
271
|
+
* walletClient,
|
|
272
|
+
* lhsHandle,
|
|
273
|
+
* op,
|
|
274
|
+
* rhsPlaintext,
|
|
275
|
+
* keypair.encodePublicKey(),
|
|
276
|
+
* keypair,
|
|
277
|
+
* );
|
|
278
|
+
* console.log(decrypted.plaintext.value);
|
|
279
|
+
* ```
|
|
245
280
|
*/
|
|
246
281
|
attestedCompute(walletClient: WalletClient<Transport, Chain, Account>, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, backoffConfig?: Partial<BackoffConfig>): Promise<DecryptionAttestation<EciesScheme, SupportedFheType>>;
|
|
282
|
+
attestedCompute(walletClient: WalletClient<Transport, Chain, Account>, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, reencryptPubKey: Uint8Array, backoffConfig?: Partial<BackoffConfig>): Promise<EncryptedDecryptionAttestation<EciesScheme, SupportedFheType>>;
|
|
283
|
+
attestedCompute(walletClient: WalletClient<Transport, Chain, Account>, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, reencryptPubKey: Uint8Array, reencryptKeypair: Secp256k1Keypair, backoffConfig?: Partial<BackoffConfig>): Promise<DecryptionAttestation<EciesScheme, SupportedFheType>>;
|
|
247
284
|
/**
|
|
248
285
|
* Performs attested compute via a voucher-backed session key.
|
|
249
286
|
*
|
|
250
|
-
* @example
|
|
287
|
+
* @example Plaintext result
|
|
251
288
|
* ```ts
|
|
252
289
|
* const attestation = await lightning.attestedComputeWithVoucher(
|
|
253
290
|
* ephemeralKeypair,
|
|
254
291
|
* voucher,
|
|
292
|
+
* ethClient,
|
|
255
293
|
* lhsHandle,
|
|
256
294
|
* AttestedComputeSupportedOps.Eq,
|
|
257
295
|
* true,
|
|
258
296
|
* );
|
|
259
297
|
* ```
|
|
298
|
+
*
|
|
299
|
+
* @example Reencrypt for a delegate
|
|
300
|
+
* ```ts
|
|
301
|
+
* const encrypted = await lightning.attestedComputeWithVoucher(
|
|
302
|
+
* ephemeralKeypair,
|
|
303
|
+
* voucher,
|
|
304
|
+
* lhsHandle,
|
|
305
|
+
* AttestedComputeSupportedOps.Eq,
|
|
306
|
+
* true,
|
|
307
|
+
* delegatePubKey,
|
|
308
|
+
* );
|
|
309
|
+
* console.log(encrypted.encryptedPlaintext.ciphertext.value);
|
|
310
|
+
* ```
|
|
311
|
+
*
|
|
312
|
+
* @example Reencrypt and decrypt locally
|
|
313
|
+
* ```ts
|
|
314
|
+
* const decrypted = await lightning.attestedComputeWithVoucher(
|
|
315
|
+
* ephemeralKeypair,
|
|
316
|
+
* voucher,
|
|
317
|
+
* lhsHandle,
|
|
318
|
+
* AttestedComputeSupportedOps.Eq,
|
|
319
|
+
* true,
|
|
320
|
+
* keypair.encodePublicKey(),
|
|
321
|
+
* keypair,
|
|
322
|
+
* );
|
|
323
|
+
* console.log(decrypted.plaintext.value);
|
|
324
|
+
* ```
|
|
260
325
|
*/
|
|
261
|
-
attestedComputeWithVoucher(ephemeralKeypair: Secp256k1Keypair, allowanceVoucherWithSig: AllowanceVoucherWithSig, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, backoffConfig?: Partial<BackoffConfig>): Promise<DecryptionAttestation<EciesScheme, SupportedFheType>>;
|
|
326
|
+
attestedComputeWithVoucher(ephemeralKeypair: Secp256k1Keypair, allowanceVoucherWithSig: AllowanceVoucherWithSig, ethClient: PublicClient<Transport, Chain> | WalletClient<Transport, Chain, Account>, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, backoffConfig?: Partial<BackoffConfig>): Promise<DecryptionAttestation<EciesScheme, SupportedFheType>>;
|
|
327
|
+
attestedComputeWithVoucher(ephemeralKeypair: Secp256k1Keypair, allowanceVoucherWithSig: AllowanceVoucherWithSig, ethClient: PublicClient<Transport, Chain> | WalletClient<Transport, Chain, Account>, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, reencryptPubKey: Uint8Array, backoffConfig?: Partial<BackoffConfig>): Promise<EncryptedDecryptionAttestation<EciesScheme, SupportedFheType>>;
|
|
328
|
+
attestedComputeWithVoucher(ephemeralKeypair: Secp256k1Keypair, allowanceVoucherWithSig: AllowanceVoucherWithSig, ethClient: PublicClient<Transport, Chain> | WalletClient<Transport, Chain, Account>, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, reencryptPubKey: Uint8Array, reencryptKeypair: Secp256k1Keypair, backoffConfig?: Partial<BackoffConfig>): Promise<DecryptionAttestation<EciesScheme, SupportedFheType>>;
|
|
262
329
|
/**
|
|
263
330
|
* Get an decryption of publicly revealed handles.
|
|
264
331
|
*
|
|
@@ -268,7 +335,7 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
|
|
|
268
335
|
*
|
|
269
336
|
* @example
|
|
270
337
|
* ```typescript
|
|
271
|
-
* const response = await lightning.attestedReveal([handle1, handle2]);
|
|
338
|
+
* const response = await lightning.attestedReveal([handle1, handle2], ethClient);
|
|
272
339
|
* const { plaintext, covalidatorSignature } = response[0];
|
|
273
340
|
* ```
|
|
274
341
|
*/
|
|
@@ -281,8 +348,17 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
|
|
|
281
348
|
}, threshold: number): string[];
|
|
282
349
|
private static isIdByName;
|
|
283
350
|
private static plaintextFromValue;
|
|
284
|
-
|
|
285
|
-
|
|
351
|
+
static getEciesPublicKey(client: PublicClient, executorAddress: Address): Promise<HexString>;
|
|
352
|
+
static getIncoVerifierContract(client: PublicClient, executorAddress: Address): Promise<GetContractReturnType<typeof incoVerifierAbi, PublicClient, Address>>;
|
|
353
|
+
/**
|
|
354
|
+
* Retrieves the verifier contract details including threshold, signers, and ECIES public key from the Inco Verifier contract.
|
|
355
|
+
*
|
|
356
|
+
* @param executorAddress The address of the Inco Lightning executor contract.
|
|
357
|
+
* @param client The public client to interact with the blockchain.
|
|
358
|
+
* @returns An object containing the threshold, signers, and ECIES public key.
|
|
359
|
+
*/
|
|
360
|
+
private static getVerifierContractDetails;
|
|
361
|
+
private static getChainConfig;
|
|
286
362
|
private static supportsThresholdRetrieval;
|
|
287
363
|
private static getDefaultThresholdAndSigners;
|
|
288
364
|
}
|