@aztec/foundation 0.0.0-test.0 → 0.0.1-fake-c83136db25

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 (498) hide show
  1. package/dest/array/array.d.ts +5 -0
  2. package/dest/array/array.d.ts.map +1 -1
  3. package/dest/array/array.js +11 -0
  4. package/dest/async-pool/index.d.ts.map +1 -1
  5. package/dest/async-pool/index.js +1 -0
  6. package/dest/bigint/index.d.ts +7 -0
  7. package/dest/bigint/index.d.ts.map +1 -0
  8. package/dest/bigint/index.js +15 -0
  9. package/dest/bigint-buffer/index.d.ts +0 -2
  10. package/dest/bigint-buffer/index.d.ts.map +1 -1
  11. package/dest/buffer/buffer16.d.ts +80 -0
  12. package/dest/buffer/buffer16.d.ts.map +1 -0
  13. package/dest/buffer/buffer16.js +100 -0
  14. package/dest/buffer/buffer32.d.ts +3 -7
  15. package/dest/buffer/buffer32.d.ts.map +1 -1
  16. package/dest/buffer/buffer32.js +6 -6
  17. package/dest/buffer/index.d.ts +1 -0
  18. package/dest/buffer/index.d.ts.map +1 -1
  19. package/dest/buffer/index.js +1 -0
  20. package/dest/collection/array.d.ts +14 -3
  21. package/dest/collection/array.d.ts.map +1 -1
  22. package/dest/collection/array.js +45 -0
  23. package/dest/collection/object.d.ts +16 -0
  24. package/dest/collection/object.d.ts.map +1 -1
  25. package/dest/collection/object.js +25 -0
  26. package/dest/config/env_var.d.ts +1 -1
  27. package/dest/config/env_var.d.ts.map +1 -1
  28. package/dest/config/index.d.ts +48 -1
  29. package/dest/config/index.d.ts.map +1 -1
  30. package/dest/config/index.js +115 -7
  31. package/dest/config/network_config.d.ts +42 -0
  32. package/dest/config/network_config.d.ts.map +1 -0
  33. package/dest/config/network_config.js +9 -0
  34. package/dest/config/network_name.d.ts +3 -0
  35. package/dest/config/network_name.d.ts.map +1 -0
  36. package/dest/config/network_name.js +19 -0
  37. package/dest/config/secret_value.d.ts +28 -0
  38. package/dest/config/secret_value.d.ts.map +1 -0
  39. package/dest/config/secret_value.js +34 -0
  40. package/dest/crypto/aes128/index.d.ts +2 -4
  41. package/dest/crypto/aes128/index.d.ts.map +1 -1
  42. package/dest/crypto/aes128/index.js +23 -6
  43. package/dest/crypto/bn254/index.d.ts +54 -0
  44. package/dest/crypto/bn254/index.d.ts.map +1 -0
  45. package/dest/crypto/bn254/index.js +140 -0
  46. package/dest/crypto/ecdsa/index.d.ts +2 -2
  47. package/dest/crypto/ecdsa/index.d.ts.map +1 -1
  48. package/dest/crypto/ecdsa/index.js +70 -48
  49. package/dest/crypto/ecdsa/signature.d.ts +1 -3
  50. package/dest/crypto/ecdsa/signature.d.ts.map +1 -1
  51. package/dest/crypto/grumpkin/index.d.ts +6 -13
  52. package/dest/crypto/grumpkin/index.d.ts.map +1 -1
  53. package/dest/crypto/grumpkin/index.js +69 -54
  54. package/dest/crypto/index.d.ts +1 -0
  55. package/dest/crypto/index.d.ts.map +1 -1
  56. package/dest/crypto/index.js +1 -0
  57. package/dest/crypto/keccak/index.d.ts +2 -4
  58. package/dest/crypto/keccak/index.d.ts.map +1 -1
  59. package/dest/crypto/keys/index.d.ts +0 -2
  60. package/dest/crypto/keys/index.d.ts.map +1 -1
  61. package/dest/crypto/keys/index.js +9 -4
  62. package/dest/crypto/pedersen/pedersen.noble.d.ts +2 -4
  63. package/dest/crypto/pedersen/pedersen.noble.d.ts.map +1 -1
  64. package/dest/crypto/pedersen/pedersen.wasm.d.ts +2 -4
  65. package/dest/crypto/pedersen/pedersen.wasm.d.ts.map +1 -1
  66. package/dest/crypto/pedersen/pedersen.wasm.js +29 -13
  67. package/dest/crypto/poseidon/index.d.ts +0 -2
  68. package/dest/crypto/poseidon/index.d.ts.map +1 -1
  69. package/dest/crypto/poseidon/index.js +42 -17
  70. package/dest/crypto/random/index.d.ts +1 -3
  71. package/dest/crypto/random/index.d.ts.map +1 -1
  72. package/dest/crypto/random/index.js +2 -34
  73. package/dest/crypto/random/randomness_singleton.d.ts +0 -2
  74. package/dest/crypto/random/randomness_singleton.d.ts.map +1 -1
  75. package/dest/crypto/schnorr/index.d.ts.map +1 -1
  76. package/dest/crypto/schnorr/index.js +35 -37
  77. package/dest/crypto/schnorr/signature.d.ts +3 -5
  78. package/dest/crypto/schnorr/signature.d.ts.map +1 -1
  79. package/dest/crypto/secp256k1/index.d.ts +4 -6
  80. package/dest/crypto/secp256k1/index.d.ts.map +1 -1
  81. package/dest/crypto/secp256k1/index.js +29 -18
  82. package/dest/crypto/secp256k1-signer/utils.d.ts +15 -2
  83. package/dest/crypto/secp256k1-signer/utils.d.ts.map +1 -1
  84. package/dest/crypto/secp256k1-signer/utils.js +21 -3
  85. package/dest/crypto/serialize.d.ts +4 -6
  86. package/dest/crypto/serialize.d.ts.map +1 -1
  87. package/dest/crypto/sha256/index.d.ts +21 -4
  88. package/dest/crypto/sha256/index.d.ts.map +1 -1
  89. package/dest/crypto/sha256/index.js +42 -0
  90. package/dest/crypto/sha512/index.d.ts +1 -3
  91. package/dest/crypto/sha512/index.d.ts.map +1 -1
  92. package/dest/crypto/signature/index.d.ts +0 -2
  93. package/dest/crypto/signature/index.d.ts.map +1 -1
  94. package/dest/crypto/sync/index.js +3 -1
  95. package/dest/crypto/sync/pedersen/index.d.ts +2 -4
  96. package/dest/crypto/sync/pedersen/index.d.ts.map +1 -1
  97. package/dest/crypto/sync/pedersen/index.js +17 -10
  98. package/dest/crypto/sync/poseidon/index.d.ts +0 -2
  99. package/dest/crypto/sync/poseidon/index.d.ts.map +1 -1
  100. package/dest/crypto/sync/poseidon/index.js +27 -12
  101. package/dest/decorators/memoize.d.ts.map +1 -1
  102. package/dest/eth-address/index.d.ts +6 -7
  103. package/dest/eth-address/index.d.ts.map +1 -1
  104. package/dest/eth-address/index.js +5 -0
  105. package/dest/eth-signature/eth_signature.d.ts +16 -14
  106. package/dest/eth-signature/eth_signature.d.ts.map +1 -1
  107. package/dest/eth-signature/eth_signature.js +31 -17
  108. package/dest/fields/bls12_fields.d.ts +148 -0
  109. package/dest/fields/bls12_fields.d.ts.map +1 -0
  110. package/dest/fields/bls12_fields.js +359 -0
  111. package/dest/fields/bls12_point.d.ts +229 -0
  112. package/dest/fields/bls12_point.d.ts.map +1 -0
  113. package/dest/fields/bls12_point.js +398 -0
  114. package/dest/fields/coordinate.d.ts +0 -2
  115. package/dest/fields/coordinate.d.ts.map +1 -1
  116. package/dest/fields/fields.d.ts +6 -3
  117. package/dest/fields/fields.d.ts.map +1 -1
  118. package/dest/fields/fields.js +43 -15
  119. package/dest/fields/index.d.ts +2 -0
  120. package/dest/fields/index.d.ts.map +1 -1
  121. package/dest/fields/index.js +2 -0
  122. package/dest/fields/point.d.ts +2 -4
  123. package/dest/fields/point.d.ts.map +1 -1
  124. package/dest/fields/point.js +3 -3
  125. package/dest/fs/index.d.ts +1 -0
  126. package/dest/fs/index.d.ts.map +1 -1
  127. package/dest/fs/index.js +1 -0
  128. package/dest/fs/try_rm_dir.d.ts +3 -0
  129. package/dest/fs/try_rm_dir.d.ts.map +1 -0
  130. package/dest/fs/try_rm_dir.js +16 -0
  131. package/dest/index.d.ts +1 -2
  132. package/dest/index.d.ts.map +1 -1
  133. package/dest/index.js +1 -2
  134. package/dest/iterable/filter.js +1 -1
  135. package/dest/iterable/map.js +1 -1
  136. package/dest/jest/env.js +48 -0
  137. package/dest/jest/setupAfterEnv.js +3 -0
  138. package/dest/json-rpc/client/fetch.d.ts +2 -2
  139. package/dest/json-rpc/client/fetch.d.ts.map +1 -1
  140. package/dest/json-rpc/client/fetch.js +16 -30
  141. package/dest/json-rpc/client/safe_json_rpc_client.d.ts +9 -3
  142. package/dest/json-rpc/client/safe_json_rpc_client.d.ts.map +1 -1
  143. package/dest/json-rpc/client/safe_json_rpc_client.js +173 -13
  144. package/dest/json-rpc/client/undici.d.ts.map +1 -1
  145. package/dest/json-rpc/client/undici.js +6 -7
  146. package/dest/json-rpc/convert.d.ts +2 -9
  147. package/dest/json-rpc/convert.d.ts.map +1 -1
  148. package/dest/json-rpc/convert.js +1 -9
  149. package/dest/json-rpc/errors.d.ts +4 -0
  150. package/dest/json-rpc/errors.d.ts.map +1 -0
  151. package/dest/json-rpc/errors.js +6 -0
  152. package/dest/json-rpc/fixtures/class_a.d.ts +5 -3
  153. package/dest/json-rpc/fixtures/class_a.d.ts.map +1 -1
  154. package/dest/json-rpc/fixtures/class_b.d.ts +5 -3
  155. package/dest/json-rpc/fixtures/class_b.d.ts.map +1 -1
  156. package/dest/json-rpc/index.d.ts +2 -1
  157. package/dest/json-rpc/index.d.ts.map +1 -1
  158. package/dest/json-rpc/index.js +2 -1
  159. package/dest/json-rpc/js_utils.d.ts.map +1 -1
  160. package/dest/json-rpc/server/safe_json_rpc_server.d.ts +21 -22
  161. package/dest/json-rpc/server/safe_json_rpc_server.d.ts.map +1 -1
  162. package/dest/json-rpc/server/safe_json_rpc_server.js +161 -56
  163. package/dest/json-rpc/test/integration.d.ts +1 -2
  164. package/dest/json-rpc/test/integration.d.ts.map +1 -1
  165. package/dest/log/console.d.ts.map +1 -1
  166. package/dest/log/gcloud-logger-config.d.ts +0 -1
  167. package/dest/log/gcloud-logger-config.d.ts.map +1 -1
  168. package/dest/log/gcloud-logger-config.js +1 -9
  169. package/dest/log/index.d.ts +4 -4
  170. package/dest/log/index.d.ts.map +1 -1
  171. package/dest/log/index.js +4 -4
  172. package/dest/log/libp2p_logger.js +13 -2
  173. package/dest/log/log_fn.d.ts +1 -1
  174. package/dest/log/log_fn.d.ts.map +1 -1
  175. package/dest/log/noir_debug_log_util.d.ts +14 -0
  176. package/dest/log/noir_debug_log_util.d.ts.map +1 -0
  177. package/dest/log/noir_debug_log_util.js +14 -0
  178. package/dest/log/pino-logger.d.ts +2 -2
  179. package/dest/log/pino-logger.d.ts.map +1 -1
  180. package/dest/log/pino-logger.js +28 -2
  181. package/dest/message/index.d.ts.map +1 -1
  182. package/dest/mutex/mutex_database.d.ts.map +1 -1
  183. package/dest/noir/noir_package_config.d.ts +4 -4
  184. package/dest/number/index.d.ts +3 -0
  185. package/dest/number/index.d.ts.map +1 -0
  186. package/dest/number/index.js +12 -0
  187. package/dest/profiler/index.d.ts +2 -0
  188. package/dest/profiler/index.d.ts.map +1 -0
  189. package/dest/profiler/index.js +1 -0
  190. package/dest/profiler/profiler.d.ts +8 -0
  191. package/dest/profiler/profiler.d.ts.map +1 -0
  192. package/dest/profiler/profiler.js +97 -0
  193. package/dest/promise/running-promise.d.ts +1 -1
  194. package/dest/promise/running-promise.d.ts.map +1 -1
  195. package/dest/promise/running-promise.js +2 -2
  196. package/dest/queue/batch_queue.d.ts +1 -1
  197. package/dest/queue/batch_queue.js +1 -1
  198. package/dest/queue/bounded_serial_queue.d.ts.map +1 -1
  199. package/dest/queue/serial_queue.d.ts +2 -2
  200. package/dest/queue/serial_queue.d.ts.map +1 -1
  201. package/dest/queue/serial_queue.js +7 -5
  202. package/dest/retry/index.d.ts +3 -2
  203. package/dest/retry/index.d.ts.map +1 -1
  204. package/dest/retry/index.js +2 -2
  205. package/dest/schemas/api.d.ts.map +1 -1
  206. package/dest/schemas/parse.js +1 -1
  207. package/dest/schemas/schemas.d.ts +9 -6
  208. package/dest/schemas/schemas.d.ts.map +1 -1
  209. package/dest/schemas/schemas.js +15 -1
  210. package/dest/schemas/utils.d.ts +1 -3
  211. package/dest/schemas/utils.d.ts.map +1 -1
  212. package/dest/serialize/buffer_reader.d.ts +27 -2
  213. package/dest/serialize/buffer_reader.d.ts.map +1 -1
  214. package/dest/serialize/buffer_reader.js +44 -2
  215. package/dest/serialize/field_reader.d.ts +10 -1
  216. package/dest/serialize/field_reader.d.ts.map +1 -1
  217. package/dest/serialize/field_reader.js +18 -1
  218. package/dest/serialize/free_funcs.d.ts +23 -21
  219. package/dest/serialize/free_funcs.d.ts.map +1 -1
  220. package/dest/serialize/free_funcs.js +21 -27
  221. package/dest/serialize/serialize.d.ts +4 -5
  222. package/dest/serialize/serialize.d.ts.map +1 -1
  223. package/dest/string/index.d.ts +3 -2
  224. package/dest/string/index.d.ts.map +1 -1
  225. package/dest/string/index.js +26 -0
  226. package/dest/testing/files/index.d.ts +0 -2
  227. package/dest/testing/files/index.d.ts.map +1 -1
  228. package/dest/testing/files/index.js +2 -2
  229. package/dest/testing/formatting.d.ts +4 -0
  230. package/dest/testing/formatting.d.ts.map +1 -0
  231. package/dest/testing/formatting.js +3 -0
  232. package/dest/testing/index.d.ts +1 -0
  233. package/dest/testing/index.d.ts.map +1 -1
  234. package/dest/testing/index.js +1 -0
  235. package/dest/timer/date.d.ts +2 -1
  236. package/dest/timer/date.d.ts.map +1 -1
  237. package/dest/timer/date.js +5 -3
  238. package/dest/timer/index.d.ts +1 -1
  239. package/dest/timer/index.d.ts.map +1 -1
  240. package/dest/timer/index.js +1 -1
  241. package/dest/timer/timeout.d.ts +18 -5
  242. package/dest/timer/timeout.d.ts.map +1 -1
  243. package/dest/timer/timeout.js +43 -22
  244. package/dest/transport/dispatch/create_dispatch_fn.d.ts.map +1 -1
  245. package/dest/transport/index.d.ts +0 -1
  246. package/dest/transport/index.d.ts.map +1 -1
  247. package/dest/transport/index.js +0 -1
  248. package/dest/transport/interface/connector.d.ts.map +1 -1
  249. package/dest/transport/interface/listener.d.ts +0 -1
  250. package/dest/transport/interface/listener.d.ts.map +1 -1
  251. package/dest/transport/interface/socket.d.ts.map +1 -1
  252. package/dest/transport/node/node_connector.d.ts +0 -1
  253. package/dest/transport/node/node_connector.d.ts.map +1 -1
  254. package/dest/transport/node/node_connector_socket.d.ts +0 -1
  255. package/dest/transport/node/node_connector_socket.d.ts.map +1 -1
  256. package/dest/transport/node/node_listener.d.ts +0 -1
  257. package/dest/transport/node/node_listener.d.ts.map +1 -1
  258. package/dest/transport/node/node_listener_socket.d.ts +0 -1
  259. package/dest/transport/node/node_listener_socket.d.ts.map +1 -1
  260. package/dest/transport/transport_client.d.ts +0 -1
  261. package/dest/transport/transport_client.d.ts.map +1 -1
  262. package/dest/transport/transport_server.d.ts.map +1 -1
  263. package/dest/trees/hasher.d.ts +4 -6
  264. package/dest/trees/hasher.d.ts.map +1 -1
  265. package/dest/trees/index.d.ts +1 -0
  266. package/dest/trees/index.d.ts.map +1 -1
  267. package/dest/trees/index.js +1 -0
  268. package/dest/trees/indexed_merkle_tree.d.ts +0 -2
  269. package/dest/trees/indexed_merkle_tree.d.ts.map +1 -1
  270. package/dest/trees/indexed_merkle_tree_calculator.d.ts +1 -3
  271. package/dest/trees/indexed_merkle_tree_calculator.d.ts.map +1 -1
  272. package/dest/trees/indexed_tree_leaf.d.ts +0 -2
  273. package/dest/trees/indexed_tree_leaf.d.ts.map +1 -1
  274. package/dest/trees/membership_witness.d.ts +19 -3
  275. package/dest/trees/membership_witness.d.ts.map +1 -1
  276. package/dest/trees/membership_witness.js +13 -0
  277. package/dest/trees/merkle_tree.d.ts +0 -2
  278. package/dest/trees/merkle_tree.d.ts.map +1 -1
  279. package/dest/trees/merkle_tree_calculator.d.ts +11 -3
  280. package/dest/trees/merkle_tree_calculator.d.ts.map +1 -1
  281. package/dest/trees/merkle_tree_calculator.js +31 -1
  282. package/dest/trees/sibling_path.d.ts +6 -8
  283. package/dest/trees/sibling_path.d.ts.map +1 -1
  284. package/dest/trees/unbalanced_merkle_tree.d.ts +19 -8
  285. package/dest/trees/unbalanced_merkle_tree.d.ts.map +1 -1
  286. package/dest/trees/unbalanced_merkle_tree.js +49 -50
  287. package/dest/trees/unbalanced_merkle_tree_calculator.d.ts +48 -0
  288. package/dest/trees/unbalanced_merkle_tree_calculator.d.ts.map +1 -0
  289. package/dest/trees/unbalanced_merkle_tree_calculator.js +162 -0
  290. package/dest/trees/unbalanced_tree_store.d.ts +1 -0
  291. package/dest/trees/unbalanced_tree_store.d.ts.map +1 -1
  292. package/dest/trees/unbalanced_tree_store.js +6 -0
  293. package/dest/types/index.d.ts +25 -2
  294. package/dest/types/index.d.ts.map +1 -1
  295. package/dest/url/index.d.ts.map +1 -1
  296. package/dest/url/index.js +1 -1
  297. package/package.json +32 -41
  298. package/src/array/array.ts +13 -0
  299. package/src/async-pool/index.ts +1 -0
  300. package/src/bigint/index.ts +20 -0
  301. package/src/buffer/buffer16.ts +133 -0
  302. package/src/buffer/buffer32.ts +8 -6
  303. package/src/buffer/index.ts +1 -0
  304. package/src/collection/array.ts +51 -1
  305. package/src/collection/object.ts +37 -0
  306. package/src/config/env_var.ts +142 -52
  307. package/src/config/index.ts +191 -8
  308. package/src/config/network_config.ts +16 -0
  309. package/src/config/network_name.ts +28 -0
  310. package/src/config/secret_value.ts +49 -0
  311. package/src/crypto/aes128/index.ts +19 -10
  312. package/src/crypto/bn254/index.ts +167 -0
  313. package/src/crypto/ecdsa/index.ts +41 -23
  314. package/src/crypto/grumpkin/index.ts +35 -45
  315. package/src/crypto/index.ts +1 -0
  316. package/src/crypto/keys/index.ts +5 -5
  317. package/src/crypto/pedersen/pedersen.wasm.ts +22 -18
  318. package/src/crypto/poseidon/index.ts +32 -24
  319. package/src/crypto/random/index.ts +2 -40
  320. package/src/crypto/schnorr/index.ts +20 -17
  321. package/src/crypto/secp256k1/index.ts +15 -11
  322. package/src/crypto/secp256k1-signer/utils.ts +25 -4
  323. package/src/crypto/sha256/index.ts +47 -0
  324. package/src/crypto/sync/index.ts +1 -1
  325. package/src/crypto/sync/pedersen/index.ts +16 -15
  326. package/src/crypto/sync/poseidon/index.ts +27 -22
  327. package/src/eth-address/index.ts +9 -2
  328. package/src/eth-signature/eth_signature.ts +44 -22
  329. package/src/fields/bls12_fields.ts +463 -0
  330. package/src/fields/bls12_point.ts +450 -0
  331. package/src/fields/fields.ts +37 -9
  332. package/src/fields/index.ts +2 -0
  333. package/src/fields/point.ts +1 -3
  334. package/src/fs/index.ts +1 -0
  335. package/src/fs/try_rm_dir.ts +15 -0
  336. package/src/index.ts +1 -2
  337. package/src/iterable/filter.ts +1 -1
  338. package/src/iterable/map.ts +1 -1
  339. package/src/jest/env.mjs +52 -0
  340. package/src/jest/setupAfterEnv.mjs +3 -0
  341. package/src/json-rpc/client/fetch.ts +14 -33
  342. package/src/json-rpc/client/safe_json_rpc_client.ts +226 -13
  343. package/src/json-rpc/client/undici.ts +8 -15
  344. package/src/json-rpc/convert.ts +3 -12
  345. package/src/json-rpc/errors.ts +6 -0
  346. package/src/json-rpc/fixtures/class_a.ts +4 -1
  347. package/src/json-rpc/fixtures/class_b.ts +4 -1
  348. package/src/json-rpc/index.ts +2 -1
  349. package/src/json-rpc/server/safe_json_rpc_server.ts +141 -48
  350. package/src/json-rpc/test/integration.ts +1 -1
  351. package/src/log/console.ts +4 -1
  352. package/src/log/gcloud-logger-config.ts +3 -7
  353. package/src/log/index.ts +4 -4
  354. package/src/log/libp2p_logger.ts +21 -2
  355. package/src/log/log_fn.ts +1 -1
  356. package/src/log/noir_debug_log_util.ts +21 -0
  357. package/src/log/pino-logger.ts +33 -2
  358. package/src/message/index.ts +5 -1
  359. package/src/mutex/mutex_database.ts +2 -3
  360. package/src/number/index.ts +14 -0
  361. package/src/profiler/index.ts +1 -0
  362. package/src/profiler/profiler.ts +125 -0
  363. package/src/promise/running-promise.ts +2 -2
  364. package/src/queue/batch_queue.ts +1 -1
  365. package/src/queue/bounded_serial_queue.ts +4 -1
  366. package/src/queue/serial_queue.ts +5 -5
  367. package/src/retry/index.ts +10 -5
  368. package/src/schemas/api.ts +4 -4
  369. package/src/schemas/parse.ts +1 -1
  370. package/src/schemas/schemas.ts +19 -1
  371. package/src/serialize/buffer_reader.ts +60 -3
  372. package/src/serialize/field_reader.ts +27 -3
  373. package/src/serialize/free_funcs.ts +25 -31
  374. package/src/serialize/serialize.ts +2 -0
  375. package/src/string/index.ts +33 -1
  376. package/src/testing/files/index.ts +6 -2
  377. package/src/testing/formatting.ts +3 -0
  378. package/src/testing/index.ts +1 -0
  379. package/src/timer/date.ts +9 -3
  380. package/src/timer/index.ts +1 -1
  381. package/src/timer/timeout.ts +54 -19
  382. package/src/transport/index.ts +0 -1
  383. package/src/transport/interface/connector.ts +0 -1
  384. package/src/transport/interface/listener.ts +2 -3
  385. package/src/transport/interface/socket.ts +2 -3
  386. package/src/transport/transport_client.ts +3 -4
  387. package/src/transport/transport_server.ts +4 -1
  388. package/src/trees/hasher.ts +4 -4
  389. package/src/trees/index.ts +1 -0
  390. package/src/trees/indexed_merkle_tree.ts +5 -1
  391. package/src/trees/indexed_merkle_tree_calculator.ts +2 -2
  392. package/src/trees/membership_witness.ts +13 -0
  393. package/src/trees/merkle_tree.ts +4 -1
  394. package/src/trees/merkle_tree_calculator.ts +43 -5
  395. package/src/trees/unbalanced_merkle_tree.ts +50 -42
  396. package/src/trees/unbalanced_merkle_tree_calculator.ts +194 -0
  397. package/src/trees/unbalanced_tree_store.ts +5 -1
  398. package/src/types/index.ts +25 -4
  399. package/src/url/index.ts +0 -1
  400. package/dest/crypto/pedersen/pedersen.elliptic.d.ts +0 -13
  401. package/dest/crypto/pedersen/pedersen.elliptic.d.ts.map +0 -1
  402. package/dest/crypto/pedersen/pedersen.elliptic.js +0 -582
  403. package/dest/log/debug.d.ts +0 -56
  404. package/dest/log/debug.d.ts.map +0 -1
  405. package/dest/log/debug.js +0 -75
  406. package/dest/log/log_history.d.ts +0 -31
  407. package/dest/log/log_history.d.ts.map +0 -1
  408. package/dest/log/log_history.js +0 -38
  409. package/dest/transport/browser/index.d.ts +0 -5
  410. package/dest/transport/browser/index.d.ts.map +0 -1
  411. package/dest/transport/browser/index.js +0 -4
  412. package/dest/transport/browser/message_port_socket.d.ts +0 -37
  413. package/dest/transport/browser/message_port_socket.d.ts.map +0 -1
  414. package/dest/transport/browser/message_port_socket.js +0 -42
  415. package/dest/transport/browser/shared_worker_connector.d.ts +0 -19
  416. package/dest/transport/browser/shared_worker_connector.d.ts.map +0 -1
  417. package/dest/transport/browser/shared_worker_connector.js +0 -19
  418. package/dest/transport/browser/shared_worker_listener.d.ts +0 -38
  419. package/dest/transport/browser/shared_worker_listener.d.ts.map +0 -1
  420. package/dest/transport/browser/shared_worker_listener.js +0 -33
  421. package/dest/transport/browser/worker_connector.d.ts +0 -26
  422. package/dest/transport/browser/worker_connector.d.ts.map +0 -1
  423. package/dest/transport/browser/worker_connector.js +0 -30
  424. package/dest/transport/browser/worker_listener.d.ts +0 -39
  425. package/dest/transport/browser/worker_listener.d.ts.map +0 -1
  426. package/dest/transport/browser/worker_listener.js +0 -35
  427. package/dest/wasm/empty_wasi_sdk.d.ts +0 -130
  428. package/dest/wasm/empty_wasi_sdk.d.ts.map +0 -1
  429. package/dest/wasm/empty_wasi_sdk.js +0 -148
  430. package/dest/wasm/index.d.ts +0 -2
  431. package/dest/wasm/index.d.ts.map +0 -1
  432. package/dest/wasm/index.js +0 -1
  433. package/dest/wasm/wasm_module.d.ts +0 -136
  434. package/dest/wasm/wasm_module.d.ts.map +0 -1
  435. package/dest/wasm/wasm_module.js +0 -196
  436. package/dest/worker/browser/index.d.ts +0 -3
  437. package/dest/worker/browser/index.d.ts.map +0 -1
  438. package/dest/worker/browser/index.js +0 -2
  439. package/dest/worker/browser/start_web_module.d.ts +0 -7
  440. package/dest/worker/browser/start_web_module.d.ts.map +0 -1
  441. package/dest/worker/browser/start_web_module.js +0 -27
  442. package/dest/worker/browser/web_data_store.d.ts +0 -24
  443. package/dest/worker/browser/web_data_store.d.ts.map +0 -1
  444. package/dest/worker/browser/web_data_store.js +0 -29
  445. package/dest/worker/browser/web_worker.d.ts +0 -10
  446. package/dest/worker/browser/web_worker.d.ts.map +0 -1
  447. package/dest/worker/browser/web_worker.js +0 -25
  448. package/dest/worker/data_store.d.ts +0 -21
  449. package/dest/worker/data_store.d.ts.map +0 -1
  450. package/dest/worker/data_store.js +0 -3
  451. package/dest/worker/index.d.ts +0 -3
  452. package/dest/worker/index.d.ts.map +0 -1
  453. package/dest/worker/index.js +0 -1
  454. package/dest/worker/node/index.d.ts +0 -3
  455. package/dest/worker/node/index.d.ts.map +0 -1
  456. package/dest/worker/node/index.js +0 -2
  457. package/dest/worker/node/node_data_store.d.ts +0 -13
  458. package/dest/worker/node/node_data_store.d.ts.map +0 -1
  459. package/dest/worker/node/node_data_store.js +0 -20
  460. package/dest/worker/node/node_worker.d.ts +0 -6
  461. package/dest/worker/node/node_worker.d.ts.map +0 -1
  462. package/dest/worker/node/node_worker.js +0 -22
  463. package/dest/worker/node/start_node_module.d.ts +0 -7
  464. package/dest/worker/node/start_node_module.d.ts.map +0 -1
  465. package/dest/worker/node/start_node_module.js +0 -31
  466. package/dest/worker/wasm_worker.d.ts +0 -9
  467. package/dest/worker/wasm_worker.d.ts.map +0 -1
  468. package/dest/worker/wasm_worker.js +0 -3
  469. package/dest/worker/worker_pool.d.ts +0 -40
  470. package/dest/worker/worker_pool.d.ts.map +0 -1
  471. package/dest/worker/worker_pool.js +0 -51
  472. package/src/crypto/pedersen/pedersen.elliptic.ts +0 -584
  473. package/src/log/debug.ts +0 -104
  474. package/src/log/log_history.ts +0 -44
  475. package/src/transport/browser/index.ts +0 -4
  476. package/src/transport/browser/message_port_socket.ts +0 -48
  477. package/src/transport/browser/shared_worker_connector.ts +0 -21
  478. package/src/transport/browser/shared_worker_listener.ts +0 -53
  479. package/src/transport/browser/worker_connector.ts +0 -30
  480. package/src/transport/browser/worker_listener.ts +0 -54
  481. package/src/wasm/README.md +0 -6
  482. package/src/wasm/empty_wasi_sdk.ts +0 -166
  483. package/src/wasm/fixtures/gcd.wasm +0 -0
  484. package/src/wasm/fixtures/gcd.wat +0 -27
  485. package/src/wasm/index.ts +0 -1
  486. package/src/wasm/wasm_module.ts +0 -260
  487. package/src/worker/browser/index.ts +0 -2
  488. package/src/worker/browser/start_web_module.ts +0 -24
  489. package/src/worker/browser/web_data_store.ts +0 -38
  490. package/src/worker/browser/web_worker.ts +0 -25
  491. package/src/worker/data_store.ts +0 -19
  492. package/src/worker/index.ts +0 -2
  493. package/src/worker/node/index.ts +0 -2
  494. package/src/worker/node/node_data_store.ts +0 -27
  495. package/src/worker/node/node_worker.ts +0 -23
  496. package/src/worker/node/start_node_module.ts +0 -30
  497. package/src/worker/wasm_worker.ts +0 -7
  498. package/src/worker/worker_pool.ts +0 -73
