@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.
Files changed (114) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/acps/acp.ts +411 -0
  3. package/acps/index.ts +70 -0
  4. package/{permits → acps}/onchain-utils.ts +49 -24
  5. package/acps/sealing.ts +90 -0
  6. package/acps/signature.ts +89 -0
  7. package/acps/store.ts +172 -0
  8. package/acps/test/acp.test.ts +615 -0
  9. package/acps/test/localstorage.test.ts +105 -0
  10. package/acps/test/sealing.test.ts +77 -0
  11. package/acps/test/store.test.ts +88 -0
  12. package/acps/test/validation.test.ts +361 -0
  13. package/acps/test-utils.ts +32 -0
  14. package/acps/types.ts +252 -0
  15. package/acps/validation.ts +392 -0
  16. package/adapters/test/ethers5.test.ts +4 -1
  17. package/adapters/test/ethers6.test.ts +4 -1
  18. package/adapters/test/wagmi.test.ts +5 -2
  19. package/chains/chains/stagingCofhe.ts +21 -0
  20. package/chains/index.ts +3 -1
  21. package/chains/test/chains.test.ts +2 -1
  22. package/core/acps.ts +625 -0
  23. package/core/client.ts +136 -39
  24. package/core/clientTypes.ts +52 -41
  25. package/core/config.ts +66 -5
  26. package/core/debug.ts +72 -0
  27. package/core/decrypt/MockThresholdNetworkAbi.ts +20 -11
  28. package/core/decrypt/apiError.ts +104 -0
  29. package/core/decrypt/cofheMocksDecryptForTx.ts +11 -11
  30. package/core/decrypt/cofheMocksDecryptForView.ts +7 -7
  31. package/core/decrypt/decryptForTxBuilder.ts +102 -102
  32. package/core/decrypt/decryptForViewBuilder.ts +90 -90
  33. package/core/decrypt/submitRetry.ts +38 -30
  34. package/core/decrypt/tnDecryptV1.ts +5 -5
  35. package/core/decrypt/tnDecryptV2.ts +45 -34
  36. package/core/decrypt/tnSealOutputV1.ts +4 -3
  37. package/core/decrypt/tnSealOutputV2.ts +44 -31
  38. package/core/encrypt/cofheMocksZkVerifySign.ts +59 -74
  39. package/core/encrypt/encryptInputsBuilder.ts +86 -52
  40. package/core/encrypt/zkPackProveVerify.ts +25 -18
  41. package/core/error.ts +34 -6
  42. package/core/index.ts +14 -14
  43. package/core/test/acpDefaults.test.ts +52 -0
  44. package/core/test/acps.test.ts +596 -0
  45. package/core/test/apiError.test.ts +130 -0
  46. package/core/test/client.test.ts +22 -19
  47. package/core/test/config.test.ts +25 -5
  48. package/core/test/decrypt.test.ts +40 -35
  49. package/core/test/decryptBuilders.test.ts +68 -68
  50. package/core/test/decryptErrorCodes.test.ts +217 -0
  51. package/core/test/encryptInputsBuilder.test.ts +72 -41
  52. package/core/test/pollCallbacks.test.ts +89 -18
  53. package/core/test/stagingRedirect.ts +18 -0
  54. package/core/test/submitRetry.test.ts +182 -0
  55. package/core/types.ts +9 -69
  56. package/dist/acp-Wi6isVQI.d.cts +407 -0
  57. package/dist/acp-Wi6isVQI.d.ts +407 -0
  58. package/dist/acps.cjs +1081 -0
  59. package/dist/acps.d.cts +480 -0
  60. package/dist/acps.d.ts +480 -0
  61. package/dist/acps.js +2 -0
  62. package/dist/chains.cjs +14 -1
  63. package/dist/chains.d.cts +30 -1
  64. package/dist/chains.d.ts +30 -1
  65. package/dist/chains.js +1 -1
  66. package/dist/{chunk-PE5V5CCV.js → chunk-43USWPEH.js} +1000 -604
  67. package/dist/{chunk-MTRAXQXC.js → chunk-N6IDQRRU.js} +14 -2
  68. package/dist/chunk-Q7CBWGQX.js +1029 -0
  69. package/dist/{clientTypes-CyUvRRzA.d.ts → clientTypes-BN3nbzYM.d.ts} +342 -165
  70. package/dist/{clientTypes-BDy1qIBu.d.cts → clientTypes-CYZjFznO.d.cts} +342 -165
  71. package/dist/core.cjs +1431 -1026
  72. package/dist/core.d.cts +55 -10
  73. package/dist/core.d.ts +55 -10
  74. package/dist/core.js +3 -3
  75. package/dist/node.cjs +1356 -976
  76. package/dist/node.d.cts +2 -2
  77. package/dist/node.d.ts +2 -2
  78. package/dist/node.js +3 -3
  79. package/dist/web.cjs +1356 -976
  80. package/dist/web.d.cts +2 -2
  81. package/dist/web.d.ts +2 -2
  82. package/dist/web.js +3 -3
  83. package/node/test/inherited.test.ts +75 -65
  84. package/node/test/tfheinit.test.ts +23 -8
  85. package/package.json +6 -6
  86. package/web/test/client.web.test.ts +5 -1
  87. package/web/test/inherited.web.test.ts +75 -65
  88. package/web/test/tfheinit.web.test.ts +14 -5
  89. package/web/test/worker.config.web.test.ts +38 -23
  90. package/web/test/worker.output.web.test.ts +25 -24
  91. package/core/encrypt/encryptUtils.ts +0 -67
  92. package/core/permits.ts +0 -206
  93. package/core/test/permits.test.ts +0 -534
  94. package/dist/chunk-VB62WYPL.js +0 -978
  95. package/dist/permit-DnVMDT5h.d.cts +0 -376
  96. package/dist/permit-DnVMDT5h.d.ts +0 -376
  97. package/dist/permits.cjs +0 -1026
  98. package/dist/permits.d.cts +0 -353
  99. package/dist/permits.d.ts +0 -353
  100. package/dist/permits.js +0 -2
  101. package/permits/index.ts +0 -68
  102. package/permits/permit.ts +0 -385
  103. package/permits/sealing.ts +0 -131
  104. package/permits/signature.ts +0 -79
  105. package/permits/store.ts +0 -157
  106. package/permits/test/localstorage.test.ts +0 -113
  107. package/permits/test/permit.test.ts +0 -557
  108. package/permits/test/sealing.test.ts +0 -84
  109. package/permits/test/store.test.ts +0 -88
  110. package/permits/test/validation.test.ts +0 -361
  111. package/permits/test-utils.ts +0 -28
  112. package/permits/types.ts +0 -204
  113. package/permits/validation.ts +0 -327
  114. /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 { P as Permit, S as SerializedPermit, C as CreateSelfPermitOptions, m as SelfPermit, d as CreateSharingPermitOptions, n as SharingPermit, I as ImportSharedPermitOptions, R as RecipientPermit, o as PermitHashFields, g as PermitUtils } from './permit-DnVMDT5h.cjs';
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
- /** Branded bytes proof blob (Solidity: bytes memory proof). */
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() when asHashPlusProof() is set.
213
- * Tuple of per-input hashes in input order, followed by a single proof blob.
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 permit expiration in seconds, default is 30 days */
246
- defaultPermitExpiration: number;
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
- defaultPermitExpiration: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
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
- * .withPermit() // optional (active permit)
398
- * // or .withPermit(permitHash) / .withPermit(permit)
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
- * withPermit() uses chainId + account to get the active permit.
404
- * withPermit(permitHash) fetches that permit using chainId + account.
405
- * withPermit(permit) uses the provided permit regardless of chainId/account.
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 a permit (no global-allowance mode).
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
- permitHash?: string;
415
- permit?: Permit;
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 permitHash?;
421
- private permit?;
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 permit.
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 permit.
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 permit" mode (optional).
469
+ * Select "use acp" mode (optional).
461
470
  *
