@cofhe/sdk 0.5.2 → 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.
@@ -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;
@@ -702,10 +751,11 @@ type EncryptInputsBuilderParams<T extends EncryptableItem[]> = BaseBuilderParams
702
751
  * account, securityZone, and chainId can be overridden in the builder.
703
752
  * config, tfhePublicKeyDeserializer, compactPkeCrsDeserializer, and zkBuilderAndCrsGenerator are required to be set in the builder.
704
753
  */
705
- declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuilder {
754
+ declare class EncryptInputsBuilder<T extends EncryptableItem[], HPP extends boolean = false> extends BaseBuilder {
706
755
  private securityZone;
707
756
  private stepCallback?;
708
757
  private inputItems;
758
+ private hpp;
709
759
  private zkvWalletClient;
710
760
  private tfhePublicKeyDeserializer;
711
761
  private compactPkeCrsDeserializer;
@@ -730,7 +780,7 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuil
730
780
  *
731
781
  * @returns The chainable EncryptInputsBuilder instance.
732
782
  */
733
- setAccount(account: string): EncryptInputsBuilder<T>;
783
+ setAccount(account: string): EncryptInputsBuilder<T, HPP>;
734
784
  getAccount(): string | undefined;
735
785
  /**
736
786
  * @param chainId - Chain that will consume the encrypted inputs.
@@ -746,7 +796,7 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuil
746
796
  *
747
797
  * @returns The chainable EncryptInputsBuilder instance.
748
798
  */
749
- setChainId(chainId: number): EncryptInputsBuilder<T>;
799
+ setChainId(chainId: number): EncryptInputsBuilder<T, HPP>;
750
800
  getChainId(): number | undefined;
751
801
  /**
752
802
  * @param securityZone - Security zone to encrypt the inputs for.
@@ -762,8 +812,19 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuil
762
812
  *
763
813
  * @returns The chainable EncryptInputsBuilder instance.
764
814
  */
765
- setSecurityZone(securityZone: number): EncryptInputsBuilder<T>;
815
+ setSecurityZone(securityZone: number): EncryptInputsBuilder<T, HPP>;
766
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>;
767
828
  /**
768
829
  * @param useWorker - Whether to use Web Workers for ZK proof generation.
769
830
  *
@@ -778,7 +839,7 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuil
778
839
  *
779
840
  * @returns The chainable EncryptInputsBuilder instance.
780
841
  */
781
- setUseWorker(useWorker: boolean): EncryptInputsBuilder<T>;
842
+ setUseWorker(useWorker: boolean): EncryptInputsBuilder<T, HPP>;
782
843
  /**
783
844
  * Gets the current worker configuration.
784
845
  *
@@ -808,7 +869,7 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuil
808
869
  *
809
870
  * @returns The EncryptInputsBuilder instance.
810
871
  */
811
- onStep(callback: EncryptStepCallbackFunction): EncryptInputsBuilder<T>;
872
+ onStep(callback: EncryptStepCallbackFunction): EncryptInputsBuilder<T, HPP>;
812
873
  getStepCallback(): EncryptStepCallbackFunction | undefined;
813
874
  /**
814
875
  * Fires the step callback if set
@@ -849,6 +910,7 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuil
849
910
  * In the production context, perform a true encryption with the CoFHE coprocessor.
850
911
  */
851
912
  private productionExecute;
913
+ private structsToHashPlusProof;
852
914
  /**
853
915
  * Final step of the encryption process. MUST BE CALLED LAST IN THE CHAIN.
854
916
  *
@@ -868,7 +930,7 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuil
868
930
  *
869
931
  * @returns The encrypted inputs.
870
932
  */
871
- execute(): Promise<[...EncryptedItemInputs<T>]>;
933
+ execute(): Promise<HPP extends true ? HashPlusProofResult<T> : [...EncryptedItemInputs<T>]>;
872
934
  }
873
935
 
874
936
  declare const permits: {
@@ -1001,4 +1063,4 @@ type CofheClientParams<TConfig extends CofheConfig> = {
1001
1063
  zkProveWorkerFn?: ZkProveWorkerFunction;
1002
1064
  };
1003
1065
 
1004
- 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;
@@ -702,10 +751,11 @@ type EncryptInputsBuilderParams<T extends EncryptableItem[]> = BaseBuilderParams
702
751
  * account, securityZone, and chainId can be overridden in the builder.
703
752
  * config, tfhePublicKeyDeserializer, compactPkeCrsDeserializer, and zkBuilderAndCrsGenerator are required to be set in the builder.
704
753
  */
705
- declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuilder {
754
+ declare class EncryptInputsBuilder<T extends EncryptableItem[], HPP extends boolean = false> extends BaseBuilder {
706
755
  private securityZone;
707
756
  private stepCallback?;
708
757
  private inputItems;
758
+ private hpp;
709
759
  private zkvWalletClient;
710
760
  private tfhePublicKeyDeserializer;
711
761
  private compactPkeCrsDeserializer;
@@ -730,7 +780,7 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuil
730
780
  *
731
781
  * @returns The chainable EncryptInputsBuilder instance.
732
782
  */
733
- setAccount(account: string): EncryptInputsBuilder<T>;
783
+ setAccount(account: string): EncryptInputsBuilder<T, HPP>;
734
784
  getAccount(): string | undefined;
735
785
  /**
736
786
  * @param chainId - Chain that will consume the encrypted inputs.
@@ -746,7 +796,7 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuil
746
796
  *
747
797
  * @returns The chainable EncryptInputsBuilder instance.
748
798
  */
749
- setChainId(chainId: number): EncryptInputsBuilder<T>;
799
+ setChainId(chainId: number): EncryptInputsBuilder<T, HPP>;
750
800
  getChainId(): number | undefined;
751
801
  /**
752
802
  * @param securityZone - Security zone to encrypt the inputs for.
@@ -762,8 +812,19 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuil
762
812
  *
763
813
  * @returns The chainable EncryptInputsBuilder instance.
764
814
  */
765
- setSecurityZone(securityZone: number): EncryptInputsBuilder<T>;
815
+ setSecurityZone(securityZone: number): EncryptInputsBuilder<T, HPP>;
766
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>;
767
828
  /**
768
829
  * @param useWorker - Whether to use Web Workers for ZK proof generation.
769
830
  *
@@ -778,7 +839,7 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuil
778
839
  *
779
840
  * @returns The chainable EncryptInputsBuilder instance.
780
841
  */
781
- setUseWorker(useWorker: boolean): EncryptInputsBuilder<T>;
842
+ setUseWorker(useWorker: boolean): EncryptInputsBuilder<T, HPP>;
782
843
  /**
783
844
  * Gets the current worker configuration.
784
845
  *
@@ -808,7 +869,7 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuil
808
869
  *
809
870
  * @returns The EncryptInputsBuilder instance.
810
871
  */
811
- onStep(callback: EncryptStepCallbackFunction): EncryptInputsBuilder<T>;
872
+ onStep(callback: EncryptStepCallbackFunction): EncryptInputsBuilder<T, HPP>;
812
873
  getStepCallback(): EncryptStepCallbackFunction | undefined;
813
874
  /**
814
875
  * Fires the step callback if set
@@ -849,6 +910,7 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuil
849
910
  * In the production context, perform a true encryption with the CoFHE coprocessor.
850
911
  */
851
912
  private productionExecute;
913
+ private structsToHashPlusProof;
852
914
  /**
853
915
  * Final step of the encryption process. MUST BE CALLED LAST IN THE CHAIN.
854
916
  *
@@ -868,7 +930,7 @@ declare class EncryptInputsBuilder<T extends EncryptableItem[]> extends BaseBuil
868
930
  *
869
931
  * @returns The encrypted inputs.
870
932
  */
871
- execute(): Promise<[...EncryptedItemInputs<T>]>;
933
+ execute(): Promise<HPP extends true ? HashPlusProofResult<T> : [...EncryptedItemInputs<T>]>;
872
934
  }
873
935
 
874
936
  declare const permits: {
@@ -1001,4 +1063,4 @@ type CofheClientParams<TConfig extends CofheConfig> = {
1001
1063
  zkProveWorkerFn?: ZkProveWorkerFunction;
1002
1064
  };
1003
1065
 
1004
- 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 };
package/dist/core.cjs CHANGED
@@ -154,7 +154,6 @@ var isCofheError = (error) => error instanceof CofheError;
154
154
  var TASK_MANAGER_ADDRESS = "0xeA30c4B8b44078Bbf8a6ef5b9f1eC1626C7848D9";
155
155
  var MOCKS_ZK_VERIFIER_ADDRESS = "0x0000000000000000000000000000000000005001";
156
156
  var MOCKS_THRESHOLD_NETWORK_ADDRESS = "0x0000000000000000000000000000000000005002";
157
- var TEST_BED_ADDRESS = "0x0000000000000000000000000000000000005003";
158
157
  var MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY = "0x6C8D7F768A6BB4AAFE85E8A2F5A9680355239C7E14646ED62B044E39DE154512";
159
158
  var MOCKS_ZK_VERIFIER_SIGNER_ADDRESS = "0x6E12D8C87503D4287c294f2Fdef96ACd9DFf6bd2";
160
159
  var MOCKS_DECRYPT_RESULT_SIGNER_PRIVATE_KEY = "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d";
@@ -546,7 +545,7 @@ var zkVerify = async (verifierUrl, serializedBytes, address, securityZone, chain
546
545
  }
547
546
  };
548
547
  var concatSigRecid = (signature, recid) => {
549
- return signature + (recid + 27).toString(16).padStart(2, "0");
548
+ return `${signature}${(recid + 27).toString(16).padStart(2, "0")}`;
550
549
  };
551
550
 
552
551
  // core/encrypt/MockZkVerifierAbi.ts
@@ -878,9 +877,9 @@ var hardhat2 = defineChain({
878
877
  name: "Hardhat",
879
878
  network: "localhost",
880
879
  // These are unused in the mock environment
881
- coFheUrl: "http://127.0.0.1:8448",
882
- verifierUrl: "http://127.0.0.1:3001",
883
- thresholdNetworkUrl: "http://127.0.0.1:3000",
880
+ coFheUrl: "http://ignored-in-mock-environment",
881
+ verifierUrl: "http://ignored-in-mock-environment",
882
+ thresholdNetworkUrl: "http://ignored-in-mock-environment",
884
883
  environment: "MOCK"
885
884
  });
886
885
  var CofheConfigSchema = zod.z.object({
@@ -1269,6 +1268,7 @@ var EncryptInputsBuilder = class extends BaseBuilder {
1269
1268
  securityZone;
1270
1269
  stepCallback;
1271
1270
  inputItems;
1271
+ hpp = false;
1272
1272
  zkvWalletClient;
1273
1273
  tfhePublicKeyDeserializer;
1274
1274
  compactPkeCrsDeserializer;
@@ -1398,6 +1398,20 @@ var EncryptInputsBuilder = class extends BaseBuilder {
1398
1398
  getSecurityZone() {
1399
1399
  return this.securityZone;
1400
1400
  }
1401
+ /**
1402
+ * Example:
1403
+ * ```typescript
1404
+ * const encrypted = await encryptInputs([Encryptable.uint128(10n)])
1405
+ * .asHashPlusProof()
1406
+ * .execute();
1407
+ * ```
1408
+ *
1409
+ * @returns Chainable EncryptInputsBuilder instance that will return a HashPlusProofResult instead of an array of EncryptedItemInputs.
1410
+ */
1411
+ asHashPlusProof() {
1412
+ this.hpp = true;
1413
+ return this;
1414
+ }
1401
1415
  /**
1402
1416
  * @param useWorker - Whether to use Web Workers for ZK proof generation.
1403
1417
  *
@@ -1679,6 +1693,15 @@ var EncryptInputsBuilder = class extends BaseBuilder {
1679
1693
  this.fireStepEnd("verify" /* Verify */);
1680
1694
  return encryptedInputs;
1681
1695
  }
1696
+ structsToHashPlusProof(inItems) {
1697
+ let hashes = [];
1698
+ let proof = "";
1699
+ for (const item of inItems) {
1700
+ hashes.push("0x" + item.ctHash.toString(16).padStart(64, "0"));
1701
+ proof += item.signature;
1702
+ }
1703
+ return [...hashes, proof];
1704
+ }
1682
1705
  /**
1683
1706
  * Final step of the encryption process. MUST BE CALLED LAST IN THE CHAIN.
1684
1707
  *
@@ -1699,9 +1722,14 @@ var EncryptInputsBuilder = class extends BaseBuilder {
1699
1722
  * @returns The encrypted inputs.
1700
1723
  */
1701
1724
  async execute() {
1725
+ let items;
1702
1726
  if (this.chainId === chains.hardhat.id)
1703
- return this.mocksExecute();
1704
- return this.productionExecute();
1727
+ items = await this.mocksExecute();
1728
+ else
1729
+ items = await this.productionExecute();
1730
+ if (this.hpp)
1731
+ return this.structsToHashPlusProof(items);
1732
+ return items;
1705
1733
  }
1706
1734
  };
1707
1735
 
@@ -4644,7 +4672,6 @@ exports.MOCKS_ZK_VERIFIER_ADDRESS = MOCKS_ZK_VERIFIER_ADDRESS;
4644
4672
  exports.MOCKS_ZK_VERIFIER_SIGNER_ADDRESS = MOCKS_ZK_VERIFIER_SIGNER_ADDRESS;
4645
4673
  exports.MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY = MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY;
4646
4674
  exports.TASK_MANAGER_ADDRESS = TASK_MANAGER_ADDRESS;
4647
- exports.TEST_BED_ADDRESS = TEST_BED_ADDRESS;
4648
4675
  exports.TFHE_RS_SAFE_SERIALIZATION_SIZE_LIMIT = TFHE_RS_SAFE_SERIALIZATION_SIZE_LIMIT;
4649
4676
  exports.TFHE_RS_ZK_MAX_BITS = TFHE_RS_ZK_MAX_BITS;
4650
4677
  exports.assertCorrectEncryptedItemInput = assertCorrectEncryptedItemInput;
package/dist/core.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as CofheConfig, c as CofheClientParams, b as CofheClient, d as CofheClientConnectionState, F as FheTypes } from './clientTypes-BJbFeeno.cjs';
2
- export { h as CofheClientPermits, C as CofheInputConfig, f as CofheInternalConfig, G as DecryptEndpoint, $ as DecryptForTxBuilder, a0 as DecryptForTxResult, _ as DecryptForViewBuilder, B as DecryptPollCallbackContext, D as DecryptPollCallbackFunction, Z as EncryptInputsBuilder, H as EncryptSetStateFn, Q as EncryptStep, J as EncryptStepCallbackContext, N as Encryptable, o as EncryptableAddress, i as EncryptableBool, E as EncryptableItem, z as EncryptableToEncryptedItemInputMap, n as EncryptableUint128, k as EncryptableUint16, l as EncryptableUint32, m as EncryptableUint64, j as EncryptableUint8, x as EncryptedAddressInput, r as EncryptedBoolInput, q as EncryptedItemInput, y as EncryptedItemInputs, p as EncryptedNumber, w as EncryptedUint128Input, t as EncryptedUint16Input, u as EncryptedUint32Input, v as EncryptedUint64Input, s as EncryptedUint8Input, M as FheAllUTypes, V as FheKeyDeserializer, A as FheTypeValue, K as FheUintUTypes, I as IStorage, X as KeysStorage, Y as KeysStore, L as LiteralToPrimitive, P as Primitive, U as UnsealedItem, a1 as ZkBuilderAndCrsGenerator, a2 as ZkProveWorkerFunction, a3 as ZkProveWorkerRequest, a4 as ZkProveWorkerResponse, S as assertCorrectEncryptedItemInput, e as createCofheConfigBase, W as createKeysStore, T as fetchKeys, g as getCofheConfigItem, O as isEncryptableItem, R as isLastEncryptionStep, a5 as zkProveWithWorker } from './clientTypes-BJbFeeno.cjs';
1
+ import { a as CofheConfig, c as CofheClientParams, b as CofheClient, d as CofheClientConnectionState, F as FheTypes } from './clientTypes-BDy1qIBu.cjs';
2
+ export { O as AnyExternalHash, h as CofheClientPermits, C as CofheInputConfig, f as CofheInternalConfig, W as DecryptEndpoint, ab as DecryptForTxBuilder, ac as DecryptForTxResult, aa as DecryptForViewBuilder, V as DecryptPollCallbackContext, T as DecryptPollCallbackFunction, a9 as EncryptInputsBuilder, X as EncryptSetStateFn, a1 as EncryptStep, Y as EncryptStepCallbackContext, $ as Encryptable, o as EncryptableAddress, i as EncryptableBool, E as EncryptableItem, z as EncryptableToEncryptedItemInputMap, Q as EncryptableToExternalHashMap, n as EncryptableUint128, k as EncryptableUint16, l as EncryptableUint32, m as EncryptableUint64, j as EncryptableUint8, x as EncryptedAddressInput, r as EncryptedBoolInput, q as EncryptedItemInput, y as EncryptedItemInputs, p as EncryptedNumber, w as EncryptedUint128Input, t as EncryptedUint16Input, u as EncryptedUint32Input, v as EncryptedUint64Input, s as EncryptedUint8Input, M as ExternalAddressHash, B as ExternalBoolHash, N as ExternalHashProof, R as ExternalItemHashes, K as ExternalUint128Hash, G as ExternalUint16Hash, H as ExternalUint32Hash, J as ExternalUint64Hash, D as ExternalUint8Hash, _ as FheAllUTypes, a5 as FheKeyDeserializer, A as FheTypeValue, Z as FheUintUTypes, S as HashPlusProofResult, I as IStorage, a7 as KeysStorage, a8 as KeysStore, L as LiteralToPrimitive, P as Primitive, U as UnsealedItem, ad as ZkBuilderAndCrsGenerator, ae as ZkProveWorkerFunction, af as ZkProveWorkerRequest, ag as ZkProveWorkerResponse, a3 as assertCorrectEncryptedItemInput, e as createCofheConfigBase, a6 as createKeysStore, a4 as fetchKeys, g as getCofheConfigItem, a0 as isEncryptableItem, a2 as isLastEncryptionStep, ah as zkProveWithWorker } from './clientTypes-BDy1qIBu.cjs';
3
3
  import { Hex, PublicClient } from 'viem';
4
4
  import './types-C07FK-cL.cjs';
5
5
  import 'zod';
@@ -106,8 +106,6 @@ declare const TASK_MANAGER_ADDRESS: "0xeA30c4B8b44078Bbf8a6ef5b9f1eC1626C7848D9"
106
106
  declare const MOCKS_ZK_VERIFIER_ADDRESS: "0x0000000000000000000000000000000000005001";
107
107
  /** Mock Threshold Network contract address (used for testing) */
108
108
  declare const MOCKS_THRESHOLD_NETWORK_ADDRESS: "0x0000000000000000000000000000000000005002";
109
- /** Test Bed contract address (used for testing) */
110
- declare const TEST_BED_ADDRESS: "0x0000000000000000000000000000000000005003";
111
109
  /** Private key for the Mock ZK Verifier signer account */
112
110
  declare const MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY: "0x6C8D7F768A6BB4AAFE85E8A2F5A9680355239C7E14646ED62B044E39DE154512";
113
111
  /** Address for the Mock ZK Verifier signer account */
@@ -139,4 +137,4 @@ declare function verifyDecryptResult(handle: bigint | string, cleartext: bigint,
139
137
  */
140
138
  declare function fheTypeToString(utype: FheTypes): string;
141
139
 
142
- export { InitialConnectStore as CONNECT_STORE_DEFAULTS, CofheClient, CofheClientConnectionState, CofheClientParams, CofheConfig, CofheError, CofheErrorCode, type CofheErrorParams, FheTypes, MOCKS_DECRYPT_RESULT_SIGNER_PRIVATE_KEY, MOCKS_THRESHOLD_NETWORK_ADDRESS, MOCKS_ZK_VERIFIER_ADDRESS, MOCKS_ZK_VERIFIER_SIGNER_ADDRESS, MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY, TASK_MANAGER_ADDRESS, TEST_BED_ADDRESS, TFHE_RS_SAFE_SERIALIZATION_SIZE_LIMIT, TFHE_RS_ZK_MAX_BITS, createCofheClientBase, fheTypeToString, isCofheError, verifyDecryptResult };
140
+ export { InitialConnectStore as CONNECT_STORE_DEFAULTS, CofheClient, CofheClientConnectionState, CofheClientParams, CofheConfig, CofheError, CofheErrorCode, type CofheErrorParams, FheTypes, MOCKS_DECRYPT_RESULT_SIGNER_PRIVATE_KEY, MOCKS_THRESHOLD_NETWORK_ADDRESS, MOCKS_ZK_VERIFIER_ADDRESS, MOCKS_ZK_VERIFIER_SIGNER_ADDRESS, MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY, TASK_MANAGER_ADDRESS, TFHE_RS_SAFE_SERIALIZATION_SIZE_LIMIT, TFHE_RS_ZK_MAX_BITS, createCofheClientBase, fheTypeToString, isCofheError, verifyDecryptResult };
package/dist/core.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as CofheConfig, c as CofheClientParams, b as CofheClient, d as CofheClientConnectionState, F as FheTypes } from './clientTypes-CEno_BEf.js';
2
- export { h as CofheClientPermits, C as CofheInputConfig, f as CofheInternalConfig, G as DecryptEndpoint, $ as DecryptForTxBuilder, a0 as DecryptForTxResult, _ as DecryptForViewBuilder, B as DecryptPollCallbackContext, D as DecryptPollCallbackFunction, Z as EncryptInputsBuilder, H as EncryptSetStateFn, Q as EncryptStep, J as EncryptStepCallbackContext, N as Encryptable, o as EncryptableAddress, i as EncryptableBool, E as EncryptableItem, z as EncryptableToEncryptedItemInputMap, n as EncryptableUint128, k as EncryptableUint16, l as EncryptableUint32, m as EncryptableUint64, j as EncryptableUint8, x as EncryptedAddressInput, r as EncryptedBoolInput, q as EncryptedItemInput, y as EncryptedItemInputs, p as EncryptedNumber, w as EncryptedUint128Input, t as EncryptedUint16Input, u as EncryptedUint32Input, v as EncryptedUint64Input, s as EncryptedUint8Input, M as FheAllUTypes, V as FheKeyDeserializer, A as FheTypeValue, K as FheUintUTypes, I as IStorage, X as KeysStorage, Y as KeysStore, L as LiteralToPrimitive, P as Primitive, U as UnsealedItem, a1 as ZkBuilderAndCrsGenerator, a2 as ZkProveWorkerFunction, a3 as ZkProveWorkerRequest, a4 as ZkProveWorkerResponse, S as assertCorrectEncryptedItemInput, e as createCofheConfigBase, W as createKeysStore, T as fetchKeys, g as getCofheConfigItem, O as isEncryptableItem, R as isLastEncryptionStep, a5 as zkProveWithWorker } from './clientTypes-CEno_BEf.js';
1
+ import { a as CofheConfig, c as CofheClientParams, b as CofheClient, d as CofheClientConnectionState, F as FheTypes } from './clientTypes-CyUvRRzA.js';
2
+ export { O as AnyExternalHash, h as CofheClientPermits, C as CofheInputConfig, f as CofheInternalConfig, W as DecryptEndpoint, ab as DecryptForTxBuilder, ac as DecryptForTxResult, aa as DecryptForViewBuilder, V as DecryptPollCallbackContext, T as DecryptPollCallbackFunction, a9 as EncryptInputsBuilder, X as EncryptSetStateFn, a1 as EncryptStep, Y as EncryptStepCallbackContext, $ as Encryptable, o as EncryptableAddress, i as EncryptableBool, E as EncryptableItem, z as EncryptableToEncryptedItemInputMap, Q as EncryptableToExternalHashMap, n as EncryptableUint128, k as EncryptableUint16, l as EncryptableUint32, m as EncryptableUint64, j as EncryptableUint8, x as EncryptedAddressInput, r as EncryptedBoolInput, q as EncryptedItemInput, y as EncryptedItemInputs, p as EncryptedNumber, w as EncryptedUint128Input, t as EncryptedUint16Input, u as EncryptedUint32Input, v as EncryptedUint64Input, s as EncryptedUint8Input, M as ExternalAddressHash, B as ExternalBoolHash, N as ExternalHashProof, R as ExternalItemHashes, K as ExternalUint128Hash, G as ExternalUint16Hash, H as ExternalUint32Hash, J as ExternalUint64Hash, D as ExternalUint8Hash, _ as FheAllUTypes, a5 as FheKeyDeserializer, A as FheTypeValue, Z as FheUintUTypes, S as HashPlusProofResult, I as IStorage, a7 as KeysStorage, a8 as KeysStore, L as LiteralToPrimitive, P as Primitive, U as UnsealedItem, ad as ZkBuilderAndCrsGenerator, ae as ZkProveWorkerFunction, af as ZkProveWorkerRequest, ag as ZkProveWorkerResponse, a3 as assertCorrectEncryptedItemInput, e as createCofheConfigBase, a6 as createKeysStore, a4 as fetchKeys, g as getCofheConfigItem, a0 as isEncryptableItem, a2 as isLastEncryptionStep, ah as zkProveWithWorker } from './clientTypes-CyUvRRzA.js';
3
3
  import { Hex, PublicClient } from 'viem';
4
4
  import './types-C07FK-cL.js';
5
5
  import 'zod';
@@ -106,8 +106,6 @@ declare const TASK_MANAGER_ADDRESS: "0xeA30c4B8b44078Bbf8a6ef5b9f1eC1626C7848D9"
106
106
  declare const MOCKS_ZK_VERIFIER_ADDRESS: "0x0000000000000000000000000000000000005001";
107
107
  /** Mock Threshold Network contract address (used for testing) */
108
108
  declare const MOCKS_THRESHOLD_NETWORK_ADDRESS: "0x0000000000000000000000000000000000005002";
109
- /** Test Bed contract address (used for testing) */
110
- declare const TEST_BED_ADDRESS: "0x0000000000000000000000000000000000005003";
111
109
  /** Private key for the Mock ZK Verifier signer account */
112
110
  declare const MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY: "0x6C8D7F768A6BB4AAFE85E8A2F5A9680355239C7E14646ED62B044E39DE154512";
113
111
  /** Address for the Mock ZK Verifier signer account */
@@ -139,4 +137,4 @@ declare function verifyDecryptResult(handle: bigint | string, cleartext: bigint,
139
137
  */
140
138
  declare function fheTypeToString(utype: FheTypes): string;
141
139
 
142
- export { InitialConnectStore as CONNECT_STORE_DEFAULTS, CofheClient, CofheClientConnectionState, CofheClientParams, CofheConfig, CofheError, CofheErrorCode, type CofheErrorParams, FheTypes, MOCKS_DECRYPT_RESULT_SIGNER_PRIVATE_KEY, MOCKS_THRESHOLD_NETWORK_ADDRESS, MOCKS_ZK_VERIFIER_ADDRESS, MOCKS_ZK_VERIFIER_SIGNER_ADDRESS, MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY, TASK_MANAGER_ADDRESS, TEST_BED_ADDRESS, TFHE_RS_SAFE_SERIALIZATION_SIZE_LIMIT, TFHE_RS_ZK_MAX_BITS, createCofheClientBase, fheTypeToString, isCofheError, verifyDecryptResult };
140
+ export { InitialConnectStore as CONNECT_STORE_DEFAULTS, CofheClient, CofheClientConnectionState, CofheClientParams, CofheConfig, CofheError, CofheErrorCode, type CofheErrorParams, FheTypes, MOCKS_DECRYPT_RESULT_SIGNER_PRIVATE_KEY, MOCKS_THRESHOLD_NETWORK_ADDRESS, MOCKS_ZK_VERIFIER_ADDRESS, MOCKS_ZK_VERIFIER_SIGNER_ADDRESS, MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY, TASK_MANAGER_ADDRESS, TFHE_RS_SAFE_SERIALIZATION_SIZE_LIMIT, TFHE_RS_ZK_MAX_BITS, createCofheClientBase, fheTypeToString, isCofheError, verifyDecryptResult };
package/dist/core.js CHANGED
@@ -1,4 +1,4 @@
1
- export { InitialConnectStore as CONNECT_STORE_DEFAULTS, CofheError, CofheErrorCode, DecryptForTxBuilder, DecryptForViewBuilder, EncryptInputsBuilder, EncryptStep, Encryptable, FheAllUTypes, FheTypes, FheUintUTypes, assertCorrectEncryptedItemInput, createCofheClientBase, createCofheConfigBase, createKeysStore, fetchKeys, fheTypeToString, getCofheConfigItem, isCofheError, isEncryptableItem, isLastEncryptionStep, verifyDecryptResult, zkProveWithWorker } from './chunk-YDOK4BDL.js';
2
- import './chunk-TBLR7NNE.js';
3
- import './chunk-MRCKUMOS.js';
4
- export { MOCKS_DECRYPT_RESULT_SIGNER_PRIVATE_KEY, MOCKS_THRESHOLD_NETWORK_ADDRESS, MOCKS_ZK_VERIFIER_ADDRESS, MOCKS_ZK_VERIFIER_SIGNER_ADDRESS, MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY, TASK_MANAGER_ADDRESS, TEST_BED_ADDRESS, TFHE_RS_SAFE_SERIALIZATION_SIZE_LIMIT, TFHE_RS_ZK_MAX_BITS } from './chunk-4FP4V35O.js';
1
+ export { InitialConnectStore as CONNECT_STORE_DEFAULTS, CofheError, CofheErrorCode, DecryptForTxBuilder, DecryptForViewBuilder, EncryptInputsBuilder, EncryptStep, Encryptable, FheAllUTypes, FheTypes, FheUintUTypes, assertCorrectEncryptedItemInput, createCofheClientBase, createCofheConfigBase, createKeysStore, fetchKeys, fheTypeToString, getCofheConfigItem, isCofheError, isEncryptableItem, isLastEncryptionStep, verifyDecryptResult, zkProveWithWorker } from './chunk-PE5V5CCV.js';
2
+ import './chunk-MTRAXQXC.js';
3
+ import './chunk-VB62WYPL.js';
4
+ export { MOCKS_DECRYPT_RESULT_SIGNER_PRIVATE_KEY, MOCKS_THRESHOLD_NETWORK_ADDRESS, MOCKS_ZK_VERIFIER_ADDRESS, MOCKS_ZK_VERIFIER_SIGNER_ADDRESS, MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY, TASK_MANAGER_ADDRESS, TFHE_RS_SAFE_SERIALIZATION_SIZE_LIMIT, TFHE_RS_ZK_MAX_BITS } from './chunk-ESMZCFJY.js';
package/dist/node.cjs CHANGED
@@ -358,7 +358,7 @@ var zkVerify = async (verifierUrl, serializedBytes, address, securityZone, chain
358
358
  }
359
359
  };
360
360
  var concatSigRecid = (signature, recid) => {
361
- return signature + (recid + 27).toString(16).padStart(2, "0");
361
+ return `${signature}${(recid + 27).toString(16).padStart(2, "0")}`;
362
362
  };
363
363
 
364
364
  // core/encrypt/MockZkVerifierAbi.ts
@@ -690,9 +690,9 @@ var hardhat2 = defineChain({
690
690
  name: "Hardhat",
691
691
  network: "localhost",
692
692
  // These are unused in the mock environment
693
- coFheUrl: "http://127.0.0.1:8448",
694
- verifierUrl: "http://127.0.0.1:3001",
695
- thresholdNetworkUrl: "http://127.0.0.1:3000",
693
+ coFheUrl: "http://ignored-in-mock-environment",
694
+ verifierUrl: "http://ignored-in-mock-environment",
695
+ thresholdNetworkUrl: "http://ignored-in-mock-environment",
696
696
  environment: "MOCK"
697
697
  });
698
698
  var CofheConfigSchema = zod.z.object({
@@ -1078,6 +1078,7 @@ var EncryptInputsBuilder = class extends BaseBuilder {
1078
1078
  securityZone;
1079
1079
  stepCallback;
1080
1080
  inputItems;
1081
+ hpp = false;
1081
1082
  zkvWalletClient;
1082
1083
  tfhePublicKeyDeserializer;
1083
1084
  compactPkeCrsDeserializer;
@@ -1207,6 +1208,20 @@ var EncryptInputsBuilder = class extends BaseBuilder {
1207
1208
  getSecurityZone() {
1208
1209
  return this.securityZone;
1209
1210
  }
1211
+ /**
1212
+ * Example:
1213
+ * ```typescript
1214
+ * const encrypted = await encryptInputs([Encryptable.uint128(10n)])
1215
+ * .asHashPlusProof()
1216
+ * .execute();
1217
+ * ```
1218
+ *
1219
+ * @returns Chainable EncryptInputsBuilder instance that will return a HashPlusProofResult instead of an array of EncryptedItemInputs.
1220
+ */
1221
+ asHashPlusProof() {
1222
+ this.hpp = true;
1223
+ return this;
1224
+ }
1210
1225
  /**
1211
1226
  * @param useWorker - Whether to use Web Workers for ZK proof generation.
1212
1227
  *
@@ -1488,6 +1503,15 @@ var EncryptInputsBuilder = class extends BaseBuilder {
1488
1503
  this.fireStepEnd("verify" /* Verify */);
1489
1504
  return encryptedInputs;
1490
1505
  }
1506
+ structsToHashPlusProof(inItems) {
1507
+ let hashes = [];
1508
+ let proof = "";
1509
+ for (const item of inItems) {
1510
+ hashes.push("0x" + item.ctHash.toString(16).padStart(64, "0"));
1511
+ proof += item.signature;
1512
+ }
1513
+ return [...hashes, proof];
1514
+ }
1491
1515
  /**
1492
1516
  * Final step of the encryption process. MUST BE CALLED LAST IN THE CHAIN.
1493
1517
  *
@@ -1508,9 +1532,14 @@ var EncryptInputsBuilder = class extends BaseBuilder {
1508
1532
  * @returns The encrypted inputs.
1509
1533
  */
1510
1534
  async execute() {
1535
+ let items;
1511
1536
  if (this.chainId === chains.hardhat.id)
1512
- return this.mocksExecute();
1513
- return this.productionExecute();
1537
+ items = await this.mocksExecute();
1538
+ else
1539
+ items = await this.productionExecute();
1540
+ if (this.hpp)
1541
+ return this.structsToHashPlusProof(items);
1542
+ return items;
1514
1543
  }
1515
1544
  };
1516
1545
 
package/dist/node.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as CofheInputConfig, a as CofheConfig, b as CofheClient } from './clientTypes-BJbFeeno.cjs';
1
+ import { C as CofheInputConfig, a as CofheConfig, b as CofheClient } from './clientTypes-BDy1qIBu.cjs';
2
2
  import 'viem';
3
3
  import './types-C07FK-cL.cjs';
4
4
  import 'zod';
package/dist/node.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as CofheInputConfig, a as CofheConfig, b as CofheClient } from './clientTypes-CEno_BEf.js';
1
+ import { C as CofheInputConfig, a as CofheConfig, b as CofheClient } from './clientTypes-CyUvRRzA.js';
2
2
  import 'viem';
3
3
  import './types-C07FK-cL.js';
4
4
  import 'zod';
package/dist/node.js CHANGED
@@ -1,7 +1,7 @@
1
- import { createCofheConfigBase, createCofheClientBase } from './chunk-YDOK4BDL.js';
2
- import './chunk-TBLR7NNE.js';
3
- import './chunk-MRCKUMOS.js';
4
- import { TFHE_RS_SAFE_SERIALIZATION_SIZE_LIMIT } from './chunk-4FP4V35O.js';
1
+ import { createCofheConfigBase, createCofheClientBase } from './chunk-PE5V5CCV.js';
2
+ import './chunk-MTRAXQXC.js';
3
+ import './chunk-VB62WYPL.js';
4
+ import { TFHE_RS_SAFE_SERIALIZATION_SIZE_LIMIT } from './chunk-ESMZCFJY.js';
5
5
  import { promises } from 'fs';
6
6
  import { join } from 'path';
7
7
  import { init_panic_hook, ProvenCompactCiphertextList, CompactPkeCrs, TfheCompactPublicKey } from 'node-tfhe';