@cofhe/sdk 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +49 -0
- package/acps/acp.ts +411 -0
- package/acps/index.ts +70 -0
- package/{permits → acps}/onchain-utils.ts +49 -24
- package/acps/sealing.ts +90 -0
- package/acps/signature.ts +89 -0
- package/acps/store.ts +172 -0
- package/acps/test/acp.test.ts +615 -0
- package/acps/test/localstorage.test.ts +105 -0
- package/acps/test/sealing.test.ts +77 -0
- package/acps/test/store.test.ts +88 -0
- package/acps/test/validation.test.ts +361 -0
- package/acps/test-utils.ts +32 -0
- package/acps/types.ts +252 -0
- package/acps/validation.ts +392 -0
- package/adapters/test/ethers5.test.ts +4 -1
- package/adapters/test/ethers6.test.ts +4 -1
- package/adapters/test/wagmi.test.ts +5 -2
- package/chains/chains/stagingCofhe.ts +21 -0
- package/chains/index.ts +3 -1
- package/chains/test/chains.test.ts +2 -1
- package/core/acps.ts +625 -0
- package/core/client.ts +136 -39
- package/core/clientTypes.ts +52 -41
- package/core/config.ts +66 -5
- package/core/debug.ts +72 -0
- package/core/decrypt/MockThresholdNetworkAbi.ts +20 -11
- package/core/decrypt/apiError.ts +104 -0
- package/core/decrypt/cofheMocksDecryptForTx.ts +11 -11
- package/core/decrypt/cofheMocksDecryptForView.ts +7 -7
- package/core/decrypt/decryptForTxBuilder.ts +102 -102
- package/core/decrypt/decryptForViewBuilder.ts +90 -90
- package/core/decrypt/submitRetry.ts +38 -30
- package/core/decrypt/tnDecryptV1.ts +5 -5
- package/core/decrypt/tnDecryptV2.ts +45 -34
- package/core/decrypt/tnSealOutputV1.ts +4 -3
- package/core/decrypt/tnSealOutputV2.ts +44 -31
- package/core/encrypt/cofheMocksZkVerifySign.ts +59 -74
- package/core/encrypt/encryptInputsBuilder.ts +86 -52
- package/core/encrypt/zkPackProveVerify.ts +25 -18
- package/core/error.ts +34 -6
- package/core/index.ts +14 -14
- package/core/test/acpDefaults.test.ts +52 -0
- package/core/test/acps.test.ts +596 -0
- package/core/test/apiError.test.ts +130 -0
- package/core/test/client.test.ts +22 -19
- package/core/test/config.test.ts +25 -5
- package/core/test/decrypt.test.ts +40 -35
- package/core/test/decryptBuilders.test.ts +68 -68
- package/core/test/decryptErrorCodes.test.ts +217 -0
- package/core/test/encryptInputsBuilder.test.ts +72 -41
- package/core/test/pollCallbacks.test.ts +89 -18
- package/core/test/stagingRedirect.ts +18 -0
- package/core/test/submitRetry.test.ts +182 -0
- package/core/types.ts +9 -69
- package/dist/acp-Wi6isVQI.d.cts +407 -0
- package/dist/acp-Wi6isVQI.d.ts +407 -0
- package/dist/acps.cjs +1081 -0
- package/dist/acps.d.cts +480 -0
- package/dist/acps.d.ts +480 -0
- package/dist/acps.js +2 -0
- package/dist/chains.cjs +14 -1
- package/dist/chains.d.cts +30 -1
- package/dist/chains.d.ts +30 -1
- package/dist/chains.js +1 -1
- package/dist/{chunk-PE5V5CCV.js → chunk-43USWPEH.js} +1000 -604
- package/dist/{chunk-MTRAXQXC.js → chunk-N6IDQRRU.js} +14 -2
- package/dist/chunk-Q7CBWGQX.js +1029 -0
- package/dist/{clientTypes-CyUvRRzA.d.ts → clientTypes-BN3nbzYM.d.ts} +342 -165
- package/dist/{clientTypes-BDy1qIBu.d.cts → clientTypes-CYZjFznO.d.cts} +342 -165
- package/dist/core.cjs +1431 -1026
- package/dist/core.d.cts +55 -10
- package/dist/core.d.ts +55 -10
- package/dist/core.js +3 -3
- package/dist/node.cjs +1356 -976
- package/dist/node.d.cts +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/node.js +3 -3
- package/dist/web.cjs +1356 -976
- package/dist/web.d.cts +2 -2
- package/dist/web.d.ts +2 -2
- package/dist/web.js +3 -3
- package/node/test/inherited.test.ts +75 -65
- package/node/test/tfheinit.test.ts +23 -8
- package/package.json +6 -6
- package/web/test/client.web.test.ts +5 -1
- package/web/test/inherited.web.test.ts +75 -65
- package/web/test/tfheinit.web.test.ts +14 -5
- package/web/test/worker.config.web.test.ts +38 -23
- package/web/test/worker.output.web.test.ts +25 -24
- package/core/encrypt/encryptUtils.ts +0 -67
- package/core/permits.ts +0 -206
- package/core/test/permits.test.ts +0 -534
- package/dist/chunk-VB62WYPL.js +0 -978
- package/dist/permit-DnVMDT5h.d.cts +0 -376
- package/dist/permit-DnVMDT5h.d.ts +0 -376
- package/dist/permits.cjs +0 -1026
- package/dist/permits.d.cts +0 -353
- package/dist/permits.d.ts +0 -353
- package/dist/permits.js +0 -2
- package/permits/index.ts +0 -68
- package/permits/permit.ts +0 -385
- package/permits/sealing.ts +0 -131
- package/permits/signature.ts +0 -79
- package/permits/store.ts +0 -157
- package/permits/test/localstorage.test.ts +0 -113
- package/permits/test/permit.test.ts +0 -557
- package/permits/test/sealing.test.ts +0 -84
- package/permits/test/store.test.ts +0 -88
- package/permits/test/validation.test.ts +0 -361
- package/permits/test-utils.ts +0 -28
- package/permits/types.ts +0 -204
- package/permits/validation.ts +0 -327
- /package/{permits → acps}/utils.ts +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WalletClient, PublicClient, Hex } from 'viem';
|
|
2
2
|
import { C as CofheChain } from './types-C07FK-cL.cjs';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import {
|
|
4
|
+
import { A as ACP, h as EIP712Domain, C as CreateSelfACPOptions, p as SelfACP, d as CreateSharingACPOptions, q as SharingACP, I as ImportSharedACPOptions, R as RecipientACP, v as ACPHashFields, S as SerializedACP, g as IncomingShare, i as ACPUtils } from './acp-Wi6isVQI.cjs';
|
|
5
5
|
import { StoreApi } from 'zustand/vanilla';
|
|
6
6
|
|
|
7
7
|
type TfheInitializer = () => Promise<boolean>;
|
|
@@ -59,34 +59,6 @@ type EncryptedNumber = {
|
|
|
59
59
|
data: Uint8Array;
|
|
60
60
|
securityZone: number;
|
|
61
61
|
};
|
|
62
|
-
type EncryptedItemInput = {
|
|
63
|
-
ctHash: bigint;
|
|
64
|
-
securityZone: number;
|
|
65
|
-
utype: FheTypes;
|
|
66
|
-
signature: `0x${string}`;
|
|
67
|
-
};
|
|
68
|
-
declare function assertCorrectEncryptedItemInput(input: EncryptedItemInput): asserts input is EncryptedItemInput;
|
|
69
|
-
type EncryptedBoolInput = EncryptedItemInput & {
|
|
70
|
-
utype: FheTypes.Bool;
|
|
71
|
-
};
|
|
72
|
-
type EncryptedUint8Input = EncryptedItemInput & {
|
|
73
|
-
utype: FheTypes.Uint8;
|
|
74
|
-
};
|
|
75
|
-
type EncryptedUint16Input = EncryptedItemInput & {
|
|
76
|
-
utype: FheTypes.Uint16;
|
|
77
|
-
};
|
|
78
|
-
type EncryptedUint32Input = EncryptedItemInput & {
|
|
79
|
-
utype: FheTypes.Uint32;
|
|
80
|
-
};
|
|
81
|
-
type EncryptedUint64Input = EncryptedItemInput & {
|
|
82
|
-
utype: FheTypes.Uint64;
|
|
83
|
-
};
|
|
84
|
-
type EncryptedUint128Input = EncryptedItemInput & {
|
|
85
|
-
utype: FheTypes.Uint128;
|
|
86
|
-
};
|
|
87
|
-
type EncryptedAddressInput = EncryptedItemInput & {
|
|
88
|
-
utype: FheTypes.Uint160;
|
|
89
|
-
};
|
|
90
62
|
type EncryptableBase<U extends FheTypes, D> = {
|
|
91
63
|
data: D;
|
|
92
64
|
securityZone: number;
|
|
@@ -146,10 +118,6 @@ declare const Encryptable: {
|
|
|
146
118
|
};
|
|
147
119
|
};
|
|
148
120
|
type EncryptableItem = EncryptableBool | EncryptableUint8 | EncryptableUint16 | EncryptableUint32 | EncryptableUint64 | EncryptableUint128 | EncryptableAddress;
|
|
149
|
-
type EncryptableToEncryptedItemInputMap<E extends EncryptableItem> = E extends EncryptableBool ? EncryptedBoolInput : E extends EncryptableUint8 ? EncryptedUint8Input : E extends EncryptableUint16 ? EncryptedUint16Input : E extends EncryptableUint32 ? EncryptedUint32Input : E extends EncryptableUint64 ? EncryptedUint64Input : E extends EncryptableUint128 ? EncryptedUint128Input : E extends EncryptableAddress ? EncryptedAddressInput : never;
|
|
150
|
-
type EncryptedItemInputs<T> = T extends Primitive ? LiteralToPrimitive<T> : T extends EncryptableItem ? EncryptableToEncryptedItemInputMap<T> : {
|
|
151
|
-
[K in keyof T]: EncryptedItemInputs<T[K]>;
|
|
152
|
-
};
|
|
153
121
|
declare function isEncryptableItem(value: unknown): value is EncryptableItem;
|
|
154
122
|
declare enum EncryptStep {
|
|
155
123
|
InitTfhe = "initTfhe",
|
|
@@ -190,7 +158,12 @@ type ExternalUint128Hash = `0x${string}` & {
|
|
|
190
158
|
type ExternalAddressHash = `0x${string}` & {
|
|
191
159
|
readonly utype: FheTypes.Uint160;
|
|
192
160
|
};
|
|
193
|
-
/**
|
|
161
|
+
/**
|
|
162
|
+
* Branded batch signature (Solidity: bytes memory signature).
|
|
163
|
+
* A single ECDSA signature (65-byte r||s||v, hex-encoded) authenticating an entire batch of
|
|
164
|
+
* ciphertexts at once — it covers keccak256(h_0 || h_1 || ... || h_n), where each h_i is the
|
|
165
|
+
* per-ciphertext message hash for the corresponding ExternalItemHashes entry, in order.
|
|
166
|
+
*/
|
|
194
167
|
type ExternalHashProof = `0x${string}` & {
|
|
195
168
|
readonly _kind: 'ExternalHashProof';
|
|
196
169
|
};
|
|
@@ -198,7 +171,6 @@ type ExternalHashProof = `0x${string}` & {
|
|
|
198
171
|
type AnyExternalHash = ExternalBoolHash | ExternalUint8Hash | ExternalUint16Hash | ExternalUint32Hash | ExternalUint64Hash | ExternalUint128Hash | ExternalAddressHash;
|
|
199
172
|
/**
|
|
200
173
|
* Maps a single EncryptableItem to its corresponding External*Hash type.
|
|
201
|
-
* Mirrors EncryptableToEncryptedItemInputMap.
|
|
202
174
|
*/
|
|
203
175
|
type EncryptableToExternalHashMap<E extends EncryptableItem> = E extends EncryptableBool ? ExternalBoolHash : E extends EncryptableUint8 ? ExternalUint8Hash : E extends EncryptableUint16 ? ExternalUint16Hash : E extends EncryptableUint32 ? ExternalUint32Hash : E extends EncryptableUint64 ? ExternalUint64Hash : E extends EncryptableUint128 ? ExternalUint128Hash : E extends EncryptableAddress ? ExternalAddressHash : never;
|
|
204
176
|
/**
|
|
@@ -209,8 +181,9 @@ type ExternalItemHashes<T extends EncryptableItem[]> = {
|
|
|
209
181
|
[K in keyof T]: T[K] extends EncryptableItem ? EncryptableToExternalHashMap<T[K]> : never;
|
|
210
182
|
};
|
|
211
183
|
/**
|
|
212
|
-
* Return type of EncryptInputsBuilder.execute()
|
|
213
|
-
* Tuple of per-input hashes in input order, followed by
|
|
184
|
+
* Return type of EncryptInputsBuilder.execute().
|
|
185
|
+
* Tuple of per-input hashes in input order, followed by the single batch signature that
|
|
186
|
+
* authenticates all of them together.
|
|
214
187
|
* e.g. [Encryptable.bool(true), Encryptable.uint32(5)] → [ExternalBoolHash, ExternalUint32Hash, ExternalHashProof]
|
|
215
188
|
*/
|
|
216
189
|
type HashPlusProofResult<T extends EncryptableItem[]> = [...ExternalItemHashes<T>, ExternalHashProof];
|
|
@@ -242,8 +215,8 @@ type CofheConfig = {
|
|
|
242
215
|
environment: 'node' | 'hardhat' | 'web' | 'react';
|
|
243
216
|
/** List of supported chains */
|
|
244
217
|
supportedChains: CofheChain[];
|
|
245
|
-
/** Default
|
|
246
|
-
|
|
218
|
+
/** Default acp expiration in seconds, default is 30 days */
|
|
219
|
+
defaultACPExpiration: number;
|
|
247
220
|
/**
|
|
248
221
|
* Storage scheme for the fetched fhe keys
|
|
249
222
|
* FHE keys are large, and caching prevents re-fetching them on each encryptInputs call
|
|
@@ -256,6 +229,32 @@ type CofheConfig = {
|
|
|
256
229
|
* Default: true
|
|
257
230
|
*/
|
|
258
231
|
useWorkers: boolean;
|
|
232
|
+
/** ACP acp defaults, applied when creating acps (user options always win) */
|
|
233
|
+
acp: {
|
|
234
|
+
/**
|
|
235
|
+
* Default revoker contract per chainId — an explicit override; when unset,
|
|
236
|
+
* the address served by the chain's ACL (`defaultRevokerContract()`) is
|
|
237
|
+
* used. When available, created acps are revocable by default:
|
|
238
|
+
* revokerContract = this address and revokerData = acp creation
|
|
239
|
+
* timestamp (interpreted by the default timestamp revoker; enables
|
|
240
|
+
* revokeSingle + O(1) revokeAll).
|
|
241
|
+
*/
|
|
242
|
+
defaultRevoker?: Record<number, `0x${string}`>;
|
|
243
|
+
/**
|
|
244
|
+
* Default contract scopes per chainId, injected into created acps'
|
|
245
|
+
* `contracts` when the caller doesn't provide scope options.
|
|
246
|
+
* Note: injecting scopes makes created acps non-global by default.
|
|
247
|
+
*/
|
|
248
|
+
defaultContractScopes?: Record<number, `0x${string}`[]>;
|
|
249
|
+
/**
|
|
250
|
+
* ACPShareRegistry address per chainId — the on-chain hand-off for sharing
|
|
251
|
+
* ACPs. An explicit override; when unset, the address served by the
|
|
252
|
+
* chain's ACL (`shareRegistry()`) is used. client.acp.shareOnChain /
|
|
253
|
+
* getIncomingShares / importFromChain throw MissingConfig when neither
|
|
254
|
+
* names a registry.
|
|
255
|
+
*/
|
|
256
|
+
sharingRegistry?: Record<number, `0x${string}`>;
|
|
257
|
+
};
|
|
259
258
|
/** Mocks configs */
|
|
260
259
|
mocks: {
|
|
261
260
|
/**
|
|
@@ -304,13 +303,18 @@ declare const CofheConfigSchema: z.ZodObject<{
|
|
|
304
303
|
thresholdNetworkUrl: string;
|
|
305
304
|
environment: "MOCK" | "TESTNET" | "MAINNET";
|
|
306
305
|
}>>;
|
|
307
|
-
|
|
306
|
+
defaultACPExpiration: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
308
307
|
fheKeyStorage: z.ZodDefault<z.ZodUnion<[z.ZodObject<{
|
|
309
308
|
getItem: z.ZodCustom<(name: string) => Promise<any>, (name: string) => Promise<any>>;
|
|
310
309
|
setItem: z.ZodCustom<(name: string, value: any) => Promise<void>, (name: string, value: any) => Promise<void>>;
|
|
311
310
|
removeItem: z.ZodCustom<(name: string) => Promise<void>, (name: string) => Promise<void>>;
|
|
312
311
|
}, z.core.$strip>, z.ZodNull]>>;
|
|
313
312
|
useWorkers: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
313
|
+
acp: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
314
|
+
defaultRevoker: z.ZodOptional<z.ZodCustom<Record<number, `0x${string}`>, Record<number, `0x${string}`>>>;
|
|
315
|
+
defaultContractScopes: z.ZodOptional<z.ZodCustom<Record<number, `0x${string}`[]>, Record<number, `0x${string}`[]>>>;
|
|
316
|
+
sharingRegistry: z.ZodOptional<z.ZodCustom<Record<number, `0x${string}`>, Record<number, `0x${string}`>>>;
|
|
317
|
+
}, z.core.$strip>>>;
|
|
314
318
|
mocks: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
315
319
|
decryptDelay: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
316
320
|
encryptDelay: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>]>>>;
|
|
@@ -323,6 +327,11 @@ declare const CofheConfigSchema: z.ZodObject<{
|
|
|
323
327
|
* Input config type inferred from the schema
|
|
324
328
|
*/
|
|
325
329
|
type CofheInputConfig = z.input<typeof CofheConfigSchema>;
|
|
330
|
+
/**
|
|
331
|
+
* Throws a migration-shaped error if any pre-ACP config key is present.
|
|
332
|
+
* @throws {Error} Naming each stale key and its replacement.
|
|
333
|
+
*/
|
|
334
|
+
declare function assertNoRenamedConfigKeys(config: object, renamedKeys: Record<string, string>, label: string): void;
|
|
326
335
|
/**
|
|
327
336
|
* Creates and validates a cofhe configuration (base implementation)
|
|
328
337
|
* @param config - The configuration object to validate
|
|
@@ -394,36 +403,36 @@ declare abstract class BaseBuilder {
|
|
|
394
403
|
* await client.decryptForView(ctHash, utype)
|
|
395
404
|
* .setChainId(chainId)
|
|
396
405
|
* .setAccount(account)
|
|
397
|
-
* .
|
|
398
|
-
* // or .
|
|
406
|
+
* .withACP() // optional (active acp)
|
|
407
|
+
* // or .withACP(acpHash) / .withACP(acp)
|
|
399
408
|
* .execute()
|
|
400
409
|
*
|
|
401
410
|
* If chainId not set, uses client's chainId
|
|
402
411
|
* If account not set, uses client's account
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
*
|
|
412
|
+
* withACP() uses chainId + account to get the active acp.
|
|
413
|
+
* withACP(acpHash) fetches that acp using chainId + account.
|
|
414
|
+
* withACP(acp) uses the provided acp regardless of chainId/account.
|
|
406
415
|
*
|
|
407
|
-
* Note: decryptForView always requires
|
|
416
|
+
* Note: decryptForView always requires an ACP (no global-allowance mode).
|
|
408
417
|
*
|
|
409
418
|
* Returns the unsealed item.
|
|
410
419
|
*/
|
|
411
420
|
type DecryptForViewBuilderParams<U extends FheTypes> = BaseBuilderParams & {
|
|
412
421
|
ctHash: bigint | string;
|
|
413
422
|
utype: U;
|
|
414
|
-
|
|
415
|
-
|
|
423
|
+
acpHash?: string;
|
|
424
|
+
acp?: ACP;
|
|
416
425
|
};
|
|
417
426
|
declare class DecryptForViewBuilder<U extends FheTypes> extends BaseBuilder {
|
|
418
427
|
private ctHash;
|
|
419
428
|
private utype;
|
|
420
|
-
private
|
|
421
|
-
private
|
|
429
|
+
private acpHash?;
|
|
430
|
+
private acp?;
|
|
422
431
|
private pollCallback?;
|
|
423
432
|
private retry404TimeoutMs;
|
|
424
433
|
constructor(params: DecryptForViewBuilderParams<U>);
|
|
425
434
|
/**
|
|
426
|
-
* @param chainId - Chain to decrypt values from. Used to fetch the threshold network URL and use the correct
|
|
435
|
+
* @param chainId - Chain to decrypt values from. Used to fetch the threshold network URL and use the correct acp.
|
|
427
436
|
*
|
|
428
437
|
* If not provided, the chainId will be fetched from the connected publicClient.
|
|
429
438
|
*
|
|
@@ -439,7 +448,7 @@ declare class DecryptForViewBuilder<U extends FheTypes> extends BaseBuilder {
|
|
|
439
448
|
setChainId(chainId: number): DecryptForViewBuilder<U>;
|
|
440
449
|
getChainId(): number | undefined;
|
|
441
450
|
/**
|
|
442
|
-
* @param account - Account to decrypt values from. Used to fetch the correct
|
|
451
|
+
* @param account - Account to decrypt values from. Used to fetch the correct acp.
|
|
443
452
|
*
|
|
444
453
|
* If not provided, the account will be fetched from the connected walletClient.
|
|
445
454
|
*
|
|
@@ -457,53 +466,53 @@ declare class DecryptForViewBuilder<U extends FheTypes> extends BaseBuilder {
|
|
|
457
466
|
onPoll(callback: DecryptPollCallbackFunction): DecryptForViewBuilder<U>;
|
|
458
467
|
set404RetryTimeout(timeoutMs: number): DecryptForViewBuilder<U>;
|
|
459
468
|
/**
|
|
460
|
-
* Select "use
|
|
469
|
+
* Select "use acp" mode (optional).
|
|
461
470
|
*
|
|
462
|
-
* - `
|
|
463
|
-
* - `
|
|
464
|
-
* - `
|
|
471
|
+
* - `withACP(acp)` uses the provided acp.
|
|
472
|
+
* - `withACP(acpHash)` fetches that acp.
|
|
473
|
+
* - `withACP()` uses the active acp for the resolved `chainId + account`.
|
|
465
474
|
*/
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
475
|
+
withACP(): DecryptForViewBuilder<U>;
|
|
476
|
+
withACP(acpHash: string): DecryptForViewBuilder<U>;
|
|
477
|
+
withACP(acp: ACP): DecryptForViewBuilder<U>;
|
|
469
478
|
/**
|
|
470
|
-
* @param
|
|
479
|
+
* @param acpHash - ACP hash to decrypt values from. Used to fetch the correct acp.
|
|
471
480
|
*
|
|
472
|
-
* If not provided, the active
|
|
473
|
-
* If `
|
|
481
|
+
* If not provided, the active acp for the chainId and account will be used.
|
|
482
|
+
* If `setACP()` is called, it will be used regardless of chainId, account, or acpHash.
|
|
474
483
|
*
|
|
475
484
|
* Example:
|
|
476
485
|
* ```typescript
|
|
477
486
|
* const unsealed = await client.decryptForView(ctHash, utype)
|
|
478
|
-
* .
|
|
487
|
+
* .setACPHash('0x1234567890123456789012345678901234567890')
|
|
479
488
|
* .execute();
|
|
480
489
|
* ```
|
|
481
490
|
*
|
|
482
491
|
* @returns The chainable DecryptForViewBuilder instance.
|
|
483
492
|
*/
|
|
484
|
-
/** @deprecated Use `
|
|
485
|
-
|
|
486
|
-
|
|
493
|
+
/** @deprecated Use `withACP(acpHash)` instead. */
|
|
494
|
+
setACPHash(acpHash: string): DecryptForViewBuilder<U>;
|
|
495
|
+
getACPHash(): string | undefined;
|
|
487
496
|
/**
|
|
488
|
-
* @param
|
|
497
|
+
* @param acp - ACP to decrypt values with. If provided, it will be used regardless of chainId, account, or acpHash.
|
|
489
498
|
*
|
|
490
|
-
* If not provided, the
|
|
499
|
+
* If not provided, the acp will be determined by chainId, account, and acpHash.
|
|
491
500
|
*
|
|
492
501
|
* Example:
|
|
493
502
|
* ```typescript
|
|
494
503
|
* const unsealed = await client.decryptForView(ctHash, utype)
|
|
495
|
-
* .
|
|
504
|
+
* .setACP(acp)
|
|
496
505
|
* .execute();
|
|
497
506
|
* ```
|
|
498
507
|
*
|
|
499
508
|
* @returns The chainable DecryptForViewBuilder instance.
|
|
500
509
|
*/
|
|
501
|
-
/** @deprecated Use `
|
|
502
|
-
|
|
503
|
-
|
|
510
|
+
/** @deprecated Use `withACP(acp)` instead. */
|
|
511
|
+
setACP(acp: ACP): DecryptForViewBuilder<U>;
|
|
512
|
+
getACP(): ACP | undefined;
|
|
504
513
|
private getThresholdNetworkUrl;
|
|
505
514
|
private validateUtypeOrThrow;
|
|
506
|
-
private
|
|
515
|
+
private getResolvedACP;
|
|
507
516
|
/**
|
|
508
517
|
* On hardhat, interact with MockZkVerifier contract instead of CoFHE
|
|
509
518
|
*/
|
|
@@ -516,10 +525,10 @@ declare class DecryptForViewBuilder<U extends FheTypes> extends BaseBuilder {
|
|
|
516
525
|
* Final step of the decryption process. MUST BE CALLED LAST IN THE CHAIN.
|
|
517
526
|
*
|
|
518
527
|
* This will:
|
|
519
|
-
* - Use
|
|
520
|
-
* - Check
|
|
521
|
-
* - Call CoFHE `/sealoutput` with the
|
|
522
|
-
* - Unseal the sealed item with the
|
|
528
|
+
* - Use an ACP based on provided acp OR chainId + account + acpHash
|
|
529
|
+
* - Check acp validity
|
|
530
|
+
* - Call CoFHE `/sealoutput` with the acp, which returns a sealed (encrypted) item
|
|
531
|
+
* - Unseal the sealed item with the acp
|
|
523
532
|
* - Return the unsealed item
|
|
524
533
|
*
|
|
525
534
|
* Example:
|
|
@@ -527,7 +536,7 @@ declare class DecryptForViewBuilder<U extends FheTypes> extends BaseBuilder {
|
|
|
527
536
|
* const unsealed = await client.decryptForView(ctHash, utype)
|
|
528
537
|
* .setChainId(11155111) // optional
|
|
529
538
|
* .setAccount('0x123...890') // optional
|
|
530
|
-
* .
|
|
539
|
+
* .withACP() // optional
|
|
531
540
|
* .execute(); // execute
|
|
532
541
|
* ```
|
|
533
542
|
*
|
|
@@ -547,21 +556,21 @@ type DecryptForTxResult = {
|
|
|
547
556
|
/**
|
|
548
557
|
* Type-level gating:
|
|
549
558
|
* - The initial builder returned from `client.decryptForTx(...)` intentionally does not expose `execute()`.
|
|
550
|
-
* - Calling `
|
|
551
|
-
* exposes `
|
|
559
|
+
* - Calling `withACP(...)` or `withoutACP()` returns a builder that *does* expose `execute()`, but no longer
|
|
560
|
+
* exposes `withACP/withoutACP` (so you can't select twice, or switch modes).
|
|
552
561
|
*/
|
|
553
562
|
type DecryptForTxBuilderUnset = Omit<DecryptForTxBuilder, 'execute'>;
|
|
554
|
-
type DecryptForTxBuilderSelected = Omit<DecryptForTxBuilder, '
|
|
563
|
+
type DecryptForTxBuilderSelected = Omit<DecryptForTxBuilder, 'withACP' | 'withoutACP'>;
|
|
555
564
|
declare class DecryptForTxBuilder extends BaseBuilder {
|
|
556
565
|
private ctHash;
|
|
557
|
-
private
|
|
558
|
-
private
|
|
559
|
-
private
|
|
566
|
+
private acpHash?;
|
|
567
|
+
private acp?;
|
|
568
|
+
private acpSelection;
|
|
560
569
|
private pollCallback?;
|
|
561
570
|
private retry404TimeoutMs;
|
|
562
571
|
constructor(params: DecryptForTxBuilderParams);
|
|
563
572
|
/**
|
|
564
|
-
* @param chainId - Chain to decrypt values from. Used to fetch the threshold network URL and use the correct
|
|
573
|
+
* @param chainId - Chain to decrypt values from. Used to fetch the threshold network URL and use the correct acp.
|
|
565
574
|
*
|
|
566
575
|
* If not provided, the chainId will be fetched from the connected publicClient.
|
|
567
576
|
*
|
|
@@ -578,7 +587,7 @@ declare class DecryptForTxBuilder extends BaseBuilder {
|
|
|
578
587
|
setChainId(this: DecryptForTxBuilderSelected, chainId: number): DecryptForTxBuilderSelected;
|
|
579
588
|
getChainId(): number | undefined;
|
|
580
589
|
/**
|
|
581
|
-
* @param account - Account to decrypt values from. Used to fetch the correct
|
|
590
|
+
* @param account - Account to decrypt values from. Used to fetch the correct acp.
|
|
582
591
|
*
|
|
583
592
|
* If not provided, the account will be fetched from the connected walletClient.
|
|
584
593
|
*
|
|
@@ -599,27 +608,27 @@ declare class DecryptForTxBuilder extends BaseBuilder {
|
|
|
599
608
|
set404RetryTimeout(this: DecryptForTxBuilderUnset, timeoutMs: number): DecryptForTxBuilderUnset;
|
|
600
609
|
set404RetryTimeout(this: DecryptForTxBuilderSelected, timeoutMs: number): DecryptForTxBuilderSelected;
|
|
601
610
|
/**
|
|
602
|
-
* Select "use
|
|
611
|
+
* Select "use acp" mode.
|
|
603
612
|
*
|
|
604
|
-
* - `
|
|
605
|
-
* - `
|
|
606
|
-
* - `
|
|
613
|
+
* - `withACP(acp)` uses the provided acp.
|
|
614
|
+
* - `withACP(acpHash)` fetches that acp.
|
|
615
|
+
* - `withACP()` uses the active acp for the resolved `chainId + account`.
|
|
607
616
|
*
|
|
608
|
-
* Note: "global allowance" (no
|
|
617
|
+
* Note: "global allowance" (no acp) is ONLY available via `withoutACP()`.
|
|
609
618
|
*/
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
619
|
+
withACP(): DecryptForTxBuilderSelected;
|
|
620
|
+
withACP(acpHash: string): DecryptForTxBuilderSelected;
|
|
621
|
+
withACP(acp: ACP): DecryptForTxBuilderSelected;
|
|
613
622
|
/**
|
|
614
|
-
* Select "no
|
|
623
|
+
* Select "no acp" mode.
|
|
615
624
|
*
|
|
616
|
-
* This uses global allowance (no
|
|
625
|
+
* This uses global allowance (no acp required) and sends an empty permission payload to `/decrypt`.
|
|
617
626
|
*/
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
627
|
+
withoutACP(): DecryptForTxBuilderSelected;
|
|
628
|
+
getACP(): ACP | undefined;
|
|
629
|
+
getACPHash(): string | undefined;
|
|
621
630
|
private getThresholdNetworkUrl;
|
|
622
|
-
private
|
|
631
|
+
private getResolvedACP;
|
|
623
632
|
/**
|
|
624
633
|
* On hardhat, interact with MockThresholdNetwork contract
|
|
625
634
|
*/
|
|
@@ -631,9 +640,9 @@ declare class DecryptForTxBuilder extends BaseBuilder {
|
|
|
631
640
|
/**
|
|
632
641
|
* Final step of the decryptForTx process. MUST BE CALLED LAST IN THE CHAIN.
|
|
633
642
|
*
|
|
634
|
-
* You must explicitly choose one
|
|
635
|
-
* - `
|
|
636
|
-
* - `
|
|
643
|
+
* You must explicitly choose one acp mode before calling `execute()`:
|
|
644
|
+
* - `withACP(acp)` / `withACP(acpHash)` / `withACP()` (active acp)
|
|
645
|
+
* - `withoutACP()` (global allowance)
|
|
637
646
|
*/
|
|
638
647
|
execute(): Promise<DecryptForTxResult>;
|
|
639
648
|
}
|
|
@@ -751,11 +760,19 @@ type EncryptInputsBuilderParams<T extends EncryptableItem[]> = BaseBuilderParams
|
|
|
751
760
|
* account, securityZone, and chainId can be overridden in the builder.
|
|
752
761
|
* config, tfhePublicKeyDeserializer, compactPkeCrsDeserializer, and zkBuilderAndCrsGenerator are required to be set in the builder.
|
|
753
762
|
*/
|
|
754
|
-
|
|
763
|
+
/**
|
|
764
|
+
* The builder as returned by `client.encryptInputs(...)`, before a consuming contract has been set.
|
|
765
|
+
*
|
|
766
|
+
* `execute()` is intentionally absent: the verifier binds the consuming contract into the signed
|
|
767
|
+
* digest, so no batch can be produced until the caller commits to the contract that will consume it.
|
|
768
|
+
* `setConsumingContract(...)` returns the full {@link EncryptInputsBuilder}, unlocking `execute()`.
|
|
769
|
+
*/
|
|
770
|
+
type EncryptInputsBuilderUnset<T extends EncryptableItem[]> = Omit<EncryptInputsBuilder<T>, 'execute'>;
|
|
771
|
+
declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuilder {
|
|
755
772
|
private securityZone;
|
|
773
|
+
protected consumingContract: string | undefined;
|
|
756
774
|
private stepCallback?;
|
|
757
775
|
private inputItems;
|
|
758
|
-
private hpp;
|
|
759
776
|
private zkvWalletClient;
|
|
760
777
|
private tfhePublicKeyDeserializer;
|
|
761
778
|
private compactPkeCrsDeserializer;
|
|
@@ -780,7 +797,8 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[], HPP extends bool
|
|
|
780
797
|
*
|
|
781
798
|
* @returns The chainable EncryptInputsBuilder instance.
|
|
782
799
|
*/
|
|
783
|
-
setAccount(account: string): EncryptInputsBuilder<T
|
|
800
|
+
setAccount(this: EncryptInputsBuilder<T>, account: string): EncryptInputsBuilder<T>;
|
|
801
|
+
setAccount(this: EncryptInputsBuilderUnset<T>, account: string): EncryptInputsBuilderUnset<T>;
|
|
784
802
|
getAccount(): string | undefined;
|
|
785
803
|
/**
|
|
786
804
|
* @param chainId - Chain that will consume the encrypted inputs.
|
|
@@ -796,7 +814,8 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[], HPP extends bool
|
|
|
796
814
|
*
|
|
797
815
|
* @returns The chainable EncryptInputsBuilder instance.
|
|
798
816
|
*/
|
|
799
|
-
setChainId(chainId: number): EncryptInputsBuilder<T
|
|
817
|
+
setChainId(this: EncryptInputsBuilder<T>, chainId: number): EncryptInputsBuilder<T>;
|
|
818
|
+
setChainId(this: EncryptInputsBuilderUnset<T>, chainId: number): EncryptInputsBuilderUnset<T>;
|
|
800
819
|
getChainId(): number | undefined;
|
|
801
820
|
/**
|
|
802
821
|
* @param securityZone - Security zone to encrypt the inputs for.
|
|
@@ -812,19 +831,32 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[], HPP extends bool
|
|
|
812
831
|
*
|
|
813
832
|
* @returns The chainable EncryptInputsBuilder instance.
|
|
814
833
|
*/
|
|
815
|
-
setSecurityZone(securityZone: number): EncryptInputsBuilder<T
|
|
834
|
+
setSecurityZone(this: EncryptInputsBuilder<T>, securityZone: number): EncryptInputsBuilder<T>;
|
|
835
|
+
setSecurityZone(this: EncryptInputsBuilderUnset<T>, securityZone: number): EncryptInputsBuilderUnset<T>;
|
|
816
836
|
getSecurityZone(): number;
|
|
817
837
|
/**
|
|
838
|
+
* @param address - The contract that will consume the resulting hashes+signature (i.e. the
|
|
839
|
+
* contract that will call `FHE.asEuint*`/`FHE.asEuint*s` with them).
|
|
840
|
+
*
|
|
841
|
+
* Required before `execute()` - the verifier binds this address into the signed digest, so a
|
|
842
|
+
* batch signed for one contract cannot be replayed into another.
|
|
843
|
+
*
|
|
818
844
|
* Example:
|
|
819
845
|
* ```typescript
|
|
820
846
|
* const encrypted = await encryptInputs([Encryptable.uint128(10n)])
|
|
821
|
-
* .
|
|
847
|
+
* .setConsumingContract("0x123...890")
|
|
822
848
|
* .execute();
|
|
823
849
|
* ```
|
|
824
850
|
*
|
|
825
|
-
* @returns
|
|
851
|
+
* @returns The chainable EncryptInputsBuilder instance.
|
|
852
|
+
*/
|
|
853
|
+
setConsumingContract(address: string): EncryptInputsBuilder<T>;
|
|
854
|
+
getConsumingContract(): string | undefined;
|
|
855
|
+
/**
|
|
856
|
+
* Asserts that this.consumingContract is populated
|
|
857
|
+
* @throws {CofheError} If consumingContract is not set
|
|
826
858
|
*/
|
|
827
|
-
|
|
859
|
+
private assertConsumingContract;
|
|
828
860
|
/**
|
|
829
861
|
* @param useWorker - Whether to use Web Workers for ZK proof generation.
|
|
830
862
|
*
|
|
@@ -839,7 +871,8 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[], HPP extends bool
|
|
|
839
871
|
*
|
|
840
872
|
* @returns The chainable EncryptInputsBuilder instance.
|
|
841
873
|
*/
|
|
842
|
-
setUseWorker(useWorker: boolean): EncryptInputsBuilder<T
|
|
874
|
+
setUseWorker(this: EncryptInputsBuilder<T>, useWorker: boolean): EncryptInputsBuilder<T>;
|
|
875
|
+
setUseWorker(this: EncryptInputsBuilderUnset<T>, useWorker: boolean): EncryptInputsBuilderUnset<T>;
|
|
843
876
|
/**
|
|
844
877
|
* Gets the current worker configuration.
|
|
845
878
|
*
|
|
@@ -869,7 +902,8 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[], HPP extends bool
|
|
|
869
902
|
*
|
|
870
903
|
* @returns The EncryptInputsBuilder instance.
|
|
871
904
|
*/
|
|
872
|
-
onStep(callback: EncryptStepCallbackFunction): EncryptInputsBuilder<T
|
|
905
|
+
onStep(this: EncryptInputsBuilder<T>, callback: EncryptStepCallbackFunction): EncryptInputsBuilder<T>;
|
|
906
|
+
onStep(this: EncryptInputsBuilderUnset<T>, callback: EncryptStepCallbackFunction): EncryptInputsBuilderUnset<T>;
|
|
873
907
|
getStepCallback(): EncryptStepCallbackFunction | undefined;
|
|
874
908
|
/**
|
|
875
909
|
* Fires the step callback if set
|
|
@@ -910,7 +944,11 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[], HPP extends bool
|
|
|
910
944
|
* In the production context, perform a true encryption with the CoFHE coprocessor.
|
|
911
945
|
*/
|
|
912
946
|
private productionExecute;
|
|
913
|
-
|
|
947
|
+
/**
|
|
948
|
+
* Converts a batch-verified result (per-item ctHash/ctType + one shared signature) into the
|
|
949
|
+
* tuple returned by `execute()`: per-item hashes in input order, followed by the single signature.
|
|
950
|
+
*/
|
|
951
|
+
private buildBatchResult;
|
|
914
952
|
/**
|
|
915
953
|
* Final step of the encryption process. MUST BE CALLED LAST IN THE CHAIN.
|
|
916
954
|
*
|
|
@@ -930,67 +968,189 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[], HPP extends bool
|
|
|
930
968
|
*
|
|
931
969
|
* @returns The encrypted inputs.
|
|
932
970
|
*/
|
|
933
|
-
execute(): Promise<
|
|
971
|
+
execute(): Promise<HashPlusProofResult<T>>;
|
|
934
972
|
}
|
|
935
973
|
|
|
936
|
-
|
|
974
|
+
interface AclServedAddresses {
|
|
975
|
+
defaultRevoker?: Hex;
|
|
976
|
+
shareRegistry?: Hex;
|
|
977
|
+
}
|
|
978
|
+
declare const acps: {
|
|
937
979
|
getSnapshot: () => {
|
|
938
|
-
|
|
980
|
+
acps: {
|
|
939
981
|
[x: number]: {
|
|
940
982
|
[x: string]: {
|
|
941
|
-
[x: string]:
|
|
983
|
+
[x: string]: {
|
|
984
|
+
hash: string;
|
|
985
|
+
name: string;
|
|
986
|
+
type: "self" | "sharing" | "recipient";
|
|
987
|
+
sealingPrivateKey: Hex;
|
|
988
|
+
_signedDomain?: EIP712Domain | undefined;
|
|
989
|
+
issuer: Hex;
|
|
990
|
+
expiration: number;
|
|
991
|
+
recipient: Hex;
|
|
992
|
+
revokerData: number;
|
|
993
|
+
revokerContract: Hex;
|
|
994
|
+
scope: number;
|
|
995
|
+
contracts: Hex[];
|
|
996
|
+
handles: Hex[];
|
|
997
|
+
sealingKey: Hex;
|
|
998
|
+
issuerSignature: Hex;
|
|
999
|
+
recipientSignature: Hex;
|
|
1000
|
+
} | undefined;
|
|
942
1001
|
};
|
|
943
1002
|
};
|
|
944
1003
|
};
|
|
945
|
-
|
|
1004
|
+
activeACPHash: {
|
|
946
1005
|
[x: number]: {
|
|
947
1006
|
[x: string]: string | undefined;
|
|
948
1007
|
};
|
|
949
1008
|
};
|
|
950
1009
|
};
|
|
951
1010
|
subscribe: (listener: (state: {
|
|
952
|
-
|
|
1011
|
+
acps: {
|
|
953
1012
|
[x: number]: {
|
|
954
1013
|
[x: string]: {
|
|
955
|
-
[x: string]:
|
|
1014
|
+
[x: string]: {
|
|
1015
|
+
hash: string;
|
|
1016
|
+
name: string;
|
|
1017
|
+
type: "self" | "sharing" | "recipient";
|
|
1018
|
+
sealingPrivateKey: Hex;
|
|
1019
|
+
_signedDomain?: EIP712Domain | undefined;
|
|
1020
|
+
issuer: Hex;
|
|
1021
|
+
expiration: number;
|
|
1022
|
+
recipient: Hex;
|
|
1023
|
+
revokerData: number;
|
|
1024
|
+
revokerContract: Hex;
|
|
1025
|
+
scope: number;
|
|
1026
|
+
contracts: Hex[];
|
|
1027
|
+
handles: Hex[];
|
|
1028
|
+
sealingKey: Hex;
|
|
1029
|
+
issuerSignature: Hex;
|
|
1030
|
+
recipientSignature: Hex;
|
|
1031
|
+
} | undefined;
|
|
956
1032
|
};
|
|
957
1033
|
};
|
|
958
1034
|
};
|
|
959
|
-
|
|
1035
|
+
activeACPHash: {
|
|
960
1036
|
[x: number]: {
|
|
961
1037
|
[x: string]: string | undefined;
|
|
962
1038
|
};
|
|
963
1039
|
};
|
|
964
1040
|
}, prevState: {
|
|
965
|
-
|
|
1041
|
+
acps: {
|
|
966
1042
|
[x: number]: {
|
|
967
1043
|
[x: string]: {
|
|
968
|
-
[x: string]:
|
|
1044
|
+
[x: string]: {
|
|
1045
|
+
hash: string;
|
|
1046
|
+
name: string;
|
|
1047
|
+
type: "self" | "sharing" | "recipient";
|
|
1048
|
+
sealingPrivateKey: Hex;
|
|
1049
|
+
_signedDomain?: EIP712Domain | undefined;
|
|
1050
|
+
issuer: Hex;
|
|
1051
|
+
expiration: number;
|
|
1052
|
+
recipient: Hex;
|
|
1053
|
+
revokerData: number;
|
|
1054
|
+
revokerContract: Hex;
|
|
1055
|
+
scope: number;
|
|
1056
|
+
contracts: Hex[];
|
|
1057
|
+
handles: Hex[];
|
|
1058
|
+
sealingKey: Hex;
|
|
1059
|
+
issuerSignature: Hex;
|
|
1060
|
+
recipientSignature: Hex;
|
|
1061
|
+
} | undefined;
|
|
969
1062
|
};
|
|
970
1063
|
};
|
|
971
1064
|
};
|
|
972
|
-
|
|
1065
|
+
activeACPHash: {
|
|
973
1066
|
[x: number]: {
|
|
974
1067
|
[x: string]: string | undefined;
|
|
975
1068
|
};
|
|
976
1069
|
};
|
|
977
1070
|
}) => void) => () => void;
|
|
978
|
-
createSelf: (options:
|
|
979
|
-
createSharing: (options:
|
|
980
|
-
importShared: (options:
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
getHash: (
|
|
984
|
-
export: (
|
|
985
|
-
serialize: (
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
1071
|
+
createSelf: (options: CreateSelfACPOptions, publicClient: PublicClient, walletClient: WalletClient) => Promise<SelfACP>;
|
|
1072
|
+
createSharing: (options: CreateSharingACPOptions, publicClient: PublicClient, walletClient: WalletClient) => Promise<SharingACP>;
|
|
1073
|
+
importShared: (options: ImportSharedACPOptions | string, publicClient: PublicClient, walletClient: WalletClient) => Promise<RecipientACP>;
|
|
1074
|
+
getOrCreateSelfACP: (publicClient: PublicClient, walletClient: WalletClient, chainId?: number, account?: string, options?: CreateSelfACPOptions) => Promise<ACP>;
|
|
1075
|
+
getOrCreateSharingACP: (publicClient: PublicClient, walletClient: WalletClient, options: CreateSharingACPOptions, chainId?: number, account?: string) => Promise<ACP>;
|
|
1076
|
+
getHash: (acp: ACPHashFields) => string;
|
|
1077
|
+
export: (acp: ACP) => string;
|
|
1078
|
+
serialize: (acp: ACP) => {
|
|
1079
|
+
hash: string;
|
|
1080
|
+
name: string;
|
|
1081
|
+
type: "self" | "sharing" | "recipient";
|
|
1082
|
+
sealingPrivateKey: Hex;
|
|
1083
|
+
_signedDomain?: EIP712Domain | undefined;
|
|
1084
|
+
issuer: Hex;
|
|
1085
|
+
expiration: number;
|
|
1086
|
+
recipient: Hex;
|
|
1087
|
+
revokerData: number;
|
|
1088
|
+
revokerContract: Hex;
|
|
1089
|
+
scope: number;
|
|
1090
|
+
contracts: Hex[];
|
|
1091
|
+
handles: Hex[];
|
|
1092
|
+
sealingKey: Hex;
|
|
1093
|
+
issuerSignature: Hex;
|
|
1094
|
+
recipientSignature: Hex;
|
|
1095
|
+
};
|
|
1096
|
+
deserialize: (serialized: SerializedACP) => {
|
|
1097
|
+
hash: string;
|
|
1098
|
+
name: string;
|
|
1099
|
+
type: "self" | "sharing" | "recipient";
|
|
1100
|
+
sealingPrivateKey: Hex;
|
|
1101
|
+
_signedDomain?: EIP712Domain | undefined;
|
|
1102
|
+
issuer: Hex;
|
|
1103
|
+
expiration: number;
|
|
1104
|
+
recipient: Hex;
|
|
1105
|
+
revokerData: number;
|
|
1106
|
+
revokerContract: Hex;
|
|
1107
|
+
scope: number;
|
|
1108
|
+
contracts: Hex[];
|
|
1109
|
+
handles: Hex[];
|
|
1110
|
+
sealingKey: Hex;
|
|
1111
|
+
issuerSignature: Hex;
|
|
1112
|
+
recipientSignature: Hex;
|
|
1113
|
+
};
|
|
1114
|
+
getACP: (chainId: number, account: string, hash: string) => ACP | undefined;
|
|
1115
|
+
getACPs: (chainId: number, account: string) => Record<string, ACP>;
|
|
1116
|
+
getActiveACP: (chainId: number, account: string) => ACP | undefined;
|
|
1117
|
+
getActiveACPHash: (chainId: number, account: string) => string | undefined;
|
|
1118
|
+
removeACP: (chainId: number, account: string, hash: string) => Promise<void>;
|
|
1119
|
+
selectActiveACP: (chainId: number, account: string, hash: string) => void;
|
|
1120
|
+
removeActiveACP: (chainId: number, account: string) => Promise<void>;
|
|
1121
|
+
revokeACP: (acp: ACP, walletClient: WalletClient) => Promise<Hex>;
|
|
1122
|
+
revokeAllACPs: (walletClient: WalletClient, publicClient: PublicClient, revokerContract?: Hex) => Promise<Hex>;
|
|
1123
|
+
isACPRevoked: (acp: ACP, publicClient: PublicClient) => Promise<boolean>;
|
|
1124
|
+
shareOnChain: (acp: ACP, walletClient: WalletClient, registry: Hex) => Promise<{
|
|
1125
|
+
txHash: Hex;
|
|
1126
|
+
shareId: Hex;
|
|
1127
|
+
}>;
|
|
1128
|
+
getIncomingShares: (publicClient: PublicClient, registry: Hex, recipient: Hex) => Promise<IncomingShare[]>;
|
|
1129
|
+
importFromChain: (share: IncomingShare, publicClient: PublicClient, walletClient: WalletClient) => Promise<RecipientACP>;
|
|
1130
|
+
removeShareOnChain: (shareId: Hex, walletClient: WalletClient, registry: Hex) => Promise<Hex>;
|
|
1131
|
+
computeShareId: (acp: ACP) => Hex;
|
|
1132
|
+
applyACPDefaults: <T extends {
|
|
1133
|
+
revokerData?: number;
|
|
1134
|
+
revokerContract?: string;
|
|
1135
|
+
scope?: number;
|
|
1136
|
+
contracts?: string[];
|
|
1137
|
+
handles?: (bigint | number | string)[];
|
|
1138
|
+
}>(options: T, acpConfig: {
|
|
1139
|
+
defaultRevoker?: Record<number, Hex>;
|
|
1140
|
+
defaultContractScopes?: Record<number, Hex[]>;
|
|
1141
|
+
} | undefined, chainId: number) => T;
|
|
1142
|
+
applyACPDefaultsFromChain: <T extends {
|
|
1143
|
+
revokerData?: number;
|
|
1144
|
+
revokerContract?: string;
|
|
1145
|
+
scope?: number;
|
|
1146
|
+
contracts?: string[];
|
|
1147
|
+
handles?: (bigint | number | string)[];
|
|
1148
|
+
}>(options: T, acpConfig: {
|
|
1149
|
+
defaultRevoker?: Record<number, Hex>;
|
|
1150
|
+
defaultContractScopes?: Record<number, Hex[]>;
|
|
1151
|
+
} | undefined, publicClient: PublicClient, chainId: number) => Promise<T>;
|
|
1152
|
+
getAclServedAddresses: (publicClient: PublicClient, chainId: number) => Promise<AclServedAddresses>;
|
|
1153
|
+
clearAclServedAddresses: () => void;
|
|
994
1154
|
};
|
|
995
1155
|
|
|
996
1156
|
type CofheClient<TConfig extends CofheConfig = CofheConfig> = {
|
|
@@ -1004,13 +1164,13 @@ type CofheClient<TConfig extends CofheConfig = CofheConfig> = {
|
|
|
1004
1164
|
/**
|
|
1005
1165
|
* Clears the current connection state (account/chainId/clients) and marks the client as disconnected.
|
|
1006
1166
|
*
|
|
1007
|
-
* This does not delete persisted
|
|
1167
|
+
* This does not delete persisted acps or stored FHE keys; it only resets the in-memory connection.
|
|
1008
1168
|
*/
|
|
1009
1169
|
disconnect(): void;
|
|
1010
1170
|
/**
|
|
1011
1171
|
* Types docstring
|
|
1012
1172
|
*/
|
|
1013
|
-
encryptInputs<T extends EncryptableItem[]>(inputs: [...T]):
|
|
1173
|
+
encryptInputs<T extends EncryptableItem[]>(inputs: [...T]): EncryptInputsBuilderUnset<[...T]>;
|
|
1014
1174
|
/**
|
|
1015
1175
|
* @deprecated Use `decryptForView` instead. Kept for backward compatibility.
|
|
1016
1176
|
*/
|
|
@@ -1018,7 +1178,8 @@ type CofheClient<TConfig extends CofheConfig = CofheConfig> = {
|
|
|
1018
1178
|
decryptForView<U extends FheTypes>(ctHash: bigint | string, utype: U): DecryptForViewBuilder<U>;
|
|
1019
1179
|
decryptForTx(ctHash: bigint | string): DecryptForTxBuilderUnset;
|
|
1020
1180
|
verifyDecryptResult(handle: bigint | string, cleartext: bigint, signature: Hex): Promise<boolean>;
|
|
1021
|
-
|
|
1181
|
+
/** ACP (Access Control Permission) management — create, share, revoke, select. */
|
|
1182
|
+
acp: CofheClientACPs;
|
|
1022
1183
|
};
|
|
1023
1184
|
type CofheClientConnectionState = {
|
|
1024
1185
|
connected: boolean;
|
|
@@ -1030,29 +1191,45 @@ type CofheClientConnectionState = {
|
|
|
1030
1191
|
walletClient: WalletClient | undefined;
|
|
1031
1192
|
};
|
|
1032
1193
|
type Listener = (snapshot: CofheClientConnectionState) => void;
|
|
1033
|
-
type
|
|
1194
|
+
type CofheClientACPsClients = {
|
|
1034
1195
|
publicClient: PublicClient;
|
|
1035
1196
|
walletClient: WalletClient;
|
|
1036
1197
|
};
|
|
1037
|
-
type
|
|
1038
|
-
getSnapshot: typeof
|
|
1039
|
-
subscribe: typeof
|
|
1040
|
-
createSelf: (options:
|
|
1041
|
-
createSharing: (options:
|
|
1042
|
-
importShared: (options:
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1198
|
+
type CofheClientACPs = {
|
|
1199
|
+
getSnapshot: typeof acps.getSnapshot;
|
|
1200
|
+
subscribe: typeof acps.subscribe;
|
|
1201
|
+
createSelf: (options: CreateSelfACPOptions, clients?: CofheClientACPsClients) => Promise<SelfACP>;
|
|
1202
|
+
createSharing: (options: CreateSharingACPOptions, clients?: CofheClientACPsClients) => Promise<SharingACP>;
|
|
1203
|
+
importShared: (options: ImportSharedACPOptions | string, clients?: CofheClientACPsClients) => Promise<RecipientACP>;
|
|
1204
|
+
getACP: (hash: string, chainId?: number, account?: string) => ACP | undefined;
|
|
1205
|
+
getACPs: (chainId?: number, account?: string) => Record<string, ACP>;
|
|
1206
|
+
getActiveACP: (chainId?: number, account?: string) => ACP | undefined;
|
|
1207
|
+
getActiveACPHash: (chainId?: number, account?: string) => string | undefined;
|
|
1208
|
+
getOrCreateSelfACP: (chainId?: number, account?: string, options?: CreateSelfACPOptions) => Promise<ACP>;
|
|
1209
|
+
getOrCreateSharingACP: (options: CreateSharingACPOptions, chainId?: number, account?: string) => Promise<ACP>;
|
|
1210
|
+
selectActiveACP: (hash: string, chainId?: number, account?: string) => void;
|
|
1211
|
+
removeACP: (hash: string, chainId?: number, account?: string) => void;
|
|
1212
|
+
removeActiveACP: (chainId?: number, account?: string) => void;
|
|
1213
|
+
revokeACP: (acp: ACP) => Promise<`0x${string}`>;
|
|
1214
|
+
revokeAllACPs: (revokerContract?: `0x${string}`) => Promise<`0x${string}`>;
|
|
1215
|
+
isACPRevoked: (acp: ACP) => Promise<boolean>;
|
|
1216
|
+
/** Post a signed sharing ACP to the on-chain share registry (ACL-served, or config `acp.sharingRegistry`). */
|
|
1217
|
+
shareOnChain: (acp: ACP) => Promise<{
|
|
1218
|
+
txHash: `0x${string}`;
|
|
1219
|
+
shareId: `0x${string}`;
|
|
1220
|
+
}>;
|
|
1221
|
+
/** Importable shares addressed to the connected account (unexpired, not revoked). */
|
|
1222
|
+
getIncomingShares: () => Promise<IncomingShare[]>;
|
|
1223
|
+
/** Import a share read from the registry: sign as recipient, store and activate. */
|
|
1224
|
+
importFromChain: (share: IncomingShare) => Promise<RecipientACP>;
|
|
1225
|
+
/** Recipient-side: remove a share from the registry (after import, or to decline). */
|
|
1226
|
+
dismissShare: (shareId: `0x${string}`) => Promise<`0x${string}`>;
|
|
1227
|
+
/** Issuer-side: retract a pending share from the registry. */
|
|
1228
|
+
cancelShare: (shareId: `0x${string}`) => Promise<`0x${string}`>;
|
|
1229
|
+
getHash: typeof ACPUtils.getHash;
|
|
1230
|
+
export: typeof ACPUtils.export;
|
|
1231
|
+
serialize: typeof ACPUtils.serialize;
|
|
1232
|
+
deserialize: typeof ACPUtils.deserialize;
|
|
1056
1233
|
};
|
|
1057
1234
|
type CofheClientParams<TConfig extends CofheConfig> = {
|
|
1058
1235
|
config: TConfig;
|
|
@@ -1063,4 +1240,4 @@ type CofheClientParams<TConfig extends CofheConfig> = {
|
|
|
1063
1240
|
zkProveWorkerFn?: ZkProveWorkerFunction;
|
|
1064
1241
|
};
|
|
1065
1242
|
|
|
1066
|
-
export {
|
|
1243
|
+
export { EncryptInputsBuilder as $, type AnyExternalHash as A, type EncryptableToExternalHashMap as B, type CofheInputConfig as C, type ExternalItemHashes as D, type EncryptableItem as E, FheTypes as F, type DecryptPollCallbackFunction as G, type HashPlusProofResult as H, type IStorage as I, type DecryptPollCallbackContext as J, type DecryptEndpoint as K, type LiteralToPrimitive as L, type EncryptStepCallbackFunction as M, type EncryptStepCallbackContext as N, FheUintUTypes as O, type Primitive as P, FheAllUTypes as Q, Encryptable as R, isEncryptableItem as S, EncryptStep as T, type UnsealedItem as U, isLastEncryptionStep as V, fetchKeys as W, type FheKeyDeserializer as X, createKeysStore as Y, type KeysStorage as Z, type KeysStore as _, type CofheConfig as a, type EncryptInputsBuilderUnset as a0, DecryptForViewBuilder as a1, DecryptForTxBuilder as a2, type DecryptForTxResult as a3, type ZkBuilderAndCrsGenerator as a4, type ZkProveWorkerFunction as a5, type ZkProveWorkerRequest as a6, type ZkProveWorkerResponse as a7, zkProveWithWorker as a8, type CofheClient as b, type CofheClientParams as c, type CofheClientConnectionState as d, createCofheConfigBase as e, assertNoRenamedConfigKeys as f, getCofheConfigItem as g, type CofheInternalConfig as h, type CofheClientACPs as i, type EncryptableBool as j, type EncryptableUint8 as k, type EncryptableUint16 as l, type EncryptableUint32 as m, type EncryptableUint64 as n, type EncryptableUint128 as o, type EncryptableAddress as p, type EncryptedNumber as q, type FheTypeValue as r, type ExternalBoolHash as s, type ExternalUint8Hash as t, type ExternalUint16Hash as u, type ExternalUint32Hash as v, type ExternalUint64Hash as w, type ExternalUint128Hash as x, type ExternalAddressHash as y, type ExternalHashProof as z };
|