@inco/js 0.9.0-devnet-test-10 → 0.10.0-devnet-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 (226) hide show
  1. package/README.md +503 -47
  2. package/dist/cjs/advancedacl/session-key.d.ts +5 -5
  3. package/dist/cjs/advancedacl/session-key.js +33 -9
  4. package/dist/cjs/attestedcompute/attested-compute.d.ts +1 -2
  5. package/dist/cjs/attestedcompute/attested-compute.js +15 -7
  6. package/dist/cjs/attesteddecrypt/attested-decrypt.d.ts +5 -43
  7. package/dist/cjs/attesteddecrypt/attested-decrypt.js +33 -96
  8. package/dist/cjs/attestedreveal/attested-reveal.d.ts +21 -0
  9. package/dist/cjs/attestedreveal/attested-reveal.js +31 -0
  10. package/dist/cjs/attestedreveal/index.d.ts +2 -0
  11. package/dist/cjs/attestedreveal/index.js +21 -0
  12. package/dist/cjs/attestedreveal/types.d.ts +4 -0
  13. package/dist/cjs/attestedreveal/types.js +13 -0
  14. package/dist/cjs/binary.d.ts +82 -0
  15. package/dist/cjs/binary.js +87 -5
  16. package/dist/cjs/chain.d.ts +29 -4
  17. package/dist/cjs/chain.js +34 -6
  18. package/dist/cjs/eip712/eip712.d.ts +18 -0
  19. package/dist/cjs/eip712/eip712.js +51 -0
  20. package/dist/cjs/eip712/index.d.ts +1 -0
  21. package/dist/cjs/eip712/index.js +8 -0
  22. package/dist/cjs/elistattesteddecrypt/elist-attested-decrypt.d.ts +49 -0
  23. package/dist/cjs/elistattesteddecrypt/elist-attested-decrypt.js +94 -0
  24. package/dist/cjs/elistattesteddecrypt/index.d.ts +2 -0
  25. package/dist/cjs/elistattesteddecrypt/index.js +22 -0
  26. package/dist/cjs/elistattesteddecrypt/types.d.ts +31 -0
  27. package/dist/cjs/elistattesteddecrypt/types.js +16 -0
  28. package/dist/cjs/encryption/encryption.d.ts +115 -0
  29. package/dist/cjs/encryption/encryption.js +98 -7
  30. package/dist/cjs/encryption/index.d.ts +1 -1
  31. package/dist/cjs/encryption/index.js +17 -16
  32. package/dist/cjs/generated/abis/lightning.d.ts +1119 -107
  33. package/dist/cjs/generated/abis/lightning.js +762 -52
  34. package/dist/cjs/generated/abis/test-elist.d.ts +20 -2
  35. package/dist/cjs/generated/abis/test-elist.js +16 -3
  36. package/dist/cjs/generated/abis/verifier.d.ts +118 -15
  37. package/dist/cjs/generated/abis/verifier.js +71 -19
  38. package/dist/cjs/generated/es/inco/covalidator/compute/v1/server_pb.d.ts +23 -37
  39. package/dist/cjs/generated/es/inco/covalidator/compute/v1/server_pb.js +36 -41
  40. package/dist/cjs/generated/es/inco/covalidator/compute/v1/types_pb.js +1 -1
  41. package/dist/cjs/generated/es/inco/helioswrapper/v1/helioswrapper_pb.js +1 -1
  42. package/dist/cjs/generated/es/inco/kms/lite/v1/kms_service_pb.d.ts +16 -0
  43. package/dist/cjs/generated/es/inco/kms/lite/v1/kms_service_pb.js +3 -3
  44. package/dist/cjs/generated/es/inco/kms/lite/v1/types_pb.js +1 -1
  45. package/dist/cjs/generated/es/inco/sealingfetcher/v1/sealingfetcher_pb.d.ts +7 -0
  46. package/dist/cjs/generated/es/inco/sealingfetcher/v1/sealingfetcher_pb.js +3 -3
  47. package/dist/cjs/generated/lightning.d.ts +150 -0
  48. package/dist/cjs/generated/lightning.js +157 -1
  49. package/dist/cjs/generated/local-node.d.ts +9 -9
  50. package/dist/cjs/generated/local-node.js +37 -10
  51. package/dist/cjs/handle.d.ts +72 -0
  52. package/dist/cjs/handle.js +113 -9
  53. package/dist/cjs/index.d.ts +1 -1
  54. package/dist/cjs/index.js +11 -2
  55. package/dist/cjs/kms/client.d.ts +1 -1
  56. package/dist/cjs/kms/client.js +4 -3
  57. package/dist/cjs/kms/quorumClient.d.ts +18 -12
  58. package/dist/cjs/kms/quorumClient.js +212 -231
  59. package/dist/cjs/kms/quorumConsistency.d.ts +82 -0
  60. package/dist/cjs/kms/quorumConsistency.js +269 -0
  61. package/dist/cjs/kms/signatureVerification.d.ts +35 -0
  62. package/dist/cjs/kms/signatureVerification.js +88 -0
  63. package/dist/cjs/kms/thresholdPromises.d.ts +4 -3
  64. package/dist/cjs/kms/thresholdPromises.js +25 -15
  65. package/dist/cjs/lite/attested-compute.d.ts +2 -2
  66. package/dist/cjs/lite/attested-compute.js +2 -3
  67. package/dist/cjs/lite/attested-decrypt.d.ts +2 -2
  68. package/dist/cjs/lite/attested-decrypt.js +2 -3
  69. package/dist/cjs/lite/hadu.d.ts +1 -1
  70. package/dist/cjs/lite/hadu.js +3 -3
  71. package/dist/cjs/lite/index.d.ts +6 -2
  72. package/dist/cjs/lite/index.js +8 -14
  73. package/dist/cjs/lite/lightning.d.ts +96 -47
  74. package/dist/cjs/lite/lightning.js +221 -267
  75. package/dist/cjs/lite/types.d.ts +47 -0
  76. package/dist/cjs/lite/types.js +3 -0
  77. package/dist/cjs/lite/xwing.d.ts +33 -2
  78. package/dist/cjs/lite/xwing.js +62 -7
  79. package/dist/cjs/local/local-node.d.ts +18 -0
  80. package/dist/cjs/local/local-node.js +18 -3
  81. package/dist/cjs/reencryption/eip712.d.ts +27 -0
  82. package/dist/cjs/reencryption/eip712.js +20 -7
  83. package/dist/cjs/reencryption/types.d.ts +24 -0
  84. package/dist/cjs/retry.d.ts +14 -0
  85. package/dist/cjs/retry.js +58 -2
  86. package/dist/cjs/test/mocks.d.ts +6 -1
  87. package/dist/cjs/test/mocks.js +31 -6
  88. package/dist/cjs/viem.d.ts +361 -1
  89. package/dist/cjs/viem.js +14 -1
  90. package/dist/esm/advancedacl/session-key.d.ts +5 -5
  91. package/dist/esm/advancedacl/session-key.js +33 -9
  92. package/dist/esm/attestedcompute/attested-compute.d.ts +1 -2
  93. package/dist/esm/attestedcompute/attested-compute.js +13 -5
  94. package/dist/esm/attesteddecrypt/attested-decrypt.d.ts +5 -43
  95. package/dist/esm/attesteddecrypt/attested-decrypt.js +34 -96
  96. package/dist/esm/attestedreveal/attested-reveal.d.ts +21 -0
  97. package/dist/esm/attestedreveal/attested-reveal.js +28 -0
  98. package/dist/esm/attestedreveal/index.d.ts +2 -0
  99. package/dist/esm/attestedreveal/index.js +3 -0
  100. package/dist/esm/attestedreveal/types.d.ts +4 -0
  101. package/dist/esm/attestedreveal/types.js +9 -0
  102. package/dist/esm/binary.d.ts +82 -0
  103. package/dist/esm/binary.js +87 -5
  104. package/dist/esm/chain.d.ts +29 -4
  105. package/dist/esm/chain.js +33 -5
  106. package/dist/esm/eip712/eip712.d.ts +18 -0
  107. package/dist/esm/eip712/eip712.js +46 -0
  108. package/dist/esm/eip712/index.d.ts +1 -0
  109. package/dist/esm/eip712/index.js +2 -0
  110. package/dist/esm/elistattesteddecrypt/elist-attested-decrypt.d.ts +49 -0
  111. package/dist/esm/elistattesteddecrypt/elist-attested-decrypt.js +89 -0
  112. package/dist/esm/elistattesteddecrypt/index.d.ts +2 -0
  113. package/dist/esm/elistattesteddecrypt/index.js +3 -0
  114. package/dist/esm/elistattesteddecrypt/types.d.ts +31 -0
  115. package/dist/esm/elistattesteddecrypt/types.js +12 -0
  116. package/dist/esm/encryption/encryption.d.ts +115 -0
  117. package/dist/esm/encryption/encryption.js +98 -7
  118. package/dist/esm/encryption/index.d.ts +1 -1
  119. package/dist/esm/encryption/index.js +2 -2
  120. package/dist/esm/generated/abis/lightning.d.ts +1119 -107
  121. package/dist/esm/generated/abis/lightning.js +761 -51
  122. package/dist/esm/generated/abis/test-elist.d.ts +20 -2
  123. package/dist/esm/generated/abis/test-elist.js +16 -3
  124. package/dist/esm/generated/abis/verifier.d.ts +118 -15
  125. package/dist/esm/generated/abis/verifier.js +71 -19
  126. package/dist/esm/generated/es/inco/covalidator/compute/v1/server_pb.d.ts +23 -37
  127. package/dist/esm/generated/es/inco/covalidator/compute/v1/server_pb.js +35 -40
  128. package/dist/esm/generated/es/inco/covalidator/compute/v1/types_pb.js +1 -1
  129. package/dist/esm/generated/es/inco/helioswrapper/v1/helioswrapper_pb.js +1 -1
  130. package/dist/esm/generated/es/inco/kms/lite/v1/kms_service_pb.d.ts +16 -0
  131. package/dist/esm/generated/es/inco/kms/lite/v1/kms_service_pb.js +3 -3
  132. package/dist/esm/generated/es/inco/kms/lite/v1/types_pb.js +1 -1
  133. package/dist/esm/generated/es/inco/sealingfetcher/v1/sealingfetcher_pb.d.ts +7 -0
  134. package/dist/esm/generated/es/inco/sealingfetcher/v1/sealingfetcher_pb.js +3 -3
  135. package/dist/esm/generated/lightning.d.ts +150 -0
  136. package/dist/esm/generated/lightning.js +157 -1
  137. package/dist/esm/generated/local-node.d.ts +9 -9
  138. package/dist/esm/generated/local-node.js +37 -10
  139. package/dist/esm/handle.d.ts +72 -0
  140. package/dist/esm/handle.js +110 -8
  141. package/dist/esm/index.d.ts +1 -1
  142. package/dist/esm/index.js +2 -2
  143. package/dist/esm/kms/client.d.ts +1 -1
  144. package/dist/esm/kms/client.js +3 -2
  145. package/dist/esm/kms/quorumClient.d.ts +18 -12
  146. package/dist/esm/kms/quorumClient.js +213 -232
  147. package/dist/esm/kms/quorumConsistency.d.ts +82 -0
  148. package/dist/esm/kms/quorumConsistency.js +260 -0
  149. package/dist/esm/kms/signatureVerification.d.ts +35 -0
  150. package/dist/esm/kms/signatureVerification.js +84 -0
  151. package/dist/esm/kms/thresholdPromises.d.ts +4 -3
  152. package/dist/esm/kms/thresholdPromises.js +25 -15
  153. package/dist/esm/lite/attested-compute.d.ts +2 -2
  154. package/dist/esm/lite/attested-compute.js +3 -3
  155. package/dist/esm/lite/attested-decrypt.d.ts +2 -2
  156. package/dist/esm/lite/attested-decrypt.js +3 -3
  157. package/dist/esm/lite/hadu.d.ts +1 -1
  158. package/dist/esm/lite/hadu.js +2 -2
  159. package/dist/esm/lite/index.d.ts +6 -2
  160. package/dist/esm/lite/index.js +5 -3
  161. package/dist/esm/lite/lightning.d.ts +96 -47
  162. package/dist/esm/lite/lightning.js +217 -263
  163. package/dist/esm/lite/types.d.ts +47 -0
  164. package/dist/esm/lite/types.js +2 -0
  165. package/dist/esm/lite/xwing.d.ts +33 -2
  166. package/dist/esm/lite/xwing.js +59 -7
  167. package/dist/esm/local/local-node.d.ts +18 -0
  168. package/dist/esm/local/local-node.js +18 -3
  169. package/dist/esm/reencryption/eip712.d.ts +27 -0
  170. package/dist/esm/reencryption/eip712.js +20 -7
  171. package/dist/esm/reencryption/types.d.ts +24 -0
  172. package/dist/esm/retry.d.ts +14 -0
  173. package/dist/esm/retry.js +56 -2
  174. package/dist/esm/test/mocks.d.ts +6 -1
  175. package/dist/esm/test/mocks.js +31 -8
  176. package/dist/esm/viem.d.ts +361 -1
  177. package/dist/esm/viem.js +15 -2
  178. package/dist/types/advancedacl/session-key.d.ts +5 -5
  179. package/dist/types/attestedcompute/attested-compute.d.ts +1 -2
  180. package/dist/types/attesteddecrypt/attested-decrypt.d.ts +5 -43
  181. package/dist/types/attestedreveal/attested-reveal.d.ts +21 -0
  182. package/dist/types/attestedreveal/index.d.ts +2 -0
  183. package/dist/types/attestedreveal/types.d.ts +4 -0
  184. package/dist/types/binary.d.ts +82 -0
  185. package/dist/types/chain.d.ts +29 -4
  186. package/dist/types/eip712/eip712.d.ts +18 -0
  187. package/dist/types/eip712/index.d.ts +1 -0
  188. package/dist/types/elistattesteddecrypt/elist-attested-decrypt.d.ts +49 -0
  189. package/dist/types/elistattesteddecrypt/index.d.ts +2 -0
  190. package/dist/types/elistattesteddecrypt/types.d.ts +31 -0
  191. package/dist/types/encryption/encryption.d.ts +115 -0
  192. package/dist/types/encryption/index.d.ts +1 -1
  193. package/dist/types/generated/abis/lightning.d.ts +1119 -107
  194. package/dist/types/generated/abis/test-elist.d.ts +20 -2
  195. package/dist/types/generated/abis/verifier.d.ts +118 -15
  196. package/dist/types/generated/es/inco/covalidator/compute/v1/server_pb.d.ts +23 -37
  197. package/dist/types/generated/es/inco/kms/lite/v1/kms_service_pb.d.ts +16 -0
  198. package/dist/types/generated/es/inco/sealingfetcher/v1/sealingfetcher_pb.d.ts +7 -0
  199. package/dist/types/generated/lightning.d.ts +150 -0
  200. package/dist/types/generated/local-node.d.ts +9 -9
  201. package/dist/types/handle.d.ts +72 -0
  202. package/dist/types/index.d.ts +1 -1
  203. package/dist/types/kms/client.d.ts +1 -1
  204. package/dist/types/kms/quorumClient.d.ts +18 -12
  205. package/dist/types/kms/quorumConsistency.d.ts +82 -0
  206. package/dist/types/kms/signatureVerification.d.ts +35 -0
  207. package/dist/types/kms/thresholdPromises.d.ts +4 -3
  208. package/dist/types/lite/attested-compute.d.ts +2 -2
  209. package/dist/types/lite/attested-decrypt.d.ts +2 -2
  210. package/dist/types/lite/hadu.d.ts +1 -1
  211. package/dist/types/lite/index.d.ts +6 -2
  212. package/dist/types/lite/lightning.d.ts +96 -47
  213. package/dist/types/lite/types.d.ts +47 -0
  214. package/dist/types/lite/xwing.d.ts +33 -2
  215. package/dist/types/local/local-node.d.ts +18 -0
  216. package/dist/types/reencryption/eip712.d.ts +27 -0
  217. package/dist/types/reencryption/types.d.ts +24 -0
  218. package/dist/types/retry.d.ts +14 -0
  219. package/dist/types/test/mocks.d.ts +6 -1
  220. package/dist/types/viem.d.ts +361 -1
  221. package/package.json +19 -21
  222. package/dist/cjs/generated/abis/lightning-preview.d.ts +0 -1385
  223. package/dist/cjs/generated/abis/lightning-preview.js +0 -857
  224. package/dist/esm/generated/abis/lightning-preview.d.ts +0 -1385
  225. package/dist/esm/generated/abis/lightning-preview.js +0 -854
  226. package/dist/types/generated/abis/lightning-preview.d.ts +0 -1385
