@primuslabs/fhetransform-sdk 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (302) hide show
  1. package/README.md +198 -0
  2. package/dist/abis/acl.abi.d.ts +379 -0
  3. package/dist/abis/acl.abi.js +495 -0
  4. package/dist/abis/acl.abi.js.map +1 -0
  5. package/dist/abis/alphatrion_reward.abi.d.ts +407 -0
  6. package/dist/abis/alphatrion_reward.abi.js +532 -0
  7. package/dist/abis/alphatrion_reward.abi.js.map +1 -0
  8. package/dist/abis/ciphertext_digests.abi.d.ts +336 -0
  9. package/dist/abis/ciphertext_digests.abi.js +444 -0
  10. package/dist/abis/ciphertext_digests.abi.js.map +1 -0
  11. package/dist/abis/ciphertext_verification.abi.d.ts +637 -0
  12. package/dist/abis/ciphertext_verification.abi.js +830 -0
  13. package/dist/abis/ciphertext_verification.abi.js.map +1 -0
  14. package/dist/abis/convert_token.abi.d.ts +922 -0
  15. package/dist/abis/convert_token.abi.js +1208 -0
  16. package/dist/abis/convert_token.abi.js.map +1 -0
  17. package/dist/abis/decryption.abi.d.ts +956 -0
  18. package/dist/abis/decryption.abi.js +1244 -0
  19. package/dist/abis/decryption.abi.js.map +1 -0
  20. package/dist/abis/erc20.abi.d.ts +265 -0
  21. package/dist/abis/erc20.abi.js +350 -0
  22. package/dist/abis/erc20.abi.js.map +1 -0
  23. package/dist/abis/fhe_executor.abi.d.ts +1535 -0
  24. package/dist/abis/fhe_executor.abi.js +1962 -0
  25. package/dist/abis/fhe_executor.abi.js.map +1 -0
  26. package/dist/abis/space_bridge_config.abi.d.ts +792 -0
  27. package/dist/abis/space_bridge_config.abi.js +1032 -0
  28. package/dist/abis/space_bridge_config.abi.js.map +1 -0
  29. package/dist/abis/token.abi.d.ts +630 -0
  30. package/dist/abis/token.abi.js +828 -0
  31. package/dist/abis/token.abi.js.map +1 -0
  32. package/dist/cli/eusdc.d.ts +2 -0
  33. package/dist/cli/eusdc.js +41 -0
  34. package/dist/cli/eusdc.js.map +1 -0
  35. package/dist/contract/callbacks.d.ts +59 -0
  36. package/dist/contract/callbacks.js +2 -0
  37. package/dist/contract/callbacks.js.map +1 -0
  38. package/dist/contract/convert-token.d.ts +107 -0
  39. package/dist/contract/convert-token.js +249 -0
  40. package/dist/contract/convert-token.js.map +1 -0
  41. package/dist/contract/token.d.ts +167 -0
  42. package/dist/contract/token.js +404 -0
  43. package/dist/contract/token.js.map +1 -0
  44. package/dist/contract/transaction.d.ts +29 -0
  45. package/dist/contract/transaction.js +2 -0
  46. package/dist/contract/transaction.js.map +1 -0
  47. package/dist/core/address.d.ts +118 -0
  48. package/dist/core/address.js +200 -0
  49. package/dist/core/address.js.map +1 -0
  50. package/dist/core/auth.d.ts +68 -0
  51. package/dist/core/auth.js +58 -0
  52. package/dist/core/auth.js.map +1 -0
  53. package/dist/core/bytes.d.ts +48 -0
  54. package/dist/core/bytes.js +117 -0
  55. package/dist/core/bytes.js.map +1 -0
  56. package/dist/core/cache-manager.d.ts +138 -0
  57. package/dist/core/cache-manager.js +440 -0
  58. package/dist/core/cache-manager.js.map +1 -0
  59. package/dist/core/chain.d.ts +41 -0
  60. package/dist/core/chain.js +59 -0
  61. package/dist/core/chain.js.map +1 -0
  62. package/dist/core/constants.d.ts +24 -0
  63. package/dist/core/constants.js +25 -0
  64. package/dist/core/constants.js.map +1 -0
  65. package/dist/core/error.d.ts +2 -0
  66. package/dist/core/error.js +14 -0
  67. package/dist/core/error.js.map +1 -0
  68. package/dist/core/errors/error-catalog.d.ts +29 -0
  69. package/dist/core/errors/error-catalog.js +84 -0
  70. package/dist/core/errors/error-catalog.js.map +1 -0
  71. package/dist/core/errors/error-codes.d.ts +52 -0
  72. package/dist/core/errors/error-codes.js +61 -0
  73. package/dist/core/errors/error-codes.js.map +1 -0
  74. package/dist/core/errors/error-utils.d.ts +27 -0
  75. package/dist/core/errors/error-utils.js +110 -0
  76. package/dist/core/errors/error-utils.js.map +1 -0
  77. package/dist/core/errors/fhe-error.d.ts +98 -0
  78. package/dist/core/errors/fhe-error.js +190 -0
  79. package/dist/core/errors/fhe-error.js.map +1 -0
  80. package/dist/core/errors/index.d.ts +4 -0
  81. package/dist/core/errors/index.js +5 -0
  82. package/dist/core/errors/index.js.map +1 -0
  83. package/dist/core/estimate.d.ts +39 -0
  84. package/dist/core/estimate.js +111 -0
  85. package/dist/core/estimate.js.map +1 -0
  86. package/dist/core/event.d.ts +212 -0
  87. package/dist/core/event.js +42 -0
  88. package/dist/core/event.js.map +1 -0
  89. package/dist/core/fhe-type.d.ts +75 -0
  90. package/dist/core/fhe-type.js +115 -0
  91. package/dist/core/fhe-type.js.map +1 -0
  92. package/dist/core/fhe.d.ts +11 -0
  93. package/dist/core/fhe.js +23 -0
  94. package/dist/core/fhe.js.map +1 -0
  95. package/dist/core/handle.d.ts +42 -0
  96. package/dist/core/handle.js +99 -0
  97. package/dist/core/handle.js.map +1 -0
  98. package/dist/core/json-utils.d.ts +18 -0
  99. package/dist/core/json-utils.js +37 -0
  100. package/dist/core/json-utils.js.map +1 -0
  101. package/dist/core/kms.d.ts +42 -0
  102. package/dist/core/kms.js +70 -0
  103. package/dist/core/kms.js.map +1 -0
  104. package/dist/core/logger.d.ts +3 -0
  105. package/dist/core/logger.js +11 -0
  106. package/dist/core/logger.js.map +1 -0
  107. package/dist/core/pretty-print.d.ts +18 -0
  108. package/dist/core/pretty-print.js +84 -0
  109. package/dist/core/pretty-print.js.map +1 -0
  110. package/dist/core/primitives.d.ts +22 -0
  111. package/dist/core/primitives.js +2 -0
  112. package/dist/core/primitives.js.map +1 -0
  113. package/dist/core/retryable-handler.d.ts +74 -0
  114. package/dist/core/retryable-handler.js +227 -0
  115. package/dist/core/retryable-handler.js.map +1 -0
  116. package/dist/core/signer-address-info.d.ts +15 -0
  117. package/dist/core/signer-address-info.js +33 -0
  118. package/dist/core/signer-address-info.js.map +1 -0
  119. package/dist/core/string.d.ts +28 -0
  120. package/dist/core/string.js +33 -0
  121. package/dist/core/string.js.map +1 -0
  122. package/dist/core/swallow.d.ts +23 -0
  123. package/dist/core/swallow.js +37 -0
  124. package/dist/core/swallow.js.map +1 -0
  125. package/dist/core/system-contract-info.d.ts +17 -0
  126. package/dist/core/system-contract-info.js +41 -0
  127. package/dist/core/system-contract-info.js.map +1 -0
  128. package/dist/core/ttl-cache.d.ts +81 -0
  129. package/dist/core/ttl-cache.js +113 -0
  130. package/dist/core/ttl-cache.js.map +1 -0
  131. package/dist/core/tx-error-parser.d.ts +40 -0
  132. package/dist/core/tx-error-parser.js +83 -0
  133. package/dist/core/tx-error-parser.js.map +1 -0
  134. package/dist/core/utils.d.ts +62 -0
  135. package/dist/core/utils.js +143 -0
  136. package/dist/core/utils.js.map +1 -0
  137. package/dist/index.d.ts +40 -0
  138. package/dist/index.js +48 -0
  139. package/dist/index.js.map +1 -0
  140. package/dist/jazz/encrypt-key-p.d.ts +65 -0
  141. package/dist/jazz/encrypt-key-p.js +283 -0
  142. package/dist/jazz/encrypt-key-p.js.map +1 -0
  143. package/dist/jazz/encrypt-p.d.ts +82 -0
  144. package/dist/jazz/encrypt-p.js +139 -0
  145. package/dist/jazz/encrypt-p.js.map +1 -0
  146. package/dist/jazz/encrypt.d.ts +58 -0
  147. package/dist/jazz/encrypt.js +155 -0
  148. package/dist/jazz/encrypt.js.map +1 -0
  149. package/dist/jazz/input-proof-p.d.ts +122 -0
  150. package/dist/jazz/input-proof-p.js +265 -0
  151. package/dist/jazz/input-proof-p.js.map +1 -0
  152. package/dist/jazz/jazz-client-i.d.ts +16 -0
  153. package/dist/jazz/jazz-client-i.js +2 -0
  154. package/dist/jazz/jazz-client-i.js.map +1 -0
  155. package/dist/jazz/jazz-client.d.ts +18 -0
  156. package/dist/jazz/jazz-client.js +24 -0
  157. package/dist/jazz/jazz-client.js.map +1 -0
  158. package/dist/jazz/key-pair.d.ts +50 -0
  159. package/dist/jazz/key-pair.js +166 -0
  160. package/dist/jazz/key-pair.js.map +1 -0
  161. package/dist/jazz/mock/fake.d.ts +3 -0
  162. package/dist/jazz/mock/fake.js +23 -0
  163. package/dist/jazz/mock/fake.js.map +1 -0
  164. package/dist/jazz/mock/fetch-input-proof.d.ts +4 -0
  165. package/dist/jazz/mock/fetch-input-proof.js +63 -0
  166. package/dist/jazz/mock/fetch-input-proof.js.map +1 -0
  167. package/dist/jazz/mock/fetch-key-url.d.ts +3 -0
  168. package/dist/jazz/mock/fetch-key-url.js +15 -0
  169. package/dist/jazz/mock/fetch-key-url.js.map +1 -0
  170. package/dist/jazz/mock/fetch-public-decrypt.d.ts +3 -0
  171. package/dist/jazz/mock/fetch-public-decrypt.js +81 -0
  172. package/dist/jazz/mock/fetch-public-decrypt.js.map +1 -0
  173. package/dist/jazz/mock/fetch-user-decrypt.d.ts +4 -0
  174. package/dist/jazz/mock/fetch-user-decrypt.js +174 -0
  175. package/dist/jazz/mock/fetch-user-decrypt.js.map +1 -0
  176. package/dist/jazz/module/fetch-input-proof.d.ts +19 -0
  177. package/dist/jazz/module/fetch-input-proof.js +72 -0
  178. package/dist/jazz/module/fetch-input-proof.js.map +1 -0
  179. package/dist/jazz/module/fetch-key-url.d.ts +17 -0
  180. package/dist/jazz/module/fetch-key-url.js +46 -0
  181. package/dist/jazz/module/fetch-key-url.js.map +1 -0
  182. package/dist/jazz/module/fetch-public-decrypt.d.ts +19 -0
  183. package/dist/jazz/module/fetch-public-decrypt.js +65 -0
  184. package/dist/jazz/module/fetch-public-decrypt.js.map +1 -0
  185. package/dist/jazz/module/fetch-user-decrypt.d.ts +19 -0
  186. package/dist/jazz/module/fetch-user-decrypt.js +109 -0
  187. package/dist/jazz/module/fetch-user-decrypt.js.map +1 -0
  188. package/dist/jazz/module/jazz-async-request.d.ts +102 -0
  189. package/dist/jazz/module/jazz-async-request.js +515 -0
  190. package/dist/jazz/module/jazz-async-request.js.map +1 -0
  191. package/dist/jazz/module/jazz-p.d.ts +61 -0
  192. package/dist/jazz/module/jazz-p.js +33 -0
  193. package/dist/jazz/module/jazz-p.js.map +1 -0
  194. package/dist/jazz/module/s3-download.d.ts +85 -0
  195. package/dist/jazz/module/s3-download.js +293 -0
  196. package/dist/jazz/module/s3-download.js.map +1 -0
  197. package/dist/jazz/permit.d.ts +200 -0
  198. package/dist/jazz/permit.js +319 -0
  199. package/dist/jazz/permit.js.map +1 -0
  200. package/dist/jazz/public-decrypt-p.d.ts +96 -0
  201. package/dist/jazz/public-decrypt-p.js +258 -0
  202. package/dist/jazz/public-decrypt-p.js.map +1 -0
  203. package/dist/jazz/public-decrypt.d.ts +48 -0
  204. package/dist/jazz/public-decrypt.js +156 -0
  205. package/dist/jazz/public-decrypt.js.map +1 -0
  206. package/dist/jazz/read-contract.d.ts +81 -0
  207. package/dist/jazz/read-contract.js +125 -0
  208. package/dist/jazz/read-contract.js.map +1 -0
  209. package/dist/jazz/types/common.d.ts +17 -0
  210. package/dist/jazz/types/common.js +2 -0
  211. package/dist/jazz/types/common.js.map +1 -0
  212. package/dist/jazz/types/input-proof.d.ts +76 -0
  213. package/dist/jazz/types/input-proof.js +2 -0
  214. package/dist/jazz/types/input-proof.js.map +1 -0
  215. package/dist/jazz/types/key-url.d.ts +68 -0
  216. package/dist/jazz/types/key-url.js +5 -0
  217. package/dist/jazz/types/key-url.js.map +1 -0
  218. package/dist/jazz/types/public-decrypt.d.ts +61 -0
  219. package/dist/jazz/types/public-decrypt.js +2 -0
  220. package/dist/jazz/types/public-decrypt.js.map +1 -0
  221. package/dist/jazz/types/user-decrypt.d.ts +123 -0
  222. package/dist/jazz/types/user-decrypt.js +2 -0
  223. package/dist/jazz/types/user-decrypt.js.map +1 -0
  224. package/dist/jazz/user-decrypt-p.d.ts +111 -0
  225. package/dist/jazz/user-decrypt-p.js +280 -0
  226. package/dist/jazz/user-decrypt-p.js.map +1 -0
  227. package/dist/jazz/user-decrypt.d.ts +74 -0
  228. package/dist/jazz/user-decrypt.js +143 -0
  229. package/dist/jazz/user-decrypt.js.map +1 -0
  230. package/dist/native/fhe-api.js +5959 -0
  231. package/dist/native/fhe-api.node.cjs +6167 -0
  232. package/dist/native/fhe-api.node.worker.cjs +210 -0
  233. package/dist/native/fhe-api.wasm +0 -0
  234. package/dist/native/fhe-api.worker.js +164 -0
  235. package/dist/native/kms/node/kms_lib.d.ts +38 -0
  236. package/dist/native/kms/node/kms_lib.js +356 -0
  237. package/dist/native/kms/node/kms_lib_bg.wasm +0 -0
  238. package/dist/native/kms/node/kms_lib_bg.wasm.d.ts +21 -0
  239. package/dist/native/kms/node/package.json +11 -0
  240. package/dist/native/kms/web/kms_lib.d.ts +84 -0
  241. package/dist/native/kms/web/kms_lib.js +443 -0
  242. package/dist/native/kms/web/kms_lib_bg.wasm +0 -0
  243. package/dist/native/kms/web/kms_lib_bg.wasm.d.ts +21 -0
  244. package/dist/native/kms/web/package.json +15 -0
  245. package/dist/runtime/browser.d.ts +36 -0
  246. package/dist/runtime/browser.js +115 -0
  247. package/dist/runtime/browser.js.map +1 -0
  248. package/dist/runtime/node.d.ts +30 -0
  249. package/dist/runtime/node.js +95 -0
  250. package/dist/runtime/node.js.map +1 -0
  251. package/dist/sdk/fhetransform-sdk-b.d.ts +102 -0
  252. package/dist/sdk/fhetransform-sdk-b.js +294 -0
  253. package/dist/sdk/fhetransform-sdk-b.js.map +1 -0
  254. package/dist/sdk/fhetransform-sdk.d.ts +87 -0
  255. package/dist/sdk/fhetransform-sdk.js +135 -0
  256. package/dist/sdk/fhetransform-sdk.js.map +1 -0
  257. package/dist/sdk/jazz-service.d.ts +13 -0
  258. package/dist/sdk/jazz-service.js +58 -0
  259. package/dist/sdk/jazz-service.js.map +1 -0
  260. package/dist/sdk/permit-service.d.ts +45 -0
  261. package/dist/sdk/permit-service.js +144 -0
  262. package/dist/sdk/permit-service.js.map +1 -0
  263. package/dist/wasm/fhe-wasm-client.d.ts +19 -0
  264. package/dist/wasm/fhe-wasm-client.js +23 -0
  265. package/dist/wasm/fhe-wasm-client.js.map +1 -0
  266. package/dist/wasm/fhe-wasm-module.d.ts +24 -0
  267. package/dist/wasm/fhe-wasm-module.js +141 -0
  268. package/dist/wasm/fhe-wasm-module.js.map +1 -0
  269. package/dist/wasm/fhe-wasm-type.d.ts +59 -0
  270. package/dist/wasm/fhe-wasm-type.js +244 -0
  271. package/dist/wasm/fhe-wasm-type.js.map +1 -0
  272. package/dist/wasm/wasm-loader.browser.d.ts +21 -0
  273. package/dist/wasm/wasm-loader.browser.js +143 -0
  274. package/dist/wasm/wasm-loader.browser.js.map +1 -0
  275. package/dist/wasm/wasm-loader.node.d.ts +24 -0
  276. package/dist/wasm/wasm-loader.node.js +114 -0
  277. package/dist/wasm/wasm-loader.node.js.map +1 -0
  278. package/dist/wasm/worker-client.browser.d.ts +6 -0
  279. package/dist/wasm/worker-client.browser.js +21 -0
  280. package/dist/wasm/worker-client.browser.js.map +1 -0
  281. package/dist/wasm/worker-client.d.ts +34 -0
  282. package/dist/wasm/worker-client.js +160 -0
  283. package/dist/wasm/worker-client.js.map +1 -0
  284. package/dist/wasm/worker-client.node.d.ts +6 -0
  285. package/dist/wasm/worker-client.node.js +20 -0
  286. package/dist/wasm/worker-client.node.js.map +1 -0
  287. package/dist/wasm/worker-message.d.ts +61 -0
  288. package/dist/wasm/worker-message.js +2 -0
  289. package/dist/wasm/worker-message.js.map +1 -0
  290. package/dist/wasm/worker-transport.browser.d.ts +15 -0
  291. package/dist/wasm/worker-transport.browser.js +35 -0
  292. package/dist/wasm/worker-transport.browser.js.map +1 -0
  293. package/dist/wasm/worker-transport.d.ts +6 -0
  294. package/dist/wasm/worker-transport.js +2 -0
  295. package/dist/wasm/worker-transport.js.map +1 -0
  296. package/dist/wasm/worker-transport.node.d.ts +17 -0
  297. package/dist/wasm/worker-transport.node.js +39 -0
  298. package/dist/wasm/worker-transport.node.js.map +1 -0
  299. package/dist/wasm/worker.d.ts +1 -0
  300. package/dist/wasm/worker.js +69 -0
  301. package/dist/wasm/worker.js.map +1 -0
  302. package/package.json +81 -0