@@ -0,0 +1,48 @@
1
+ import type { Hasher } from './hasher.js';
2
+ import { SiblingPath } from './sibling_path.js';
3
+ import { type TreeNodeLocation } from './unbalanced_tree_store.js';
4
+ export declare function computeCompressedUnbalancedMerkleTreeRoot(leaves: Buffer[], valueToCompress?: Buffer<ArrayBuffer>, hasher?: Hasher['hash']): Buffer;
5
+ /**
6
+ * An ephemeral unbalanced Merkle tree implementation.
7
+ * Follows the rollup implementation which greedily hashes pairs of nodes up the tree.
8
+ * Remaining rightmost nodes are shifted up until they can be paired.
9
+ * The values that match the `valueToCompress` are skipped and the sibling of the compressed leaf are shifted up until
10
+ * they can be paired.
11
+ * If there is only one leaf, the root is the leaf.
12
+ */
13
+ export declare class UnbalancedMerkleTreeCalculator {
14
+ private readonly leaves;
15
+ private readonly valueToCompress;
16
+ private readonly hasher;
17
+ private store;
18
+ private leafLocations;
19
+ constructor(leaves: Buffer[], valueToCompress: Buffer, hasher: Hasher['hash']);
20
+ static create(leaves: Buffer[], valueToCompress?: Buffer<ArrayBuffer>, hasher?: (left: Buffer, right: Buffer) => Buffer<ArrayBuffer>): UnbalancedMerkleTreeCalculator;
21
+ /**
22
+ * Returns the root of the tree.
23
+ * @returns The root of the tree.
24
+ */
25
+ getRoot(): Buffer;
26
+ /**
27
+ * Returns a sibling path for the element.
28
+ * @param value - The value of the element.
29
+ * @returns A sibling path for the element.
30
+ * Note: The sibling path is an array of sibling hashes, with the lowest hash (leaf hash) first, and the highest hash last.
31
+ */
32
+ getSiblingPath<N extends number>(value: Buffer): SiblingPath<N>;
33
+ /**
34
+ * Returns a sibling path for the leaf at the given index.
35
+ * @param leafIndex - The index of the leaf.
36
+ * @returns A sibling path for the leaf.
37
+ */
38
+ getSiblingPathByLeafIndex<N extends number>(leafIndex: number): SiblingPath<N>;
39
+ getLeafLocation(leafIndex: number): TreeNodeLocation;
40
+ /**
41
+ * Adds leaves and nodes to the store. Updates the leafLocations.
42
+ * @param leaves - The leaves of the tree.
43
+ */
44
+ private buildTree;
45
+ private shiftNodeUp;
46
+ private shiftChildrenUp;
47
+ }
48
+ //# sourceMappingURL=unbalanced_merkle_tree_calculator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unbalanced_merkle_tree_calculator.d.ts","sourceRoot":"","sources":["../../src/trees/unbalanced_merkle_tree_calculator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,KAAK,gBAAgB,EAAuB,MAAM,4BAA4B,CAAC;AAExF,wBAAgB,yCAAyC,CACvD,MAAM,EAAE,MAAM,EAAE,EAChB,eAAe,sBAAmB,EAClC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,GACtB,MAAM,CAGR;AAOD;;;;;;;GAOG;AACH,qBAAa,8BAA8B;IAKvC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM;IANzB,OAAO,CAAC,KAAK,CAAgC;IAC7C,OAAO,CAAC,aAAa,CAA0B;gBAG5B,MAAM,EAAE,MAAM,EAAE,EAChB,eAAe,EAAE,MAAM,EACvB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;IAUzC,MAAM,CAAC,MAAM,CACX,MAAM,EAAE,MAAM,EAAE,EAChB,eAAe,sBAAkB,EACjC,MAAM,IAAI,MAAM,MAAM,EAAE,OAAO,MAAM,KAAkD,MAAM,CAAC,WAAW,CAAC;IAK5G;;;OAGG;IACI,OAAO,IAAI,MAAM;IAIxB;;;;;OAKG;IACI,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC;IAStE;;;;OAIG;IACI,yBAAyB,CAAC,CAAC,SAAS,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC;IAqB9E,eAAe,CAAC,SAAS,EAAE,MAAM;IAIxC;;;OAGG;IACH,OAAO,CAAC,SAAS;IAkDjB,OAAO,CAAC,WAAW;IAcnB,OAAO,CAAC,eAAe;CAoBxB"}
@@ -0,0 +1,162 @@
1
+ import { sha256Trunc } from '../crypto/index.js';
2
+ import { SiblingPath } from './sibling_path.js';
3
+ import { UnbalancedTreeStore } from './unbalanced_tree_store.js';
4
+ export function computeCompressedUnbalancedMerkleTreeRoot(leaves, valueToCompress = Buffer.alloc(32), hasher) {
5
+ const calculator = UnbalancedMerkleTreeCalculator.create(leaves, valueToCompress, hasher);
6
+ return calculator.getRoot();
7
+ }
8
+ /**
9
+ * An ephemeral unbalanced Merkle tree implementation.
10
+ * Follows the rollup implementation which greedily hashes pairs of nodes up the tree.
11
+ * Remaining rightmost nodes are shifted up until they can be paired.
12
+ * The values that match the `valueToCompress` are skipped and the sibling of the compressed leaf are shifted up until
13
+ * they can be paired.
14
+ * If there is only one leaf, the root is the leaf.
15
+ */ export class UnbalancedMerkleTreeCalculator {
16
+ leaves;
17
+ valueToCompress;
18
+ hasher;
19
+ store;
20
+ leafLocations;
21
+ constructor(leaves, valueToCompress, hasher){
22
+ this.leaves = leaves;
23
+ this.valueToCompress = valueToCompress;
24
+ this.hasher = hasher;
25
+ this.leafLocations = [];
26
+ if (leaves.length === 0) {
27
+ throw Error('Cannot create a compressed unbalanced tree with 0 leaves.');
28
+ }
29
+ this.store = new UnbalancedTreeStore(leaves.length);
30
+ this.buildTree();
31
+ }
32
+ static create(leaves, valueToCompress = Buffer.alloc(0), hasher = (left, right)=>sha256Trunc(Buffer.concat([
33
+ left,
34
+ right
35
+ ]))) {
36
+ return new UnbalancedMerkleTreeCalculator(leaves, valueToCompress, hasher);
37
+ }
38
+ /**
39
+ * Returns the root of the tree.
40
+ * @returns The root of the tree.
41
+ */ getRoot() {
42
+ return this.store.getRoot().value;
43
+ }
44
+ /**
45
+ * Returns a sibling path for the element.
46
+ * @param value - The value of the element.
47
+ * @returns A sibling path for the element.
48
+ * Note: The sibling path is an array of sibling hashes, with the lowest hash (leaf hash) first, and the highest hash last.
49
+ */ getSiblingPath(value) {
50
+ const leafIndex = this.leaves.findIndex((leaf)=>leaf.equals(value));
51
+ if (leafIndex === -1) {
52
+ throw Error(`Leaf value ${value.toString('hex')} not found in tree.`);
53
+ }
54
+ return this.getSiblingPathByLeafIndex(leafIndex);
55
+ }
56
+ /**
57
+ * Returns a sibling path for the leaf at the given index.
58
+ * @param leafIndex - The index of the leaf.
59
+ * @returns A sibling path for the leaf.
60
+ */ getSiblingPathByLeafIndex(leafIndex) {
61
+ if (leafIndex >= this.leaves.length) {
62
+ throw Error(`Leaf index ${leafIndex} out of bounds. Tree has ${this.leaves.length} leaves.`);
63
+ }
64
+ const leaf = this.leaves[leafIndex];
65
+ if (leaf.equals(this.valueToCompress)) {
66
+ throw Error(`Leaf at index ${leafIndex} has been compressed.`);
67
+ }
68
+ const path = [];
69
+ let location = this.leafLocations[leafIndex];
70
+ while(location.level > 0){
71
+ const sibling = this.store.getSibling(location);
72
+ path.push(sibling.value);
73
+ location = this.store.getParentLocation(location);
74
+ }
75
+ return new SiblingPath(path.length, path);
76
+ }
77
+ getLeafLocation(leafIndex) {
78
+ return this.leafLocations[leafIndex];
79
+ }
80
+ /**
81
+ * Adds leaves and nodes to the store. Updates the leafLocations.
82
+ * @param leaves - The leaves of the tree.
83
+ */ buildTree() {
84
+ this.leafLocations = this.leaves.map((value, i)=>this.store.setLeaf(i, {
85
+ value,
86
+ leafIndex: i
87
+ }));
88
+ // Start with the leaves that are not compressed.
89
+ let toProcess = this.leafLocations.filter((_, i)=>!this.leaves[i].equals(this.valueToCompress));
90
+ if (!toProcess.length) {
91
+ // All leaves are compressed. Set 0 to the root.
92
+ this.store.setNode({
93
+ level: 0,
94
+ index: 0
95
+ }, {
96
+ value: Buffer.alloc(32)
97
+ });
98
+ return;
99
+ }
100
+ const level = toProcess[0].level;
101
+ for(let i = level; i > 0; i--){
102
+ const toProcessNext = [];
103
+ for (const location of toProcess){
104
+ if (location.level !== i) {
105
+ toProcessNext.push(location);
106
+ continue;
107
+ }
108
+ const parentLocation = this.store.getParentLocation(location);
109
+ if (this.store.getNode(parentLocation)) {
110
+ continue;
111
+ }
112
+ const sibling = this.store.getSibling(location);
113
+ // If sibling is undefined, all its children are compressed.
114
+ const shouldShiftUp = !sibling || sibling.value.equals(this.valueToCompress);
115
+ if (shouldShiftUp) {
116
+ // The node becomes the parent if the sibling is a compressed leaf.
117
+ const isLeaf = this.shiftNodeUp(location, parentLocation);
118
+ if (!isLeaf) {
119
+ this.shiftChildrenUp(location);
120
+ }
121
+ } else {
122
+ // Hash the value with the (right) sibling and update the parent node.
123
+ const node = this.store.getNode(location);
124
+ const parentValue = this.hasher(node.value, sibling.value);
125
+ this.store.setNode(parentLocation, {
126
+ value: parentValue
127
+ });
128
+ }
129
+ // Add the parent location to be processed next.
130
+ toProcessNext.push(parentLocation);
131
+ }
132
+ toProcess = toProcessNext;
133
+ }
134
+ }
135
+ shiftNodeUp(fromLocation, toLocation) {
136
+ const node = this.store.getNode(fromLocation);
137
+ this.store.setNode(toLocation, node);
138
+ const isLeaf = node.leafIndex !== undefined;
139
+ if (isLeaf) {
140
+ // Update the location if the node is a leaf.
141
+ this.leafLocations[node.leafIndex] = toLocation;
142
+ }
143
+ return isLeaf;
144
+ }
145
+ shiftChildrenUp(parent) {
146
+ const [left, right] = this.store.getChildLocations(parent);
147
+ const level = parent.level;
148
+ const groupSize = 2 ** level;
149
+ const computeNewLocation = (index)=>({
150
+ level,
151
+ index: Math.floor(index / (groupSize * 2)) * groupSize + index % groupSize
152
+ });
153
+ const isLeftLeaf = this.shiftNodeUp(left, computeNewLocation(left.index));
154
+ const isRightLeaf = this.shiftNodeUp(right, computeNewLocation(right.index));
155
+ if (!isLeftLeaf) {
156
+ this.shiftChildrenUp(left);
157
+ }
158
+ if (!isRightLeaf) {
159
+ this.shiftChildrenUp(right);
160
+ }
161
+ }
162
+ }
@@ -12,6 +12,7 @@ export declare class UnbalancedTreeStore<T> {
12
12
  getChildLocations({ level, index }: TreeNodeLocation): [TreeNodeLocation, TreeNodeLocation];
13
13
  getLeaf(leafIndex: number): T | undefined;
14
14
  getNode(location: TreeNodeLocation): T | undefined;
15
+ getRoot(): T | undefined;
15
16
  getParent(location: TreeNodeLocation): T | undefined;
16
17
  getSibling(location: TreeNodeLocation): T | undefined;
17
18
  getChildren(location: TreeNodeLocation): [T | undefined, T | undefined];
@@ -1 +1 @@
1
- {"version":3,"file":"unbalanced_tree_store.d.ts","sourceRoot":"","sources":["../../src/trees/unbalanced_tree_store.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAOD,qBAAa,mBAAmB,CAAC,CAAC;;gBAIpB,SAAS,EAAE,MAAM;IAI7B,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,gBAAgB;IAiBtD,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC;IAWpD,iBAAiB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,gBAAgB,GAAG,gBAAgB;IAQvE,kBAAkB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,gBAAgB,GAAG,gBAAgB;IAQxE,iBAAiB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,gBAAgB,GAAG,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAM3F,OAAO,CAAC,SAAS,EAAE,MAAM;IASzB,OAAO,CAAC,QAAQ,EAAE,gBAAgB,GAAG,CAAC,GAAG,SAAS;IAIlD,SAAS,CAAC,QAAQ,EAAE,gBAAgB,GAAG,CAAC,GAAG,SAAS;IAKpD,UAAU,CAAC,QAAQ,EAAE,gBAAgB,GAAG,CAA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ancedTreeStore {
73
73
  getNode(location) {
74
74
  return this.#nodeMapping.get(this.#getKey(location))?.value;
75
75
  }
76
+ getRoot() {
77
+ return this.getNode({
78
+ level: 0,
79
+ index: 0
80
+ });
81
+ }
76
82
  getParent(location) {
77
83
  const parentLocation = this.getParentLocation(location);
78
84
  return this.getNode(parentLocation);
@@ -14,6 +14,29 @@ export type Writeable<T> = {
14
14
  };
15
15
  /** Removes readonly modifiers for an object. */
16
16
  export declare function unfreeze<T>(obj: T): Writeable<T>;
17
- /** Maybe exists, maybe not. */
18
- export type Maybe<T extends object> = T | unknown;
17
+ /** Resolves a record-like type. Lifted from viem. */
18
+ export type Prettify<T> = {
19
+ [K in keyof T]: T[K];
20
+ } & {};
21
+ /**
22
+ * Type-safe Event Emitter type
23
+ * @example
24
+ * export type ArchiverEmitter = TypedEventEmitter<{
25
+ * [L2BlockSourceEvents.L2PruneDetected]: (args: L2BlockSourceEvent) => void;
26
+ * [L2BlockSourceEvents.L2BlockProven]: (args: L2BlockSourceEvent) => void;
27
+ * }>;
28
+ * class Archiver extends (EventEmitter as new () => ArchiverEmitter) {
29
+ * // ...
30
+ * }
31
+ */
32
+ export interface TypedEventEmitter<TEventMap extends {
33
+ [key in keyof TEventMap]: (...args: any[]) => void;
34
+ }> {
35
+ once<K extends keyof TEventMap>(event: K, listener: TEventMap[K]): this;
36
+ on<K extends keyof TEventMap>(event: K, listener: TEventMap[K]): this;
37
+ off<K extends keyof TEventMap>(event: K, listener: TEventMap[K]): this;
38
+ emit<K extends keyof TEventMap>(event: K, ...args: Parameters<TEventMap[K]>): boolean;
39
+ removeListener<K extends keyof TEventMap>(event: K, listener: TEventMap[K]): this;
40
+ removeAllListeners<K extends keyof TEventMap>(event: K): this;
41
+ }
19
42
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,MAAM,MAAM,QAAQ,C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,GAAG,IAAI,CAAC;IACvE,IAAI,CAAC,CAAC,SAAS,MAAM,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;IACtF,cAAc,CAAC,CAAC,SAAS,MAAM,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAClF,kBAAkB,CAAC,CAAC,SAAS,MAAM,SAAS,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;CAE/D"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/url/index.ts"],"names":[],"mappings":"AAoBA;;;;;;GAMG;AAEH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CA4CjD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/url/index.ts"],"names":[],"mappings":"AAmBA;;;;;;GAMG;AAEH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CA4CjD"}
package/dest/url/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /* eslint-disable */ // Copyright (c) 2014 Nathan Rajlich <nathan@tootallnate.net>
1
+ // Copyright (c) 2014 Nathan Rajlich <nathan@tootallnate.net>
2
2
  // Permission is hereby granted, free of charge, to any person obtaining
3
3
  // a copy of this software and associated documentation files (the
4
4
  // 'Software'), to deal in the Software without restriction, including
package/package.json CHANGED
@@ -1,16 +1,17 @@
1
1
  {
2
2
  "name": "@aztec/foundation",
3
- "version": "0.0.0-test.0",
3
+ "version": "0.0.1-fake-c83136db25",
4
4
  "type": "module",
5
5
  "main": "./dest/index.js",
6
6
  "types": "./dest/index.d.ts",
7
7
  "exports": {
8
- "./eslint": "./.eslintrc.cjs",
9
- "./eslint.docs": "./.eslintrc.docs.cjs",
8
+ "./eslint": "./eslint.config.js",
9
+ "./eslint.docs": "./eslint.config.docs.js",
10
10
  "./prettier": "./.prettierrc.json",
11
11
  "./abi": "./dest/abi/index.js",
12
12
  "./async-map": "./dest/async-map/index.js",
13
13
  "./async-pool": "./dest/async-pool/index.js",
14
+ "./bigint": "./dest/bigint/index.js",
14
15
  "./collection": "./dest/collection/index.js",
15
16
  "./config": "./dest/config/index.js",
16
17
  "./crypto": "./dest/crypto/index.js",
@@ -38,8 +39,6 @@
38
39
  "./timer": "./dest/timer/index.js",
39
40
  "./transport": "./dest/transport/index.js",
40
41
  "./trees": "./dest/trees/index.js",
41
- "./wasm": "./dest/wasm/index.js",
42
- "./worker": "./dest/worker/index.js",
43
42
  "./bigint-buffer": "./dest/bigint-buffer/index.js",
44
43
  "./types": "./dest/types/index.js",
45
44
  "./schemas": "./dest/schemas/index.js",
@@ -48,19 +47,19 @@
48
47
  "./noir": "./dest/noir/index.js",
49
48
  "./testing": "./dest/testing/index.js",
50
49
  "./testing/files": "./dest/testing/files/index.js",
50
+ "./profiler": "./dest/profiler/index.js",
51
51
  "./array": "./dest/array/index.js",
52
52
  "./validation": "./dest/validation/index.js",
53
53
  "./promise": "./dest/promise/index.js",
54
54
  "./string": "./dest/string/index.js",
55
- "./message": "./dest/message/index.js"
55
+ "./message": "./dest/message/index.js",
56
+ "./number": "./dest/number/index.js"
56
57
  },
57
58
  "scripts": {
58
59
  "build": "yarn clean && tsc -b",
59
60
  "build:dev": "tsc -b --watch",
60
61
  "clean": "rm -rf ./dest .tsbuildinfo",
61
62
  "generate": "true",
62
- "formatting": "run -T prettier --check ./src && run -T eslint ./src",
63
- "formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
64
63
  "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
65
64
  },
66
65
  "inherits": [
@@ -96,74 +95,66 @@
96
95
  ],
97
96
  "testTimeout": 120000,
98
97
  "setupFilesAfterEnv": [
99
- "../../foundation/src/jest/setup.mjs"
98
+ "../../foundation/src/jest/setupAfterEnv.mjs"
100
99
  ],
101
100
  "setupFiles": [
102
101
  "../../foundation/src/jest/setup.mjs"
103
- ]
102
+ ],
103
+ "testEnvironment": "../../foundation/src/jest/env.mjs"
104
104
  },