@@ -1,22 +1,104 @@
1
1
  import { Schema } from 'effect';
2
2
  import { Hex } from 'viem';
3
+ /** Schema for a `0x`-prefixed hex string. */
3
4
  export declare const HexString: Schema.TemplateLiteral<`0x${string}`>;
5
+ /** A `0x`-prefixed hex-encoded string (e.g. `"0xdeadbeef"`). */
4
6
  export type HexString = typeof HexString.Type;
7
+ /** A value that can represent raw bytes — either a hex string or a `Uint8Array`. */
5
8
  export type BytesIsh = string | Uint8Array;
9
+ /**
10
+ * Converts a `Uint8Array` to a `bigint`. Returns `0n` for empty arrays.
11
+ * @param byteArray - The byte array to convert.
12
+ * @returns The unsigned big-endian integer representation of the bytes.
13
+ */
6
14
  export declare function bytesToBigInt(byteArray: Uint8Array): bigint;
15
+ /**
16
+ * Converts a `Buffer` to a `bigint`.
17
+ * @param buffer - The buffer to convert.
18
+ * @returns The unsigned big-endian integer representation of the buffer.
19
+ */
7
20
  export declare function bufferToBigInt(buffer: Buffer): bigint;
21
+ /**
22
+ * Converts a `bigint` to a 32-byte `Buffer`, zero-padded on the left.
23
+ * @param value - The bigint to convert.
24
+ * @returns A 32-byte big-endian buffer.
25
+ * @throws If the bigint is negative or too large to fit in 32 bytes.
26
+ */
8
27
  export declare function bigintToBytes(value: bigint): Buffer;