462
- * - `withPermit(permit)` uses the provided permit.
463
- * - `withPermit(permitHash)` fetches that permit.
464
- * - `withPermit()` uses the active permit for the resolved `chainId + account`.
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
- withPermit(): DecryptForViewBuilder<U>;
467
- withPermit(permitHash: string): DecryptForViewBuilder<U>;
468
- withPermit(permit: Permit): DecryptForViewBuilder<U>;
475
+ withACP(): DecryptForViewBuilder<U>;
476
+ withACP(acpHash: string): DecryptForViewBuilder<U>;
477
+ withACP(acp: ACP): DecryptForViewBuilder<U>;
469
478
  /**
470
- * @param permitHash - Permit hash to decrypt values from. Used to fetch the correct permit.
479
+ * @param acpHash - ACP hash to decrypt values from. Used to fetch the correct acp.
471
480
  *
472
- * If not provided, the active permit for the chainId and account will be used.
473
- * If `setPermit()` is called, it will be used regardless of chainId, account, or permitHash.
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
- * .setPermitHash('0x1234567890123456789012345678901234567890')
487
+ * .setACPHash('0x1234567890123456789012345678901234567890')
479
488
  * .execute();
480
489
  * ```
481
490
  *
482
491
  * @returns The chainable DecryptForViewBuilder instance.
483
492
  */