105
105
  "dependencies": {
106
- "@aztec/bb.js": "0.0.0-test.0",
106
+ "@aztec/bb.js": "0.0.1-fake-c83136db25",
107
107
  "@koa/cors": "^5.0.0",
108
- "@noble/curves": "^1.2.0",
108
+ "@noble/curves": "=1.7.0",
109
109
  "bn.js": "^5.2.1",
110
- "c-kzg": "4.0.0-alpha.1",
111
110
  "colorette": "^2.0.20",
112
- "debug": "^4.3.4",
113
111
  "detect-node": "^2.1.0",
114
- "elliptic": "^6.5.4",
115
112
  "hash.js": "^1.1.7",
116
- "koa": "^2.14.2",
113
+ "koa": "^2.16.1",
117
114
  "koa-bodyparser": "^4.4.0",
118
115
  "koa-compress": "^5.1.0",
119
- "koa-router": "^12.0.0",
116
+ "koa-router": "^13.1.1",
120
117
  "leveldown": "^6.1.1",
121
- "levelup": "^5.1.1",
122
118
  "lodash.chunk": "^4.2.0",
123
119
  "lodash.clonedeepwith": "^4.5.0",
124
- "memdown": "^6.1.1",
125
120
  "pako": "^2.1.0",
126
121
  "pino": "^9.5.0",
127
122
  "pino-pretty": "^13.0.0",
128
123
  "sha3": "^2.1.4",
129
- "undici": "^7.3.0",
124
+ "undici": "^5.28.5",
130
125
  "zod": "^3.23.8"
131
126
  },