28
+ /**
29
+ * Converts a `bigint` to a {@link Bytes32} hex string, left-padded to 32 bytes.
30
+ * @param value - The bigint to convert.
31
+ * @returns A `Bytes32` hex string.
32
+ * @throws If the bigint is negative or too large to fit in 32 bytes.
33
+ */
9
34
  export declare function bigintToBytes32(value: bigint): Bytes32;
35
+ /**
36
+ * Left-pads a byte array with zeros to the specified length.
37
+ * @param bs - The byte array to pad.
38
+ * @param n - The desired total length in bytes.
39
+ * @returns A new `Buffer` of length `n` with `bs` right-aligned.
40
+ * @throws If `bs` is longer than `n` (would require truncation).
41
+ */
10
42
  export declare function padLeft(bs: Uint8Array, n: number): Buffer;
43
+ /**
44
+ * Parses a {@link BytesIsh} value as a 32-byte value and converts it to a `bigint`.
45
+ * @param bs - A hex string or `Uint8Array` representing exactly 32 bytes.
46
+ * @returns The `bigint` representation of the 32-byte value.
47
+ * @throws If the input is not exactly 32 bytes.
48
+ */
11
49
  export declare function bytes32ToBigint(bs: BytesIsh): bigint;
50
+ /**
51
+ * Decodes a hex string into a `Buffer`. Handles both `0x`-prefixed and bare hex strings.
52
+ * @param hexString - The hex string to decode.
53
+ * @returns A `Buffer` containing the decoded bytes.
54
+ */
12
55
  export declare function bytesFromHexString(hexString: string): Buffer;
