@cofhe/sdk 0.7.1 → 1.0.0-alpha.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 (123) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/acps/acp.ts +35 -7
  3. package/acps/index.ts +28 -12
  4. package/acps/onchain-utils.ts +188 -49
  5. package/acps/registry.ts +231 -0
  6. package/acps/sealing.ts +9 -3
  7. package/acps/share-metadata/appKey.ts +8 -0
  8. package/acps/share-metadata/decode.ts +120 -0
  9. package/acps/share-metadata/describe.ts +198 -0
  10. package/acps/share-metadata/encode.ts +147 -0
  11. package/acps/share-metadata/erc7984.ts +26 -0
  12. package/acps/share-metadata/index.ts +9 -0
  13. package/acps/share-metadata/layout.ts +69 -0
  14. package/acps/share-metadata/presets.ts +116 -0
  15. package/acps/share-metadata/schema.ts +47 -0
  16. package/acps/share-metadata/test/codec.test.ts +140 -0
  17. package/acps/share-metadata/test/describe.test.ts +112 -0
  18. package/acps/share-metadata/test/fixtures.ts +157 -0
  19. package/acps/share-metadata/test/live.test.ts +56 -0
  20. package/acps/share-metadata/test/presets.test.ts +119 -0
  21. package/acps/share-metadata/test/verify.test.ts +144 -0
  22. package/acps/share-metadata/verify.ts +155 -0
  23. package/acps/store.ts +48 -18
  24. package/acps/test/acp.test.ts +102 -7
  25. package/acps/test/localstorage.test.ts +28 -1
  26. package/acps/test/onchainAccessStatus.test.ts +116 -0
  27. package/acps/test/registry.test.ts +144 -0
  28. package/acps/test/sealing.test.ts +23 -0
  29. package/acps/test/store.test.ts +71 -0
  30. package/acps/test/utils.test.ts +63 -0
  31. package/acps/test/validation.test.ts +0 -4
  32. package/acps/types.ts +59 -6
  33. package/acps/utils.ts +15 -2
  34. package/acps/validation.ts +3 -1
  35. package/chains/chains/arbitrum.ts +14 -0
  36. package/chains/chains/ethereum.ts +14 -0
  37. package/chains/index.ts +5 -1
  38. package/chains/test/chains.test.ts +24 -3
  39. package/core/acps.ts +164 -207
  40. package/core/client.ts +44 -13
  41. package/core/clientTypes.ts +50 -7
  42. package/core/config.ts +33 -1
  43. package/core/consts.ts +14 -2
  44. package/core/decrypt/apiError.ts +4 -1
  45. package/core/decrypt/verifyDecryptResult.ts +8 -4
  46. package/core/encrypt/cofheMocksZkVerifySign.ts +19 -2
  47. package/core/encrypt/encryptInputsBuilder.ts +6 -0
  48. package/core/encrypt/zkPackProveVerify.ts +7 -1
  49. package/core/error.ts +1 -0
  50. package/core/fetchKeys.ts +2 -2
  51. package/core/index.ts +9 -1
  52. package/core/keyStore.ts +23 -10
  53. package/core/taskManager.ts +48 -0
  54. package/core/test/acpDefaults.test.ts +108 -19
  55. package/core/test/acpStoreAccountCase.test.ts +80 -0
  56. package/core/test/acps.test.ts +128 -3
  57. package/core/test/apiError.test.ts +8 -0
  58. package/core/test/appKeyConfig.test.ts +94 -0
  59. package/core/test/client.test.ts +41 -0
  60. package/core/test/config.test.ts +24 -0
  61. package/core/test/decrypt.test.ts +11 -4
  62. package/core/test/decryptBuilders.test.ts +110 -2
  63. package/core/test/encryptInputsBuilder.test.ts +1 -1
  64. package/core/test/fetchKeys.test.ts +23 -2
  65. package/core/test/incomingShares.test.ts +84 -0
  66. package/core/test/keyStore.test.ts +18 -6
  67. package/core/test/mocksEncryptRange.test.ts +90 -0
  68. package/core/test/taskManager.test.ts +57 -0
  69. package/core/test/utils.test.ts +128 -0
  70. package/core/test/verifyDecryptResult.test.ts +51 -0
  71. package/core/types.ts +8 -0
  72. package/core/utils.ts +16 -9
  73. package/dist/acps.cjs +984 -64
  74. package/dist/acps.d.cts +589 -10
  75. package/dist/acps.d.ts +589 -10
  76. package/dist/acps.js +2 -2
  77. package/dist/chains.cjs +26 -0
  78. package/dist/chains.d.cts +45 -1
  79. package/dist/chains.d.ts +45 -1
  80. package/dist/chains.js +1 -1
  81. package/dist/chunk-6ZW76ZKB.js +228 -0
  82. package/dist/chunk-BQWHPIYU.js +1828 -0
  83. package/dist/chunk-KSOV5B4B.js +50 -0
  84. package/dist/{chunk-43USWPEH.js → chunk-OL3DZN7A.js} +159 -523
  85. package/dist/{chunk-N6IDQRRU.js → chunk-UKQAJK4N.js} +25 -1
  86. package/dist/chunk-XQ32JG3T.js +174 -0
  87. package/dist/{clientTypes-CYZjFznO.d.cts → clientTypes-C0A9ji5O.d.cts} +132 -29
  88. package/dist/{clientTypes-BN3nbzYM.d.ts → clientTypes-CcU5WvdV.d.ts} +132 -29
  89. package/dist/core.cjs +3269 -2626
  90. package/dist/core.d.cts +32 -8
  91. package/dist/core.d.ts +32 -8
  92. package/dist/core.js +5 -4
  93. package/dist/node.cjs +3074 -2436
  94. package/dist/node.d.cts +2 -2
  95. package/dist/node.d.ts +2 -2
  96. package/dist/node.js +20 -19
  97. package/dist/{acp-Wi6isVQI.d.cts → onchain-utils-D9Z33IP7.d.cts} +166 -12
  98. package/dist/{acp-Wi6isVQI.d.ts → onchain-utils-D9Z33IP7.d.ts} +166 -12
  99. package/dist/web.cjs +3204 -2493
  100. package/dist/web.d.cts +49 -3
  101. package/dist/web.d.ts +49 -3
  102. package/dist/web.js +52 -27
  103. package/dist/zkProve.worker.cjs +79 -18
  104. package/dist/zkProve.worker.js +24 -24
  105. package/node/index.ts +1 -10
  106. package/node/storage.ts +20 -9
  107. package/node/test/inherited.test.ts +5 -1
  108. package/node/test/storage-memory-fallback.test.ts +47 -0
  109. package/node/test/storage-permissions.test.ts +40 -0
  110. package/package.json +3 -1
  111. package/web/index.ts +101 -36
  112. package/web/test/countingZkProveWorker.ts +31 -0
  113. package/web/test/inherited.web.test.ts +5 -1
  114. package/web/test/mainThreadPool.web.test.ts +174 -0
  115. package/web/test/threadPoolBenchHelper.ts +134 -0
  116. package/web/test/threadPoolOff.web.test.ts +17 -0
  117. package/web/test/threadPoolOn.web.test.ts +80 -0
  118. package/web/test/workerInitRace.web.test.ts +79 -0
  119. package/web/tfheThreadPool.ts +140 -0
  120. package/web/workerManager.ts +4 -2
  121. package/web/zkProve.worker.ts +42 -26
  122. package/dist/chunk-ESMZCFJY.js +0 -12
  123. package/dist/chunk-Q7CBWGQX.js +0 -1029
