@cofhe/sdk 0.5.1 → 0.6.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 (47) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/adapters/test/ethers5.test.ts +1 -1
  3. package/adapters/test/ethers6.test.ts +1 -1
  4. package/adapters/test/wagmi.test.ts +1 -1
  5. package/chains/chains/hardhat.ts +3 -3
  6. package/core/consts.ts +0 -3
  7. package/core/decrypt/decryptForTxBuilder.ts +21 -0
  8. package/core/decrypt/decryptForViewBuilder.ts +19 -0
  9. package/core/decrypt/submitRetry.ts +126 -0
  10. package/core/decrypt/tnDecryptV2.ts +48 -53
  11. package/core/decrypt/tnSealOutputV2.ts +48 -54
  12. package/core/encrypt/cofheMocksZkVerifySign.ts +2 -2
  13. package/core/encrypt/encryptInputsBuilder.ts +46 -11
  14. package/core/encrypt/zkPackProveVerify.ts +3 -3
  15. package/core/index.ts +13 -1
  16. package/core/test/decryptBuilders.test.ts +28 -0
  17. package/core/test/encryptInputsBuilder.test.ts +35 -0
  18. package/core/test/pollCallbacks.test.ts +226 -0
  19. package/core/types.ts +65 -5
  20. package/dist/chains.cjs +3 -3
  21. package/dist/chains.js +1 -1
  22. package/dist/{chunk-4FP4V35O.js → chunk-ESMZCFJY.js} +1 -2
  23. package/dist/{chunk-TBLR7NNE.js → chunk-MTRAXQXC.js} +3 -3
  24. package/dist/{chunk-S7OKGLFD.js → chunk-PE5V5CCV.js} +288 -153
  25. package/dist/{chunk-MRCKUMOS.js → chunk-VB62WYPL.js} +1 -1
  26. package/dist/{clientTypes-BSbwairE.d.cts → clientTypes-BDy1qIBu.d.cts} +78 -11
  27. package/dist/{clientTypes-DDmcgZ0a.d.ts → clientTypes-CyUvRRzA.d.ts} +78 -11
  28. package/dist/core.cjs +288 -155
  29. package/dist/core.d.cts +3 -5
  30. package/dist/core.d.ts +3 -5
  31. package/dist/core.js +4 -4
  32. package/dist/node.cjs +243 -108
  33. package/dist/node.d.cts +1 -1
  34. package/dist/node.d.ts +1 -1
  35. package/dist/node.js +4 -4
  36. package/dist/permits.d.cts +10 -6
  37. package/dist/permits.d.ts +10 -6
  38. package/dist/permits.js +2 -2
  39. package/dist/web.cjs +243 -108
  40. package/dist/web.d.cts +1 -1
  41. package/dist/web.d.ts +1 -1
  42. package/dist/web.js +4 -4
  43. package/dist/zkProve.worker.js +1 -1
  44. package/package.json +2 -2
  45. package/permits/store.ts +1 -0
  46. package/web/test/ssr.test.ts +23 -0
  47. package/web/test/tfheinit.web.test.ts +81 -5
@@ -59,13 +59,13 @@ type EncryptedNumber = {
59
59
  data: Uint8Array;
60
60
  securityZone: number;
61
61
  };