56
+ /**
57
+ * Asserts that a string is a valid `0x`-prefixed hex string and narrows its type to `Hex`.
58
+ * @param value - The string to validate.
59
+ * @returns The input typed as `Hex`.
60
+ * @throws If `value` is not a valid hex string.
61
+ */
13
62
  export declare function mustBeHex(value: string): Hex;
63
+ /**
64
+ * Normalises a string to a `0x`-prefixed `Hex` value, adding the prefix if missing.
65
+ * @param value - A hex string, with or without a `0x` prefix.
66
+ * @returns The `0x`-prefixed `Hex` string.
67
+ * @throws If the resulting string is not valid hex.
68
+ */
14
69
  export declare function normaliseToHex(value: string): Hex;
70
+ /**
71
+ * Encodes a `Uint8Array` as a `0x`-prefixed hex string.
72
+ * @param bs - The byte array to encode.
73
+ * @returns A `Hex` string representation of the bytes.
74
+ */
15
75
  export declare function bytesToHex(bs: Uint8Array): Hex;
76
+ /** Schema for a 32-byte (66-character with `0x` prefix) hex string, branded as `Bytes32`. Accepts both hex strings and `Uint8Array` inputs. */
16
77
  export declare const Bytes32: Schema.brand<Schema.filter<Schema.transformOrFail<Schema.Union<[typeof Schema.String, Schema.refine<object & Uint8Array<ArrayBufferLike>, Schema.Schema<object, object, never>>]>, Schema.TemplateLiteral<`0x${string}`>, never>>, "Bytes32">;
78
+ /**
79
+ * Parses and validates a {@link BytesIsh} value as a {@link Bytes32}.
80
+ * @param x - A hex string or `Uint8Array` to parse.
81
+ * @returns A validated `Bytes32` value.
82
+ * @throws If the input is not exactly 32 bytes.
83
+ */
17
84
  export declare function asBytes32(x: BytesIsh): Bytes32;
85
+ /** A branded 32-byte hex string type (`0x` + 64 hex characters). */
18
86
  export type Bytes32 = typeof Bytes32.Type;
87
+ /** A branded 20-byte Ethereum address type (`0x` + 40 hex characters). */
19
88
  export type Address = typeof Address.Type;
89
+ /** Schema for a 20-byte `0x`-prefixed Ethereum address, branded as `Address`. */
20
90
  export declare const Address: Schema.brand<Schema.filter<Schema.TemplateLiteral<`0x${string}`>>, "Address">;
91
+ /**
92
+ * Parses and validates a string as an Ethereum {@link Address} (20-byte, `0x`-prefixed).
93
+ * @param address - The string to parse.
94
+ * @returns A validated `Address` value.
95
+ * @throws If the input is not a valid 20-byte hex address.
96
+ */
21
97
  export declare function parseAddress(address: string): Address;
98
+ /**
99
+ * Parses and validates a string as a {@link HexString} (`0x`-prefixed).
100
+ * @param hex - The string to parse.
101
+ * @returns A validated `HexString` value.
102
+ * @throws If the input is not a valid `0x`-prefixed hex string.
103
+ */
22
104
  export declare function parseHex(hex: string): HexString;
