@aztec/foundation 3.0.0-canary.a9708bd → 3.0.0-devnet.20251212

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 (451) hide show
  1. package/dest/array/array.d.ts +1 -9
  2. package/dest/array/array.d.ts.map +1 -1
  3. package/dest/array/array.js +0 -11
  4. package/dest/array/index.d.ts +1 -1
  5. package/dest/async-map/index.d.ts +1 -1
  6. package/dest/async-pool/index.d.ts +1 -1
  7. package/dest/bigint/index.d.ts +1 -1
  8. package/dest/bigint-buffer/index.d.ts +1 -1
  9. package/dest/branded-types/block_number.d.ts +53 -0
  10. package/dest/branded-types/block_number.d.ts.map +1 -0
  11. package/dest/branded-types/block_number.js +75 -0
  12. package/dest/branded-types/checkpoint_number.d.ts +46 -0
  13. package/dest/branded-types/checkpoint_number.d.ts.map +1 -0
  14. package/dest/branded-types/checkpoint_number.js +68 -0
  15. package/dest/branded-types/epoch.d.ts +42 -0
  16. package/dest/branded-types/epoch.d.ts.map +1 -0
  17. package/dest/branded-types/epoch.js +59 -0
  18. package/dest/branded-types/index.d.ts +6 -0
  19. package/dest/branded-types/index.d.ts.map +1 -0
  20. package/dest/branded-types/index.js +4 -0
  21. package/dest/branded-types/slot.d.ts +42 -0
  22. package/dest/branded-types/slot.d.ts.map +1 -0
  23. package/dest/branded-types/slot.js +59 -0
  24. package/dest/branded-types/types.d.ts +5 -0
  25. package/dest/branded-types/types.d.ts.map +1 -0
  26. package/dest/branded-types/types.js +1 -0
  27. package/dest/buffer/buffer16.d.ts +2 -5
  28. package/dest/buffer/buffer16.d.ts.map +1 -1
  29. package/dest/buffer/buffer16.js +1 -1
  30. package/dest/buffer/buffer32.d.ts +2 -5
  31. package/dest/buffer/buffer32.d.ts.map +1 -1
  32. package/dest/buffer/buffer32.js +1 -1
  33. package/dest/buffer/index.d.ts +1 -1
  34. package/dest/collection/array.d.ts +3 -1
  35. package/dest/collection/array.d.ts.map +1 -1
  36. package/dest/collection/array.js +12 -3
  37. package/dest/collection/index.d.ts +1 -1
  38. package/dest/collection/object.d.ts +5 -1
  39. package/dest/collection/object.d.ts.map +1 -1
  40. package/dest/collection/object.js +6 -0
  41. package/dest/committable/committable.d.ts +1 -1
  42. package/dest/committable/committable.d.ts.map +1 -1
  43. package/dest/committable/index.d.ts +1 -1
  44. package/dest/config/env_var.d.ts +2 -2
  45. package/dest/config/env_var.d.ts.map +1 -1
  46. package/dest/config/index.d.ts +12 -2
  47. package/dest/config/index.d.ts.map +1 -1
  48. package/dest/config/index.js +18 -3
  49. package/dest/config/network_config.d.ts +42 -0
  50. package/dest/config/network_config.d.ts.map +1 -0
  51. package/dest/config/network_config.js +9 -0
  52. package/dest/config/network_name.d.ts +2 -2
  53. package/dest/config/network_name.d.ts.map +1 -1
  54. package/dest/config/network_name.js +10 -2
  55. package/dest/config/secret_value.d.ts +1 -1
  56. package/dest/config/secret_value.d.ts.map +1 -1
  57. package/dest/crypto/aes128/index.d.ts +1 -1
  58. package/dest/crypto/aes128/index.d.ts.map +1 -1
  59. package/dest/crypto/aes128/index.js +19 -6
  60. package/dest/crypto/bls/bn254_keystore.d.ts +296 -0
  61. package/dest/crypto/bls/bn254_keystore.d.ts.map +1 -0
  62. package/dest/crypto/bls/bn254_keystore.js +218 -0
  63. package/dest/crypto/bls/index.d.ts +13 -0
  64. package/dest/crypto/bls/index.d.ts.map +1 -0
  65. package/dest/crypto/bls/index.js +87 -0
  66. package/dest/crypto/bn254/index.d.ts +39 -0
  67. package/dest/crypto/bn254/index.d.ts.map +1 -0
  68. package/dest/crypto/bn254/index.js +56 -0
  69. package/dest/crypto/ecdsa/index.d.ts +1 -1
  70. package/dest/crypto/ecdsa/index.d.ts.map +1 -1
  71. package/dest/crypto/ecdsa/index.js +58 -48
  72. package/dest/crypto/ecdsa/signature.d.ts +2 -11
  73. package/dest/crypto/ecdsa/signature.d.ts.map +1 -1
  74. package/dest/crypto/ecdsa/signature.js +2 -2
  75. package/dest/crypto/grumpkin/index.d.ts +10 -13
  76. package/dest/crypto/grumpkin/index.d.ts.map +1 -1
  77. package/dest/crypto/grumpkin/index.js +61 -55
  78. package/dest/crypto/keccak/index.d.ts +1 -1
  79. package/dest/crypto/keys/index.d.ts +2 -2
  80. package/dest/crypto/keys/index.d.ts.map +1 -1
  81. package/dest/crypto/keys/index.js +8 -5
  82. package/dest/crypto/pedersen/index.d.ts +1 -1
  83. package/dest/crypto/pedersen/pedersen.noble.d.ts +1 -1
  84. package/dest/crypto/pedersen/pedersen.wasm.d.ts +2 -2
  85. package/dest/crypto/pedersen/pedersen.wasm.d.ts.map +1 -1
  86. package/dest/crypto/pedersen/pedersen.wasm.js +24 -14
  87. package/dest/crypto/poseidon/index.d.ts +2 -2
  88. package/dest/crypto/poseidon/index.d.ts.map +1 -1
  89. package/dest/crypto/poseidon/index.js +33 -18
  90. package/dest/crypto/random/index.d.ts +1 -1
  91. package/dest/crypto/random/index.d.ts.map +1 -1
  92. package/dest/crypto/random/randomness_singleton.d.ts +1 -1
  93. package/dest/crypto/random/randomness_singleton.d.ts.map +1 -1
  94. package/dest/crypto/schnorr/index.d.ts +3 -2
  95. package/dest/crypto/schnorr/index.d.ts.map +1 -1
  96. package/dest/crypto/schnorr/index.js +30 -38
  97. package/dest/crypto/schnorr/signature.d.ts +2 -2
  98. package/dest/crypto/schnorr/signature.d.ts.map +1 -1
  99. package/dest/crypto/schnorr/signature.js +2 -2
  100. package/dest/crypto/secp256k1/index.d.ts +1 -1
  101. package/dest/crypto/secp256k1/index.d.ts.map +1 -1
  102. package/dest/crypto/secp256k1/index.js +23 -18
  103. package/dest/crypto/secp256k1-signer/index.d.ts +1 -1
  104. package/dest/crypto/secp256k1-signer/secp256k1_signer.d.ts +1 -1
  105. package/dest/crypto/secp256k1-signer/secp256k1_signer.d.ts.map +1 -1
  106. package/dest/crypto/secp256k1-signer/utils.d.ts +49 -3
  107. package/dest/crypto/secp256k1-signer/utils.d.ts.map +1 -1
  108. package/dest/crypto/secp256k1-signer/utils.js +87 -5
  109. package/dest/crypto/serialize.d.ts +1 -1
  110. package/dest/crypto/sha256/index.d.ts +2 -2
  111. package/dest/crypto/sha256/index.d.ts.map +1 -1
  112. package/dest/crypto/sha256/index.js +1 -1
  113. package/dest/crypto/sha512/index.d.ts +3 -3
  114. package/dest/crypto/sha512/index.d.ts.map +1 -1
  115. package/dest/crypto/sha512/index.js +1 -1
  116. package/dest/crypto/signature/index.d.ts +2 -2
  117. package/dest/crypto/signature/index.d.ts.map +1 -1
  118. package/dest/crypto/sync/index.d.ts +1 -1
  119. package/dest/crypto/sync/index.js +1 -1
  120. package/dest/crypto/sync/pedersen/index.d.ts +2 -2
  121. package/dest/crypto/sync/pedersen/index.d.ts.map +1 -1
  122. package/dest/crypto/sync/pedersen/index.js +18 -11
  123. package/dest/crypto/sync/poseidon/index.d.ts +2 -2
  124. package/dest/crypto/sync/poseidon/index.d.ts.map +1 -1
  125. package/dest/crypto/sync/poseidon/index.js +28 -13
  126. package/dest/{fields/bls12_fields.d.ts → curves/bls12/field.d.ts} +3 -3
  127. package/dest/curves/bls12/field.d.ts.map +1 -0
  128. package/dest/{fields/bls12_fields.js → curves/bls12/field.js} +6 -6
  129. package/dest/curves/bls12/index.d.ts +3 -0
  130. package/dest/curves/bls12/index.d.ts.map +1 -0
  131. package/dest/curves/bls12/index.js +2 -0
  132. package/dest/{fields/bls12_point.d.ts → curves/bls12/point.d.ts} +11 -20
  133. package/dest/curves/bls12/point.d.ts.map +1 -0
  134. package/dest/{fields/bls12_point.js → curves/bls12/point.js} +14 -14
  135. package/dest/{fields/fields.d.ts → curves/bn254/field.d.ts} +16 -9
  136. package/dest/curves/bn254/field.d.ts.map +1 -0
  137. package/dest/{fields/fields.js → curves/bn254/field.js} +41 -16
  138. package/dest/curves/bn254/index.d.ts +3 -0
  139. package/dest/curves/bn254/index.d.ts.map +1 -0
  140. package/dest/curves/bn254/index.js +2 -0
  141. package/dest/curves/bn254/point.d.ts +54 -0
  142. package/dest/curves/bn254/point.d.ts.map +1 -0
  143. package/dest/curves/bn254/point.js +143 -0
  144. package/dest/curves/grumpkin/index.d.ts +10 -0
  145. package/dest/curves/grumpkin/index.d.ts.map +1 -0
  146. package/dest/curves/grumpkin/index.js +3 -0
  147. package/dest/{fields → curves/grumpkin}/point.d.ts +13 -13
  148. package/dest/curves/grumpkin/point.d.ts.map +1 -0
  149. package/dest/{fields → curves/grumpkin}/point.js +24 -7
  150. package/dest/decorators/index.d.ts +1 -1
  151. package/dest/decorators/memoize.d.ts +1 -1
  152. package/dest/decorators/memoize.d.ts.map +1 -1
  153. package/dest/error/index.d.ts +4 -4
  154. package/dest/error/index.d.ts.map +1 -1
  155. package/dest/eth-address/index.d.ts +14 -4
  156. package/dest/eth-address/index.d.ts.map +1 -1
  157. package/dest/eth-address/index.js +23 -1
  158. package/dest/eth-signature/eth_signature.d.ts +1 -4
  159. package/dest/eth-signature/eth_signature.d.ts.map +1 -1
  160. package/dest/eth-signature/eth_signature.js +2 -4
  161. package/dest/eth-signature/index.d.ts +1 -1
  162. package/dest/fs/index.d.ts +1 -1
  163. package/dest/fs/run_in_dir.d.ts +1 -1
  164. package/dest/fs/try_rm_dir.d.ts +1 -1
  165. package/dest/iterable/all.d.ts +1 -1
  166. package/dest/iterable/filter.d.ts +1 -1
  167. package/dest/iterable/index.d.ts +1 -1
  168. package/dest/iterable/isAsyncIt.d.ts +1 -1
  169. package/dest/iterable/map.d.ts +1 -1
  170. package/dest/iterable/peek.d.ts +1 -1
  171. package/dest/iterable/sort.d.ts +1 -1
  172. package/dest/iterable/take.d.ts +1 -1
  173. package/dest/iterable/toArray.d.ts +1 -1
  174. package/dest/json-rpc/client/fetch.d.ts +1 -1
  175. package/dest/json-rpc/client/index.d.ts +1 -1
  176. package/dest/json-rpc/client/safe_json_rpc_client.d.ts +1 -1
  177. package/dest/json-rpc/client/safe_json_rpc_client.d.ts.map +1 -1
  178. package/dest/json-rpc/client/safe_json_rpc_client.js +9 -0
  179. package/dest/json-rpc/client/undici.d.ts +1 -1
  180. package/dest/json-rpc/convert.d.ts +1 -1
  181. package/dest/json-rpc/errors.d.ts +1 -1
  182. package/dest/json-rpc/errors.d.ts.map +1 -1
  183. package/dest/json-rpc/fixtures/class_a.d.ts +3 -3
  184. package/dest/json-rpc/fixtures/class_a.d.ts.map +1 -1
  185. package/dest/json-rpc/fixtures/class_b.d.ts +3 -3
  186. package/dest/json-rpc/fixtures/class_b.d.ts.map +1 -1
  187. package/dest/json-rpc/fixtures/test_state.d.ts +1 -1
  188. package/dest/json-rpc/fixtures/test_state.d.ts.map +1 -1
  189. package/dest/json-rpc/index.d.ts +1 -1
  190. package/dest/json-rpc/js_utils.d.ts +1 -1
  191. package/dest/json-rpc/js_utils.d.ts.map +1 -1
  192. package/dest/json-rpc/server/index.d.ts +1 -1
  193. package/dest/json-rpc/server/safe_json_rpc_server.d.ts +1 -1
  194. package/dest/json-rpc/server/safe_json_rpc_server.d.ts.map +1 -1
  195. package/dest/json-rpc/server/telemetry.d.ts +1 -1
  196. package/dest/json-rpc/test/index.d.ts +1 -1
  197. package/dest/json-rpc/test/integration.d.ts +1 -1
  198. package/dest/log/console.d.ts +1 -1
  199. package/dest/log/gcloud-logger-config.d.ts +1 -1
  200. package/dest/log/gcloud-logger-config.d.ts.map +1 -1
  201. package/dest/log/index.d.ts +1 -1
  202. package/dest/log/libp2p_logger.d.ts +1 -1
  203. package/dest/log/log-filters.d.ts +1 -1
  204. package/dest/log/log-levels.d.ts +1 -1
  205. package/dest/log/log_fn.d.ts +2 -2
  206. package/dest/log/log_fn.d.ts.map +1 -1
  207. package/dest/log/noir_debug_log_util.d.ts +1 -1
  208. package/dest/log/pino-logger.d.ts +2 -2
  209. package/dest/log/pino-logger.d.ts.map +1 -1
  210. package/dest/log/pino-logger.js +0 -1
  211. package/dest/message/index.d.ts +1 -1
  212. package/dest/message/index.d.ts.map +1 -1
  213. package/dest/mutex/index.d.ts +1 -1
  214. package/dest/mutex/index.d.ts.map +1 -1
  215. package/dest/mutex/mutex_database.d.ts +1 -1
  216. package/dest/noir/index.d.ts +1 -1
  217. package/dest/noir/noir_package_config.d.ts +9 -9
  218. package/dest/number/index.d.ts +1 -1
  219. package/dest/profiler/index.d.ts +2 -0
  220. package/dest/profiler/index.d.ts.map +1 -0
  221. package/dest/profiler/index.js +1 -0
  222. package/dest/profiler/profiler.d.ts +8 -0
  223. package/dest/profiler/profiler.d.ts.map +1 -0
  224. package/dest/profiler/profiler.js +97 -0
  225. package/dest/promise/index.d.ts +1 -1
  226. package/dest/promise/running-promise.d.ts +1 -1
  227. package/dest/promise/running-promise.d.ts.map +1 -1
  228. package/dest/promise/utils.d.ts +1 -1
  229. package/dest/queue/base_memory_queue.d.ts +1 -1
  230. package/dest/queue/base_memory_queue.d.ts.map +1 -1
  231. package/dest/queue/batch_queue.d.ts +1 -1
  232. package/dest/queue/batch_queue.d.ts.map +1 -1
  233. package/dest/queue/bounded_serial_queue.d.ts +1 -1
  234. package/dest/queue/bounded_serial_queue.d.ts.map +1 -1
  235. package/dest/queue/fifo_memory_queue.d.ts +1 -1
  236. package/dest/queue/fifo_memory_queue.d.ts.map +1 -1
  237. package/dest/queue/index.d.ts +1 -1
  238. package/dest/queue/priority_memory_queue.d.ts +1 -1
  239. package/dest/queue/priority_memory_queue.d.ts.map +1 -1
  240. package/dest/queue/priority_queue.d.ts +1 -1
  241. package/dest/queue/priority_queue.d.ts.map +1 -1
  242. package/dest/queue/semaphore.d.ts +1 -1
  243. package/dest/queue/semaphore.d.ts.map +1 -1
  244. package/dest/queue/serial_queue.d.ts +1 -1
  245. package/dest/queue/serial_queue.d.ts.map +1 -1
  246. package/dest/retry/index.d.ts +1 -1
  247. package/dest/running-promise/index.d.ts +1 -1
  248. package/dest/schemas/api.d.ts +1 -1
  249. package/dest/schemas/index.d.ts +1 -1
  250. package/dest/schemas/parse.d.ts +1 -1
  251. package/dest/schemas/schemas.d.ts +13 -17
  252. package/dest/schemas/schemas.d.ts.map +1 -1
  253. package/dest/schemas/schemas.js +9 -10
  254. package/dest/schemas/types.d.ts +1 -1
  255. package/dest/schemas/utils.d.ts +4 -4
  256. package/dest/schemas/utils.d.ts.map +1 -1
  257. package/dest/schemas/utils.js +15 -5
  258. package/dest/serialize/buffer_reader.d.ts +3 -1
  259. package/dest/serialize/buffer_reader.d.ts.map +1 -1
  260. package/dest/serialize/buffer_reader.js +3 -0
  261. package/dest/serialize/field_reader.d.ts +2 -2
  262. package/dest/serialize/field_reader.d.ts.map +1 -1
  263. package/dest/serialize/field_reader.js +1 -1
  264. package/dest/serialize/free_funcs.d.ts +2 -2
  265. package/dest/serialize/free_funcs.d.ts.map +1 -1
  266. package/dest/serialize/free_funcs.js +1 -1
  267. package/dest/serialize/index.d.ts +1 -1
  268. package/dest/serialize/serialize.d.ts +2 -2
  269. package/dest/serialize/serialize.d.ts.map +1 -1
  270. package/dest/serialize/serialize.js +1 -1
  271. package/dest/serialize/type_registry.d.ts +1 -1
  272. package/dest/serialize/type_registry.d.ts.map +1 -1
  273. package/dest/serialize/types.d.ts +1 -1
  274. package/dest/sleep/index.d.ts +1 -1
  275. package/dest/sleep/index.d.ts.map +1 -1
  276. package/dest/string/index.d.ts +5 -1
  277. package/dest/string/index.d.ts.map +1 -1
  278. package/dest/string/index.js +19 -2
  279. package/dest/testing/files/index.d.ts +2 -1
  280. package/dest/testing/files/index.d.ts.map +1 -1
  281. package/dest/testing/files/index.js +1 -1
  282. package/dest/testing/formatting.d.ts +4 -0
  283. package/dest/testing/formatting.d.ts.map +1 -0
  284. package/dest/testing/formatting.js +3 -0
  285. package/dest/testing/index.d.ts +2 -1
  286. package/dest/testing/index.d.ts.map +1 -1
  287. package/dest/testing/index.js +1 -0
  288. package/dest/testing/port_allocator.d.ts +1 -1
  289. package/dest/testing/snapshot_serializer.d.ts +1 -1
  290. package/dest/testing/test_data.d.ts +1 -1
  291. package/dest/timer/date.d.ts +1 -1
  292. package/dest/timer/date.d.ts.map +1 -1
  293. package/dest/timer/elapsed.d.ts +1 -1
  294. package/dest/timer/index.d.ts +2 -2
  295. package/dest/timer/index.d.ts.map +1 -1
  296. package/dest/timer/index.js +1 -1
  297. package/dest/timer/timeout.d.ts +3 -1
  298. package/dest/timer/timeout.d.ts.map +1 -1
  299. package/dest/timer/timeout.js +9 -0
  300. package/dest/timer/timer.d.ts +1 -1
  301. package/dest/timer/timer.d.ts.map +1 -1
  302. package/dest/transport/dispatch/create_dispatch_fn.d.ts +1 -1
  303. package/dest/transport/dispatch/create_dispatch_fn.d.ts.map +1 -1
  304. package/dest/transport/dispatch/create_dispatch_proxy.d.ts +1 -1
  305. package/dest/transport/dispatch/messages.d.ts +1 -1
  306. package/dest/transport/index.d.ts +1 -1
  307. package/dest/transport/interface/connector.d.ts +1 -1
  308. package/dest/transport/interface/listener.d.ts +1 -1
  309. package/dest/transport/interface/socket.d.ts +1 -1
  310. package/dest/transport/interface/transferable.d.ts +1 -1
  311. package/dest/transport/node/index.d.ts +1 -1
  312. package/dest/transport/node/node_connector.d.ts +1 -1
  313. package/dest/transport/node/node_connector.d.ts.map +1 -1
  314. package/dest/transport/node/node_connector_socket.d.ts +1 -1
  315. package/dest/transport/node/node_connector_socket.d.ts.map +1 -1
  316. package/dest/transport/node/node_listener.d.ts +1 -1
  317. package/dest/transport/node/node_listener.d.ts.map +1 -1
  318. package/dest/transport/node/node_listener_socket.d.ts +1 -1
  319. package/dest/transport/node/node_listener_socket.d.ts.map +1 -1
  320. package/dest/transport/transport_client.d.ts +1 -1
  321. package/dest/transport/transport_client.d.ts.map +1 -1
  322. package/dest/transport/transport_server.d.ts +1 -10
  323. package/dest/transport/transport_server.d.ts.map +1 -1
  324. package/dest/trees/balanced_merkle_tree.d.ts +22 -0
  325. package/dest/trees/balanced_merkle_tree.d.ts.map +1 -0
  326. package/dest/trees/balanced_merkle_tree.js +66 -0
  327. package/dest/trees/hasher.d.ts +1 -1
  328. package/dest/trees/index.d.ts +2 -1
  329. package/dest/trees/index.d.ts.map +1 -1
  330. package/dest/trees/index.js +1 -0
  331. package/dest/trees/indexed_merkle_tree.d.ts +1 -1
  332. package/dest/trees/indexed_merkle_tree.d.ts.map +1 -1
  333. package/dest/trees/indexed_merkle_tree.js +1 -1
  334. package/dest/trees/indexed_merkle_tree_calculator.d.ts +1 -1
  335. package/dest/trees/indexed_merkle_tree_calculator.d.ts.map +1 -1
  336. package/dest/trees/indexed_tree_leaf.d.ts +1 -1
  337. package/dest/trees/membership_witness.d.ts +3 -24
  338. package/dest/trees/membership_witness.d.ts.map +1 -1
  339. package/dest/trees/membership_witness.js +1 -1
  340. package/dest/trees/merkle_tree.d.ts +1 -1
  341. package/dest/trees/merkle_tree.d.ts.map +1 -1
  342. package/dest/trees/merkle_tree_calculator.d.ts +2 -12
  343. package/dest/trees/merkle_tree_calculator.d.ts.map +1 -1
  344. package/dest/trees/merkle_tree_calculator.js +1 -31
  345. package/dest/trees/sibling_path.d.ts +5 -39
  346. package/dest/trees/sibling_path.d.ts.map +1 -1
  347. package/dest/trees/sibling_path.js +2 -2
  348. package/dest/trees/unbalanced_merkle_tree.d.ts +5 -4
  349. package/dest/trees/unbalanced_merkle_tree.d.ts.map +1 -1
  350. package/dest/trees/unbalanced_merkle_tree.js +33 -10
  351. package/dest/trees/unbalanced_merkle_tree_calculator.d.ts +27 -23
  352. package/dest/trees/unbalanced_merkle_tree_calculator.d.ts.map +1 -1
  353. package/dest/trees/unbalanced_merkle_tree_calculator.js +123 -97
  354. package/dest/trees/unbalanced_tree_store.d.ts +2 -1
  355. package/dest/trees/unbalanced_tree_store.d.ts.map +1 -1
  356. package/dest/trees/unbalanced_tree_store.js +6 -0
  357. package/dest/types/index.d.ts +1 -1
  358. package/dest/url/index.d.ts +1 -1
  359. package/dest/validation/index.d.ts +1 -1
  360. package/package.json +31 -8
  361. package/src/array/array.ts +0 -16
  362. package/src/branded-types/block_number.ts +112 -0
  363. package/src/branded-types/checkpoint_number.ts +100 -0
  364. package/src/branded-types/epoch.ts +88 -0
  365. package/src/branded-types/index.ts +6 -0
  366. package/src/branded-types/slot.ts +88 -0
  367. package/src/branded-types/types.ts +2 -0
  368. package/src/buffer/buffer16.ts +2 -2
  369. package/src/buffer/buffer32.ts +2 -2
  370. package/src/collection/array.ts +15 -3
  371. package/src/collection/object.ts +8 -0
  372. package/src/config/env_var.ts +38 -21
  373. package/src/config/index.ts +23 -3
  374. package/src/config/network_config.ts +16 -0
  375. package/src/config/network_name.ts +18 -3
  376. package/src/crypto/aes128/index.ts +19 -10
  377. package/src/crypto/bls/bn254_keystore.ts +287 -0
  378. package/src/crypto/bls/index.ts +77 -0
  379. package/src/crypto/bn254/index.ts +64 -0
  380. package/src/crypto/ecdsa/index.ts +40 -37
  381. package/src/crypto/ecdsa/signature.ts +2 -2
  382. package/src/crypto/grumpkin/index.ts +38 -46
  383. package/src/crypto/keys/index.ts +6 -6
  384. package/src/crypto/pedersen/pedersen.wasm.ts +23 -19
  385. package/src/crypto/poseidon/index.ts +33 -25
  386. package/src/crypto/schnorr/index.ts +22 -18
  387. package/src/crypto/schnorr/signature.ts +2 -2
  388. package/src/crypto/secp256k1/index.ts +15 -11
  389. package/src/crypto/secp256k1-signer/utils.ts +115 -7
  390. package/src/crypto/sha256/index.ts +1 -1
  391. package/src/crypto/sha512/index.ts +1 -1
  392. package/src/crypto/signature/index.ts +1 -1
  393. package/src/crypto/sync/index.ts +1 -1
  394. package/src/crypto/sync/pedersen/index.ts +17 -16
  395. package/src/crypto/sync/poseidon/index.ts +28 -23
  396. package/src/{fields/bls12_fields.ts → curves/bls12/field.ts} +6 -6
  397. package/src/curves/bls12/index.ts +2 -0
  398. package/src/{fields/bls12_point.ts → curves/bls12/point.ts} +14 -14
  399. package/src/{fields/fields.ts → curves/bn254/field.ts} +41 -19
  400. package/src/curves/bn254/index.ts +2 -0
  401. package/src/curves/bn254/point.ts +170 -0
  402. package/src/curves/grumpkin/index.ts +11 -0
  403. package/src/{fields → curves/grumpkin}/point.ts +26 -7
  404. package/src/eth-address/index.ts +28 -3
  405. package/src/eth-signature/eth_signature.ts +2 -4
  406. package/src/json-rpc/client/safe_json_rpc_client.ts +9 -0
  407. package/src/log/log_fn.ts +1 -1
  408. package/src/log/pino-logger.ts +0 -1
  409. package/src/profiler/index.ts +1 -0
  410. package/src/profiler/profiler.ts +125 -0
  411. package/src/schemas/schemas.ts +16 -13
  412. package/src/schemas/utils.ts +21 -8
  413. package/src/serialize/buffer_reader.ts +5 -0
  414. package/src/serialize/field_reader.ts +1 -1
  415. package/src/serialize/free_funcs.ts +1 -1
  416. package/src/serialize/serialize.ts +1 -1
  417. package/src/string/index.ts +24 -1
  418. package/src/testing/files/index.ts +1 -1
  419. package/src/testing/formatting.ts +3 -0
  420. package/src/testing/index.ts +1 -0
  421. package/src/timer/index.ts +1 -1
  422. package/src/timer/timeout.ts +13 -0
  423. package/src/trees/balanced_merkle_tree.ts +84 -0
  424. package/src/trees/index.ts +1 -0
  425. package/src/trees/indexed_merkle_tree.ts +1 -1
  426. package/src/trees/membership_witness.ts +1 -1
  427. package/src/trees/merkle_tree_calculator.ts +1 -34
  428. package/src/trees/sibling_path.ts +2 -2
  429. package/src/trees/unbalanced_merkle_tree.ts +55 -7
  430. package/src/trees/unbalanced_merkle_tree_calculator.ts +134 -93
  431. package/src/trees/unbalanced_tree_store.ts +5 -1
  432. package/dest/crypto/index.d.ts +0 -15
  433. package/dest/crypto/index.d.ts.map +0 -1
  434. package/dest/crypto/index.js +0 -14
  435. package/dest/fields/bls12_fields.d.ts.map +0 -1
  436. package/dest/fields/bls12_point.d.ts.map +0 -1
  437. package/dest/fields/coordinate.d.ts +0 -66
  438. package/dest/fields/coordinate.d.ts.map +0 -1
  439. package/dest/fields/coordinate.js +0 -96
  440. package/dest/fields/fields.d.ts.map +0 -1
  441. package/dest/fields/index.d.ts +0 -6
  442. package/dest/fields/index.d.ts.map +0 -1
  443. package/dest/fields/index.js +0 -5
  444. package/dest/fields/point.d.ts.map +0 -1
  445. package/dest/index.d.ts +0 -29
  446. package/dest/index.d.ts.map +0 -1
  447. package/dest/index.js +0 -29
  448. package/src/crypto/index.ts +0 -14
  449. package/src/fields/coordinate.ts +0 -104
  450. package/src/fields/index.ts +0 -5
  451. package/src/index.ts +0 -29