62
- type EncryptedItemInput<TSignature = string> = {
62
+ type EncryptedItemInput = {
63
63
  ctHash: bigint;
64
64
  securityZone: number;
65
65
  utype: FheTypes;
66
- signature: TSignature;
66
+ signature: `0x${string}`;
67
67
  };
68
- declare function assertCorrectEncryptedItemInput(input: EncryptedItemInput): asserts input is EncryptedItemInput<`0x${string}`>;
68
+ declare function assertCorrectEncryptedItemInput(input: EncryptedItemInput): asserts input is EncryptedItemInput;
69
69
  type EncryptedBoolInput = EncryptedItemInput & {
70
70
  utype: FheTypes.Bool;
71
71
  };
@@ -165,6 +165,55 @@ type EncryptStepCallbackContext = Record<string, any> & {
165
165
  duration: number;
166
166
  };
167
167
  type EncryptStepCallbackFunction = (state: EncryptStep, context?: EncryptStepCallbackContext) => void;
168
+ /**
169
+ * Branded bytes32 types for external encrypted inputs (Solidity: externalEbool, externalEuint*, externalEaddress).
170
+ * The readonly `utype` field brands each hash so it can't be accidentally passed to the wrong asE* function.
171
+ */
172
+ type ExternalBoolHash = `0x${string}` & {
173
+ readonly utype: FheTypes.Bool;
174
+ };
175
+ type ExternalUint8Hash = `0x${string}` & {
176
+ readonly utype: FheTypes.Uint8;
177
+ };
178
+ type ExternalUint16Hash = `0x${string}` & {
179
+ readonly utype: FheTypes.Uint16;
180
+ };
181
+ type ExternalUint32Hash = `0x${string}` & {
182
+ readonly utype: FheTypes.Uint32;
183
+ };
184
+ type ExternalUint64Hash = `0x${string}` & {
185
+ readonly utype: FheTypes.Uint64;
186
+ };
187
+ type ExternalUint128Hash = `0x${string}` & {
188
+ readonly utype: FheTypes.Uint128;
189
+ };
190
+ type ExternalAddressHash = `0x${string}` & {
191
+ readonly utype: FheTypes.Uint160;
192
+ };
193
+ /** Branded bytes proof blob (Solidity: bytes memory proof). */
194
+ type ExternalHashProof = `0x${string}` & {
195
+ readonly _kind: 'ExternalHashProof';
196
+ };
197
+ /** Union of all External*Hash types — useful for utilities that operate on any hash without caring about the specific FHE type. */
198
+ type AnyExternalHash = ExternalBoolHash | ExternalUint8Hash | ExternalUint16Hash | ExternalUint32Hash | ExternalUint64Hash | ExternalUint128Hash | ExternalAddressHash;
199
+ /**
200
+ * Maps a single EncryptableItem to its corresponding External*Hash type.
201
+ * Mirrors EncryptableToEncryptedItemInputMap.
202
+ */
203
+ 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
+ /**
205
+ * Maps an EncryptableItem[] tuple to a tuple of corresponding External*Hash types,
206
+ * preserving index positions. e.g. [EncryptableBool, EncryptableUint32] → [ExternalBoolHash, ExternalUint32Hash]
207
+ */
208
+ type ExternalItemHashes<T extends EncryptableItem[]> = {
209
+ [K in keyof T]: T[K] extends EncryptableItem ? EncryptableToExternalHashMap<T[K]> : never;
210
+ };
211
+ /**
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.
214
+ * e.g. [Encryptable.bool(true), Encryptable.uint32(5)] → [ExternalBoolHash, ExternalUint32Hash, ExternalHashProof]
215
+ */
216
+ type HashPlusProofResult<T extends EncryptableItem[]> = [...ExternalItemHashes<T>, ExternalHashProof];
168
217
  type DecryptEndpoint = 'decrypt' | 'sealoutput';
169
218
  type DecryptPollCallbackContext = {
170
219
  operation: DecryptEndpoint;
@@ -371,6 +420,7 @@ declare class DecryptForViewBuilder<U extends FheTypes> extends BaseBuilder {
371
420
  private permitHash?;
372
421
  private permit?;
373
422
  private pollCallback?;
423
+ private retry404TimeoutMs;
374
424
  constructor(params: DecryptForViewBuilderParams<U>);
375
425
  /**
376
426
  * @param chainId - Chain to decrypt values from. Used to fetch the threshold network URL and use the correct permit.
@@ -405,6 +455,7 @@ declare class DecryptForViewBuilder<U extends FheTypes> extends BaseBuilder {
405
455
  setAccount(account: string): DecryptForViewBuilder<U>;
406
456
  getAccount(): string | undefined;
407
457
  onPoll(callback: DecryptPollCallbackFunction): DecryptForViewBuilder<U>;
458
+ set404RetryTimeout(timeoutMs: number): DecryptForViewBuilder<U>;
408
459
  /**
409
460
  * Select "use permit" mode (optional).
410
461
  *
@@ -507,6 +558,7 @@ declare class DecryptForTxBuilder extends BaseBuilder {
507
558
  private permit?;
508
559
  private permitSelection;
509
560
  private pollCallback?;
561
+ private retry404TimeoutMs;
510
562
  constructor(params: DecryptForTxBuilderParams);
511
563
  /**
512
564
  * @param chainId - Chain to decrypt values from. Used to fetch the threshold network URL and use the correct permit.
@@ -544,6 +596,8 @@ declare class DecryptForTxBuilder extends BaseBuilder {
544
596
  getAccount(): string | undefined;
545
597
  onPoll(this: DecryptForTxBuilderUnset, callback: DecryptPollCallbackFunction): DecryptForTxBuilderUnset;
546
598
  onPoll(this: DecryptForTxBuilderSelected, callback: DecryptPollCallbackFunction): DecryptForTxBuilderSelected;
599
+ set404RetryTimeout(this: DecryptForTxBuilderUnset, timeoutMs: number): DecryptForTxBuilderUnset;
600
+ set404RetryTimeout(this: DecryptForTxBuilderSelected, timeoutMs: number): DecryptForTxBuilderSelected;
547
601
  /**
548
602
  * Select "use permit" mode.
549
603
  *
@@ -697,10 +751,11 @@ type EncryptInputsBuilderParams<T extends EncryptableItem[]> = BaseBuilderParams
697
751
  * account, securityZone, and chainId can be overridden in the builder.
698
752
  * config, tfhePublicKeyDeserializer, compactPkeCrsDeserializer, and zkBuilderAndCrsGenerator are required to be set in the builder.
699
753
  */
700
- declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuilder {
754
+ declare class EncryptInputsBuilder<T extends EncryptableItem[], HPP extends boolean = false> extends BaseBuilder {
701
755
  private securityZone;
702
756
  private stepCallback?;
703
757
  private inputItems;
758
+ private hpp;
704
759
  private zkvWalletClient;
705
760
  private tfhePublicKeyDeserializer;
706
761
  private compactPkeCrsDeserializer;
@@ -725,7 +780,7 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuil
725
780
  *
726
781
  * @returns The chainable EncryptInputsBuilder instance.
727
782
  */
728
- setAccount(account: string): EncryptInputsBuilder<T>;
783
+ setAccount(account: string): EncryptInputsBuilder<T, HPP>;
729
784
  getAccount(): string | undefined;
730
785
  /**
731
786
  * @param chainId - Chain that will consume the encrypted inputs.
@@ -741,7 +796,7 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuil
741
796
  *
742
797
  * @returns The chainable EncryptInputsBuilder instance.
743
798
  */
744
- setChainId(chainId: number): EncryptInputsBuilder<T>;
799
+ setChainId(chainId: number): EncryptInputsBuilder<T, HPP>;
745
800
  getChainId(): number | undefined;
746
801
  /**
747
802
  * @param securityZone - Security zone to encrypt the inputs for.
@@ -757,8 +812,19 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuil
757
812
  *
758
813
  * @returns The chainable EncryptInputsBuilder instance.
759
814
  */
760
- setSecurityZone(securityZone: number): EncryptInputsBuilder<T>;
815
+ setSecurityZone(securityZone: number): EncryptInputsBuilder<T, HPP>;
761
816
  getSecurityZone(): number;
817
+ /**
818
+ * Example:
819
+ * ```typescript
820
+ * const encrypted = await encryptInputs([Encryptable.uint128(10n)])
821
+ * .asHashPlusProof()
822
+ * .execute();
823
+ * ```
824
+ *
825
+ * @returns Chainable EncryptInputsBuilder instance that will return a HashPlusProofResult instead of an array of EncryptedItemInputs.
826
+ */
827
+ asHashPlusProof(): EncryptInputsBuilder<T, true>;
762
828
  /**
763
829
  * @param useWorker - Whether to use Web Workers for ZK proof generation.
764
830
  *
@@ -773,7 +839,7 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuil
773
839
  *
774
840
  * @returns The chainable EncryptInputsBuilder instance.
775
841
  */
776
- setUseWorker(useWorker: boolean): EncryptInputsBuilder<T>;
842
+ setUseWorker(useWorker: boolean): EncryptInputsBuilder<T, HPP>;
777
843
  /**
778
844
  * Gets the current worker configuration.
779
845
  *
@@ -803,7 +869,7 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuil
803
869
  *
804
870
  * @returns The EncryptInputsBuilder instance.
805
871
  */
806
- onStep(callback: EncryptStepCallbackFunction): EncryptInputsBuilder<T>;
872
+ onStep(callback: EncryptStepCallbackFunction): EncryptInputsBuilder<T, HPP>;
807
873
  getStepCallback(): EncryptStepCallbackFunction | undefined;
808
874
  /**
809
875
  * Fires the step callback if set
@@ -844,6 +910,7 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuil
844
910
  * In the production context, perform a true encryption with the CoFHE coprocessor.
845
911
  */
846
912
  private productionExecute;
913
+ private structsToHashPlusProof;
847
914
  /**
848
915
  * Final step of the encryption process. MUST BE CALLED LAST IN THE CHAIN.
849
916
  *
@@ -863,7 +930,7 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuil
863
930
  *
864
931
  * @returns The encrypted inputs.
865
932
  */
866
- execute(): Promise<[...EncryptedItemInputs<T>]>;
933
+ execute(): Promise<HPP extends true ? HashPlusProofResult<T> : [...EncryptedItemInputs<T>]>;
867
934
  }
868
935
 
869
936
  declare const permits: {
@@ -996,4 +1063,4 @@ type CofheClientParams<TConfig extends CofheConfig> = {
996
1063
  zkProveWorkerFn?: ZkProveWorkerFunction;
997
1064
  };
998
1065
 
999
- export { DecryptForTxBuilder as $, type FheTypeValue as A, type DecryptPollCallbackContext as B, type CofheInputConfig as C, type DecryptPollCallbackFunction as D, type EncryptableItem as E, FheTypes as F, type DecryptEndpoint as G, type EncryptStepCallbackFunction as H, type IStorage as I, type EncryptStepCallbackContext as J, FheUintUTypes as K, type LiteralToPrimitive as L, FheAllUTypes as M, Encryptable as N, isEncryptableItem as O, type Primitive as P, EncryptStep as Q, isLastEncryptionStep as R, assertCorrectEncryptedItemInput as S, fetchKeys as T, type UnsealedItem as U, type FheKeyDeserializer as V, createKeysStore as W, type KeysStorage as X, type KeysStore as Y, EncryptInputsBuilder as Z, DecryptForViewBuilder as _, type CofheConfig as a, type DecryptForTxResult as a0, type ZkBuilderAndCrsGenerator as a1, type ZkProveWorkerFunction as a2, type ZkProveWorkerRequest as a3, type ZkProveWorkerResponse as a4, zkProveWithWorker as a5, 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 };
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 };
@@ -59,13 +59,13 @@ type EncryptedNumber = {
59
59
  data: Uint8Array;
60
60
  securityZone: number;
61
61
  };
62
- type EncryptedItemInput<TSignature = string> = {
62
+ type EncryptedItemInput = {
63
63
  ctHash: bigint;
64
64
  securityZone: number;
65
65
  utype: FheTypes;
66
- signature: TSignature;
66
+ signature: `0x${string}`;
67
67
  };
68
- declare function assertCorrectEncryptedItemInput(input: EncryptedItemInput): asserts input is EncryptedItemInput<`0x${string}`>;
68
+ declare function assertCorrectEncryptedItemInput(input: EncryptedItemInput): asserts input is EncryptedItemInput;
69
69
  type EncryptedBoolInput = EncryptedItemInput & {
70
70
  utype: FheTypes.Bool;
71
71
  };
@@ -165,6 +165,55 @@ type EncryptStepCallbackContext = Record<string, any> & {
165
165
  duration: number;
166
166
  };
167
167
  type EncryptStepCallbackFunction = (state: EncryptStep, context?: EncryptStepCallbackContext) => void;
168
+ /**
169
+ * Branded bytes32 types for external encrypted inputs (Solidity: externalEbool, externalEuint*, externalEaddress).
170
+ * The readonly `utype` field brands each hash so it can't be accidentally passed to the wrong asE* function.
171
+ */
172
+ type ExternalBoolHash = `0x${string}` & {
173
+ readonly utype: FheTypes.Bool;
174
+ };
175
+ type ExternalUint8Hash = `0x${string}` & {
176
+ readonly utype: FheTypes.Uint8;
177
+ };
178
+ type ExternalUint16Hash = `0x${string}` & {
179
+ readonly utype: FheTypes.Uint16;
180
+ };
181
+ type ExternalUint32Hash = `0x${string}` & {
182
+ readonly utype: FheTypes.Uint32;
183
+ };
184
+ type ExternalUint64Hash = `0x${string}` & {
185
+ readonly utype: FheTypes.Uint64;
186
+ };
187
+ type ExternalUint128Hash = `0x${string}` & {
188
+ readonly utype: FheTypes.Uint128;
189
+ };
190
+ type ExternalAddressHash = `0x${string}` & {
191
+ readonly utype: FheTypes.Uint160;
192
+ };
193
+ /** Branded bytes proof blob (Solidity: bytes memory proof). */
194
+ type ExternalHashProof = `0x${string}` & {
195
+ readonly _kind: 'ExternalHashProof';
196
+ };
197
+ /** Union of all External*Hash types — useful for utilities that operate on any hash without caring about the specific FHE type. */
198
+ type AnyExternalHash = ExternalBoolHash | ExternalUint8Hash | ExternalUint16Hash | ExternalUint32Hash | ExternalUint64Hash | ExternalUint128Hash | ExternalAddressHash;
199
+ /**
200
+ * Maps a single EncryptableItem to its corresponding External*Hash type.
201
+ * Mirrors EncryptableToEncryptedItemInputMap.
202
+ */
203
+ 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
+ /**
205
+ * Maps an EncryptableItem[] tuple to a tuple of corresponding External*Hash types,
206
+ * preserving index positions. e.g. [EncryptableBool, EncryptableUint32] → [ExternalBoolHash, ExternalUint32Hash]
207
+ */
208
+ type ExternalItemHashes<T extends EncryptableItem[]> = {
209
+ [K in keyof T]: T[K] extends EncryptableItem ? EncryptableToExternalHashMap<T[K]> : never;
210
+ };
211
+ /**
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.
214
+ * e.g. [Encryptable.bool(true), Encryptable.uint32(5)] → [ExternalBoolHash, ExternalUint32Hash, ExternalHashProof]
215
+ */
216
+ type HashPlusProofResult<T extends EncryptableItem[]> = [...ExternalItemHashes<T>, ExternalHashProof];
168
217
  type DecryptEndpoint = 'decrypt' | 'sealoutput';
169
218
  type DecryptPollCallbackContext = {
170
219
  operation: DecryptEndpoint;
@@ -371,6 +420,7 @@ declare class DecryptForViewBuilder<U extends FheTypes> extends BaseBuilder {
371
420
  private permitHash?;
372
421
  private permit?;
373
422
  private pollCallback?;
423
+ private retry404TimeoutMs;
374
424
  constructor(params: DecryptForViewBuilderParams<U>);
375
425
  /**
376
426
  * @param chainId - Chain to decrypt values from. Used to fetch the threshold network URL and use the correct permit.
@@ -405,6 +455,7 @@ declare class DecryptForViewBuilder<U extends FheTypes> extends BaseBuilder {
405
455
  setAccount(account: string): DecryptForViewBuilder<U>;
406
456
  getAccount(): string | undefined;
407
457
  onPoll(callback: DecryptPollCallbackFunction): DecryptForViewBuilder<U>;
458
+ set404RetryTimeout(timeoutMs: number): DecryptForViewBuilder<U>;
408
459
  /**
409
460
  * Select "use permit" mode (optional).
410
461
  *
@@ -507,6 +558,7 @@ declare class DecryptForTxBuilder extends BaseBuilder {
507
558
  private permit?;
508
559
  private permitSelection;
509
560
  private pollCallback?;
561
+ private retry404TimeoutMs;
510
562
  constructor(params: DecryptForTxBuilderParams);
511
563
  /**
512
564
  * @param chainId - Chain to decrypt values from. Used to fetch the threshold network URL and use the correct permit.
@@ -544,6 +596,8 @@ declare class DecryptForTxBuilder extends BaseBuilder {
544
596
  getAccount(): string | undefined;
545
597
  onPoll(this: DecryptForTxBuilderUnset, callback: DecryptPollCallbackFunction): DecryptForTxBuilderUnset;
546
598
  onPoll(this: DecryptForTxBuilderSelected, callback: DecryptPollCallbackFunction): DecryptForTxBuilderSelected;
599
+ set404RetryTimeout(this: DecryptForTxBuilderUnset, timeoutMs: number): DecryptForTxBuilderUnset;
600
+ set404RetryTimeout(this: DecryptForTxBuilderSelected, timeoutMs: number): DecryptForTxBuilderSelected;
547
601
  /**
548
602
  * Select "use permit" mode.
549
603
  *
@@ -697,10 +751,11 @@ type EncryptInputsBuilderParams<T extends EncryptableItem[]> = BaseBuilderParams
697
751
  * account, securityZone, and chainId can be overridden in the builder.
698
752
  * config, tfhePublicKeyDeserializer, compactPkeCrsDeserializer, and zkBuilderAndCrsGenerator are required to be set in the builder.
699
753
  */
700
- declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuilder {
754
+ declare class EncryptInputsBuilder<T extends EncryptableItem[], HPP extends boolean = false> extends BaseBuilder {
701
755
  private securityZone;
702
756
  private stepCallback?;
703
757
  private inputItems;
758
+ private hpp;
704
759
  private zkvWalletClient;
705
760
  private tfhePublicKeyDeserializer;
706
761
  private compactPkeCrsDeserializer;
@@ -725,7 +780,7 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuil
725
780
  *
726
781
  * @returns The chainable EncryptInputsBuilder instance.
727
782
  */
728
- setAccount(account: string): EncryptInputsBuilder<T>;
783
+ setAccount(account: string): EncryptInputsBuilder<T, HPP>;
729
784
  getAccount(): string | undefined;
730
785
  /**
731
786
  * @param chainId - Chain that will consume the encrypted inputs.
@@ -741,7 +796,7 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuil
741
796
  *
742
797
  * @returns The chainable EncryptInputsBuilder instance.
743
798
  */
744
- setChainId(chainId: number): EncryptInputsBuilder<T>;
799
+ setChainId(chainId: number): EncryptInputsBuilder<T, HPP>;
745
800
  getChainId(): number | undefined;
746
801
  /**
747
802
  * @param securityZone - Security zone to encrypt the inputs for.
@@ -757,8 +812,19 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuil
757
812
  *
758
813
  * @returns The chainable EncryptInputsBuilder instance.
759
814
  */
760
- setSecurityZone(securityZone: number): EncryptInputsBuilder<T>;
815
+ setSecurityZone(securityZone: number): EncryptInputsBuilder<T, HPP>;
761
816
  getSecurityZone(): number;
817
+ /**
818
+ * Example:
819
+ * ```typescript
820
+ * const encrypted = await encryptInputs([Encryptable.uint128(10n)])
821
+ * .asHashPlusProof()
822
+ * .execute();
823
+ * ```
824
+ *
825
+ * @returns Chainable EncryptInputsBuilder instance that will return a HashPlusProofResult instead of an array of EncryptedItemInputs.
826
+ */
827
+ asHashPlusProof(): EncryptInputsBuilder<T, true>;
762
828
  /**
763
829
  * @param useWorker - Whether to use Web Workers for ZK proof generation.
764
830
  *
@@ -773,7 +839,7 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuil
773
839
  *
774
840
  * @returns The chainable EncryptInputsBuilder instance.
775
841
  */
776
- setUseWorker(useWorker: boolean): EncryptInputsBuilder<T>;
842
+ setUseWorker(useWorker: boolean): EncryptInputsBuilder<T, HPP>;
777
843
  /**
778
844
  * Gets the current worker configuration.
779
845
  *
@@ -803,7 +869,7 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuil
803
869
  *
804
870
  * @returns The EncryptInputsBuilder instance.
805
871
  */
806
- onStep(callback: EncryptStepCallbackFunction): EncryptInputsBuilder<T>;
872
+ onStep(callback: EncryptStepCallbackFunction): EncryptInputsBuilder<T, HPP>;
807
873
  getStepCallback(): EncryptStepCallbackFunction | undefined;
808
874
  /**
809
875
  * Fires the step callback if set
@@ -844,6 +910,7 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuil
844
910
  * In the production context, perform a true encryption with the CoFHE coprocessor.
845
911
  */
846
912
  private productionExecute;
913
+ private structsToHashPlusProof;
847
914
  /**
848
915
  * Final step of the encryption process. MUST BE CALLED LAST IN THE CHAIN.
849
916
  *
@@ -863,7 +930,7 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuil
863
930
  *
864
931
  * @returns The encrypted inputs.
865
932
  */
866
- execute(): Promise<[...EncryptedItemInputs<T>]>;
933
+ execute(): Promise<HPP extends true ? HashPlusProofResult<T> : [...EncryptedItemInputs<T>]>;
867
934
  }
868
935
 
869
936
  declare const permits: {
@@ -996,4 +1063,4 @@ type CofheClientParams<TConfig extends CofheConfig> = {
996
1063
  zkProveWorkerFn?: ZkProveWorkerFunction;
997
1064
  };
998
1065
 
999
- export { DecryptForTxBuilder as $, type FheTypeValue as A, type DecryptPollCallbackContext as B, type CofheInputConfig as C, type DecryptPollCallbackFunction as D, type EncryptableItem as E, FheTypes as F, type DecryptEndpoint as G, type EncryptStepCallbackFunction as H, type IStorage as I, type EncryptStepCallbackContext as J, FheUintUTypes as K, type LiteralToPrimitive as L, FheAllUTypes as M, Encryptable as N, isEncryptableItem as O, type Primitive as P, EncryptStep as Q, isLastEncryptionStep as R, assertCorrectEncryptedItemInput as S, fetchKeys as T, type UnsealedItem as U, type FheKeyDeserializer as V, createKeysStore as W, type KeysStorage as X, type KeysStore as Y, EncryptInputsBuilder as Z, DecryptForViewBuilder as _, type CofheConfig as a, type DecryptForTxResult as a0, type ZkBuilderAndCrsGenerator as a1, type ZkProveWorkerFunction as a2, type ZkProveWorkerRequest as a3, type ZkProveWorkerResponse as a4, zkProveWithWorker as a5, 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 };
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 };