@@ -1,4 +1,12 @@
1
+ /**
2
+ * Map of supported chain short names to their chain IDs.
3
+ *
4
+ * @remarks This mirrors viem chain definitions without depending on viem directly,
5
+ * to work around Pulumi closure serialisation issues.
6
+ */
1
7
  export declare const supportedChains: {
8
+ readonly mainnet: 1;
9
+ readonly base: 8453;
2
10
  readonly baseSepolia: 84532;
3
11
  readonly sepolia: 11155111;
4
12
  readonly monadTestnet: 10143;
@@ -6,20 +14,37 @@ export declare const supportedChains: {
6
14
  readonly worldchainSepolia: 4801;
7
15
  readonly anvil: 31337;
8
16
  };
9
- export declare const fheSupportedChains: {
10
- readonly baseSepolia: 84532;
11
- readonly sepolia: 11155111;
12
- };
13
17
  type SupportedChains = typeof supportedChains;
18
+ /** Numeric chain ID of a supported chain (e.g. `84532`, `11155111`). */
14
19
  export type SupportedChainId = SupportedChains[keyof SupportedChains];
20
+ /** Short name of a supported chain (e.g. `"baseSepolia"`, `"sepolia"`). */
15
21
  export type SupportedChainName = keyof SupportedChains;
22
+ /** A supported chain identified by both its short name and numeric ID. */
16
23
  export type SupportedChain = {
17
24
  name: SupportedChainName;
18
25
  id: SupportedChainId;
19
26
  };
27
+ /** A value that can represent a number — either a `number` or a `bigint`. */
20
28
  export type Numberish = number | bigint;
29
+ /** A flexible chain identifier: a chain ID (`number` | `bigint`), an object with an `id` field, or a chain short name. */
21
30
  export type Chainish = {
22
31
  id: Numberish;
23
32
  } | Numberish | string;
33
+ /**
34
+ * Map of supported chain IDs to their short names.
35
+ * Public networks use the `shortName` from https://github.com/ethereum-lists/chains.
36
+ * Local Anvil uses `31337` (same ID as GoChain Testnet in the registry) but the SDK labels it `anvil`.
37
+ */
38
+ export declare const chainShortNames: Record<SupportedChainId, string>;
39
+ /**
40
+ * Resolves a {@link Chainish} value to a {@link SupportedChain}.
41
+ *
42
+ * Accepts a chain ID (`number` or `bigint`), an object with an `id` field,
43
+ * or a chain short name (e.g. `"baseSepolia"`).
44
+ *
45
+ * @param chainish - The chain identifier to resolve.
46
+ * @returns The matching `SupportedChain` with both `name` and `id`.
47
+ * @throws If no supported chain matches the given identifier.
48
+ */
24
49
  export declare function getSupportedChain(chainish: Chainish): SupportedChain;
25
50
  export {};
@@ -0,0 +1,18 @@
1
+ import type { Account, Chain, Transport, WalletClient } from 'viem';
2
+ import type { HexString } from '../binary.js';
3
+ import type { SupportedChainId } from '../chain.js';
4
+ import { ViemClient } from '../viem.js';
5
+ export declare function fetchEip712DomainVersion(executorAddress: HexString, ethClient: ViemClient): Promise<string>;
6
+ export declare function buildEip712Payload(params: {
7
+ executorAddress: HexString;
8
+ ethClient: ViemClient;
9
+ chainId: SupportedChainId;
10
+ handles: HexString[];
11
+ reencryptPubKey: Uint8Array;
12
+ }): Promise<import("../reencryption/eip712.js").EIP712<{
13
+ handles: `0x${string}`[];
14
+ publicKey: `0x${string}`;
15
+ }>>;
16
+ type WalletSignTypedDataParams = Parameters<WalletClient<Transport, Chain, Account>['signTypedData']>[0];
17
+ export declare function signEip712(walletClient: WalletClient<Transport, Chain, Account>, eip712Payload: WalletSignTypedDataParams): Promise<`0x${string}`>;
18
+ export {};
@@ -0,0 +1 @@
1
+ export { buildEip712Payload, fetchEip712DomainVersion, signEip712, } from './eip712.js';
@@ -0,0 +1,49 @@
1
+ import type { Account, Chain, Transport, WalletClient } from 'viem';
2
+ import { validateHandle } from '../attesteddecrypt/attested-decrypt.js';
3
+ import { type HexString } from '../binary.js';
4
+ import { type SupportedChainId } from '../chain.js';
5
+ import { type EncryptionScheme, type SupportedFheType } from '../encryption/encryption.js';
6
+ import { KmsQuorumClient } from '../kms/quorumClient.js';
7
+ import type { XwingKeypair } from '../lite/xwing.js';
8
+ import type { BackoffConfig } from '../retry.js';
9
+ import { type EListDecryptionAttestation, type EncryptedEListDecryptionAttestation } from './types.js';
10
+ export { validateHandle };
11
+ export declare function eListAttestedDecrypt({ handle, backoffConfig, walletClient, chainId, reencryptPubKey, reencryptKeypair, kmsQuorumClient, executorAddress, }: {
12
+ handle: HexString;
13
+ backoffConfig?: Partial<BackoffConfig> | undefined;
14
+ walletClient: WalletClient<Transport, Chain, Account>;
15
+ chainId: SupportedChainId;
16
+ reencryptPubKey: Uint8Array;
17
+ reencryptKeypair: XwingKeypair;
18
+ kmsQuorumClient: KmsQuorumClient;
19
+ executorAddress: HexString;
20
+ }): Promise<EListDecryptionAttestation<EncryptionScheme, SupportedFheType>>;
21
+ export declare function eListAttestedDecrypt({ handle, backoffConfig, walletClient, chainId, reencryptPubKey, kmsQuorumClient, executorAddress, }: {
22
+ handle: HexString;
23
+ backoffConfig?: Partial<BackoffConfig> | undefined;
24
+ walletClient: WalletClient<Transport, Chain, Account>;
25
+ chainId: SupportedChainId;
26
+ reencryptPubKey: Uint8Array;
27
+ reencryptKeypair?: never;
28
+ kmsQuorumClient: KmsQuorumClient;
29
+ executorAddress: HexString;
30
+ }): Promise<EncryptedEListDecryptionAttestation<EncryptionScheme, SupportedFheType>>;
31
+ export declare function eListAttestedDecrypt({ handle, backoffConfig, walletClient, chainId, kmsQuorumClient, executorAddress, }: {
32
+ handle: HexString;
33
+ backoffConfig?: Partial<BackoffConfig> | undefined;
34
+ walletClient: WalletClient<Transport, Chain, Account>;
35
+ chainId: SupportedChainId;
36
+ reencryptPubKey?: never;
37
+ reencryptKeypair?: never;
38
+ kmsQuorumClient: KmsQuorumClient;
39
+ executorAddress: HexString;
40
+ }): Promise<EListDecryptionAttestation<EncryptionScheme, SupportedFheType>>;
41
+ /**
42
+ * Reveal a single elist handle without wallet authentication.
43
+ * Returns plaintext values along with an attestation of the checksum.
44
+ */
45
+ export declare function eListAttestedReveal({ handle, backoffConfig, kmsQuorumClient, }: {
46
+ handle: HexString;
47
+ backoffConfig?: Partial<BackoffConfig> | undefined;
48
+ kmsQuorumClient: KmsQuorumClient;
49
+ }): Promise<EListDecryptionAttestation<EncryptionScheme, SupportedFheType>>;
@@ -0,0 +1,2 @@
1
+ export { eListAttestedDecrypt, eListAttestedReveal, } from './elist-attested-decrypt.js';
2
+ export * from './types.js';
@@ -0,0 +1,31 @@
1
+ import type { HexString } from '../binary.js';
2
+ import type { EncryptionScheme, EncryptResultOf, PlaintextOf, SupportedFheType } from '../encryption/encryption.js';
3
+ import { handleTypes } from '../index.js';
4
+ import type { BackoffConfig } from '../retry.js';
5
+ /**
6
+ * Custom error class for elist attested decrypt operations.
7
+ */
8
+ export declare class EListAttestedDecryptError extends Error {
9
+ readonly cause?: unknown | undefined;
10
+ constructor(message: string, cause?: unknown | undefined);
11
+ }
12
+ export type EListDecryptionAttestation<S extends EncryptionScheme, T extends SupportedFheType> = {
13
+ handle: HexString;
14
+ commitmentProof: PlaintextOf<S, typeof handleTypes.euint256>;
15
+ values: PlaintextOf<S, T>[];
16
+ covalidatorSignatures: Uint8Array[];
17
+ commitments: Uint8Array[];
18
+ };
19
+ export type EncryptedEListDecryptionAttestation<S extends EncryptionScheme, T extends SupportedFheType> = {
20
+ handle: HexString;
21
+ commitmentProof: PlaintextOf<S, typeof handleTypes.euint256>;
22
+ values: EncryptResultOf<S, T>[];
23
+ covalidatorSignatures: Uint8Array[];
24
+ commitments: Uint8Array[];
25
+ };
26
+ export type EListAttestedDecryptor<S extends EncryptionScheme> = <T extends SupportedFheType>(args: EListAttestedDecryptFnArgs<S, T>) => Promise<EListDecryptionAttestation<S, T>>;
27
+ export type EListAttestedDecryptFnArgs<S extends EncryptionScheme, T extends SupportedFheType> = {
28
+ /** The handle to decrypt */
29
+ handle: HexString;
30
+ backoffConfig?: Partial<BackoffConfig>;
31
+ };
@@ -1,37 +1,79 @@
1
1
  import { Schema } from 'effect';
2
2
  import { ByteArray, Hex } from 'viem';
3
3
  import { Bytes32 } from '../binary.js';
4
+ /**
5
+ * A function that encrypts a plaintext value, embedding its {@link InputContext} into the resulting ciphertext.
6
+ *
7
+ * @typeParam S - The encryption scheme (e.g. X-Wing).
8
+ * @example
9
+ * ```ts
10
+ * const result = await encrypt({ plaintext: { scheme: 2, type: 5, value: 42n }, context });
11
+ * // result.handle, result.ciphertext, result.prehandle
12
+ * ```
13
+ */
4
14
  export type Encryptor<S extends EncryptionScheme = EncryptionScheme> = <T extends SupportedFheType>(plaintext: PlaintextWithContextOf<S, T>) => Promise<EncryptResultOf<S, T>>;
15
+ /**
16
+ * A function that decrypts a ciphertext back to its plaintext value.
17
+ *
18
+ * @typeParam S - The encryption scheme (e.g. X-Wing).
19
+ * @example
20
+ * ```ts
21
+ * const plaintext = await decrypt({ scheme: 2, type: 5, value: '0x...' });
22
+ * ```
23
+ */
5
24
  export type Decryptor<S extends EncryptionScheme = EncryptionScheme> = <T extends SupportedFheType>(ciphertext: CiphertextOf<S, T>) => Promise<PlaintextOf<S, T>>;
25
+ /**
26
+ * Subset of ENCRYPTION types currently supported for encryption/decryption.
27
+ *
28
+ * @remarks TODO: review need of `euint64` and `euint160` — `Lib.sol` only supports `euint256` and `ebool`.
29
+ */
6
30
  export declare const supportedFheTypes: {
7
31
  readonly euint64: 5;
8
32
  readonly euint160: 7;
9
33
  readonly euint256: 8;
10
34
  readonly ebool: 0;
11
35
  };
36
+ /** Schema that validates a string is one of the supported ENCRYPTION type names. */
12
37
  export declare const SupportedFheTypeName: Schema.SchemaClass<"ebool" | "euint64" | "euint160" | "euint256", "ebool" | "euint64" | "euint160" | "euint256", never>;
38
+ /** A supported ENCRYPTION type name (e.g. `"euint256"`, `"ebool"`). */
13
39
  export type SupportedFheTypeName = typeof SupportedFheTypeName.Type;
40
+ /** Schema that validates a number is one of the supported ENCRYPTION type integer identifiers. */
14
41
  export declare const SupportedFheType: Schema.SchemaClass<0 | 5 | 7 | 8, 0 | 5 | 7 | 8, never>;
42
+ /** Integer identifier of a supported ENCRYPTION type (a subset of all ENCRYPTION types). */
15
43
  export type SupportedFheType = typeof SupportedFheType.Type;
44
+ /** Map of encryption scheme names to their integer identifiers. Currently only X-Wing (2) is supported. */
16
45
  export declare const encryptionSchemes: {
17
46
  readonly xwing: 2;
18
47
  };
48
+ /**
49
+ * Returns the human-readable name of an encryption scheme.
50
+ * @param scheme - The encryption scheme integer identifier.
51
+ * @returns The scheme name (e.g. `"X-Wing"`).
52
+ * @throws If the scheme identifier is unknown.
53
+ */
19
54
  export declare function getEncryptionSchemeName(scheme: number): string;
55
+ /** The typeof {@link encryptionSchemes} — mapping from scheme names to integer IDs. */
20
56
  export type EncryptionSchemes = typeof encryptionSchemes;
57
+ /** The integer identifier for the X-Wing encryption scheme (`2`). */
21
58
  export type XwingScheme = EncryptionSchemes['xwing'];
59
+ /** Schema that validates a value is a known encryption scheme identifier. */
22
60
  export declare const EncryptionScheme: Schema.Literal<[2]>;
61
+ /** An encryption scheme identifier (currently only X-Wing = `2`). */
23
62
  export type EncryptionScheme = typeof EncryptionScheme.Type;
24
63
  type DistType<P, S extends EncryptionScheme, T extends SupportedFheType> = P extends any ? P & {
25
64
  scheme: S;
26
65
  type: T;
27
66
  } : never;
67
+ /** Schema for an ENCRYPTION ciphertext: encryption scheme, ENCRYPTION type, and the encrypted value as a hex string. */
28
68
  export declare const Ciphertext: Schema.Struct<{
29
69
  scheme: Schema.Literal<[2]>;
30
70
  type: Schema.SchemaClass<0 | 5 | 7 | 8, 0 | 5 | 7 | 8, never>;
31
71
  value: Schema.TemplateLiteral<`0x${string}`>;
32
72
  }>;
73
+ /** An ENCRYPTION ciphertext containing the encryption scheme, ENCRYPTION type, and encrypted hex value. */
33
74
  export type Ciphertext = typeof Ciphertext.Type;
34
75
  export type CiphertextOf<S extends EncryptionScheme, T extends SupportedFheType> = DistType<Ciphertext, S, T>;
76
+ /** Schema for a ciphertext paired with the {@link InputContext} it was encrypted under. */
35
77
  export declare const CiphertextWithContext: Schema.Struct<{
36
78
  ciphertext: Schema.Struct<{
37
79
  scheme: Schema.Literal<[2]>;
@@ -46,10 +88,12 @@ export declare const CiphertextWithContext: Schema.Struct<{
46
88
  version: typeof Schema.Number;
47
89
  }>;
48
90
  }>;
91
+ /** A ciphertext paired with the {@link InputContext} it was encrypted under. */
49
92
  export type CiphertextWithContext = typeof CiphertextWithContext.Type;
50
93
  export type CiphertextWithContextOf<S extends EncryptionScheme, T extends SupportedFheType> = CiphertextWithContext & {
51
94
  ciphertext: CiphertextOf<S, T>;
52
95
  };
96
+ /** Schema for the result of an encryption operation: ciphertext, input context, prehandle, and final handle. */
53
97
  export declare const EncryptResult: Schema.Struct<{
54
98
  ciphertext: Schema.Struct<{
55
99
  scheme: Schema.Literal<[2]>;
@@ -66,10 +110,16 @@ export declare const EncryptResult: Schema.Struct<{
66
110
  prehandle: Schema.brand<Schema.filter<Schema.transformOrFail<Schema.Union<[typeof Schema.String, Schema.refine<object & Uint8Array<ArrayBufferLike>, Schema.Schema<object, object, never>>]>, Schema.TemplateLiteral<`0x${string}`>, never>>, "Bytes32">;
67
111
  handle: Schema.brand<Schema.filter<Schema.transformOrFail<Schema.Union<[typeof Schema.String, Schema.refine<object & Uint8Array<ArrayBufferLike>, Schema.Schema<object, object, never>>]>, Schema.TemplateLiteral<`0x${string}`>, never>>, "Bytes32">;
68
112
  }>;
113
+ /** The result of an encryption operation, containing the ciphertext, context, prehandle, and deterministic handle. */
69
114
  export type EncryptResult = typeof EncryptResult.Type;
70
115
  export type EncryptResultOf<S extends EncryptionScheme, T extends SupportedFheType> = EncryptResult & {
71
116
  ciphertext: CiphertextOf<S, T>;
72
117
  };
118
+ /**
119
+ * Schema for an ENCRYPTION plaintext value. The `value` field type depends on the ENCRYPTION type:
120
+ * - `euint64` / `euint160` / `euint256`: `bigint`
121
+ * - `ebool`: `boolean`
122
+ */
73
123
  export declare const Plaintext: Schema.Union<[Schema.Struct<{
74
124
  scheme: Schema.Literal<[2]>;
75
125
  type: Schema.Literal<[5, 7, 8]>;
@@ -79,8 +129,10 @@ export declare const Plaintext: Schema.Union<[Schema.Struct<{
79
129
  type: Schema.Literal<[0]>;
80
130
  value: typeof Schema.Boolean;
81
131
  }>]>;
132
+ /** An ENCRYPTION plaintext value — `bigint` for integer types, `boolean` for `ebool`. */
82
133
  export type Plaintext = typeof Plaintext.Type;
83
134
  export type PlaintextOf<S extends EncryptionScheme, T extends SupportedFheType> = DistType<Plaintext, S, T>;
135
+ /** Schema for a plaintext paired with the {@link InputContext} it will be encrypted under. */
84
136
  export declare const PlaintextWithContext: Schema.Struct<{
85
137
  plaintext: Schema.Union<[Schema.Struct<{
86
138
  scheme: Schema.Literal<[2]>;
@@ -99,20 +151,83 @@ export declare const PlaintextWithContext: Schema.Struct<{
99
151
  version: typeof Schema.Number;
100
152
  }>;
101
153
  }>;
154
+ /** A plaintext paired with the {@link InputContext} it will be encrypted under. */
102
155
  export type PlaintextWithContext = typeof PlaintextWithContext.Type;
103
156
  export type PlaintextWithContextOf<S extends EncryptionScheme, T extends SupportedFheType> = PlaintextWithContext & {
104
157
  plaintext: PlaintextOf<S, T>;
105
158
  };
159
+ /**
160
+ * Converts a `bigint` to a typed {@link Plaintext} value.
161
+ *
162
+ * For integer ENCRYPTION types (`euint64`, `euint160`, `euint256`) the value is passed through as-is.
163
+ * For `ebool`, non-zero values become `true`.
164
+ *
165
+ * @param scheme - The encryption scheme identifier.
166
+ * @param type - The ENCRYPTION type to interpret the value as.
167
+ * @param bigPt - The raw bigint plaintext value.
168
+ * @returns A typed `Plaintext` matching the given scheme and ENCRYPTION type.
169
+ * @throws If `type` is not a supported ENCRYPTION type.
170
+ */
106
171
  export declare function bigintToPlaintext<S extends EncryptionScheme, T extends SupportedFheType>(scheme: S, type: T, bigPt: bigint): PlaintextOf<S, T>;
172
+ /**
173
+ * Decodes an ABI-encoded ciphertext input into its components.
174
+ *
175
+ * The input format is: `4-byte version || abi.encode(bytes32 handle, bytes ciphertext)`.
176
+ *
177
+ * @param input - The raw encoded input as a byte array or hex string.
178
+ * @returns The decoded version, handle, and ciphertext.
179
+ */
107
180
  export declare function decodeCiphertextInput(input: ByteArray | Hex): {
108
181
  version: number;
109
182
  handle: Hex;
110
183
  ciphertext: Hex;
111
184
  };
185
+ /**
186
+ * Encodes a handle and ciphertext into the on-chain input format.
187
+ *
188
+ * The output format is: `4-byte version || abi.encode(bytes32 handle, bytes ciphertext)`.
189
+ *
190
+ * @param version - The encoding version (int32).
191
+ * @param handle - The 32-byte handle as a hex string.
192
+ * @param ciphertext - The ciphertext as a hex string.
193
+ * @returns The ABI-encoded input as a hex string.
194
+ */
112
195
  export declare function encodeCiphertextInput(version: number, handle: Hex, ciphertext: Hex): Hex;
196
+ /**
197
+ * Converts a {@link Plaintext} to its `bigint` representation.
198
+ *
199
+ * Integer types pass through directly; `ebool` maps `true` → `1n`, `false` → `0n`.
200
+ *
201
+ * @param plaintext - The plaintext to convert.
202
+ * @returns The bigint representation of the plaintext value.
203
+ */
113
204
  export declare function plaintextToBigint(plaintext: Plaintext): bigint;
205
+ /**
206
+ * Converts a {@link Plaintext} to a {@link Bytes32} hex string.
207
+ * @param plaintext - The plaintext to convert.
208
+ * @returns A 32-byte hex representation of the plaintext value.
209
+ */
114
210
  export declare function plaintextToBytes32(plaintext: Plaintext): Bytes32;
211
+ /**
212
+ * Converts a {@link Plaintext} to a 32-byte `Buffer`.
213
+ * @param plaintext - The plaintext to convert.
214
+ * @returns A 32-byte big-endian buffer of the plaintext value.
215
+ */
115
216
  export declare function plaintextToBytes(plaintext: Plaintext): Buffer;
217
+ /**
218
+ * Parses a {@link Bytes32} hex string into a typed {@link Plaintext}.
219
+ * @param plaintext - The 32-byte hex value to interpret.
220
+ * @param scheme - The encryption scheme identifier.
221
+ * @param type - The ENCRYPTION type to interpret the bytes as.
222
+ * @returns A typed `Plaintext` value.
223
+ */
116
224
  export declare function bytes32ToPlaintext(plaintext: Bytes32, scheme: EncryptionScheme, type: SupportedFheType): Plaintext;
225
+ /**
226
+ * Parses a `Uint8Array` into a typed {@link Plaintext}.
227
+ * @param plaintext - The byte array to interpret.
228
+ * @param scheme - The encryption scheme identifier.
229
+ * @param type - The ENCRYPTION type to interpret the bytes as.
230
+ * @returns A typed `Plaintext` value.
231
+ */
117
232
  export declare function bytesToPlaintext(plaintext: Uint8Array, scheme: EncryptionScheme, type: SupportedFheType): Plaintext;
118
233
  export {};
@@ -1 +1 @@
1
- export * from './encryption.js';
1
+ export { Ciphertext, EncryptionScheme, Plaintext, SupportedFheType, SupportedFheTypeName, bigintToPlaintext, bytes32ToPlaintext, bytesToPlaintext, encryptionSchemes, getEncryptionSchemeName, plaintextToBigint, plaintextToBytes, plaintextToBytes32, supportedFheTypes, type EncryptionSchemes, } from './encryption.js';