@cofhe/sdk 0.2.1 → 0.3.1

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 (54) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/core/baseBuilder.ts +18 -18
  3. package/core/client.test.ts +58 -55
  4. package/core/client.ts +50 -30
  5. package/core/clientTypes.ts +21 -17
  6. package/core/config.test.ts +32 -33
  7. package/core/config.ts +47 -48
  8. package/core/consts.ts +6 -2
  9. package/core/decrypt/{MockQueryDecrypterAbi.ts → MockThresholdNetworkAbi.ts} +71 -21
  10. package/core/decrypt/cofheMocksDecryptForTx.ts +142 -0
  11. package/core/decrypt/{cofheMocksSealOutput.ts → cofheMocksDecryptForView.ts} +12 -12
  12. package/core/decrypt/decryptForTxBuilder.ts +340 -0
  13. package/core/decrypt/{decryptHandleBuilder.ts → decryptForViewBuilder.ts} +75 -42
  14. package/core/decrypt/tnDecrypt.ts +232 -0
  15. package/core/decrypt/tnSealOutputV1.ts +5 -5
  16. package/core/decrypt/tnSealOutputV2.ts +27 -27
  17. package/core/encrypt/cofheMocksZkVerifySign.ts +15 -15
  18. package/core/encrypt/encryptInputsBuilder.test.ts +57 -61
  19. package/core/encrypt/encryptInputsBuilder.ts +65 -42
  20. package/core/encrypt/zkPackProveVerify.ts +11 -11
  21. package/core/error.ts +18 -18
  22. package/core/fetchKeys.test.ts +3 -3
  23. package/core/fetchKeys.ts +3 -3
  24. package/core/index.ts +14 -11
  25. package/core/utils.ts +10 -10
  26. package/dist/{chunk-I5WFEYXX.js → chunk-2TPSCOW3.js} +791 -209
  27. package/dist/{chunk-R3B5TMVX.js → chunk-NWDKXBIP.js} +3 -2
  28. package/dist/{clientTypes-RqkgkV2i.d.ts → clientTypes-6aTZPQ_4.d.ts} +204 -85
  29. package/dist/{clientTypes-e4filDzK.d.cts → clientTypes-Bhq7pCSA.d.cts} +204 -85
  30. package/dist/core.cjs +799 -214
  31. package/dist/core.d.cts +25 -23
  32. package/dist/core.d.ts +25 -23
  33. package/dist/core.js +2 -2
  34. package/dist/node.cjs +748 -165
  35. package/dist/node.d.cts +10 -10
  36. package/dist/node.d.ts +10 -10
  37. package/dist/node.js +7 -7
  38. package/dist/permits.js +1 -1
  39. package/dist/web.cjs +751 -168
  40. package/dist/web.d.cts +11 -11
  41. package/dist/web.d.ts +11 -11
  42. package/dist/web.js +9 -9
  43. package/node/client.test.ts +34 -34
  44. package/node/config.test.ts +11 -11
  45. package/node/encryptInputs.test.ts +29 -29
  46. package/node/index.ts +15 -15
  47. package/package.json +3 -3
  48. package/web/client.web.test.ts +34 -34
  49. package/web/config.web.test.ts +11 -11
  50. package/web/encryptInputs.web.test.ts +29 -29
  51. package/web/index.ts +19 -19
  52. package/web/worker.builder.web.test.ts +28 -28
  53. package/web/worker.config.web.test.ts +47 -47
  54. package/web/worker.output.web.test.ts +10 -10
package/dist/node.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as CofhesdkInputConfig, a as CofhesdkConfig, b as CofhesdkClient } from './clientTypes-e4filDzK.cjs';
1
+ import { C as CofheInputConfig, a as CofheConfig, b as CofheClient } from './clientTypes-Bhq7pCSA.cjs';
2
2
  import 'viem';
3
3
  import './types-YiAC4gig.cjs';
4
4
  import 'zod';