484
- /** @deprecated Use `withPermit(permitHash)` instead. */
485
- setPermitHash(permitHash: string): DecryptForViewBuilder<U>;
486
- getPermitHash(): string | undefined;
493
+ /** @deprecated Use `withACP(acpHash)` instead. */
494
+ setACPHash(acpHash: string): DecryptForViewBuilder<U>;
495
+ getACPHash(): string | undefined;
487
496
  /**
488
- * @param permit - Permit to decrypt values with. If provided, it will be used regardless of chainId, account, or permitHash.
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 permit will be determined by chainId, account, and permitHash.
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
- * .setPermit(permit)
504
+ * .setACP(acp)
496
505
  * .execute();
497
506
  * ```
498
507
  *
499
508
  * @returns The chainable DecryptForViewBuilder instance.
500
509
  */
501
- /** @deprecated Use `withPermit(permit)` instead. */
502
- setPermit(permit: Permit): DecryptForViewBuilder<U>;
503
- getPermit(): Permit | undefined;
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 getResolvedPermit;
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 a permit based on provided permit OR chainId + account + permitHash
520
- * - Check permit validity
521
- * - Call CoFHE `/sealoutput` with the permit, which returns a sealed (encrypted) item
522
- * - Unseal the sealed item with the permit
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
- * .withPermit() // optional
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 `withPermit(...)` or `withoutPermit()` returns a builder that *does* expose `execute()`, but no longer
551
- * exposes `withPermit/withoutPermit` (so you can't select twice, or switch modes).
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, 'withPermit' | 'withoutPermit'>;
563
+ type DecryptForTxBuilderSelected = Omit<DecryptForTxBuilder, 'withACP' | 'withoutACP'>;
555
564
  declare class DecryptForTxBuilder extends BaseBuilder {
556
565
  private ctHash;
557
- private permitHash?;
558
- private permit?;
559
- private permitSelection;
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 permit.
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 permit.
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 permit" mode.
611
+ * Select "use acp" mode.
603
612
  *
604
- * - `withPermit(permit)` uses the provided permit.
605
- * - `withPermit(permitHash)` fetches that permit.
606
- * - `withPermit()` uses the active permit for the resolved `chainId + account`.
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 permit) is ONLY available via `withoutPermit()`.
617
+ * Note: "global allowance" (no acp) is ONLY available via `withoutACP()`.
609
618
  */
610
- withPermit(): DecryptForTxBuilderSelected;
611
- withPermit(permitHash: string): DecryptForTxBuilderSelected;
612
- withPermit(permit: Permit): DecryptForTxBuilderSelected;
619
+ withACP(): DecryptForTxBuilderSelected;
620
+ withACP(acpHash: string): DecryptForTxBuilderSelected;
621
+ withACP(acp: ACP): DecryptForTxBuilderSelected;
613
622
  /**
614
- * Select "no permit" mode.
623
+ * Select "no acp" mode.
615
624
  *
616
- * This uses global allowance (no permit required) and sends an empty permission payload to `/decrypt`.
625
+ * This uses global allowance (no acp required) and sends an empty permission payload to `/decrypt`.
617
626
  */
618
- withoutPermit(): DecryptForTxBuilderSelected;
619
- getPermit(): Permit | undefined;
620
- getPermitHash(): string | undefined;
627
+ withoutACP(): DecryptForTxBuilderSelected;
628
+ getACP(): ACP | undefined;
629
+ getACPHash(): string | undefined;
621
630
  private getThresholdNetworkUrl;
622
- private getResolvedPermit;
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 permit mode before calling `execute()`:
635
- * - `withPermit(permit)` / `withPermit(permitHash)` / `withPermit()` (active permit)
636
- * - `withoutPermit()` (global allowance)
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
- declare class EncryptInputsBuilder<T extends EncryptableItem[], HPP extends boolean = false> extends BaseBuilder {
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, HPP>;
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, HPP>;
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, HPP>;
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
- * .asHashPlusProof()
847
+ * .setConsumingContract("0x123...890")
822
848
  * .execute();
823
849
  * ```
824
850
  *
825
- * @returns Chainable EncryptInputsBuilder instance that will return a HashPlusProofResult instead of an array of EncryptedItemInputs.
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
- asHashPlusProof(): EncryptInputsBuilder<T, true>;
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, HPP>;
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, HPP>;
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
- private structsToHashPlusProof;
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<HPP extends true ? HashPlusProofResult<T> : [...EncryptedItemInputs<T>]>;
971
+ execute(): Promise<HashPlusProofResult<T>>;
934
972
  }
935
973
 
936
- declare const permits: {
974
+ interface AclServedAddresses {
975
+ defaultRevoker?: Hex;
976
+ shareRegistry?: Hex;
977
+ }
978
+ declare const acps: {
937
979
  getSnapshot: () => {
938
- permits: {
980
+ acps: {
939
981
  [x: number]: {
940
982
  [x: string]: {
941
- [x: string]: SerializedPermit | undefined;
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
- activePermitHash: {
1004
+ activeACPHash: {
946
1005
  [x: number]: {
947
1006
  [x: string]: string | undefined;
948
1007
  };
949
1008
  };
950
1009
  };
951
1010
  subscribe: (listener: (state: {
952
- permits: {
1011
+ acps: {
953
1012
  [x: number]: {
954
1013
  [x: string]: {
955
- [x: string]: SerializedPermit | undefined;
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
- activePermitHash: {
1035
+ activeACPHash: {
960
1036
  [x: number]: {
961
1037
  [x: string]: string | undefined;
962
1038
  };
963
1039
  };
964
1040
  }, prevState: {
965
- permits: {
1041
+ acps: {
966
1042
  [x: number]: {
967
1043
  [x: string]: {
968
- [x: string]: SerializedPermit | undefined;
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
- activePermitHash: {
1065
+ activeACPHash: {
973
1066
  [x: number]: {
974
1067
  [x: string]: string | undefined;
975
1068
  };
976
1069
  };
977
1070
  }) => void) => () => void;
978
- createSelf: (options: CreateSelfPermitOptions, publicClient: PublicClient, walletClient: WalletClient) => Promise<SelfPermit>;
979
- createSharing: (options: CreateSharingPermitOptions, publicClient: PublicClient, walletClient: WalletClient) => Promise<SharingPermit>;
980
- importShared: (options: ImportSharedPermitOptions | string, publicClient: PublicClient, walletClient: WalletClient) => Promise<RecipientPermit>;
981
- getOrCreateSelfPermit: (publicClient: PublicClient, walletClient: WalletClient, chainId?: number, account?: string, options?: CreateSelfPermitOptions) => Promise<Permit>;
982
- getOrCreateSharingPermit: (publicClient: PublicClient, walletClient: WalletClient, options: CreateSharingPermitOptions, chainId?: number, account?: string) => Promise<Permit>;
983
- getHash: (permit: PermitHashFields) => string;
984
- export: (permit: Permit) => string;
985
- serialize: (permit: Permit) => SerializedPermit;
986
- deserialize: (serialized: SerializedPermit) => Permit;
987
- getPermit: (chainId: number, account: string, hash: string) => Permit | undefined;
988
- getPermits: (chainId: number, account: string) => Record<string, Permit>;
989
- getActivePermit: (chainId: number, account: string) => Permit | undefined;
990
- getActivePermitHash: (chainId: number, account: string) => string | undefined;
991
- removePermit: (chainId: number, account: string, hash: string) => Promise<void>;
992
- selectActivePermit: (chainId: number, account: string, hash: string) => void;
993
- removeActivePermit: (chainId: number, account: string) => Promise<void>;
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 permits or stored FHE keys; it only resets the in-memory connection.
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]): EncryptInputsBuilder<[...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
- permits: CofheClientPermits;
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 CofheClientPermitsClients = {
1194
+ type CofheClientACPsClients = {
1034
1195
  publicClient: PublicClient;
1035
1196
  walletClient: WalletClient;
1036
1197
  };
1037
- type CofheClientPermits = {
1038
- getSnapshot: typeof permits.getSnapshot;
1039
- subscribe: typeof permits.subscribe;
1040
- createSelf: (options: CreateSelfPermitOptions, clients?: CofheClientPermitsClients) => Promise<SelfPermit>;
1041
- createSharing: (options: CreateSharingPermitOptions, clients?: CofheClientPermitsClients) => Promise<SharingPermit>;
1042
- importShared: (options: ImportSharedPermitOptions | string, clients?: CofheClientPermitsClients) => Promise<RecipientPermit>;
1043
- getPermit: (hash: string, chainId?: number, account?: string) => Permit | undefined;
1044
- getPermits: (chainId?: number, account?: string) => Record<string, Permit>;
1045
- getActivePermit: (chainId?: number, account?: string) => Permit | undefined;
1046
- getActivePermitHash: (chainId?: number, account?: string) => string | undefined;
1047
- getOrCreateSelfPermit: (chainId?: number, account?: string, options?: CreateSelfPermitOptions) => Promise<Permit>;
1048
- getOrCreateSharingPermit: (options: CreateSharingPermitOptions, chainId?: number, account?: string) => Promise<Permit>;
1049
- selectActivePermit: (hash: string, chainId?: number, account?: string) => void;
1050
- removePermit: (hash: string, chainId?: number, account?: string) => void;
1051
- removeActivePermit: (chainId?: number, account?: string) => void;
1052
- getHash: typeof PermitUtils.getHash;
1053
- export: typeof PermitUtils.export;
1054
- serialize: typeof PermitUtils.serialize;
1055
- deserialize: typeof PermitUtils.deserialize;
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 { Encryptable as $, type FheTypeValue as A, type ExternalBoolHash as B, type CofheInputConfig as C, type ExternalUint8Hash as D, type EncryptableItem as E, FheTypes as F, type ExternalUint16Hash as G, type ExternalUint32Hash as H, type IStorage as I, type ExternalUint64Hash as J, type ExternalUint128Hash as K, type LiteralToPrimitive as L, type ExternalAddressHash as M, type ExternalHashProof as N, type AnyExternalHash as O, type Primitive as P, type EncryptableToExternalHashMap as Q, type ExternalItemHashes as R, type HashPlusProofResult as S, type DecryptPollCallbackFunction as T, type UnsealedItem as U, type DecryptPollCallbackContext as V, type DecryptEndpoint as W, type EncryptStepCallbackFunction as X, type EncryptStepCallbackContext as Y, FheUintUTypes as Z, FheAllUTypes as _, type CofheConfig as a, isEncryptableItem as a0, EncryptStep as a1, isLastEncryptionStep as a2, assertCorrectEncryptedItemInput as a3, fetchKeys as a4, type FheKeyDeserializer as a5, createKeysStore as a6, type KeysStorage as a7, type KeysStore as a8, EncryptInputsBuilder as a9, DecryptForViewBuilder as aa, DecryptForTxBuilder as ab, type DecryptForTxResult as ac, type ZkBuilderAndCrsGenerator as ad, type ZkProveWorkerFunction as ae, type ZkProveWorkerRequest as af, type ZkProveWorkerResponse as ag, zkProveWithWorker as ah, type CofheClient as b, type CofheClientParams as c, type CofheClientConnectionState as d, createCofheConfigBase as e, type CofheInternalConfig as f, getCofheConfigItem as g, type CofheClientPermits as h, type EncryptableBool as i, type EncryptableUint8 as j, type EncryptableUint16 as k, type EncryptableUint32 as l, type EncryptableUint64 as m, type EncryptableUint128 as n, type EncryptableAddress as o, type EncryptedNumber as p, type EncryptedItemInput as q, type EncryptedBoolInput as r, type EncryptedUint8Input as s, type EncryptedUint16Input as t, type EncryptedUint32Input as u, type EncryptedUint64Input as v, type EncryptedUint128Input as w, type EncryptedAddressInput as x, type EncryptedItemInputs as y, type EncryptableToEncryptedItemInputMap as z };
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 };