package/dist/index.js ADDED
@@ -0,0 +1,48 @@
1
+ // ============================================================================
2
+ // Core types
3
+ // ============================================================================
4
+ export { FheType, Operator } from "./core/fhe-type.js";
5
+ // ============================================================================
6
+ // SDK
7
+ // ============================================================================
8
+ export { FheTransformSDK } from "./sdk/fhetransform-sdk.js";
9
+ export { PermitService } from "./sdk/permit-service.js";
10
+ // ============================================================================
11
+ // Contract wrappers and transaction types
12
+ // ============================================================================
13
+ export { ConvertToken } from "./contract/convert-token.js";
14
+ export { Token, TokenBase } from "./contract/token.js";
15
+ // ============================================================================
16
+ // Events
17
+ // ============================================================================
18
+ export { FheTransformSDKEvents } from "./core/event.js";
19
+ // ============================================================================
20
+ // Address helpers
21
+ // ============================================================================
22
+ export { ADDRESS_ZERO, areEqualAddresses, assertChecksumAddress, ChecksumAddressError, isChecksumAddress, isValidAddress, isZeroAddress, toChecksumAddress, toChecksumAddresses, toChecksumAddressesFiltered, toChecksumAddressesSafe, } from "./core/address.js";
23
+ // ============================================================================
24
+ // Chain & system information
25
+ // ============================================================================
26
+ export { buildSetChainKeysArgs, CHAINS, getChainKey } from "./core/chain.js";
27
+ export { getSystemContractInfo } from "./core/system-contract-info.js";
28
+ export { getSignerAddressInfo } from "./core/signer-address-info.js";
29
+ // ============================================================================
30
+ // Fee estimation
31
+ // ============================================================================
32
+ export { estimateFheFee } from "./core/estimate.js";
33
+ // ============================================================================
34
+ // Authentication
35
+ // ============================================================================
36
+ export { setAxiosAuth } from "./core/auth.js";
37
+ // ============================================================================
38
+ // Error parsing
39
+ // ============================================================================
40
+ export { ErrorParser } from "./core/tx-error-parser.js";
41
+ // ============================================================================
42
+ // Unified errors
43
+ // ============================================================================
44
+ export { FheError } from "./core/errors/fhe-error.js";
45
+ export { FheErrorCode } from "./core/errors/error-codes.js";
46
+ export { formatMessage, getErrorCatalogEntry } from "./core/errors/error-catalog.js";
47
+ export { getErrorCode, getErrorMessage, getErrorRetryPolicy, isFheError, toFheError, withFheError, } from "./core/errors/error-utils.js";
48
+ //# sourceMapping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YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,+EAA+E;AAC/E,gBAAgB;AAChB,+EAA+E;AAE/E,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAE/E,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACrF,OAAO,EACL,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,UAAU,EACV,UAAU,EACV,YAAY,GACb,MAAM,8BAA8B,CAAC"}
@@ -0,0 +1,65 @@
1
+ import { IJazzClient } from "./jazz-client-i.js";
2
+ /**
3
+ * Public key types supported by the FHE encryption backend.
4
+ */
5
+ export declare enum PkType {
6
+ /** Unspecified/unknown key type */
7
+ PK_TYPE_UNSPECIFIED = 0,
8
+ /** V1 public key type */
9
+ PK_TYPE_V1 = 1,
10
+ /** V2 public key type */
11
+ PK_TYPE_V2 = 2,
12
+ /** ZK CRS (Common Reference String) type */
13
+ ZK_CRS = 3
14
+ }
15
+ /**
16
+ * Public key item containing the key data and its type.
17
+ */
18
+ export interface PublicKeyItem {
19
+ /** Public key bytes as Uint8Array */
20
+ data: Uint8Array;
21
+ /** Type of public key (V1, V2, or ZK_CRS) */
22
+ type: PkType;
23
+ }
24
+ /**
25
+ * Container object for both public key and CRS.
26
+ */
27
+ export interface PublickeyItemObject {
28
+ /** Public key item (V1 or V2) */
29
+ pk: PublicKeyItem;
30
+ /** CRS item (ZK_CRS) */
31
+ crs: PublicKeyItem;
32
+ }
33
+ /**
34
+ * Options for fetching public keys.
35
+ */
36
+ export interface GetOrFetchPublickeyOptions {
37
+ /** Whether to use mock/local files instead of remote S3 URLs */
38
+ isMock?: boolean;
39
+ /** Force refresh of cached keys */
40
+ refresh?: boolean;
41
+ }
42
+ /**
43
+ * Parameters for fetching public keys from URLs.
44
+ */
45
+ export interface GetPublickeyParameters {
46
+ /** URL to fetch the public key from */
47
+ pkUrl: string;
48
+ /** URL to fetch the CRS from */
49
+ crsUrl: string;
50
+ }
51
+ /**
52
+ * Gets or fetches the FHE public key and CRS.
53
+ *
54
+ * This function implements a caching strategy:
55
+ * 1. Checks if keys are already in the in-memory cache
56
+ * 2. If not, or if refresh is requested or TTL expired, fetches from source
57
+ * 3. Saves fetched keys to both in-memory and persistent cache
58
+ * 4. Returns the keys
59
+ *
60
+ * @param client - The Jazz client instance
61
+ * @param options - Configuration options (mock mode, refresh)
62
+ * @returns Promise resolving to PublickeyItemObject containing pk and crs
63
+ * @throws Error if fetching fails
64
+ */
65
+ export declare function getOrFetchPublickey(client: IJazzClient, options?: GetOrFetchPublickeyOptions): Promise<PublickeyItemObject>;
@@ -0,0 +1,283 @@
1
+ import { fetchKeyUrl as fetchKeyUrlMock } from "./mock/fetch-key-url.js";
2
+ import { fetchKeyUrl } from "./module/fetch-key-url.js";
3
+ import { logger } from "../core/logger.js";
4
+ import { S3Downloader } from "./module/s3-download.js";
5
+ import { DEFAULT_PUBLIC_KEY_TTL_SECONDS } from "../core/constants.js";
6
+ import { readLocalFile } from "#runtime";
7
+ import { FheErrorCode } from "../core/errors/error-codes.js";
8
+ import { FheError } from "../core/errors/fhe-error.js";
9
+ // ============================================================================
10
+ // Enums and Types
11
+ // ============================================================================
12
+ /**
13
+ * Public key types supported by the FHE encryption backend.
14
+ */
15
+ export var PkType;
16
+ (function (PkType) {
17
+ /** Unspecified/unknown key type */
18
+ PkType[PkType["PK_TYPE_UNSPECIFIED"] = 0] = "PK_TYPE_UNSPECIFIED";
19
+ /** V1 public key type */
20
+ PkType[PkType["PK_TYPE_V1"] = 1] = "PK_TYPE_V1";
21
+ /** V2 public key type */
22
+ PkType[PkType["PK_TYPE_V2"] = 2] = "PK_TYPE_V2";
23
+ /** ZK CRS (Common Reference String) type */
24
+ PkType[PkType["ZK_CRS"] = 3] = "ZK_CRS";
25
+ })(PkType || (PkType = {}));
26
+ // ============================================================================
27
+ // Private Helpers
28
+ // ============================================================================
29
+ /**
30
+ * Loads a local file and returns it as a PublicKeyItem.
31
+ *
32
+ * @param filepath - Path to the local file
33
+ * @param pk_type - Type of the public key being loaded
34
+ * @returns PublicKeyItem containing the loaded data
35
+ * @throws Error if the file cannot be read or is empty
36
+ */
37
+ async function loadLocalFile(filepath, pk_type) {
38
+ logger.debug('[loadLocalFile] Loading local file', {
39
+ filepath,
40
+ pkType: pk_type,
41
+ });
42
+ try {
43
+ const pkBytes = await readLocalFile(filepath);
44
+ if (pkBytes.length <= 0) {
45
+ logger.error('[loadLocalFile] File is empty', {
46
+ filepath,
47
+ size: pkBytes.length,
48
+ });
49
+ throw new FheError({ code: FheErrorCode.InvalidArgument, message: 'pkBytes.length is 0' });
50
+ }
51
+ const result = {
52
+ data: pkBytes,
53
+ type: pk_type,
54
+ };
55
+ logger.debug('[loadLocalFile] Local file loaded successfully', {
56
+ filepath,
57
+ size: pkBytes.length,
58
+ pkType: pk_type,
59
+ });
60
+ return result;
61
+ }
62
+ catch (error) {
63
+ logger.error('[loadLocalFile] Failed to load local file', {
64
+ filepath,
65
+ error: error.message,
66
+ stack: error.stack,
67
+ });
68
+ throw error;
69
+ }
70
+ }
71
+ /**
72
+ * Fetches public key and CRS from local files (mock mode).
73
+ *
74
+ * @param parameters - URLs to the local files
75
+ * @returns PublickeyItemObject containing both pk and crs
76
+ */
77
+ async function _getPublickeyMock(parameters) {
78
+ logger.debug('[_getPublickeyMock] Fetching public keys from local files', {
79
+ pkUrl: parameters.pkUrl,
80
+ crsUrl: parameters.crsUrl,
81
+ });
82
+ // Load both files in parallel for better performance
83
+ const [pk, crs] = await Promise.all([
84
+ loadLocalFile(parameters.pkUrl, PkType.PK_TYPE_V1),
85
+ loadLocalFile(parameters.crsUrl, PkType.ZK_CRS),
86
+ ]);
87
+ logger.debug('[_getPublickeyMock] Public keys loaded from local files', {
88
+ pkSize: pk.data.length,
89
+ crsSize: crs.data.length,
90
+ });
91
+ return { pk, crs };
92
+ }
93
+ /**
94
+ * Fetches public key and CRS from remote S3 URLs.
95
+ *
96
+ * @param parameters - URLs to fetch from S3
97
+ * @returns PublickeyItemObject containing both pk and crs
98
+ */
99
+ async function _getPublickey(parameters) {
100
+ logger.debug('[_getPublickey] Fetching public keys from S3 URLs', {
101
+ pkUrl: parameters.pkUrl,
102
+ crsUrl: parameters.crsUrl,
103
+ });
104
+ const s3Downloader = new S3Downloader();
105
+ // Download both files in parallel for better performance
106
+ const [pkBinary, crsBinary] = await Promise.all([
107
+ s3Downloader.downloadBinary({ url: parameters.pkUrl }),
108
+ s3Downloader.downloadBinary({ url: parameters.crsUrl }),
109
+ ]);
110
+ const pk = {
111
+ data: pkBinary.data,
112
+ type: PkType.PK_TYPE_V1,
113
+ };
114
+ const crs = {
115
+ data: crsBinary.data,
116
+ type: PkType.ZK_CRS,
117
+ };
118
+ logger.debug('[_getPublickey] Public keys downloaded from S3', {
119
+ pkSize: pk.data.length,
120
+ crsSize: crs.data.length,
121
+ });
122
+ return { pk, crs };
123
+ }
124
+ // ============================================================================
125
+ // Public API
126
+ // ============================================================================
127
+ /** Cache for public keys (scoped to module) */
128
+ let pks = null; // TODO: Scope to chainId and contract address
129
+ let pksPromise = null;
130
+ /**
131
+ * Cache key for the FHE public key in the cache manager.
132
+ * TODO: Make chainId and contract address aware for multi-chain support.
133
+ */
134
+ const PK_STORE_KEY = 'fhekey:pk_mcl_snark1';
135
+ /**
136
+ * Cache key for the CRS in the cache manager.
137
+ * TODO: Make chainId and contract address aware for multi-chain support.
138
+ */
139
+ const CRS_STORE_KEY = 'fhekey:crs_mcl_snark1';
140
+ /**
141
+ * Gets or fetches the FHE public key and CRS.
142
+ *
143
+ * This function implements a caching strategy:
144
+ * 1. Checks if keys are already in the in-memory cache
145
+ * 2. If not, or if refresh is requested or TTL expired, fetches from source
146
+ * 3. Saves fetched keys to both in-memory and persistent cache
147
+ * 4. Returns the keys
148
+ *
149
+ * @param client - The Jazz client instance
150
+ * @param options - Configuration options (mock mode, refresh)
151
+ * @returns Promise resolving to PublickeyItemObject containing pk and crs
152
+ * @throws Error if fetching fails
153
+ */
154
+ export async function getOrFetchPublickey(client, options) {
155
+ if (pks)
156
+ return pks;
157
+ if (pksPromise)
158
+ return pksPromise;
159
+ pksPromise = (async () => {
160
+ try {
161
+ // Enter method
162
+ const isMock = options?.isMock ?? false;
163
+ const refresh = options?.refresh ?? false;
164
+ logger.debug('[getOrFetchPublickey] Enter', {
165
+ isMock,
166
+ refresh,
167
+ hasCachedKeys: !!pks,
168
+ });
169
+ // ============================================================================
170
+ // Step 1: Check Cache Expiration
171
+ // ============================================================================
172
+ // Check if cached keys have expired
173
+ const shouldRefreshPk = await client.sdk.cacheManager.shouldRefresh(PK_STORE_KEY, DEFAULT_PUBLIC_KEY_TTL_SECONDS);
174
+ const shouldRefreshCrs = await client.sdk.cacheManager.shouldRefresh(CRS_STORE_KEY, DEFAULT_PUBLIC_KEY_TTL_SECONDS);
175
+ logger.debug('[getOrFetchPublickey] Cache status', {
176
+ refresh,
177
+ pkExpired: shouldRefreshPk,
178
+ crsExpired: shouldRefreshCrs,
179
+ ttlSeconds: DEFAULT_PUBLIC_KEY_TTL_SECONDS,
180
+ });
181
+ // ============================================================================
182
+ // Step 2: Fetch Keys (if refresh requested or cache expired)
183
+ // ============================================================================
184
+ const needsRefresh = refresh || shouldRefreshPk || shouldRefreshCrs;
185
+ if (needsRefresh) {
186
+ logger.debug('[getOrFetchPublickey] Fetching fresh keys from source', {
187
+ reason: refresh ? 'user requested refresh' : 'cache expired',
188
+ });
189
+ // Fetch key URLs from Jazz service
190
+ let fetchKeyUrlResult;
191
+ if (isMock) {
192
+ logger.trace('[getOrFetchPublickey] Using mock mode for key URL fetch');
193
+ fetchKeyUrlResult = await fetchKeyUrlMock(client, {});
194
+ }
195
+ else {
196
+ logger.trace('[getOrFetchPublickey] Using production mode for key URL fetch');
197
+ fetchKeyUrlResult = await fetchKeyUrl(client, {});
198
+ }
199
+ logger.debug('[getOrFetchPublickey] Key URLs fetched', {
200
+ publicKeyId: fetchKeyUrlResult.publicKeySource.id,
201
+ publicKeyUrl: fetchKeyUrlResult.publicKeySource.url,
202
+ crsId: fetchKeyUrlResult.crsSource.id,
203
+ crsUrl: fetchKeyUrlResult.crsSource.url,
204
+ });
205
+ // Build parameters for fetching the actual key data
206
+ const getPublickeyParameters = {
207
+ pkUrl: fetchKeyUrlResult.publicKeySource.url,
208
+ crsUrl: fetchKeyUrlResult.crsSource.url,
209
+ };
210
+ // Fetch the actual key data (from local files in mock mode, or S3 in production)
211
+ if (isMock) {
212
+ logger.debug('[getOrFetchPublickey] Fetching keys from local files (mock)');
213
+ pks = await _getPublickeyMock(getPublickeyParameters);
214
+ }
215
+ else {
216
+ logger.debug('[getOrFetchPublickey] Fetching keys from S3 (production)');
217
+ pks = await _getPublickey(getPublickeyParameters);
218
+ }
219
+ logger.debug('[getOrFetchPublickey] Keys fetched successfully', {
220
+ pkSize: pks.pk.data.length,
221
+ crsSize: pks.crs.data.length,
222
+ });
223
+ // ============================================================================
224
+ // Step 3: Save to Persistent Cache
225
+ // ============================================================================
226
+ // Save to persistent cache for future use
227
+ await Promise.all([
228
+ client.sdk.cacheManager.save(PK_STORE_KEY, pks.pk.data),
229
+ client.sdk.cacheManager.save(CRS_STORE_KEY, pks.crs.data),
230
+ ]);
231
+ logger.debug('[getOrFetchPublickey] Keys saved to persistent cache', {
232
+ pkStoreKey: PK_STORE_KEY,
233
+ crsStoreKey: CRS_STORE_KEY,
234
+ pkSize: pks.pk.data.length,
235
+ crsSize: pks.crs.data.length,
236
+ });
237
+ }
238
+ else {
239
+ logger.trace('[getOrFetchPublickey] Cache is fresh, no refresh needed');
240
+ }
241
+ // ============================================================================
242
+ // Step 4: Load from Cache (if not already in memory)
243
+ // ============================================================================
244
+ if (!pks) {
245
+ logger.debug('[getOrFetchPublickey] Loading keys from persistent cache');
246
+ // Load from persistent cache
247
+ const [pkData, crsData] = await Promise.all([
248
+ client.sdk.cacheManager.load(PK_STORE_KEY),
249
+ client.sdk.cacheManager.load(CRS_STORE_KEY),
250
+ ]);
251
+ if (!pkData || !crsData) {
252
+ logger.error('[getOrFetchPublickey] Cache miss - keys not found in persistent cache');
253
+ throw new FheError({ code: FheErrorCode.CacheMiss, message: 'Failed to load public keys from cache' });
254
+ }
255
+ pks = {
256
+ pk: {
257
+ data: pkData,
258
+ type: PkType.PK_TYPE_V1,
259
+ },
260
+ crs: {
261
+ data: crsData,
262
+ type: PkType.ZK_CRS,
263
+ },
264
+ };
265
+ logger.debug('[getOrFetchPublickey] Keys loaded from persistent cache', {
266
+ pkSize: pks.pk.data.length,
267
+ crsSize: pks.crs.data.length,
268
+ });
269
+ }
270
+ logger.debug('[getOrFetchPublickey] Public keys ready', {
271
+ pkSize: pks.pk.data.length,
272
+ crsSize: pks.crs.data.length,
273
+ fromCache: !needsRefresh,
274
+ });
275
+ return pks;
276
+ }
277
+ finally {
278
+ pksPromise = null;
279
+ }
280
+ })();
281
+ return pksPromise;
282
+ }
283
+ //# sourceMappingURL=encrypt-key-p.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encrypt-key-p.js","sourceRoot":"","sources":["../../src/jazz/encrypt-key-p.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,M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,CAAC;YACL,CAAC;YAED,MAAM,CAAC,KAAK,CAAC,yCAAyC,EAAE;gBACtD,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM;gBAC1B,OAAO,EAAE,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM;gBAC5B,SAAS,EAAE,CAAC,YAAY;aACzB,CAAC,CAAC;YAEH,OAAO,GAAG,CAAC;QAGb,CAAC;gBAAS,CAAC;YACT,UAAU,GAAG,IAAI,CAAC;QACpB,CAAC;IACH,CAAC,CAAC,EAAE,CAAC;IAEL,OAAO,UAAU,CAAC;AACpB,CAAC"}
@@ -0,0 +1,82 @@
1
+ import { EncryptPayloadItem } from "./encrypt.js";
2
+ import { PublickeyItemObject } from "./encrypt-key-p.js";
3
+ /**
4
+ * Parameters for encrypting with zero-knowledge proof support.
5
+ */
6
+ export type EncryptWithZkParameters = {
7
+ /** List of payload items to encrypt (value + FHE type) */
8
+ readonly payloads: EncryptPayloadItem[];
9
+ /** Public key and CRS for encryption */
10
+ readonly pks: PublickeyItemObject;
11
+ /** Additional metadata for the ZK proof */
12
+ readonly metadata: Uint8Array;
13
+ };
14
+ /**
15
+ * Result of ZK encryption operation.
16
+ */
17
+ export type EncryptWithZkResult = Uint8Array;
18
+ /**
19
+ * Encrypts a batch of values with zero-knowledge proof generation.
20
+ * This provides verifiable encryption for multiple values in one call.
21
+ *
22
+ * The input format for the WASM module:
23
+ * - 8 bytes: number of elements
24
+ * - For each element:
25
+ * - 8 bytes: length of the value in bytes
26
+ * - N bytes: value bytes (padded to FHE type length)
27
+ *
28
+ * @param parameters - Encryption parameters including payloads, keys, and metadata
29
+ * @returns Combined ciphertext with ZK proof as Uint8Array
30
+ * @throws Error if encryption fails
31
+ */
32
+ export declare function encryptWithZk(parameters: EncryptWithZkParameters): Promise<EncryptWithZkResult>;
33
+ /**
34
+ * Result of encoding a value with both hex and buffer representations.
35
+ */
36
+ export interface EncodedData {
37
+ /** Hex string representation with 0x prefix */
38
+ hex: string;
39
+ /** Buffer representation as Uint8Array */
40
+ buf: Uint8Array;
41
+ }
42
+ /**
43
+ * Encodes a bigint or number to a fixed-size buffer with hex representation.
44
+ *
45
+ * @param data - The value to encode (bigint or number)
46
+ * @param size - The desired output size in bytes (hex characters = size * 2)
47
+ * @returns EncodedData containing hex string and buffer
48
+ */
49
+ export declare function encodeData(data: bigint | number, size: number): EncodedData;
50
+ /**
51
+ * Encodes an Ethereum address to a buffer with hex representation.
52
+ *
53
+ * @param address - Ethereum address (with or without 0x prefix)
54
+ * @returns EncodedData containing hex string and buffer
55
+ */
56
+ export declare function encodeAddress(address: string): EncodedData;
57
+ /**
58
+ * Metadata information required for ZK proof generation.
59
+ */
60
+ export interface MetadataInfo {
61
+ /** Chain ID */
62
+ chainId: bigint;
63
+ /** ACL contract address (with 0x prefix) */
64
+ aclAddress: string;
65
+ /** Target contract address (with 0x prefix) */
66
+ contractAddress: string;
67
+ /** User address (with 0x prefix) */
68
+ userAddress: string;
69
+ }
70
+ /**
71
+ * Generates metadata buffer for ZK proof from metadata information.
72
+ *
73
+ * The metadata is concatenated in the following order:
74
+ * 1. contractAddress (20 bytes)
75
+ * 2. userAddress (20 bytes)
76
+ * 3. aclAddress (20 bytes)
77
+ * 4. chainId (8 bytes)
78
+ *
79
+ * @param metadataInfo - Metadata information for the ZK proof
80
+ * @returns Metadata buffer as Uint8Array
81
+ */
82
+ export declare function getMetadata(metadataInfo: MetadataInfo): Uint8Array;
@@ -0,0 +1,139 @@
1
+ import { ethers } from "ethers";
2
+ import { fromHexString } from "../core/bytes.js";
3
+ import { getTypeLength } from "../core/fhe-type.js";
4
+ import { logger } from "../core/logger.js";
5
+ import { concatUint8Arrays } from "../core/utils.js";
6
+ import { encryptIntegerWithZkProof } from "../core/fhe.js";
7
+ import { formatValue } from "../core/pretty-print.js";
8
+ // ============================================================================
9
+ // Main Encryption Function
10
+ // ============================================================================
11
+ /**
12
+ * Encrypts a batch of values with zero-knowledge proof generation.
13
+ * This provides verifiable encryption for multiple values in one call.
14
+ *
15
+ * The input format for the WASM module:
16
+ * - 8 bytes: number of elements
17
+ * - For each element:
18
+ * - 8 bytes: length of the value in bytes
19
+ * - N bytes: value bytes (padded to FHE type length)
20
+ *
21
+ * @param parameters - Encryption parameters including payloads, keys, and metadata
22
+ * @returns Combined ciphertext with ZK proof as Uint8Array
23
+ * @throws Error if encryption fails
24
+ */
25
+ export async function encryptWithZk(parameters) {
26
+ // Enter method
27
+ logger.debug(() => ['[encryptWithZk] Enter', formatValue({ parameters })]);
28
+ const { payloads, pks, metadata } = parameters;
29
+ // ============================================================================
30
+ // Step 1: Build Input Buffer
31
+ // ============================================================================
32
+ // Build input: [num_elements (8 bytes), [length (8 bytes), value_bytes, ...]]
33
+ const inputs = [];
34
+ // Add number of elements as 8-byte
35
+ const elems = payloads.length;
36
+ const elemsBytes = fromHexString(elems.toString(16).padStart(16, '0'));
37
+ inputs.push(elemsBytes);
38
+ // Encode each payload item
39
+ for (let i = 0; i < payloads.length; i++) {
40
+ const payload = payloads[i];
41
+ const { value, fheType } = payload;
42
+ // Convert value to bytes (64 hex chars = 32 bytes for uint256)
43
+ const valueBytes = fromHexString(value.toString(16).padStart(64, '0'));
44
+ // Get the correct byte length for the FHE type
45
+ const typeLength = getTypeLength(fheType);
46
+ // Extract the rightmost bytes (matching the FHE type length)
47
+ const inputBytes = valueBytes.subarray(valueBytes.length - typeLength);
48
+ // Encode the length as 8-byte
49
+ const inputLengthBytes = fromHexString(inputBytes.length.toString(16).padStart(16, '0'));
50
+ // Append length and value to the input buffer
51
+ inputs.push(inputLengthBytes, inputBytes);
52
+ logger.debug(() => ['[encryptWithZk] Payload encoded', formatValue({
53
+ index: i, fheType, value, valueBytes,
54
+ typeLength, inputBytes, inputLengthBytes,
55
+ })]);
56
+ }
57
+ // Concatenate all input parts into a single Uint8Array
58
+ const input = concatUint8Arrays(inputs);
59
+ logger.debug(() => ['[encryptWithZk] Input buffer built', formatValue({ input })]);
60
+ // ============================================================================
61
+ // Step 2: Perform ZK Encryption
62
+ // ============================================================================
63
+ // Encrypt the plaintext with the current public key and CRS for ZK proof
64
+ const ciphertextWithZKProof = await encryptIntegerWithZkProof(input, pks.pk.data, pks.crs.data, metadata);
65
+ logger.debug('[encryptWithZk] ZK encryption completed', {
66
+ inputSize: input.length,
67
+ outputSize: ciphertextWithZKProof.length,
68
+ payloadCount: payloads.length,
69
+ });
70
+ return ciphertextWithZKProof;
71
+ }
72
+ /**
73
+ * Encodes a bigint or number to a fixed-size buffer with hex representation.
74
+ *
75
+ * @param data - The value to encode (bigint or number)
76
+ * @param size - The desired output size in bytes (hex characters = size * 2)
77
+ * @returns EncodedData containing hex string and buffer
78
+ */
79
+ export function encodeData(data, size) {
80
+ // Convert to hex and pad to the specified size
81
+ const hex = data.toString(16).padStart(size, '0');
82
+ const bytes = fromHexString(hex);
83
+ logger.trace('[encodeData] Data encoded', {
84
+ data: data.toString(),
85
+ size,
86
+ hexLength: hex.length,
87
+ bytesLength: bytes.length,
88
+ });
89
+ return { hex: `0x${hex}`, buf: bytes };
90
+ }
91
+ /**
92
+ * Encodes an Ethereum address to a buffer with hex representation.
93
+ *
94
+ * @param address - Ethereum address (with or without 0x prefix)
95
+ * @returns EncodedData containing hex string and buffer
96
+ */
97
+ export function encodeAddress(address) {
98
+ // Remove 0x prefix if present
99
+ const hex = address.replace(/^0x/, '');
100
+ const bytes = fromHexString(hex);
101
+ logger.trace('[encodeAddress] Address encoded', {
102
+ address,
103
+ hexLength: hex.length,
104
+ bytesLength: bytes.length,
105
+ });
106
+ return { hex: `0x${hex}`, buf: bytes };
107
+ }
108
+ /**
109
+ * Generates metadata buffer for ZK proof from metadata information.
110
+ *
111
+ * The metadata is concatenated in the following order:
112
+ * 1. contractAddress (20 bytes)
113
+ * 2. userAddress (20 bytes)
114
+ * 3. aclAddress (20 bytes)
115
+ * 4. chainId (8 bytes)
116
+ *
117
+ * @param metadataInfo - Metadata information for the ZK proof
118
+ * @returns Metadata buffer as Uint8Array
119
+ */
120
+ export function getMetadata(metadataInfo) {
121
+ logger.debug('[getMetadata] Generating metadata buffer:', metadataInfo);
122
+ // Encode each field
123
+ const chainIdBuffer = encodeData(metadataInfo.chainId, 16).buf;
124
+ const aclAddressBuffer = encodeAddress(metadataInfo.aclAddress).buf;
125
+ const contractAddressBuffer = encodeAddress(metadataInfo.contractAddress).buf;
126
+ const userAddressBuffer = encodeAddress(metadataInfo.userAddress).buf;
127
+ // Concatenate in order: contractAddress + userAddress + aclAddress + chainId
128
+ const metadata = ethers.concat([
129
+ contractAddressBuffer,
130
+ userAddressBuffer,
131
+ aclAddressBuffer,
132
+ chainIdBuffer,
133
+ ]);
134
+ // Convert to Uint8Array and log
135
+ const result = fromHexString(metadata);
136
+ logger.debug('[getMetadata] Metadata generated', { metadataInfo, metadata });
137
+ return result;
138
+ }
139
+ //# sourceMappingURL=encrypt-p.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encrypt-p.js","sourceRoot":"","sources":["../../src/jazz/encrypt-p.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAG3D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAuBtD,+EAA+E;AAC/E,2BAA2B;AAC3B,+EAA+E;AAE/E;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,UAAmC;IACrE,eAAe;IACf,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,uBAAuB,EAAE,WAAW,CAAC,E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