@@ -6,17 +6,17 @@ import './permit-MZ502UBl.cjs';
6
6
  import 'zustand/vanilla';
7
7
 
8
8
  /**
9
- * Creates a CoFHE SDK configuration for Node.js with filesystem storage as default
10
- * @param config - The CoFHE SDK input configuration (fheKeyStorage will default to filesystem if not provided)
11
- * @returns The CoFHE SDK configuration with Node.js defaults applied
9
+ * Creates a CoFHE configuration for Node.js with filesystem storage as default
10
+ * @param config - The CoFHE input configuration (fheKeyStorage will default to filesystem if not provided)
11
+ * @returns The CoFHE configuration with Node.js defaults applied
12
12
  */
13
- declare function createCofhesdkConfig(config: CofhesdkInputConfig): CofhesdkConfig;
13
+ declare function createCofheConfig(config: CofheInputConfig): CofheConfig;
14
14
  /**
15
- * Creates a CoFHE SDK client instance for Node.js with node-tfhe automatically configured
15
+ * Creates a CoFHE client instance for Node.js with node-tfhe automatically configured
16
16
  * TFHE will be initialized automatically on first encryption - no manual setup required
17
- * @param config - The CoFHE SDK configuration (use createCofhesdkConfig to create with Node.js defaults)
18
- * @returns The CoFHE SDK client instance
17
+ * @param config - The CoFHE configuration (use createCofheConfig to create with Node.js defaults)
18
+ * @returns The CoFHE client instance
19
19
  */
20
- declare function createCofhesdkClient(config: CofhesdkConfig): CofhesdkClient;
20
+ declare function createCofheClient(config: CofheConfig): CofheClient;
21
21
 
22
- export { createCofhesdkClient, createCofhesdkConfig };
22
+ export { createCofheClient, createCofheConfig };
package/dist/node.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as CofhesdkInputConfig, a as CofhesdkConfig, b as CofhesdkClient } from './clientTypes-RqkgkV2i.js';
1
+ import { C as CofheInputConfig, a as CofheConfig, b as CofheClient } from './clientTypes-6aTZPQ_4.js';
2
2
  import 'viem';
3
3
  import './types-YiAC4gig.js';
4
4
  import 'zod';
@@ -6,17 +6,17 @@ import './permit-MZ502UBl.js';
6
6
  import 'zustand/vanilla';
7
7
 
8
8
  /**
9
- * Creates a CoFHE SDK configuration for Node.js with filesystem storage as default
10
- * @param config - The CoFHE SDK input configuration (fheKeyStorage will default to filesystem if not provided)
11
- * @returns The CoFHE SDK configuration with Node.js defaults applied
9
+ * Creates a CoFHE configuration for Node.js with filesystem storage as default
10
+ * @param config - The CoFHE input configuration (fheKeyStorage will default to filesystem if not provided)
11
+ * @returns The CoFHE configuration with Node.js defaults applied
12
12
  */
13
- declare function createCofhesdkConfig(config: CofhesdkInputConfig): CofhesdkConfig;
13
+ declare function createCofheConfig(config: CofheInputConfig): CofheConfig;
14
14
  /**
15
- * Creates a CoFHE SDK client instance for Node.js with node-tfhe automatically configured
15
+ * Creates a CoFHE client instance for Node.js with node-tfhe automatically configured
16
16
  * TFHE will be initialized automatically on first encryption - no manual setup required
17
- * @param config - The CoFHE SDK configuration (use createCofhesdkConfig to create with Node.js defaults)
18
- * @returns The CoFHE SDK client instance
17
+ * @param config - The CoFHE configuration (use createCofheConfig to create with Node.js defaults)
18
+ * @returns The CoFHE client instance
19
19
  */
20
- declare function createCofhesdkClient(config: CofhesdkConfig): CofhesdkClient;
20
+ declare function createCofheClient(config: CofheConfig): CofheClient;
21
21
 