package/dist/core.d.cts CHANGED
@@ -1,9 +1,9 @@
1
- import { a as CofheConfig, c as CofheClientParams, b as CofheClient, d as CofheClientConnectionState, F as FheTypes } from './clientTypes-CYZjFznO.cjs';
2
- export { A as AnyExternalHash, i as CofheClientACPs, C as CofheInputConfig, h as CofheInternalConfig, K as DecryptEndpoint, a2 as DecryptForTxBuilder, a3 as DecryptForTxResult, a1 as DecryptForViewBuilder, J as DecryptPollCallbackContext, G as DecryptPollCallbackFunction, $ as EncryptInputsBuilder, a0 as EncryptInputsBuilderUnset, M as EncryptSetStateFn, T as EncryptStep, N as EncryptStepCallbackContext, R as Encryptable, p as EncryptableAddress, j as EncryptableBool, E as EncryptableItem, B as EncryptableToExternalHashMap, o as EncryptableUint128, l as EncryptableUint16, m as EncryptableUint32, n as EncryptableUint64, k as EncryptableUint8, q as EncryptedNumber, y as ExternalAddressHash, s as ExternalBoolHash, z as ExternalHashProof, D as ExternalItemHashes, x as ExternalUint128Hash, u as ExternalUint16Hash, v as ExternalUint32Hash, w as ExternalUint64Hash, t as ExternalUint8Hash, Q as FheAllUTypes, X as FheKeyDeserializer, r as FheTypeValue, O as FheUintUTypes, H as HashPlusProofResult, I as IStorage, Z as KeysStorage, _ as KeysStore, L as LiteralToPrimitive, P as Primitive, U as UnsealedItem, a4 as ZkBuilderAndCrsGenerator, a5 as ZkProveWorkerFunction, a6 as ZkProveWorkerRequest, a7 as ZkProveWorkerResponse, f as assertNoRenamedConfigKeys, e as createCofheConfigBase, Y as createKeysStore, W as fetchKeys, g as getCofheConfigItem, S as isEncryptableItem, V as isLastEncryptionStep, a8 as zkProveWithWorker } from './clientTypes-CYZjFznO.cjs';
3
- import { Hex, PublicClient } from 'viem';
1
+ import { a as CofheConfig, c as CofheClientParams, b as CofheClient, d as CofheClientConnectionState, F as FheTypes } from './clientTypes-C0A9ji5O.cjs';
2
+ export { A as AnyExternalHash, i as CofheClientACPs, C as CofheInputConfig, h as CofheInternalConfig, K as DecryptEndpoint, a4 as DecryptForTxBuilder, a5 as DecryptForTxResult, a3 as DecryptForViewBuilder, J as DecryptPollCallbackContext, G as DecryptPollCallbackFunction, a1 as EncryptInputsBuilder, a2 as EncryptInputsBuilderUnset, M as EncryptSetStateFn, W as EncryptStep, N as EncryptStepCallbackContext, S as Encryptable, p as EncryptableAddress, j as EncryptableBool, E as EncryptableItem, B as EncryptableToExternalHashMap, o as EncryptableUint128, l as EncryptableUint16, m as EncryptableUint32, n as EncryptableUint64, k as EncryptableUint8, q as EncryptedNumber, y as ExternalAddressHash, s as ExternalBoolHash, z as ExternalHashProof, D as ExternalItemHashes, x as ExternalUint128Hash, u as ExternalUint16Hash, v as ExternalUint32Hash, w as ExternalUint64Hash, t as ExternalUint8Hash, R as FheAllUTypes, Z as FheKeyDeserializer, r as FheTypeValue, Q as FheUintUTypes, H as HashPlusProofResult, I as IStorage, $ as KeysStorage, a0 as KeysStore, L as LiteralToPrimitive, P as Primitive, T as TfheInitializer, O as TfheThreadsSetting, U as UnsealedItem, a6 as ZkBuilderAndCrsGenerator, a7 as ZkProveWorkerFunction, a8 as ZkProveWorkerRequest, a9 as ZkProveWorkerResponse, f as assertNoRenamedConfigKeys, e as createCofheConfigBase, _ as createKeysStore, Y as fetchKeys, g as getCofheConfigItem, V as isEncryptableItem, X as isLastEncryptionStep, aa as zkProveWithWorker } from './clientTypes-C0A9ji5O.cjs';
3
+ import { PublicClient, Address, Hex } from 'viem';
4
4
  import './types-C07FK-cL.cjs';