@@ -1,132 +1,158 @@
1
- import { serializeToBuffer } from '@aztec/foundation/serialize';
2
- import { SiblingPath } from '@aztec/foundation/trees';
3
- import { sha256Trunc } from '../crypto/index.js';
4
- const indexToKeyHash = (level, index)=>`${level}:${index}`;
1
+ import { shaMerkleHash } from './balanced_merkle_tree.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), emptyRoot = Buffer.alloc(32), hasher) {
5
+ const calculator = UnbalancedMerkleTreeCalculator.create(leaves, valueToCompress, emptyRoot, hasher);
6
+ return calculator.getRoot();
7
+ }
5
8
  /**
6
9
  * An ephemeral unbalanced Merkle tree implementation.
7
10
  * Follows the rollup implementation which greedily hashes pairs of nodes up the tree.
8
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.
9
14
  * If there is only one leaf, the root is the leaf.
10
15
  */ export class UnbalancedMerkleTreeCalculator {
11
- maxDepth;
16
+ leaves;
17
+ valueToCompress;
18
+ emptyRoot;
12
19
  hasher;
13
- // This map stores index and depth -> value
14
- cache;
15
- // This map stores value -> index and depth, since we have variable depth
16
- valueCache;
17
- size;
18
- root;
19
- constructor(maxDepth, hasher){
20
- this.maxDepth = maxDepth;
20
+ store;
21
+ leafLocations;
22
+ constructor(leaves, valueToCompress, emptyRoot, hasher){
23
+ this.leaves = leaves;
24
+ this.valueToCompress = valueToCompress;
25
+ this.emptyRoot = emptyRoot;
21
26
  this.hasher = hasher;
22
- this.cache = {};
23
- this.valueCache = {};
24
- this.size = 0n;
25
- this.root = Buffer.alloc(32);
27
+ this.leafLocations = [];
28
+ this.store = new UnbalancedTreeStore(leaves.length);
29
+ this.buildTree();
26
30
  }
27
- static create(height, hasher = (left, right)=>Promise.resolve(sha256Trunc(Buffer.concat([
28
- left,
29
- right
30
- ])))) {
31
- return new UnbalancedMerkleTreeCalculator(height, hasher);
31
+ static create(leaves, valueToCompress = Buffer.alloc(0), emptyRoot = Buffer.alloc(32), hasher = shaMerkleHash) {
32
+ return new UnbalancedMerkleTreeCalculator(leaves, valueToCompress, emptyRoot, hasher);
32
33
  }
33
34
  /**
34
35
  * Returns the root of the tree.
35
36
  * @returns The root of the tree.
36
37
  */ getRoot() {
37
- return this.root;
38
+ return this.store.getRoot().value;
38
39
  }
39
40
  /**
40
- * Returns a sibling path for the element at the given index.
41
+ * Returns a sibling path for the element.
41
42
  * @param value - The value of the element.
42
43
  * @returns A sibling path for the element.
43
44
  * Note: The sibling path is an array of sibling hashes, with the lowest hash (leaf hash) first, and the highest hash last.
44
45
  */ getSiblingPath(value) {
45
- if (this.size === 1n) {
46
- return Promise.resolve(new SiblingPath(0, []));
47
- }
48
- const path = [];
49
- const [depth, _index] = this.valueCache[serializeToBuffer(value).toString('hex')].split(':');
50
- let level = parseInt(depth, 10);
51
- let index = BigInt(_index);
52
- while(level > 0){
53
- const isRight = index & 0x01n;
54
- const key = indexToKeyHash(level, isRight ? index - 1n : index + 1n);
55
- const sibling = this.cache[key];
56
- path.push(sibling);
57
- level -= 1;
58
- index >>= 1n;
46
+ const leafIndex = this.leaves.findIndex((leaf)=>leaf.equals(value));
47
+ if (leafIndex === -1) {
48
+ throw Error(`Leaf value ${value.toString('hex')} not found in tree.`);
59
49
  }
60
- return Promise.resolve(new SiblingPath(parseInt(depth, 10), path));
50
+ return this.getSiblingPathByLeafIndex(leafIndex);
61
51
  }
62
52
  /**
63
- * Appends the given leaves to the tree.
64
- * @param leaves - The leaves to append.
65
- * @returns Empty promise.
66
- */ async appendLeaves(leaves) {
67
- if (this.size != BigInt(0)) {
68
- throw Error(`Can't re-append to an unbalanced tree. Current has ${this.size} leaves.`);
53
+ * Returns a sibling path for the leaf at the given index.
54
+ * @param leafIndex - The index of the leaf.
55
+ * @returns A sibling path for the leaf.
56
+ */ getSiblingPathByLeafIndex(leafIndex) {
57
+ if (leafIndex >= this.leaves.length) {
58
+ throw Error(`Leaf index ${leafIndex} out of bounds. Tree has ${this.leaves.length} leaves.`);
69
59
  }
70
- if (leaves.length === 0) {
71
- throw Error(`Can't append 0 leaves to an unbalanced tree.`);
60
+ const leaf = this.leaves[leafIndex];
61
+ if (leaf.equals(this.valueToCompress)) {
62
+ throw Error(`Leaf at index ${leafIndex} has been compressed.`);
72
63
  }
73
- if (leaves.length === 1) {
74
- this.root = leaves[0];
75
- } else {
76
- this.root = await this.batchInsert(leaves);
64
+ const path = [];
65
+ let location = this.leafLocations[leafIndex];
66
+ while(location.level > 0){
67
+ const sibling = this.store.getSibling(location);
68
+ path.push(sibling.value);
69
+ location = this.store.getParentLocation(location);
77
70
  }
78
- this.size = BigInt(leaves.length);
79
- return Promise.resolve();
71
+ return new SiblingPath(path.length, path);
72
+ }
73
+ getLeafLocation(leafIndex) {
74
+ return this.leafLocations[leafIndex];
80
75
  }
81
76
  /**
82
- * Calculates root while adding leaves and nodes to the cache.
83
- * @param leaves - The leaves to append.
84
- * @returns Resulting root of the tree.
85
- */ async batchInsert(_leaves) {
86
- // If we have an even number of leaves, hash them all in pairs
87
- // Otherwise, store the final leaf to be shifted up to the next odd sized level
88
- let [layerWidth, nodeToShift] = _leaves.length & 1 ? [
89
- _leaves.length - 1,
90
- serializeToBuffer(_leaves[_leaves.length - 1])
91
- ] : [
92
- _leaves.length,
93
- Buffer.alloc(0)
94
- ];
95
- // Allocate this layer's leaves and init the next layer up
96
- let thisLayer = _leaves.slice(0, layerWidth).map((l)=>serializeToBuffer(l));
97
- let nextLayer = [];
98
- // Store the bottom level leaves
99
- thisLayer.forEach((leaf, i)=>this.storeNode(leaf, this.maxDepth, BigInt(i)));
100
- for(let i = 0; i < this.maxDepth; i++){
101
- for(let j = 0; j < layerWidth; j += 2){
102
- // Store the hash of each pair one layer up
103
- nextLayer[j / 2] = await this.hasher(serializeToBuffer(thisLayer[j]), serializeToBuffer(thisLayer[j + 1]));
104
- this.storeNode(nextLayer[j / 2], this.maxDepth - i - 1, BigInt(j >> 1));
105
- }
106
- layerWidth /= 2;
107
- if (layerWidth & 1) {
108
- if (nodeToShift.length) {
109
- // If the next layer has odd length, and we have a node that needs to be shifted up, add it here
110
- nextLayer.push(serializeToBuffer(nodeToShift));
111
- this.storeNode(nodeToShift, this.maxDepth - i - 1, BigInt(layerWidth * 2 >> 1));
112
- layerWidth += 1;
113
- nodeToShift = Buffer.alloc(0);
77
+ * Adds leaves and nodes to the store. Updates the leafLocations.
78
+ * @param leaves - The leaves of the tree.
79
+ */ buildTree() {
80
+ this.leafLocations = this.leaves.map((value, i)=>this.store.setLeaf(i, {
81
+ value,
82
+ leafIndex: i
83
+ }));
84
+ // Start with the leaves that are not compressed.
85
+ let toProcess = this.leafLocations.filter((_, i)=>!this.leaves[i].equals(this.valueToCompress));
86
+ if (!toProcess.length) {
87
+ // All leaves are compressed. Set empty root to the root.
88
+ this.store.setNode({
89
+ level: 0,
90
+ index: 0
91
+ }, {
92
+ value: this.emptyRoot
93
+ });
94
+ return;
95
+ }
96
+ const level = toProcess[0].level;
97
+ for(let i = level; i > 0; i--){
98
+ const toProcessNext = [];
99
+ for (const location of toProcess){
100
+ if (location.level !== i) {
101
+ toProcessNext.push(location);
102
+ continue;
103
+ }
104
+ const parentLocation = this.store.getParentLocation(location);
105
+ if (this.store.getNode(parentLocation)) {
106
+ continue;
107
+ }
108
+ const sibling = this.store.getSibling(location);
109
+ // If sibling is undefined, all its children are compressed.
110
+ const shouldShiftUp = !sibling || sibling.value.equals(this.valueToCompress);
111
+ if (shouldShiftUp) {
112
+ // The node becomes the parent if the sibling is a compressed leaf.
113
+ this.shiftNodeUp(location, parentLocation);
114
114
  } else {
115
- // If we don't have a node waiting to be shifted, store the next layer's final node to be shifted
116
- layerWidth -= 1;
117
- nodeToShift = nextLayer[layerWidth];
115
+ // Hash the value with the (right) sibling and update the parent node.
116
+ const node = this.store.getNode(location);
117
+ const parentValue = this.hasher(node.value, sibling.value);
118
+ this.store.setNode(parentLocation, {
119
+ value: parentValue
120
+ });
118
121
  }
122
+ // Add the parent location to be processed next.
123
+ toProcessNext.push(parentLocation);
124
+ }
125
+ toProcess = toProcessNext;
126
+ }
127
+ }
128
+ shiftNodeUp(from, to) {
129
+ // Collect all nodes that need to shift.
130
+ const nodesToShift = this.collectNodesToShift(from, to);
131
+ // Move all nodes to their new locations.
132
+ for (const { node, newLocation } of nodesToShift){
133
+ this.store.setNode(newLocation, node);
134
+ if (node.leafIndex !== undefined) {
135
+ this.leafLocations[node.leafIndex] = newLocation;
119
136
  }
120
- // reset the layers
121
- thisLayer = nextLayer;
122
- nextLayer = [];
123
137
  }
124
- // return the root
125
- return thisLayer[0];
126
138
  }
127
- storeNode(value, depth, index) {
128
- const key = indexToKeyHash(depth, index);
129
- this.cache[key] = value;
130
- this.valueCache[value.toString('hex')] = key;
139
+ collectNodesToShift(from, to) {
140
+ const node = this.store.getNode(from);
141
+ if (!node) {
142
+ return [];
143
+ }
144
+ let result = [
145
+ {
146
+ node,
147
+ newLocation: to
148
+ }
149
+ ];
150
+ // If not a leaf, collect its children.
151
+ if (node.leafIndex === undefined) {
152
+ const [leftChild, rightChild] = this.store.getChildLocations(from);
153
+ const [leftChildNew, rightChildNew] = this.store.getChildLocations(to);
154
+ result = result.concat(this.collectNodesToShift(leftChild, leftChildNew)).concat(this.collectNodesToShift(rightChild, rightChildNew));
155
+ }
156
+ return result;
131
157
  }
132
158
  }
@@ -12,8 +12,9 @@ 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];
18
19
  }
19
- //# sourceMappingURL=unbalanced_tree_store.d.ts.map
20
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidW5iYWxhbmNlZF90cmVlX3N0b3JlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHJlZXMvdW5iYWxhbmNlZF90cmVlX3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE1BQU0sV0FBVyxnQkFBZ0I7SUFDL0IsS0FBSyxFQUFFLE1BQU0sQ0FBQztJQUNkLEtBQUssRUFBRSxNQUFNLENBQUM7Q0FDZjtBQU9ELHFCQUFhLG1CQUFtQixDQUFDLENBQUM7O0lBSWhDLFlBQVksU0FBUyxFQUFFLE1BQU0sRUFFNUI7SUFFRCxPQUFPLENBQUMsU0FBUyxFQUFFLE1BQU0sRUFBRSxLQUFLLEVBQUUsQ0FBQyxHQUFHLGdCQUFnQixDQWVyRDtJQUVELE9BQU8sQ0FBQyxFQUFFLEtBQUssRUFBRSxLQUFLLEVBQUUsRUFBRSxnQkFBZ0IsRUFBRSxLQUFLLEVBQUUsQ0FBQyxRQVNuRDtJQUVELGlCQUFpQixDQUFDLEVBQUUsS0FBSyxFQUFFLEtBQUssRUFBRSxFQUFFLGdCQUFnQixHQUFHLGdCQUFnQixDQU10RTtJQUVELGtCQUFrQixDQUFDLEVBQUUsS0FBSyxFQUFFLEtBQUssRUFBRSxFQUFFLGdCQUFnQixHQUFHLGdCQUFnQixDQU12RTtJQUVELGlCQUFpQixDQUFDLEVBQUUsS0FBSyxFQUFFLEtBQUssRUFBRSxFQUFFLGdCQUFnQixHQUFHLENBQUMsZ0JBQWdCLEVBQUUsZ0JBQWdCLENBQUMsQ0FJ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,OAAO,IAAI,CAAC,GAAG,SAAS,CAEvB;IAED,SAAS,CAAC,QAAQ,EAAE,gBAAgB,GAAG,CAAC,GAAG,SAAS,CAGnD;IAED,UAAU,CAAC,QAAQ,EAAE,gBAAgB,GAAG,CAAC,GAAG,SAAS,CAGpD;IAED,WAAW,CAAC,QAAQ,EAAE,gBAAgB,GAAG,CAAC,CAAC,GAAG,SAAS,EAAE,CAAC,GAAG,SAAS,CAAC,CAGtE;CAKF"}
@@ -73,6 +73,12 @@ export class UnbalancedTreeStore {
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);
@@ -39,4 +39,4 @@ export interface TypedEventEmitter<TEventMap extends {
39
39
  removeListener<K extends keyof TEventMap>(event: K, listener: TEventMap[K]): this;
40
40
  removeAllListeners<K extends keyof TEventMap>(event: K): this;
41
41
  }
42
- //# sourceMappingURL=index.d.ts.map
42
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90eXBlcy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxnQ0FBZ0M7QUFDaEMsTUFBTSxNQUFNLFFBQVEsQ0FBQyxDQUFDLElBQUk7S0FDdkIsQ0FBQyxJQUFJLE1BQU0sQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLENBQUMsU0FBUyxRQUFRLEdBQUcsS0FBSyxHQUFHLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQyxDQUFDO0NBQzFELENBQUM7QUFFRixrQ0FBa0M7QUFDbEMsTUFBTSxNQUFNLFdBQVcsQ0FBQyxDQUFDLEl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TLE1BQU0sU0FBUyxFQUFFLEtBQUssRUFBRSxDQUFDLEVBQUUsUUFBUSxFQUFFLFNBQVMsQ0FBQyxDQUFDLENBQUMsR0FBRyxJQUFJLENBQUM7SUFDeEUsRUFBRSxDQUFDLENBQUMsU0FBUyxNQUFNLFNBQVMsRUFBRSxLQUFLLEVBQUUsQ0FBQyxFQUFFLFFBQVEsRUFBRSxTQUFTLENBQUMsQ0FBQyxDQUFDLEdBQUcsSUFBSSxDQUFDO0lBQ3RFLEdBQUcsQ0FBQyxDQUFDLFNBQVMsTUFBTSxTQUFTLEVBQUUsS0FBSyxFQUFFLENBQUMsRUFBRSxRQUFRLEVBQUUsU0FBUyxDQUFDLENBQUMsQ0FBQyxHQUFHLElBQUksQ0FBQztJQUN2RSxJQUFJLENBQUMsQ0FBQyxTQUFTLE1BQU0sU0FBUyxFQUFFLEtBQUssRUFBRSxDQUFDLEVBQUUsR0FBRyxJQUFJLEVBQUUsVUFBVSxDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLE9BQU8sQ0FBQztJQUN0RixjQUFjLENBQUMsQ0FBQyxTQUFTLE1BQU0sU0FBUyxFQUFFLEtBQUssRUFBRSxDQUFDLEVBQUUsUUFBUSxFQUFFLFNBQVMsQ0FBQyxDQUFDLENBQUMsR0FBRyxJQUFJLENBQUM7SUFDbEYsa0JBQWtCLENBQUMsQ0FBQyxTQUFTLE1BQU0sU0FBUyxFQUFFLEtBQUssRUFBRSxDQUFDLEdBQUcsSUFBSSxDQUFDO0NBRS9EIn0=
@@ -6,4 +6,4 @@
6
6
  * @api public
7
7
  */
8
8
  export declare function fileURLToPath(uri: string): string;
9
- //# sourceMappingURL=index.d.ts.map
9
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91cmwvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBbUJBOzs7Ozs7R0FNRztBQUVILHdCQUFnQixhQUFhLENBQUMsR0FBRyxFQUFFLE1BQU0sR0FBRyxNQUFNLENBNENqRCJ9
@@ -6,4 +6,4 @@ export declare function required<T>(value: T | undefined, errMsg?: string): T;
6
6
  * @param err - Error message to throw if x isn't met.
7
7
  */
8
8
  export declare function assert(x: any, err: string): asserts x;
9
- //# sourceMappingURL=index.d.ts.map
9
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy92YWxpZGF0aW9uL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLHlFQUF5RTtBQUN6RSx3QkFBZ0IsUUFBUSxDQUFDLENBQUMsRUFBRSxLQUFLLEVBQUUsQ0FBQyxHQUFHLFNBQVMsRUFBRSxNQUFNLENBQUMsRUFBRSxNQUFNLEdBQUcsQ0FBQyxDQUtwRTtBQUVEOzs7O0dBSUc7QUFDSCx3QkFBZ0IsTUFBTSxDQUFDLENBQUMsRUFBRSxHQUFHLEVBQUUsR0FBRyxFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsQ0FBQyxDQUlyRCJ9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/foundation",
3
- "version": "3.0.0-canary.a9708bd",
3
+ "version": "3.0.0-devnet.20251212",
4
4
  "type": "module",
5
5
  "main": "./dest/index.js",
6
6
  "types": "./dest/index.d.ts",
@@ -12,10 +12,30 @@
12
12
  "./async-map": "./dest/async-map/index.js",
13
13
  "./async-pool": "./dest/async-pool/index.js",
14
14
  "./bigint": "./dest/bigint/index.js",
15
+ "./branded-types": "./dest/branded-types/index.js",
15
16
  "./collection": "./dest/collection/index.js",
16
17
  "./config": "./dest/config/index.js",
17
- "./crypto": "./dest/crypto/index.js",
18
+ "./crypto/aes128": "./dest/crypto/aes128/index.js",
19
+ "./crypto/bls": "./dest/crypto/bls/index.js",
20
+ "./crypto/bls/bn254_keystore": "./dest/crypto/bls/bn254_keystore.js",
21
+ "./crypto/bn254": "./dest/crypto/bn254/index.js",
22
+ "./crypto/ecdsa": "./dest/crypto/ecdsa/index.js",
23
+ "./crypto/grumpkin": "./dest/crypto/grumpkin/index.js",
24
+ "./crypto/keccak": "./dest/crypto/keccak/index.js",
25
+ "./crypto/keys": "./dest/crypto/keys/index.js",
26
+ "./crypto/pedersen": "./dest/crypto/pedersen/index.js",
27
+ "./crypto/poseidon": "./dest/crypto/poseidon/index.js",
28
+ "./crypto/random": "./dest/crypto/random/index.js",
29
+ "./crypto/schnorr": "./dest/crypto/schnorr/index.js",
30
+ "./crypto/secp256k1": "./dest/crypto/secp256k1/index.js",
31
+ "./crypto/secp256k1-signer": "./dest/crypto/secp256k1-signer/index.js",
32
+ "./crypto/sha256": "./dest/crypto/sha256/index.js",
33
+ "./crypto/sha512": "./dest/crypto/sha512/index.js",
34
+ "./crypto/signature": "./dest/crypto/signature/index.js",
18
35
  "./crypto/sync": "./dest/crypto/sync/index.js",
36
+ "./curves/bn254": "./dest/curves/bn254/index.js",
37
+ "./curves/grumpkin": "./dest/curves/grumpkin/index.js",
38
+ "./curves/bls12": "./dest/curves/bls12/index.js",
19
39
  "./decorators": "./dest/decorators/index.js",
20
40
  "./error": "./dest/error/index.js",
21
41
  "./eth-address": "./dest/eth-address/index.js",
@@ -31,7 +51,6 @@
31
51
  "./iterable": "./dest/iterable/index.js",
32
52
  "./log": "./dest/log/index.js",
33
53
  "./mutex": "./dest/mutex/index.js",
34
- "./fields": "./dest/fields/index.js",
35
54
  "./retry": "./dest/retry/index.js",
36
55
  "./running-promise": "./dest/running-promise/index.js",
37
56
  "./serialize": "./dest/serialize/index.js",
@@ -47,6 +66,7 @@
47
66
  "./noir": "./dest/noir/index.js",
48
67
  "./testing": "./dest/testing/index.js",
49
68
  "./testing/files": "./dest/testing/files/index.js",
69
+ "./profiler": "./dest/profiler/index.js",
50
70
  "./array": "./dest/array/index.js",
51
71
  "./validation": "./dest/validation/index.js",
52
72
  "./promise": "./dest/promise/index.js",
@@ -55,8 +75,8 @@
55
75
  "./number": "./dest/number/index.js"
56
76
  },
57
77
  "scripts": {
58
- "build": "yarn clean && tsc -b",
59
- "build:dev": "tsc -b --watch",
78
+ "build": "yarn clean && ../scripts/tsc.sh",
79
+ "build:dev": "../scripts/tsc.sh --watch",
60
80
  "clean": "rm -rf ./dest .tsbuildinfo",
61
81
  "generate": "true",
62
82
  "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
@@ -102,9 +122,11 @@
102
122
  "testEnvironment": "../../foundation/src/jest/env.mjs"
103
123
  },
104
124
  "dependencies": {
105
- "@aztec/bb.js": "3.0.0-canary.a9708bd",
125
+ "@aztec/bb.js": "3.0.0-devnet.20251212",
106
126
  "@koa/cors": "^5.0.0",
107
127
  "@noble/curves": "=1.7.0",
128
+ "@noble/hashes": "^1.6.1",
129
+ "@scure/bip39": "^2.0.1",
108
130
  "bn.js": "^5.2.1",
109
131
  "colorette": "^2.0.20",
110
132
  "detect-node": "^2.1.0",
@@ -112,7 +134,7 @@
112
134
  "koa": "^2.16.1",
113
135
  "koa-bodyparser": "^4.4.0",
114
136
  "koa-compress": "^5.1.0",
115
- "koa-router": "^12.0.0",
137
+ "koa-router": "^13.1.1",
116
138
  "leveldown": "^6.1.1",
117
139
  "lodash.chunk": "^4.2.0",
118
140
  "lodash.clonedeepwith": "^4.5.0",
@@ -139,6 +161,7 @@
139
161
  "@types/node": "^22.15.17",
140
162
  "@types/pako": "^2.0.0",
141
163
  "@types/supertest": "^2.0.12",
164
+ "@typescript/native-preview": "7.0.0-dev.20251126.1",
142
165
  "comlink": "^4.4.1",
143
166
  "eslint": "^9.26.0",
144
167
  "eslint-config-prettier": "^10.1.5",
@@ -153,7 +176,7 @@
153
176
  "ts-node": "^10.9.1",
154
177
  "typescript": "^5.3.3",
155
178
  "typescript-eslint": "^8.32.1",
156
- "viem": "2.23.7"
179
+ "viem": "npm:@aztec/viem@2.38.2"
157
180
  },
158
181
  "files": [
159
182
  "dest",
@@ -42,22 +42,6 @@ export async function makeTupleAsync<T, N extends number>(length: N, fn: (i: num
42
42
  )) as Tuple<T, N>;
43
43
  }
44
44
 
45
- /**
46
- * Create an array over an integer range, filled with a function 'fn'. However, the latter half of the array are set to zeros.
47
- * see `makeTuple` above.
48
- * @param n - The number of integers.
49
- * @param fn - The generator function.
50
- * @returns The array of numbers.
51
- */
52
- export function makeHalfFullTuple<T, N extends number>(
53
- length: N,
54
- fn: (i: number) => T,
55
- offset = 0,
56
- makeEmpty: () => T,
57
- ) {
58
- return Array.from({ length }, (_: any, i: number) => (i < length / 2 ? fn(i + offset) : makeEmpty())) as Tuple<T, N>;
59
- }
60
-
61
45
  /**
62
46
  * Assert a member of an object is a certain length.
63
47
  * @param obj - An object.
@@ -0,0 +1,112 @@
1
+ import { z } from 'zod';
2
+
3
+ import type { CheckpointNumber } from './checkpoint_number.js';
4
+ import type { Branded } from './types.js';
5
+
6
+ /**
7
+ * A branded type representing an Aztec (L2) block number.
8
+ * Block numbers are sequential identifiers for blocks in the Aztec rollup chain.
9
+ *
10
+ * This is a nominal type backed by a number, but TypeScript will treat it as
11
+ * incompatible with plain numbers and other branded numeric types (like EpochNumber, SlotNumber, etc.).
12
+ *
13
+ * Note: This type should ONLY be used for Aztec L2 block numbers, NOT for Ethereum L1 block numbers.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const blockNumber = BlockNumber(100);
18
+ * const plainNumber: number = blockNumber; // OK - BlockNumber is assignable to number
19
+ * const blockFromNumber: BlockNumber = 100; // ERROR - number is not assignable to BlockNumber
20
+ * ```
21
+ */
22
+ export type BlockNumber = Branded<number, 'BlockNumber'>;
23
+
24
+ /**
25
+ * Creates a BlockNumber from a number.
26
+ * @param value - The block number (must be a non-negative integer)
27
+ * @returns The branded BlockNumber value
28
+ * @throws If the value is negative or not an integer
29
+ */
30
+ export function BlockNumber(value: number): BlockNumber {
31
+ if (!Number.isInteger(value)) {
32
+ throw new Error(`BlockNumber must be an integer, got ${value}`);
33
+ }
34
+ if (value < 0) {
35
+ throw new Error(`BlockNumber must be non-negative, got ${value}`);
36
+ }
37
+ return value as BlockNumber;
38
+ }
39
+
40
+ /**
41
+ * Creates a BlockNumber from a bigint.
42
+ * @param value - The block number as bigint (must be a non-negative integer within safe integer range)
43
+ * @returns The branded BlockNumber value
44
+ * @throws If the value is negative or exceeds Number.MAX_SAFE_INTEGER
45
+ */
46
+ BlockNumber.fromBigInt = function (value: bigint): BlockNumber {
47
+ if (value < 0n) {
48
+ throw new Error(`BlockNumber must be non-negative, got ${value}`);
49
+ }
50
+ if (value > BigInt(Number.MAX_SAFE_INTEGER)) {
51
+ throw new Error(`BlockNumber ${value} exceeds MAX_SAFE_INTEGER`);
52
+ }
53
+ return Number(value) as BlockNumber;
54
+ };
55
+
56
+ /**
57
+ * Creates a BlockNumber from a string.
58
+ * @param value - The block number as a string
59
+ * @returns The branded BlockNumber value
60
+ * @throws If the string cannot be parsed as a valid block number
61
+ */
62
+ BlockNumber.fromString = function (value: string): BlockNumber {
63
+ const parsed = parseInt(value, 10);
64
+ if (isNaN(parsed)) {
65
+ throw new Error(`Cannot parse BlockNumber from string: ${value}`);
66
+ }
67
+ return BlockNumber(parsed);
68
+ };
69
+
70
+ /**
71
+ * Converts a CheckpointNumber to a BlockNumber.
72
+ * This is used in checkpoint-based systems where checkpoint numbers align with block numbers.
73
+ * WARNING: This should only be used when you know the checkpoint number corresponds to a block number.
74
+ * @param value - The checkpoint number to convert
75
+ * @returns The corresponding BlockNumber
76
+ */
77
+ BlockNumber.fromCheckpointNumber = function (value: CheckpointNumber): BlockNumber {
78
+ return value as unknown as BlockNumber;
79
+ };
80
+
81
+ /**
82
+ * Type guard to check if a value is a valid BlockNumber.
83
+ * Note: At runtime, a BlockNumber is just a number, so this checks if the value
84
+ * is a non-negative integer.
85
+ */
86
+ BlockNumber.isValid = function (value: unknown): value is BlockNumber {
87
+ return typeof value === 'number' && Number.isInteger(value) && value >= 0;
88
+ };
89
+
90
+ /**
91
+ * The zero block value (genesis block).
92
+ */
93
+ BlockNumber.ZERO = BlockNumber(0);
94
+
95
+ function makeBlockNumberSchema(minValue: number) {
96
+ return z
97
+ .union([z.number(), z.bigint(), z.string()])
98
+ .pipe(z.coerce.number().int().min(minValue))
99
+ .transform(value => BlockNumber(value));
100
+ }
101
+
102
+ /**
103
+ * Zod schema for parsing and validating BlockNumber values.
104
+ * Accepts numbers, bigints, or strings and coerces them to BlockNumber.
105
+ */
106
+ export const BlockNumberSchema = makeBlockNumberSchema(0);
107
+
108
+ /**
109
+ * Zod schema for parsing and validating BlockNumber values that are strictly positive.
110
+ * Accepts numbers, bigints, or strings and coerces them to BlockNumber.
111
+ */
112
+ export const BlockNumberPositiveSchema = makeBlockNumberSchema(1);