132
127
  "devDependencies": {
133
- "@jest/globals": "^29.5.0",
128
+ "@jest/globals": "^30.0.0",
134
129
  "@libp2p/interface": "1.3.1",
135
- "@types/bn.js": "^5.1.3",
136
- "@types/debug": "^4.1.7",
137
130
  "@types/detect-node": "^2.0.0",
138
- "@types/elliptic": "^6.4.16",
139
- "@types/jest": "^29.5.0",
140
- "@types/koa": "^2.13.5",
131
+ "@types/jest": "^30.0.0",
132
+ "@types/koa": "^2.15.0",
141
133
  "@types/koa-bodyparser": "^4.3.10",
142
134
  "@types/koa-compress": "^4.0.3",
143
135
  "@types/koa-router": "^7.4.4",
144
136
  "@types/koa__cors": "^4.0.0",
145
137
  "@types/leveldown": "^4.0.3",
146
- "@types/levelup": "^5.1.2",
147
138
  "@types/lodash.chunk": "^4.2.9",
148
139
  "@types/lodash.clonedeepwith": "^4.5.7",
149
- "@types/memdown": "^3.0.1",
150
- "@types/node": "^18.7.23",
140
+ "@types/node": "^22.15.17",
151
141
  "@types/pako": "^2.0.0",
152
142
  "@types/supertest": "^2.0.12",
153
- "@typescript-eslint/eslint-plugin": "^6.2.1",
154
- "@typescript-eslint/parser": "^6.2.1",
155
143
  "comlink": "^4.4.1",
156
- "eslint": "^8.21.0",
157
- "eslint-config-prettier": "^8.5.0",
158
- "eslint-plugin-jsdoc": "^40.1.0",
159
- "eslint-plugin-no-only-tests": "^3.1.0",
160
- "eslint-plugin-tsdoc": "^0.2.17",
161
- "jest": "^29.5.0",
162
- "prettier": "^2.7.1",
144
+ "eslint": "^9.26.0",
145
+ "eslint-config-prettier": "^10.1.5",
146
+ "eslint-plugin-import": "^2.31.0",
147
+ "eslint-plugin-jsdoc": "^50.6.14",
148
+ "eslint-plugin-no-only-tests": "^3.3.0",
149
+ "eslint-plugin-tsdoc": "^0.4.0",
150
+ "globals": "^16.1.0",
151
+ "jest": "^30.0.0",
152
+ "prettier": "^3.5.3",
163
153
  "supertest": "^6.3.3",
164
154
  "ts-node": "^10.9.1",
165
- "typescript": "^5.0.4",
166
- "viem": "2.22.8"
155
+ "typescript": "^5.3.3",
156
+ "typescript-eslint": "^8.32.1",
157
+ "viem": "npm:@spalladino/viem@2.38.2-eip7594.0"
167
158
  },
