@cofhe/sdk 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/adapters/ethers6.test.ts +1 -1
- package/core/client.ts +6 -6
- package/core/clientTypes.ts +7 -7
- package/core/decrypt/cofheMocksDecryptForTx.ts +21 -79
- package/core/decrypt/cofheMocksDecryptForView.ts +3 -10
- package/core/decrypt/decryptForTxBuilder.ts +19 -14
- package/core/decrypt/decryptForViewBuilder.ts +9 -4
- package/core/decrypt/tnDecryptUtils.ts +65 -0
- package/core/decrypt/{tnDecrypt.ts → tnDecryptV1.ts} +10 -71
- package/core/decrypt/tnDecryptV2.ts +343 -0
- package/core/decrypt/tnSealOutputV2.ts +3 -3
- package/core/encrypt/cofheMocksZkVerifySign.ts +15 -11
- package/core/permits.ts +3 -3
- package/core/types.ts +8 -0
- package/dist/{chunk-2TPSCOW3.js → chunk-MXND5SVN.js} +275 -171
- package/dist/{clientTypes-Bhq7pCSA.d.cts → clientTypes-ACVWbrXL.d.cts} +22 -14
- package/dist/{clientTypes-6aTZPQ_4.d.ts → clientTypes-kkrRdawm.d.ts} +22 -14
- package/dist/core.cjs +274 -170
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +1 -1
- package/dist/node.cjs +274 -170
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.js +1 -1
- package/dist/web.cjs +274 -170
- package/dist/web.d.cts +1 -1
- package/dist/web.d.ts +1 -1
- package/dist/web.js +1 -1
- package/node/client.test.ts +1 -1
- package/package.json +1 -1
- package/web/client.web.test.ts +1 -1
|
@@ -165,6 +165,14 @@ type EncryptStepCallbackContext = Record<string, any> & {
|
|
|
165
165
|
duration: number;
|
|
166
166
|
};
|
|
167
167
|
type EncryptStepCallbackFunction = (state: EncryptStep, context?: EncryptStepCallbackContext) => void;
|
|
168
|
+
/**
|
|
169
|
+
* Decrypted plaintext value returned by view-decryption helpers.
|
|
170
|
+
*
|
|
171
|
+
* This is a scalar JS value (not a wrapper object):
|
|
172
|
+
* - `boolean` for `FheTypes.Bool`
|
|
173
|
+
* - checksummed address `string` for `FheTypes.Uint160`
|
|
174
|
+
* - `bigint` for supported integer utypes
|
|
175
|
+
*/
|
|
168
176
|
type UnsealedItem<U extends FheTypes> = U extends FheTypes.Bool ? boolean : U extends FheTypes.Uint160 ? string : U extends FheUintUTypesType ? bigint : never;
|
|
169
177
|
|
|
170
178
|
/**
|
|
@@ -342,7 +350,7 @@ declare abstract class BaseBuilder {
|
|
|
342
350
|
* Returns the unsealed item.
|
|
343
351
|
*/
|
|
344
352
|
type DecryptForViewBuilderParams<U extends FheTypes> = BaseBuilderParams & {
|
|
345
|
-
ctHash: bigint;
|
|
353
|
+
ctHash: bigint | string;
|
|
346
354
|
utype: U;
|
|
347
355
|
permitHash?: string;
|
|
348
356
|
permit?: Permit;
|
|
@@ -466,12 +474,12 @@ declare class DecryptForViewBuilder<U extends FheTypes> extends BaseBuilder {
|
|
|
466
474
|
}
|
|
467
475
|
|
|
468
476
|
type DecryptForTxBuilderParams = BaseBuilderParams & {
|
|
469
|
-
ctHash: bigint;
|
|
477
|
+
ctHash: bigint | string;
|
|
470
478
|
};
|
|
471
479
|
type DecryptForTxResult = {
|
|
472
|
-
ctHash: bigint;
|
|
480
|
+
ctHash: bigint | string;
|
|
473
481
|
decryptedValue: bigint;
|
|
474
|
-
signature: string
|
|
482
|
+
signature: `0x${string}`;
|
|
475
483
|
};
|
|
476
484
|
/**
|
|
477
485
|
* Type-level gating:
|
|
@@ -894,9 +902,9 @@ declare const permits: {
|
|
|
894
902
|
getHash: (permit: PermitHashFields) => string;
|
|
895
903
|
serialize: (permit: Permit) => SerializedPermit;
|
|
896
904
|
deserialize: (serialized: SerializedPermit) => Permit;
|
|
897
|
-
getPermit: (chainId: number, account: string, hash: string) =>
|
|
898
|
-
getPermits: (chainId: number, account: string) =>
|
|
899
|
-
getActivePermit: (chainId: number, account: string) =>
|
|
905
|
+
getPermit: (chainId: number, account: string, hash: string) => Permit | undefined;
|
|
906
|
+
getPermits: (chainId: number, account: string) => Record<string, Permit>;
|
|
907
|
+
getActivePermit: (chainId: number, account: string) => Permit | undefined;
|
|
900
908
|
getActivePermitHash: (chainId: number, account: string) => string | undefined;
|
|
901
909
|
removePermit: (chainId: number, account: string, hash: string) => Promise<void>;
|
|
902
910
|
selectActivePermit: (chainId: number, account: string, hash: string) => void;
|
|
@@ -924,9 +932,9 @@ type CofheClient<TConfig extends CofheConfig = CofheConfig> = {
|
|
|
924
932
|
/**
|
|
925
933
|
* @deprecated Use `decryptForView` instead. Kept for backward compatibility.
|
|
926
934
|
*/
|
|
927
|
-
decryptHandle<U extends FheTypes>(ctHash: bigint, utype: U): DecryptForViewBuilder<U>;
|
|
928
|
-
decryptForView<U extends FheTypes>(ctHash: bigint, utype: U): DecryptForViewBuilder<U>;
|
|
929
|
-
decryptForTx(ctHash: bigint): DecryptForTxBuilderUnset;
|
|
935
|
+
decryptHandle<U extends FheTypes>(ctHash: bigint | string, utype: U): DecryptForViewBuilder<U>;
|
|
936
|
+
decryptForView<U extends FheTypes>(ctHash: bigint | string, utype: U): DecryptForViewBuilder<U>;
|
|
937
|
+
decryptForTx(ctHash: bigint | string): DecryptForTxBuilderUnset;
|
|
930
938
|
permits: CofheClientPermits;
|
|
931
939
|
};
|
|
932
940
|
type CofheClientConnectionState = {
|
|
@@ -949,10 +957,10 @@ type CofheClientPermits = {
|
|
|
949
957
|
createSelf: (options: CreateSelfPermitOptions, clients?: CofheClientPermitsClients) => Promise<SelfPermit>;
|
|
950
958
|
createSharing: (options: CreateSharingPermitOptions, clients?: CofheClientPermitsClients) => Promise<SharingPermit>;
|
|
951
959
|
importShared: (options: ImportSharedPermitOptions | string, clients?: CofheClientPermitsClients) => Promise<RecipientPermit>;
|
|
952
|
-
getPermit: (hash: string, chainId?: number, account?: string) =>
|
|
953
|
-
getPermits: (chainId?: number, account?: string) =>
|
|
954
|
-
getActivePermit: (chainId?: number, account?: string) =>
|
|
955
|
-
getActivePermitHash: (chainId?: number, account?: string) =>
|
|
960
|
+
getPermit: (hash: string, chainId?: number, account?: string) => Permit | undefined;
|
|
961
|
+
getPermits: (chainId?: number, account?: string) => Record<string, Permit>;
|
|
962
|
+
getActivePermit: (chainId?: number, account?: string) => Permit | undefined;
|
|
963
|
+
getActivePermitHash: (chainId?: number, account?: string) => string | undefined;
|
|
956
964
|
getOrCreateSelfPermit: (chainId?: number, account?: string, options?: CreateSelfPermitOptions) => Promise<Permit>;
|
|
957
965
|
getOrCreateSharingPermit: (options: CreateSharingPermitOptions, chainId?: number, account?: string) => Promise<Permit>;
|
|
958
966
|
selectActivePermit: (hash: string, chainId?: number, account?: string) => void;
|
|
@@ -165,6 +165,14 @@ type EncryptStepCallbackContext = Record<string, any> & {
|
|
|
165
165
|
duration: number;
|
|
166
166
|
};
|
|
167
167
|
type EncryptStepCallbackFunction = (state: EncryptStep, context?: EncryptStepCallbackContext) => void;
|
|
168
|
+
/**
|
|
169
|
+
* Decrypted plaintext value returned by view-decryption helpers.
|
|
170
|
+
*
|
|
171
|
+
* This is a scalar JS value (not a wrapper object):
|
|
172
|
+
* - `boolean` for `FheTypes.Bool`
|
|
173
|
+
* - checksummed address `string` for `FheTypes.Uint160`
|
|
174
|
+
* - `bigint` for supported integer utypes
|
|
175
|
+
*/
|
|
168
176
|
type UnsealedItem<U extends FheTypes> = U extends FheTypes.Bool ? boolean : U extends FheTypes.Uint160 ? string : U extends FheUintUTypesType ? bigint : never;
|
|
169
177
|
|
|
170
178
|
/**
|
|
@@ -342,7 +350,7 @@ declare abstract class BaseBuilder {
|
|
|
342
350
|
* Returns the unsealed item.
|
|
343
351
|
*/
|
|
344
352
|
type DecryptForViewBuilderParams<U extends FheTypes> = BaseBuilderParams & {
|
|
345
|
-
ctHash: bigint;
|
|
353
|
+
ctHash: bigint | string;
|
|
346
354
|
utype: U;
|
|
347
355
|
permitHash?: string;
|
|
348
356
|
permit?: Permit;
|
|
@@ -466,12 +474,12 @@ declare class DecryptForViewBuilder<U extends FheTypes> extends BaseBuilder {
|
|
|
466
474
|
}
|
|
467
475
|
|
|
468
476
|
type DecryptForTxBuilderParams = BaseBuilderParams & {
|
|
469
|
-
ctHash: bigint;
|
|
477
|
+
ctHash: bigint | string;
|
|
470
478
|
};
|
|
471
479
|
type DecryptForTxResult = {
|
|
472
|
-
ctHash: bigint;
|
|
480
|
+
ctHash: bigint | string;
|
|
473
481
|
decryptedValue: bigint;
|
|
474
|
-
signature: string
|
|
482
|
+
signature: `0x${string}`;
|
|
475
483
|
};
|
|
476
484
|
/**
|
|
477
485
|
* Type-level gating:
|
|
@@ -894,9 +902,9 @@ declare const permits: {
|
|
|
894
902
|
getHash: (permit: PermitHashFields) => string;
|
|
895
903
|
serialize: (permit: Permit) => SerializedPermit;
|
|
896
904
|
deserialize: (serialized: SerializedPermit) => Permit;
|
|
897
|
-
getPermit: (chainId: number, account: string, hash: string) =>
|
|
898
|
-
getPermits: (chainId: number, account: string) =>
|
|
899
|
-
getActivePermit: (chainId: number, account: string) =>
|
|
905
|
+
getPermit: (chainId: number, account: string, hash: string) => Permit | undefined;
|
|
906
|
+
getPermits: (chainId: number, account: string) => Record<string, Permit>;
|
|
907
|
+
getActivePermit: (chainId: number, account: string) => Permit | undefined;
|
|
900
908
|
getActivePermitHash: (chainId: number, account: string) => string | undefined;
|
|
901
909
|
removePermit: (chainId: number, account: string, hash: string) => Promise<void>;
|
|
902
910
|
selectActivePermit: (chainId: number, account: string, hash: string) => void;
|
|
@@ -924,9 +932,9 @@ type CofheClient<TConfig extends CofheConfig = CofheConfig> = {
|
|
|
924
932
|
/**
|
|
925
933
|
* @deprecated Use `decryptForView` instead. Kept for backward compatibility.
|
|
926
934
|
*/
|
|
927
|
-
decryptHandle<U extends FheTypes>(ctHash: bigint, utype: U): DecryptForViewBuilder<U>;
|
|
928
|
-
decryptForView<U extends FheTypes>(ctHash: bigint, utype: U): DecryptForViewBuilder<U>;
|
|
929
|
-
decryptForTx(ctHash: bigint): DecryptForTxBuilderUnset;
|
|
935
|
+
decryptHandle<U extends FheTypes>(ctHash: bigint | string, utype: U): DecryptForViewBuilder<U>;
|
|
936
|
+
decryptForView<U extends FheTypes>(ctHash: bigint | string, utype: U): DecryptForViewBuilder<U>;
|
|
937
|
+
decryptForTx(ctHash: bigint | string): DecryptForTxBuilderUnset;
|
|
930
938
|
permits: CofheClientPermits;
|
|
931
939
|
};
|
|
932
940
|
type CofheClientConnectionState = {
|
|
@@ -949,10 +957,10 @@ type CofheClientPermits = {
|
|
|
949
957
|
createSelf: (options: CreateSelfPermitOptions, clients?: CofheClientPermitsClients) => Promise<SelfPermit>;
|
|
950
958
|
createSharing: (options: CreateSharingPermitOptions, clients?: CofheClientPermitsClients) => Promise<SharingPermit>;
|
|
951
959
|
importShared: (options: ImportSharedPermitOptions | string, clients?: CofheClientPermitsClients) => Promise<RecipientPermit>;
|
|
952
|
-
getPermit: (hash: string, chainId?: number, account?: string) =>
|
|
953
|
-
getPermits: (chainId?: number, account?: string) =>
|
|
954
|
-
getActivePermit: (chainId?: number, account?: string) =>
|
|
955
|
-
getActivePermitHash: (chainId?: number, account?: string) =>
|
|
960
|
+
getPermit: (hash: string, chainId?: number, account?: string) => Permit | undefined;
|
|
961
|
+
getPermits: (chainId?: number, account?: string) => Record<string, Permit>;
|
|
962
|
+
getActivePermit: (chainId?: number, account?: string) => Permit | undefined;
|
|
963
|
+
getActivePermitHash: (chainId?: number, account?: string) => string | undefined;
|
|
956
964
|
getOrCreateSelfPermit: (chainId?: number, account?: string, options?: CreateSelfPermitOptions) => Promise<Permit>;
|
|
957
965
|
getOrCreateSharingPermit: (options: CreateSharingPermitOptions, chainId?: number, account?: string) => Promise<Permit>;
|
|
958
966
|
selectActivePermit: (hash: string, chainId?: number, account?: string) => void;
|