5
5
  import 'zod';
6
- import './acp-Wi6isVQI.cjs';
6
+ import './onchain-utils-D9Z33IP7.cjs';
7
7
  import 'zustand/vanilla';
8
8
 
9
9
  declare const InitialConnectStore: CofheClientConnectionState;
@@ -82,6 +82,7 @@ declare enum CofheErrorCode {
82
82
  PublicWalletGetChainIdFailed = "PUBLIC_WALLET_GET_CHAIN_ID_FAILED",
83
83
  PublicWalletGetAddressesFailed = "PUBLIC_WALLET_GET_ADDRESSES_FAILED",
84
84
  RehydrateKeysStoreFailed = "REHYDRATE_KEYS_STORE_FAILED",
85
+ TaskManagerUnresolved = "TASK_MANAGER_UNRESOLVED",
85
86
  BadRequest = "BAD_REQUEST",
86
87
  UnknownChain = "UNKNOWN_CHAIN",
87
88
  ACPMalformed = "ACP_MALFORMED",
@@ -145,8 +146,18 @@ declare class CofheError extends Error {
145
146
  }
146
147
  declare const isCofheError: (error: unknown) => error is CofheError;
147
148
 
148
- /** Main Task Manager contract address */
149
- declare const TASK_MANAGER_ADDRESS: "0xeA30c4B8b44078Bbf8a6ef5b9f1eC1626C7848D9";
149
+ /**
150
+ * CoFHEAddressBook contract address - the same on every chain. Resolves `TASK_MANAGER_ID` to the
151
+ * chain's Task Manager. Keep in sync with `COFHE_ADDRESS_BOOK` in `@fhenixprotocol/cofhe-contracts/FHE.sol`.
152
+ */
153
+ declare const COFHE_ADDRESS_BOOK_ADDRESS: "0xC0F4e00E531a2B086492Ae3DCC1515038307196b";
154
+ /** Id of the Task Manager in the CoFHEAddressBook. Keep in sync with `TASK_MANAGER_ID` in FHE.sol */
155
+ declare const TASK_MANAGER_ID = 1n;
156
+ /**
157
+ * Mock Task Manager contract address (used for testing). Registered in the mock CoFHEAddressBook;
158
+ * SDK reads still resolve the Task Manager through the book.
159
+ */
160
+ declare const MOCKS_TASK_MANAGER_ADDRESS: "0x0000000000000000000000000000000000005000";
150
161
  /** Mock ZK Verifier contract address (used for testing) */
151
162
  declare const MOCKS_ZK_VERIFIER_ADDRESS: "0x0000000000000000000000000000000000005001";
152
163
  /** Mock Threshold Network contract address (used for testing) */
@@ -162,15 +173,28 @@ declare const TFHE_RS_ZK_MAX_BITS: 2048;
162
173
  /** Size limit for safe_serialize/safe_deserialize (1 GB) */
163
174
  declare const TFHE_RS_SAFE_SERIALIZATION_SIZE_LIMIT: bigint;
164
175
 
176
+ /**
177
+ * The chain's Task Manager, resolved through the CoFHEAddressBook
178
+ * (`getTm(TASK_MANAGER_ID)`) - the same lookup FHE.sol performs on every call.
179
+ *
180
+ * Resolutions are cached per chainId. A failed resolution (network error, no
181
+ * CoFHE deployment, id unset) is NOT cached, so a later call retries.
182
+ */
183
+ declare const getTaskManagerAddress: (publicClient: PublicClient, chainId?: number) => Promise<Address>;
184
+
165
185
  /**
166
186
  * Verifies a decrypt result signature **locally** (no `ctHash`/plaintext sent over RPC).
167
187
  *
168
188
  * The recovered signer must equal the on-chain configured `decryptResultSigner`.
169
189
  *
190
+ * Fails closed: if the chain has no `decryptResultSigner` set (zero address), this returns `false`.
191
+ * The on-chain `verifyDecryptResult` instead accepts any signature in that case.
192
+ *
170
193
  * This mirrors the TaskManager decrypt-result hash format:
171
194
  * `keccak256(abi.encodePacked(result, encType, chainId, ctHash))`
172
195
  *
173
- * The only on-chain read performed is `TaskManager.decryptResultSigner()` (via `eth_call`).
196
+ * The only on-chain reads performed are the Task Manager lookup in the CoFHEAddressBook (cached
197
+ * per chain) and `TaskManager.decryptResultSigner()` (via `eth_call`).
174
198
  *
175
199
  * Works with both production and mock deployments.
176
200
  */
@@ -182,4 +206,4 @@ declare function verifyDecryptResult(handle: bigint | string, cleartext: bigint,
182
206
  */
183
207
  declare function fheTypeToString(utype: FheTypes): string;
184
208
 
185
- export { InitialConnectStore as CONNECT_STORE_DEFAULTS, CofheClient, CofheClientConnectionState, CofheClientParams, CofheConfig, type CofheDebugInterceptors, CofheError, CofheErrorCode, type CofheErrorParams, type CofheOnRequest, type CofheOnResponse, type CofheRequestContext, type CofheRequestOverride, 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, cofheFetch, createCofheClientBase, fheTypeToString, getCofheDebugInterceptors, isCofheError, setCofheDebugInterceptors, verifyDecryptResult };
209
+ export { COFHE_ADDRESS_BOOK_ADDRESS, InitialConnectStore as CONNECT_STORE_DEFAULTS, CofheClient, CofheClientConnectionState, CofheClientParams, CofheConfig, type CofheDebugInterceptors, CofheError, CofheErrorCode, type CofheErrorParams, type CofheOnRequest, type CofheOnResponse, type CofheRequestContext, type CofheRequestOverride, FheTypes, MOCKS_DECRYPT_RESULT_SIGNER_PRIVATE_KEY, MOCKS_TASK_MANAGER_ADDRESS, MOCKS_THRESHOLD_NETWORK_ADDRESS, MOCKS_ZK_VERIFIER_ADDRESS, MOCKS_ZK_VERIFIER_SIGNER_ADDRESS, MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY, TASK_MANAGER_ID, TFHE_RS_SAFE_SERIALIZATION_SIZE_LIMIT, TFHE_RS_ZK_MAX_BITS, cofheFetch, createCofheClientBase, fheTypeToString, getCofheDebugInterceptors, getTaskManagerAddress, isCofheError, setCofheDebugInterceptors, verifyDecryptResult };
package/dist/core.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { a as CofheConfig, c as CofheClientParams, b as CofheClient, d as CofheClientConnectionState, F as FheTypes } from './clientTypes-BN3nbzYM.js';
2
- export { A as AnyExternalHash, i as CofheClientACPs, C as CofheInputConfig, h as CofheInternalConfig, K as DecryptEndpoint, a2 as DecryptForTxBuilder, a3 as DecryptForTxResult, a1 as DecryptForViewBuilder, J as DecryptPollCallbackContext, G as DecryptPollCallbackFunction, $ as EncryptInputsBuilder, a0 as EncryptInputsBuilderUnset, M as EncryptSetStateFn, T as EncryptStep, N as EncryptStepCallbackContext, R as Encryptable, p as EncryptableAddress, j as EncryptableBool, E as EncryptableItem, B as EncryptableToExternalHashMap, o as EncryptableUint128, l as EncryptableUint16, m as EncryptableUint32, n as EncryptableUint64, k as EncryptableUint8, q as EncryptedNumber, y as ExternalAddressHash, s as ExternalBoolHash, z as ExternalHashProof, D as ExternalItemHashes, x as ExternalUint128Hash, u as ExternalUint16Hash, v as ExternalUint32Hash, w as ExternalUint64Hash, t as ExternalUint8Hash, Q as FheAllUTypes, X as FheKeyDeserializer, r as FheTypeValue, O as FheUintUTypes, H as HashPlusProofResult, I as IStorage, Z as KeysStorage, _ as KeysStore, L as LiteralToPrimitive, P as Primitive, U as UnsealedItem, a4 as ZkBuilderAndCrsGenerator, a5 as ZkProveWorkerFunction, a6 as ZkProveWorkerRequest, a7 as ZkProveWorkerResponse, f as assertNoRenamedConfigKeys, e as createCofheConfigBase, Y as createKeysStore, W as fetchKeys, g as getCofheConfigItem, S as isEncryptableItem, V as isLastEncryptionStep, a8 as zkProveWithWorker } from './clientTypes-BN3nbzYM.js';
3
- import { Hex, PublicClient } from 'viem';
1
+ import { a as CofheConfig, c as CofheClientParams, b as CofheClient, d as CofheClientConnectionState, F as FheTypes } from './clientTypes-CcU5WvdV.js';
2
+ export { A as AnyExternalHash, i as CofheClientACPs, C as CofheInputConfig, h as CofheInternalConfig, K as DecryptEndpoint, a4 as DecryptForTxBuilder, a5 as DecryptForTxResult, a3 as DecryptForViewBuilder, J as DecryptPollCallbackContext, G as DecryptPollCallbackFunction, a1 as EncryptInputsBuilder, a2 as EncryptInputsBuilderUnset, M as EncryptSetStateFn, W as EncryptStep, N as EncryptStepCallbackContext, S as Encryptable, p as EncryptableAddress, j as EncryptableBool, E as EncryptableItem, B as EncryptableToExternalHashMap, o as EncryptableUint128, l as EncryptableUint16, m as EncryptableUint32, n as EncryptableUint64, k as EncryptableUint8, q as EncryptedNumber, y as ExternalAddressHash, s as ExternalBoolHash, z as ExternalHashProof, D as ExternalItemHashes, x as ExternalUint128Hash, u as ExternalUint16Hash, v as ExternalUint32Hash, w as ExternalUint64Hash, t as ExternalUint8Hash, R as FheAllUTypes, Z as FheKeyDeserializer, r as FheTypeValue, Q as FheUintUTypes, H as HashPlusProofResult, I as IStorage, $ as KeysStorage, a0 as KeysStore, L as LiteralToPrimitive, P as Primitive, T as TfheInitializer, O as TfheThreadsSetting, U as UnsealedItem, a6 as ZkBuilderAndCrsGenerator, a7 as ZkProveWorkerFunction, a8 as ZkProveWorkerRequest, a9 as ZkProveWorkerResponse, f as assertNoRenamedConfigKeys, e as createCofheConfigBase, _ as createKeysStore, Y as fetchKeys, g as getCofheConfigItem, V as isEncryptableItem, X as isLastEncryptionStep, aa as zkProveWithWorker } from './clientTypes-CcU5WvdV.js';
3
+ import { PublicClient, Address, Hex } from 'viem';
4
4
  import './types-C07FK-cL.js';
5
5
  import 'zod';
6
- import './acp-Wi6isVQI.js';
6
+ import './onchain-utils-D9Z33IP7.js';
7
7
  import 'zustand/vanilla';
8
8
 
9
9
  declare const InitialConnectStore: CofheClientConnectionState;
@@ -82,6 +82,7 @@ declare enum CofheErrorCode {
82
82
  PublicWalletGetChainIdFailed = "PUBLIC_WALLET_GET_CHAIN_ID_FAILED",
83
83
  PublicWalletGetAddressesFailed = "PUBLIC_WALLET_GET_ADDRESSES_FAILED",
84
84
  RehydrateKeysStoreFailed = "REHYDRATE_KEYS_STORE_FAILED",
85
+ TaskManagerUnresolved = "TASK_MANAGER_UNRESOLVED",
85
86
  BadRequest = "BAD_REQUEST",
86
87
  UnknownChain = "UNKNOWN_CHAIN",
87
88
  ACPMalformed = "ACP_MALFORMED",
@@ -145,8 +146,18 @@ declare class CofheError extends Error {
145
146
  }
146
147
  declare const isCofheError: (error: unknown) => error is CofheError;
147
148
 
148
- /** Main Task Manager contract address */
149
- declare const TASK_MANAGER_ADDRESS: "0xeA30c4B8b44078Bbf8a6ef5b9f1eC1626C7848D9";
149
+ /**
150
+ * CoFHEAddressBook contract address - the same on every chain. Resolves `TASK_MANAGER_ID` to the
151
+ * chain's Task Manager. Keep in sync with `COFHE_ADDRESS_BOOK` in `@fhenixprotocol/cofhe-contracts/FHE.sol`.
152
+ */
153
+ declare const COFHE_ADDRESS_BOOK_ADDRESS: "0xC0F4e00E531a2B086492Ae3DCC1515038307196b";
154
+ /** Id of the Task Manager in the CoFHEAddressBook. Keep in sync with `TASK_MANAGER_ID` in FHE.sol */
155
+ declare const TASK_MANAGER_ID = 1n;
156
+ /**
157
+ * Mock Task Manager contract address (used for testing). Registered in the mock CoFHEAddressBook;
158
+ * SDK reads still resolve the Task Manager through the book.
159
+ */
160
+ declare const MOCKS_TASK_MANAGER_ADDRESS: "0x0000000000000000000000000000000000005000";
150
161
  /** Mock ZK Verifier contract address (used for testing) */
151
162
  declare const MOCKS_ZK_VERIFIER_ADDRESS: "0x0000000000000000000000000000000000005001";
152
163
  /** Mock Threshold Network contract address (used for testing) */
@@ -162,15 +173,28 @@ declare const TFHE_RS_ZK_MAX_BITS: 2048;
162
173
  /** Size limit for safe_serialize/safe_deserialize (1 GB) */
163
174
  declare const TFHE_RS_SAFE_SERIALIZATION_SIZE_LIMIT: bigint;
164
175
 
176
+ /**
177
+ * The chain's Task Manager, resolved through the CoFHEAddressBook
178
+ * (`getTm(TASK_MANAGER_ID)`) - the same lookup FHE.sol performs on every call.
179
+ *
180
+ * Resolutions are cached per chainId. A failed resolution (network error, no
181
+ * CoFHE deployment, id unset) is NOT cached, so a later call retries.
182
+ */
183
+ declare const getTaskManagerAddress: (publicClient: PublicClient, chainId?: number) => Promise<Address>;
184
+
165
185
  /**
166
186
  * Verifies a decrypt result signature **locally** (no `ctHash`/plaintext sent over RPC).
167
187
  *
168
188
  * The recovered signer must equal the on-chain configured `decryptResultSigner`.
169
189
  *
190
+ * Fails closed: if the chain has no `decryptResultSigner` set (zero address), this returns `false`.
191
+ * The on-chain `verifyDecryptResult` instead accepts any signature in that case.
192
+ *
170
193
  * This mirrors the TaskManager decrypt-result hash format:
171
194
  * `keccak256(abi.encodePacked(result, encType, chainId, ctHash))`
172
195
  *
173
- * The only on-chain read performed is `TaskManager.decryptResultSigner()` (via `eth_call`).
196
+ * The only on-chain reads performed are the Task Manager lookup in the CoFHEAddressBook (cached
197
+ * per chain) and `TaskManager.decryptResultSigner()` (via `eth_call`).
174
198
  *
175
199
  * Works with both production and mock deployments.
176
200
  */
@@ -182,4 +206,4 @@ declare function verifyDecryptResult(handle: bigint | string, cleartext: bigint,
182
206
  */
183
207
  declare function fheTypeToString(utype: FheTypes): string;
184
208
 
185
- export { InitialConnectStore as CONNECT_STORE_DEFAULTS, CofheClient, CofheClientConnectionState, CofheClientParams, CofheConfig, type CofheDebugInterceptors, CofheError, CofheErrorCode, type CofheErrorParams, type CofheOnRequest, type CofheOnResponse, type CofheRequestContext, type CofheRequestOverride, 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, cofheFetch, createCofheClientBase, fheTypeToString, getCofheDebugInterceptors, isCofheError, setCofheDebugInterceptors, verifyDecryptResult };
209
+ export { COFHE_ADDRESS_BOOK_ADDRESS, InitialConnectStore as CONNECT_STORE_DEFAULTS, CofheClient, CofheClientConnectionState, CofheClientParams, CofheConfig, type CofheDebugInterceptors, CofheError, CofheErrorCode, type CofheErrorParams, type CofheOnRequest, type CofheOnResponse, type CofheRequestContext, type CofheRequestOverride, FheTypes, MOCKS_DECRYPT_RESULT_SIGNER_PRIVATE_KEY, MOCKS_TASK_MANAGER_ADDRESS, MOCKS_THRESHOLD_NETWORK_ADDRESS, MOCKS_ZK_VERIFIER_ADDRESS, MOCKS_ZK_VERIFIER_SIGNER_ADDRESS, MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY, TASK_MANAGER_ID, TFHE_RS_SAFE_SERIALIZATION_SIZE_LIMIT, TFHE_RS_ZK_MAX_BITS, cofheFetch, createCofheClientBase, fheTypeToString, getCofheDebugInterceptors, getTaskManagerAddress, isCofheError, setCofheDebugInterceptors, verifyDecryptResult };
package/dist/core.js CHANGED
@@ -1,4 +1,5 @@
1
- export { InitialConnectStore as CONNECT_STORE_DEFAULTS, CofheError, CofheErrorCode, DecryptForTxBuilder, DecryptForViewBuilder, EncryptInputsBuilder, EncryptStep, Encryptable, FheAllUTypes, FheTypes, FheUintUTypes, assertNoRenamedConfigKeys, cofheFetch, createCofheClientBase, createCofheConfigBase, createKeysStore, fetchKeys, fheTypeToString, getCofheConfigItem, getCofheDebugInterceptors, isCofheError, isEncryptableItem, isLastEncryptionStep, setCofheDebugInterceptors, verifyDecryptResult, zkProveWithWorker } from './chunk-43USWPEH.js';
2
- import './chunk-N6IDQRRU.js';
3
- import './chunk-Q7CBWGQX.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';
1
+ export { InitialConnectStore as CONNECT_STORE_DEFAULTS, DecryptForTxBuilder, DecryptForViewBuilder, EncryptInputsBuilder, assertNoRenamedConfigKeys, cofheFetch, createCofheClientBase, createCofheConfigBase, createKeysStore, fetchKeys, getCofheConfigItem, getCofheDebugInterceptors, setCofheDebugInterceptors, verifyDecryptResult, zkProveWithWorker } from './chunk-OL3DZN7A.js';
2
+ import './chunk-UKQAJK4N.js';
3
+ export { getTaskManagerAddress } from './chunk-BQWHPIYU.js';
4
+ export { EncryptStep, Encryptable, FheAllUTypes, FheTypes, FheUintUTypes, fheTypeToString, isEncryptableItem, isLastEncryptionStep } from './chunk-6ZW76ZKB.js';
5
+ export { COFHE_ADDRESS_BOOK_ADDRESS, CofheError, CofheErrorCode, MOCKS_DECRYPT_RESULT_SIGNER_PRIVATE_KEY, MOCKS_TASK_MANAGER_ADDRESS, MOCKS_THRESHOLD_NETWORK_ADDRESS, MOCKS_ZK_VERIFIER_ADDRESS, MOCKS_ZK_VERIFIER_SIGNER_ADDRESS, MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY, TASK_MANAGER_ID, TFHE_RS_SAFE_SERIALIZATION_SIZE_LIMIT, TFHE_RS_ZK_MAX_BITS, isCofheError } from './chunk-XQ32JG3T.js';