168
159
  "files": [
169
160
  "dest",
@@ -171,6 +162,6 @@
171
162
  "!*.test.*"
172
163
  ],
173
164
  "engines": {
174
- "node": ">=18"
165
+ "node": ">=20.10"
175
166
  }
176
167
  }
@@ -148,3 +148,16 @@ export function assertRightPadded<T>(arr: T[], isEmpty: (item: T) => boolean) {
148
148
  }
149
149
  }
150
150
  }
151
+
152
+ /**
153
+ * Shuffles an array in-place using the Fisher-Yates algorith,
154
+ * @param arr - The array to shuffle
155
+ */
156
+ export function shuffle<T>(arr: T[]): void {
157
+ for (let i = arr.length - 1; i > 0; i--) {
158
+ const j = (Math.random() * (i + 1)) | 0;
159
+ const temp = arr[i];
160
+ arr[i] = arr[j];
161
+ arr[j] = temp;
162
+ }
163
+ }
@@ -29,6 +29,7 @@
29
29
  export function asyncPool<T, R>(poolLimit: number, iterable: T[], iteratorFn: (item: T, iterable: T[]) => Promise<R>) {
30
30
  let i = 0;
31
31
  const ret: Promise<R>[] = [];
32
+ // eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
32
33
  const executing: Set<Promise<R>> = new Set();
33
34
  const enqueue = (): Promise<any> => {
34
35
  if (i === iterable.length) {
@@ -0,0 +1,20 @@
1
+ /** Returns minimum value across a list of bigints. */
2
+ export function minBigint(...values: bigint[]): bigint {
3
+ if (values.length === 0) {
4
+ throw new Error('Cannot get min of empty array');
5
+ }
6
+ return values.reduce((min, value) => (value < min ? value : min), values[0]);
7
+ }
8
+
9
+ /** Returns maximim value across a list of bigints. */
10
+ export function maxBigint(...values: bigint[]): bigint {
11
+ if (values.length === 0) {
12
+ throw new Error('Cannot get max of empty array');
13
+ }
14
+ return values.reduce((max, value) => (value > max ? value : max), values[0]);
15
+ }
16
+
17
+ /** Sums an array of bigints */
18
+ export function sumBigint(values: bigint[]): bigint {
19
+ return values.reduce((sum, value) => sum + value, 0n);
20
+ }
@@ -0,0 +1,133 @@
1
+ import { randomBytes } from '@aztec/foundation/crypto';
2
+ import type { Fr } from '@aztec/foundation/fields';
3
+ import { BufferReader, deserializeBigInt, serializeBigInt } from '@aztec/foundation/serialize';
4
+
5
+ import { inspect } from 'util';
6
+
7
+ import { bufferToHex } from '../string/index.js';
8
+
9
+ /**
10
+ * A class representing a 16 byte Buffer.
11
+ */
12
+ export class Buffer16 {
13
+ /**
14
+ * The size of the hash in bytes.
15
+ */
16
+ public static SIZE = 16;
17
+
18
+ /**
19
+ * Buffer16 with value zero.
20
+ */
21
+ public static ZERO = new Buffer16(Buffer.alloc(Buffer16.SIZE));
22
+
23
+ constructor(
24
+ /**
25
+ * The buffer containing the hash.
26
+ */
27
+ public buffer: Buffer,
28
+ ) {
29
+ if (buffer.length !== Buffer16.SIZE) {
30
+ throw new Error(`Expected buffer to have length ${Buffer16.SIZE} but was ${buffer.length}`);
31
+ }
32
+ }
33
+
34
+ /**
35
+ * Returns the raw buffer of the hash.
36
+ * @returns The buffer containing the hash.
37
+ */
38
+ public toBuffer() {
39
+ return this.buffer;
40
+ }
41
+
42
+ /**
43
+ * Creates a Buffer16 from a buffer.
44
+ * @param buffer - The buffer to create from.
45
+ * @returns A new Buffer16 object.
46
+ */
47
+ public static fromBuffer(buffer: Buffer | BufferReader) {
48
+ const reader = BufferReader.asReader(buffer);
49
+ return new Buffer16(reader.readBytes(Buffer16.SIZE));
50
+ }
51
+
52
+ /**
53
+ * Checks if this hash and another hash are equal.
54
+ * @param hash - A hash to compare with.
55
+ * @returns True if the hashes are equal, false otherwise.
56
+ */
57
+ public equals(hash: Buffer16): boolean {
58
+ return this.buffer.equals(hash.buffer);
59
+ }
60
+
61
+ /**
62
+ * Returns true if this hash is zero.
63
+ * @returns True if this hash is zero.
64
+ */
65
+ public isZero(): boolean {
66
+ return this.buffer.equals(Buffer.alloc(16, 0));
67
+ }
68
+
69
+ /**
70
+ * Convert this hash to a hex string.
71
+ * @returns The hex string.
72
+ */
73
+ public toString() {
74
+ return bufferToHex(this.buffer);
75
+ }
76
+
77
+ [inspect.custom]() {
78
+ return `Buffer16<${this.toString()}>`;
79
+ }
80
+
81
+ toJSON() {
82
+ return this.toString();
83
+ }
84
+
85
+ /**
86
+ * Convert this hash to a big int.
87
+ * @returns The big int.
88
+ */
89
+ public toBigInt() {
90
+ return deserializeBigInt(this.buffer, 0, Buffer16.SIZE).elem;
91
+ }
92
+
93
+ /**
94
+ * Creates a Buffer16 from a bigint.
95
+ */
96
+ public static fromBigInt(hash: bigint) {
97
+ return new Buffer16(serializeBigInt(hash, Buffer16.SIZE));
98
+ }
99
+
100
+ public static fromField(hash: Fr) {
101
+ return new Buffer16(serializeBigInt(hash.toBigInt()));
102
+ }
103
+
104
+ /**
105
+ * Converts a hex string into a Buffer16 object.
106
+ */
107
+ public static fromString(str: string): Buffer16 {
108
+ if (str.startsWith('0x')) {
109
+ str = str.slice(2);
110
+ }
111
+ if (str.length !== this.SIZE * 2) {
112
+ throw new Error(`Expected string to be ${this.SIZE * 2} characters long, but was ${str.length}`);
113
+ }
114
+ return new Buffer16(Buffer.from(str, 'hex'));
115
+ }
116
+
117
+ /**
118
+ * Converts a number into a Buffer16 object.
119
+ * @param num - The number to convert.
120
+ * @returns A new Buffer16 object.
121
+ */
122
+ public static fromNumber(num: number): Buffer16 {
123
+ return new Buffer16(serializeBigInt(BigInt(num), Buffer16.SIZE));
124
+ }
125
+
126
+ /**
127
+ * Generates a random Buffer16.
128
+ * @returns A new Buffer16 object.
129
+ */
130
+ public static random(): Buffer16 {
131
+ return new Buffer16(Buffer.from(randomBytes(Buffer16.SIZE)));
132
+ }
133
+ }