22
- export { createCofhesdkClient, createCofhesdkConfig };
22
+ export { createCofheClient, createCofheConfig };
package/dist/node.js CHANGED
@@ -1,6 +1,6 @@
1
- import { createCofhesdkConfigBase, createCofhesdkClientBase } from './chunk-I5WFEYXX.js';
1
+ import { createCofheConfigBase, createCofheClientBase } from './chunk-2TPSCOW3.js';
2
2
  import './chunk-TBLR7NNE.js';
3
- import './chunk-R3B5TMVX.js';
3
+ import './chunk-NWDKXBIP.js';
4
4
  import { promises } from 'fs';
5
5
  import { join } from 'path';
6
6
  import { init_panic_hook, TfheCompactPublicKey, CompactPkeCrs, ProvenCompactCiphertextList } from 'node-tfhe';
@@ -71,15 +71,15 @@ var zkBuilderAndCrsGenerator = (fhe, crs) => {
71
71
  const zkCrs = CompactPkeCrs.deserialize(fromHexString(crs));
72
72
  return { zkBuilder, zkCrs };
73
73
  };
74
- function createCofhesdkConfig(config) {
75
- return createCofhesdkConfigBase({
74
+ function createCofheConfig(config) {
75
+ return createCofheConfigBase({
76
76
  environment: "node",
77
77
  ...config,
78
78
  fheKeyStorage: config.fheKeyStorage === null ? null : config.fheKeyStorage ?? createNodeStorage()
79
79
  });
80
80
  }
81
- function createCofhesdkClient(config) {
82
- return createCofhesdkClientBase({
81
+ function createCofheClient(config) {
82
+ return createCofheClientBase({
83
83
  config,
84
84
  zkBuilderAndCrsGenerator,
85
85
  tfhePublicKeyDeserializer,
@@ -88,4 +88,4 @@ function createCofhesdkClient(config) {
88
88
  });
89
89
  }
90
90
 
91
- export { createCofhesdkClient, createCofhesdkConfig };
91
+ export { createCofheClient, createCofheConfig };
package/dist/permits.js CHANGED
@@ -1 +1 @@
1
- export { GenerateSealingKey, ImportPermitOptionsValidator, ImportPermitValidator, PERMIT_STORE_DEFAULTS, PermitUtils, SealingKey, SelfPermitOptionsValidator, SelfPermitValidator, SharingPermitOptionsValidator, SharingPermitValidator, SignatureTypes, SignatureUtils, ValidationUtils, _permitStore, addressNotZeroSchema, addressSchema, bytesNotEmptySchema, bytesSchema, clearStaleStore, getActivePermit, getActivePermitHash, getPermit, getPermits, getSignatureTypesAndMessage, permitStore, removeActivePermitHash, removePermit, resetStore, setActivePermitHash, setPermit, validateImportPermit, validateImportPermitOptions, validateSelfPermit, validateSelfPermitOptions, validateSharingPermit, validateSharingPermitOptions } from './chunk-R3B5TMVX.js';
1
+ export { GenerateSealingKey, ImportPermitOptionsValidator, ImportPermitValidator, PERMIT_STORE_DEFAULTS, PermitUtils, SealingKey, SelfPermitOptionsValidator, SelfPermitValidator, SharingPermitOptionsValidator, SharingPermitValidator, SignatureTypes, SignatureUtils, ValidationUtils, _permitStore, addressNotZeroSchema, addressSchema, bytesNotEmptySchema, bytesSchema, clearStaleStore, getActivePermit, getActivePermitHash, getPermit, getPermits, getSignatureTypesAndMessage, permitStore, removeActivePermitHash, removePermit, resetStore, setActivePermitHash, setPermit, validateImportPermit, validateImportPermitOptions, validateSelfPermit, validateSelfPermitOptions, validateSharingPermit, validateSharingPermitOptions } from './chunk-NWDKXBIP.js';