@cofhe/sdk 0.0.0-alpha-20260409113701
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 +146 -0
- package/adapters/ethers5.test.ts +174 -0
- package/adapters/ethers5.ts +36 -0
- package/adapters/ethers6.test.ts +169 -0
- package/adapters/ethers6.ts +36 -0
- package/adapters/hardhat-node.ts +167 -0
- package/adapters/hardhat.hh2.test.ts +159 -0
- package/adapters/hardhat.ts +36 -0
- package/adapters/index.test.ts +20 -0
- package/adapters/index.ts +5 -0
- package/adapters/smartWallet.ts +99 -0
- package/adapters/test-utils.ts +53 -0
- package/adapters/types.ts +6 -0
- package/adapters/wagmi.test.ts +156 -0
- package/adapters/wagmi.ts +17 -0
- package/chains/chains/arbSepolia.ts +14 -0
- package/chains/chains/baseSepolia.ts +14 -0
- package/chains/chains/hardhat.ts +15 -0
- package/chains/chains/localcofhe.ts +14 -0
- package/chains/chains/sepolia.ts +14 -0
- package/chains/chains.test.ts +50 -0
- package/chains/defineChain.ts +18 -0
- package/chains/index.ts +35 -0
- package/chains/types.ts +32 -0
- package/core/baseBuilder.ts +119 -0
- package/core/client.test.ts +429 -0
- package/core/client.ts +341 -0
- package/core/clientTypes.ts +119 -0
- package/core/config.test.ts +242 -0
- package/core/config.ts +225 -0
- package/core/consts.ts +22 -0
- package/core/decrypt/MockThresholdNetworkAbi.ts +179 -0
- package/core/decrypt/cofheMocksDecryptForTx.ts +84 -0
- package/core/decrypt/cofheMocksDecryptForView.ts +48 -0
- package/core/decrypt/decryptForTxBuilder.ts +359 -0
- package/core/decrypt/decryptForViewBuilder.ts +332 -0
- package/core/decrypt/decryptUtils.ts +28 -0
- package/core/decrypt/pollCallbacks.test.ts +194 -0
- package/core/decrypt/polling.ts +14 -0
- package/core/decrypt/tnDecryptUtils.ts +65 -0
- package/core/decrypt/tnDecryptV1.ts +171 -0
- package/core/decrypt/tnDecryptV2.ts +365 -0
- package/core/decrypt/tnSealOutputV1.ts +59 -0
- package/core/decrypt/tnSealOutputV2.ts +324 -0
- package/core/decrypt/verifyDecryptResult.ts +52 -0
- package/core/encrypt/MockZkVerifierAbi.ts +106 -0
- package/core/encrypt/cofheMocksZkVerifySign.ts +281 -0
- package/core/encrypt/encryptInputsBuilder.test.ts +747 -0
- package/core/encrypt/encryptInputsBuilder.ts +583 -0
- package/core/encrypt/encryptUtils.ts +67 -0
- package/core/encrypt/zkPackProveVerify.ts +335 -0
- package/core/error.ts +168 -0
- package/core/fetchKeys.test.ts +195 -0
- package/core/fetchKeys.ts +144 -0
- package/core/index.ts +106 -0
- package/core/keyStore.test.ts +226 -0
- package/core/keyStore.ts +154 -0
- package/core/permits.test.ts +493 -0
- package/core/permits.ts +201 -0
- package/core/types.ts +419 -0
- package/core/utils.ts +130 -0
- package/dist/adapters.cjs +88 -0
- package/dist/adapters.d.cts +14576 -0
- package/dist/adapters.d.ts +14576 -0
- package/dist/adapters.js +83 -0
- package/dist/chains.cjs +111 -0
- package/dist/chains.d.cts +121 -0
- package/dist/chains.d.ts +121 -0
- package/dist/chains.js +1 -0
- package/dist/chunk-36FBWLUS.js +3310 -0
- package/dist/chunk-7HLGHV67.js +990 -0
- package/dist/chunk-TBLR7NNE.js +102 -0
- package/dist/clientTypes-AVSCBet7.d.cts +998 -0
- package/dist/clientTypes-flH1ju82.d.ts +998 -0
- package/dist/core.cjs +4362 -0
- package/dist/core.d.cts +138 -0
- package/dist/core.d.ts +138 -0
- package/dist/core.js +3 -0
- package/dist/node.cjs +4225 -0
- package/dist/node.d.cts +22 -0
- package/dist/node.d.ts +22 -0
- package/dist/node.js +91 -0
- package/dist/permit-jRirYqFt.d.cts +376 -0
- package/dist/permit-jRirYqFt.d.ts +376 -0
- package/dist/permits.cjs +1025 -0
- package/dist/permits.d.cts +353 -0
- package/dist/permits.d.ts +353 -0
- package/dist/permits.js +1 -0
- package/dist/types-YiAC4gig.d.cts +33 -0
- package/dist/types-YiAC4gig.d.ts +33 -0
- package/dist/web.cjs +4434 -0
- package/dist/web.d.cts +42 -0
- package/dist/web.d.ts +42 -0
- package/dist/web.js +256 -0
- package/dist/zkProve.worker.cjs +93 -0
- package/dist/zkProve.worker.d.cts +2 -0
- package/dist/zkProve.worker.d.ts +2 -0
- package/dist/zkProve.worker.js +91 -0
- package/node/client.test.ts +159 -0
- package/node/config.test.ts +68 -0
- package/node/encryptInputs.test.ts +155 -0
- package/node/index.ts +97 -0
- package/node/storage.ts +51 -0
- package/package.json +121 -0
- package/permits/index.ts +68 -0
- package/permits/localstorage.test.ts +113 -0
- package/permits/onchain-utils.ts +221 -0
- package/permits/permit.test.ts +534 -0
- package/permits/permit.ts +386 -0
- package/permits/sealing.test.ts +84 -0
- package/permits/sealing.ts +131 -0
- package/permits/signature.ts +79 -0
- package/permits/store.test.ts +88 -0
- package/permits/store.ts +156 -0
- package/permits/test-utils.ts +28 -0
- package/permits/types.ts +204 -0
- package/permits/utils.ts +58 -0
- package/permits/validation.test.ts +361 -0
- package/permits/validation.ts +327 -0
- package/web/client.web.test.ts +159 -0
- package/web/config.web.test.ts +69 -0
- package/web/const.ts +2 -0
- package/web/encryptInputs.web.test.ts +172 -0
- package/web/index.ts +166 -0
- package/web/storage.ts +49 -0
- package/web/worker.builder.web.test.ts +148 -0
- package/web/worker.config.web.test.ts +329 -0
- package/web/worker.output.web.test.ts +84 -0
- package/web/workerManager.test.ts +80 -0
- package/web/workerManager.ts +214 -0
- package/web/workerManager.web.test.ts +114 -0
- package/web/zkProve.worker.ts +133 -0
package/dist/core.d.cts
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { c as CofheClientConnectionState, a as CofheConfig, d as CofheClientParams, b as CofheClient, F as FheTypes } from './clientTypes-AVSCBet7.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-AVSCBet7.cjs';
|
|
3
|
+
import { Hex, PublicClient } from 'viem';
|
|
4
|
+
import './types-YiAC4gig.cjs';
|
|
5
|
+
import 'zod';
|
|
6
|
+
import './permit-jRirYqFt.cjs';
|
|
7
|
+
import 'zustand/vanilla';
|
|
8
|
+
|
|
9
|
+
declare const InitialConnectStore: CofheClientConnectionState;
|
|
10
|
+
/**
|
|
11
|
+
* Creates a CoFHE client instance (base implementation)
|
|
12
|
+
* @param {CofheClientParams} opts - Initialization options including config and platform-specific serializers
|
|
13
|
+
* @returns {CofheClient} - The CoFHE client instance
|
|
14
|
+
*/
|
|
15
|
+
declare function createCofheClientBase<TConfig extends CofheConfig>(opts: CofheClientParams<TConfig>): CofheClient<TConfig>;
|
|
16
|
+
|
|
17
|
+
declare enum CofheErrorCode {
|
|
18
|
+
InternalError = "INTERNAL_ERROR",
|
|
19
|
+
UnknownEnvironment = "UNKNOWN_ENVIRONMENT",
|
|
20
|
+
InitTfheFailed = "INIT_TFHE_FAILED",
|
|
21
|
+
InitViemFailed = "INIT_VIEM_FAILED",
|
|
22
|
+
InitEthersFailed = "INIT_ETHERS_FAILED",
|
|
23
|
+
NotConnected = "NOT_CONNECTED",
|
|
24
|
+
MissingPublicClient = "MISSING_PUBLIC_CLIENT",
|
|
25
|
+
MissingWalletClient = "MISSING_WALLET_CLIENT",
|
|
26
|
+
MissingProviderParam = "MISSING_PROVIDER_PARAM",
|
|
27
|
+
EmptySecurityZonesParam = "EMPTY_SECURITY_ZONES_PARAM",
|
|
28
|
+
InvalidPermitData = "INVALID_PERMIT_DATA",
|
|
29
|
+
InvalidPermitDomain = "INVALID_PERMIT_DOMAIN",
|
|
30
|
+
PermitNotFound = "PERMIT_NOT_FOUND",
|
|
31
|
+
CannotRemoveLastPermit = "CANNOT_REMOVE_LAST_PERMIT",
|
|
32
|
+
AccountUninitialized = "ACCOUNT_UNINITIALIZED",
|
|
33
|
+
ChainIdUninitialized = "CHAIN_ID_UNINITIALIZED",
|
|
34
|
+
SealOutputFailed = "SEAL_OUTPUT_FAILED",
|
|
35
|
+
SealOutputReturnedNull = "SEAL_OUTPUT_RETURNED_NULL",
|
|
36
|
+
InvalidUtype = "INVALID_UTYPE",
|
|
37
|
+
DecryptFailed = "DECRYPT_FAILED",
|
|
38
|
+
DecryptReturnedNull = "DECRYPT_RETURNED_NULL",
|
|
39
|
+
ZkMocksInsertCtHashesFailed = "ZK_MOCKS_INSERT_CT_HASHES_FAILED",
|
|
40
|
+
ZkMocksCalcCtHashesFailed = "ZK_MOCKS_CALC_CT_HASHES_FAILED",
|
|
41
|
+
ZkMocksVerifySignFailed = "ZK_MOCKS_VERIFY_SIGN_FAILED",
|
|
42
|
+
ZkMocksCreateProofSignatureFailed = "ZK_MOCKS_CREATE_PROOF_SIGNATURE_FAILED",
|
|
43
|
+
ZkVerifyFailed = "ZK_VERIFY_FAILED",
|
|
44
|
+
ZkPackFailed = "ZK_PACK_FAILED",
|
|
45
|
+
ZkProveFailed = "ZK_PROVE_FAILED",
|
|
46
|
+
EncryptRemainingInItems = "ENCRYPT_REMAINING_IN_ITEMS",
|
|
47
|
+
ZkUninitialized = "ZK_UNINITIALIZED",
|
|
48
|
+
ZkVerifierUrlUninitialized = "ZK_VERIFIER_URL_UNINITIALIZED",
|
|
49
|
+
ThresholdNetworkUrlUninitialized = "THRESHOLD_NETWORK_URL_UNINITIALIZED",
|
|
50
|
+
MissingConfig = "MISSING_CONFIG",
|
|
51
|
+
UnsupportedChain = "UNSUPPORTED_CHAIN",
|
|
52
|
+
MissingZkBuilderAndCrsGenerator = "MISSING_ZK_BUILDER_AND_CRS_GENERATOR",
|
|
53
|
+
MissingTfhePublicKeyDeserializer = "MISSING_TFHE_PUBLIC_KEY_DESERIALIZER",
|
|
54
|
+
MissingCompactPkeCrsDeserializer = "MISSING_COMPACT_PKE_CRS_DESERIALIZER",
|
|
55
|
+
MissingFheKey = "MISSING_FHE_KEY",
|
|
56
|
+
MissingCrs = "MISSING_CRS",
|
|
57
|
+
FetchKeysFailed = "FETCH_KEYS_FAILED",
|
|
58
|
+
PublicWalletGetChainIdFailed = "PUBLIC_WALLET_GET_CHAIN_ID_FAILED",
|
|
59
|
+
PublicWalletGetAddressesFailed = "PUBLIC_WALLET_GET_ADDRESSES_FAILED",
|
|
60
|
+
RehydrateKeysStoreFailed = "REHYDRATE_KEYS_STORE_FAILED"
|
|
61
|
+
}
|
|
62
|
+
type CofheErrorParams = {
|
|
63
|
+
code: CofheErrorCode;
|
|
64
|
+
message: string;
|
|
65
|
+
cause?: Error;
|
|
66
|
+
hint?: string;
|
|
67
|
+
context?: Record<string, unknown>;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* CofheError class
|
|
71
|
+
* This class is used to create errors that are specific to the CoFHE SDK
|
|
72
|
+
* It extends the Error class and adds a code, cause, hint, and context
|
|
73
|
+
* The code is used to identify the type of error
|
|
74
|
+
* The cause is used to indicate the inner error that caused the CofheError
|
|
75
|
+
* The hint is used to provide a hint about how to fix the error
|
|
76
|
+
* The context is used to provide additional context about the state that caused the error
|
|
77
|
+
* The serialize method is used to serialize the error to a JSON string
|
|
78
|
+
* The toString method is used to provide a human-readable string representation of the error
|
|
79
|
+
*/
|
|
80
|
+
declare class CofheError extends Error {
|
|
81
|
+
readonly code: CofheErrorCode;
|
|
82
|
+
readonly cause?: Error;
|
|
83
|
+
readonly hint?: string;
|
|
84
|
+
readonly context?: Record<string, unknown>;
|
|
85
|
+
constructor({ code, message, cause, hint, context }: CofheErrorParams);
|
|
86
|
+
/**
|
|
87
|
+
* Creates a CofheError from an unknown error
|
|
88
|
+
* If the error is a CofheError, it is returned unchanged, else a new CofheError is created
|
|
89
|
+
* If a wrapperError is provided, it is used to create the new CofheError, else a default is used
|
|
90
|
+
*/
|
|
91
|
+
static fromError(error: unknown, wrapperError?: CofheErrorParams): CofheError;
|
|
92
|
+
/**
|
|
93
|
+
* Serializes the error to JSON string with proper handling of Error objects
|
|
94
|
+
*/
|
|
95
|
+
serialize(): string;
|
|
96
|
+
/**
|
|
97
|
+
* Returns a human-readable string representation of the error
|
|
98
|
+
*/
|
|
99
|
+
toString(): string;
|
|
100
|
+
}
|
|
101
|
+
declare const isCofheError: (error: unknown) => error is CofheError;
|
|
102
|
+
|
|
103
|
+
/** Main Task Manager contract address */
|
|
104
|
+
declare const TASK_MANAGER_ADDRESS: "0xeA30c4B8b44078Bbf8a6ef5b9f1eC1626C7848D9";
|
|
105
|
+
/** Mock ZK Verifier contract address (used for testing) */
|
|
106
|
+
declare const MOCKS_ZK_VERIFIER_ADDRESS: "0x0000000000000000000000000000000000005001";
|
|
107
|
+
/** Mock Threshold Network contract address (used for testing) */
|
|
108
|
+
declare const MOCKS_THRESHOLD_NETWORK_ADDRESS: "0x0000000000000000000000000000000000005002";
|
|
109
|
+
/** Test Bed contract address (used for testing) */
|
|
110
|
+
declare const TEST_BED_ADDRESS: "0x0000000000000000000000000000000000005003";
|
|
111
|
+
/** Private key for the Mock ZK Verifier signer account */
|
|
112
|
+
declare const MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY: "0x6C8D7F768A6BB4AAFE85E8A2F5A9680355239C7E14646ED62B044E39DE154512";
|
|
113
|
+
/** Address for the Mock ZK Verifier signer account */
|
|
114
|
+
declare const MOCKS_ZK_VERIFIER_SIGNER_ADDRESS: "0x6E12D8C87503D4287c294f2Fdef96ACd9DFf6bd2";
|
|
115
|
+
/** Private key for the Mock decrypt result signer account */
|
|
116
|
+
declare const MOCKS_DECRYPT_RESULT_SIGNER_PRIVATE_KEY: "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d";
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Verifies a decrypt result signature **locally** (no `ctHash`/plaintext sent over RPC).
|
|
120
|
+
*
|
|
121
|
+
* This matches the TaskManager contract logic:
|
|
122
|
+
* - messageHash = keccak256(abi.encodePacked(ctHash, result))
|
|
123
|
+
* - recovered = ecrecover(messageHash, signature)
|
|
124
|
+
* - recovered must equal the on-chain configured `decryptResultSigner`
|
|
125
|
+
*
|
|
126
|
+
* The only on-chain read performed is `TaskManager.decryptResultSigner()` (via `eth_call`).
|
|
127
|
+
*
|
|
128
|
+
* Works with both production and mock deployments.
|
|
129
|
+
*/
|
|
130
|
+
declare function verifyDecryptResult(handle: bigint | string, cleartext: bigint, signature: Hex, publicClient: PublicClient): Promise<boolean>;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Converts FheTypes enum to string representation for serialization
|
|
134
|
+
* Used when passing data to Web Workers or other serialization contexts
|
|
135
|
+
*/
|
|
136
|
+
declare function fheTypeToString(utype: FheTypes): string;
|
|
137
|
+
|
|
138
|
+
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, createCofheClientBase, fheTypeToString, isCofheError, verifyDecryptResult };
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { c as CofheClientConnectionState, a as CofheConfig, d as CofheClientParams, b as CofheClient, F as FheTypes } from './clientTypes-flH1ju82.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-flH1ju82.js';
|
|
3
|
+
import { Hex, PublicClient } from 'viem';
|
|
4
|
+
import './types-YiAC4gig.js';
|
|
5
|
+
import 'zod';
|
|
6
|
+
import './permit-jRirYqFt.js';
|
|
7
|
+
import 'zustand/vanilla';
|
|
8
|
+
|
|
9
|
+
declare const InitialConnectStore: CofheClientConnectionState;
|
|
10
|
+
/**
|
|
11
|
+
* Creates a CoFHE client instance (base implementation)
|
|
12
|
+
* @param {CofheClientParams} opts - Initialization options including config and platform-specific serializers
|
|
13
|
+
* @returns {CofheClient} - The CoFHE client instance
|
|
14
|
+
*/
|
|
15
|
+
declare function createCofheClientBase<TConfig extends CofheConfig>(opts: CofheClientParams<TConfig>): CofheClient<TConfig>;
|
|
16
|
+
|
|
17
|
+
declare enum CofheErrorCode {
|
|
18
|
+
InternalError = "INTERNAL_ERROR",
|
|
19
|
+
UnknownEnvironment = "UNKNOWN_ENVIRONMENT",
|
|
20
|
+
InitTfheFailed = "INIT_TFHE_FAILED",
|
|
21
|
+
InitViemFailed = "INIT_VIEM_FAILED",
|
|
22
|
+
InitEthersFailed = "INIT_ETHERS_FAILED",
|
|
23
|
+
NotConnected = "NOT_CONNECTED",
|
|
24
|
+
MissingPublicClient = "MISSING_PUBLIC_CLIENT",
|
|
25
|
+
MissingWalletClient = "MISSING_WALLET_CLIENT",
|
|
26
|
+
MissingProviderParam = "MISSING_PROVIDER_PARAM",
|
|
27
|
+
EmptySecurityZonesParam = "EMPTY_SECURITY_ZONES_PARAM",
|
|
28
|
+
InvalidPermitData = "INVALID_PERMIT_DATA",
|
|
29
|
+
InvalidPermitDomain = "INVALID_PERMIT_DOMAIN",
|
|
30
|
+
PermitNotFound = "PERMIT_NOT_FOUND",
|
|
31
|
+
CannotRemoveLastPermit = "CANNOT_REMOVE_LAST_PERMIT",
|
|
32
|
+
AccountUninitialized = "ACCOUNT_UNINITIALIZED",
|
|
33
|
+
ChainIdUninitialized = "CHAIN_ID_UNINITIALIZED",
|
|
34
|
+
SealOutputFailed = "SEAL_OUTPUT_FAILED",
|
|
35
|
+
SealOutputReturnedNull = "SEAL_OUTPUT_RETURNED_NULL",
|
|
36
|
+
InvalidUtype = "INVALID_UTYPE",
|
|
37
|
+
DecryptFailed = "DECRYPT_FAILED",
|
|
38
|
+
DecryptReturnedNull = "DECRYPT_RETURNED_NULL",
|
|
39
|
+
ZkMocksInsertCtHashesFailed = "ZK_MOCKS_INSERT_CT_HASHES_FAILED",
|
|
40
|
+
ZkMocksCalcCtHashesFailed = "ZK_MOCKS_CALC_CT_HASHES_FAILED",
|
|
41
|
+
ZkMocksVerifySignFailed = "ZK_MOCKS_VERIFY_SIGN_FAILED",
|
|
42
|
+
ZkMocksCreateProofSignatureFailed = "ZK_MOCKS_CREATE_PROOF_SIGNATURE_FAILED",
|
|
43
|
+
ZkVerifyFailed = "ZK_VERIFY_FAILED",
|
|
44
|
+
ZkPackFailed = "ZK_PACK_FAILED",
|
|
45
|
+
ZkProveFailed = "ZK_PROVE_FAILED",
|
|
46
|
+
EncryptRemainingInItems = "ENCRYPT_REMAINING_IN_ITEMS",
|
|
47
|
+
ZkUninitialized = "ZK_UNINITIALIZED",
|
|
48
|
+
ZkVerifierUrlUninitialized = "ZK_VERIFIER_URL_UNINITIALIZED",
|
|
49
|
+
ThresholdNetworkUrlUninitialized = "THRESHOLD_NETWORK_URL_UNINITIALIZED",
|
|
50
|
+
MissingConfig = "MISSING_CONFIG",
|
|
51
|
+
UnsupportedChain = "UNSUPPORTED_CHAIN",
|
|
52
|
+
MissingZkBuilderAndCrsGenerator = "MISSING_ZK_BUILDER_AND_CRS_GENERATOR",
|
|
53
|
+
MissingTfhePublicKeyDeserializer = "MISSING_TFHE_PUBLIC_KEY_DESERIALIZER",
|
|
54
|
+
MissingCompactPkeCrsDeserializer = "MISSING_COMPACT_PKE_CRS_DESERIALIZER",
|
|
55
|
+
MissingFheKey = "MISSING_FHE_KEY",
|
|
56
|
+
MissingCrs = "MISSING_CRS",
|
|
57
|
+
FetchKeysFailed = "FETCH_KEYS_FAILED",
|
|
58
|
+
PublicWalletGetChainIdFailed = "PUBLIC_WALLET_GET_CHAIN_ID_FAILED",
|
|
59
|
+
PublicWalletGetAddressesFailed = "PUBLIC_WALLET_GET_ADDRESSES_FAILED",
|
|
60
|
+
RehydrateKeysStoreFailed = "REHYDRATE_KEYS_STORE_FAILED"
|
|
61
|
+
}
|
|
62
|
+
type CofheErrorParams = {
|
|
63
|
+
code: CofheErrorCode;
|
|
64
|
+
message: string;
|
|
65
|
+
cause?: Error;
|
|
66
|
+
hint?: string;
|
|
67
|
+
context?: Record<string, unknown>;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* CofheError class
|
|
71
|
+
* This class is used to create errors that are specific to the CoFHE SDK
|
|
72
|
+
* It extends the Error class and adds a code, cause, hint, and context
|
|
73
|
+
* The code is used to identify the type of error
|
|
74
|
+
* The cause is used to indicate the inner error that caused the CofheError
|
|
75
|
+
* The hint is used to provide a hint about how to fix the error
|
|
76
|
+
* The context is used to provide additional context about the state that caused the error
|
|
77
|
+
* The serialize method is used to serialize the error to a JSON string
|
|
78
|
+
* The toString method is used to provide a human-readable string representation of the error
|
|
79
|
+
*/
|
|
80
|
+
declare class CofheError extends Error {
|
|
81
|
+
readonly code: CofheErrorCode;
|
|
82
|
+
readonly cause?: Error;
|
|
83
|
+
readonly hint?: string;
|
|
84
|
+
readonly context?: Record<string, unknown>;
|
|
85
|
+
constructor({ code, message, cause, hint, context }: CofheErrorParams);
|
|
86
|
+
/**
|
|
87
|
+
* Creates a CofheError from an unknown error
|
|
88
|
+
* If the error is a CofheError, it is returned unchanged, else a new CofheError is created
|
|
89
|
+
* If a wrapperError is provided, it is used to create the new CofheError, else a default is used
|
|
90
|
+
*/
|
|
91
|
+
static fromError(error: unknown, wrapperError?: CofheErrorParams): CofheError;
|
|
92
|
+
/**
|
|
93
|
+
* Serializes the error to JSON string with proper handling of Error objects
|
|
94
|
+
*/
|
|
95
|
+
serialize(): string;
|
|
96
|
+
/**
|
|
97
|
+
* Returns a human-readable string representation of the error
|
|
98
|
+
*/
|
|
99
|
+
toString(): string;
|
|
100
|
+
}
|
|
101
|
+
declare const isCofheError: (error: unknown) => error is CofheError;
|
|
102
|
+
|
|
103
|
+
/** Main Task Manager contract address */
|
|
104
|
+
declare const TASK_MANAGER_ADDRESS: "0xeA30c4B8b44078Bbf8a6ef5b9f1eC1626C7848D9";
|
|
105
|
+
/** Mock ZK Verifier contract address (used for testing) */
|
|
106
|
+
declare const MOCKS_ZK_VERIFIER_ADDRESS: "0x0000000000000000000000000000000000005001";
|
|
107
|
+
/** Mock Threshold Network contract address (used for testing) */
|
|
108
|
+
declare const MOCKS_THRESHOLD_NETWORK_ADDRESS: "0x0000000000000000000000000000000000005002";
|
|
109
|
+
/** Test Bed contract address (used for testing) */
|
|
110
|
+
declare const TEST_BED_ADDRESS: "0x0000000000000000000000000000000000005003";
|
|
111
|
+
/** Private key for the Mock ZK Verifier signer account */
|
|
112
|
+
declare const MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY: "0x6C8D7F768A6BB4AAFE85E8A2F5A9680355239C7E14646ED62B044E39DE154512";
|
|
113
|
+
/** Address for the Mock ZK Verifier signer account */
|
|
114
|
+
declare const MOCKS_ZK_VERIFIER_SIGNER_ADDRESS: "0x6E12D8C87503D4287c294f2Fdef96ACd9DFf6bd2";
|
|
115
|
+
/** Private key for the Mock decrypt result signer account */
|
|
116
|
+
declare const MOCKS_DECRYPT_RESULT_SIGNER_PRIVATE_KEY: "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d";
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Verifies a decrypt result signature **locally** (no `ctHash`/plaintext sent over RPC).
|
|
120
|
+
*
|
|
121
|
+
* This matches the TaskManager contract logic:
|
|
122
|
+
* - messageHash = keccak256(abi.encodePacked(ctHash, result))
|
|
123
|
+
* - recovered = ecrecover(messageHash, signature)
|
|
124
|
+
* - recovered must equal the on-chain configured `decryptResultSigner`
|
|
125
|
+
*
|
|
126
|
+
* The only on-chain read performed is `TaskManager.decryptResultSigner()` (via `eth_call`).
|
|
127
|
+
*
|
|
128
|
+
* Works with both production and mock deployments.
|
|
129
|
+
*/
|
|
130
|
+
declare function verifyDecryptResult(handle: bigint | string, cleartext: bigint, signature: Hex, publicClient: PublicClient): Promise<boolean>;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Converts FheTypes enum to string representation for serialization
|
|
134
|
+
* Used when passing data to Web Workers or other serialization contexts
|
|
135
|
+
*/
|
|
136
|
+
declare function fheTypeToString(utype: FheTypes): string;
|
|
137
|
+
|
|
138
|
+
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, createCofheClientBase, fheTypeToString, isCofheError, verifyDecryptResult };
|
package/dist/core.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
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-36FBWLUS.js';
|
|
2
|
+
import './chunk-TBLR7NNE.js';
|
|
3
|
+
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 } from './chunk-7HLGHV67.js';
|