@aztec/foundation 0.0.1-commit.b655e406 → 0.0.1-commit.c7c42ec

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 (434) 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 +2 -1
  5. package/dest/array/index.d.ts.map +1 -1
  6. package/dest/array/index.js +1 -0
  7. package/dest/array/sorted_array.d.ts +10 -0
  8. package/dest/array/sorted_array.d.ts.map +1 -0
  9. package/dest/array/sorted_array.js +106 -0
  10. package/dest/async-map/index.d.ts +1 -1
  11. package/dest/async-pool/index.d.ts +1 -1
  12. package/dest/bigint/index.d.ts +1 -1
  13. package/dest/bigint-buffer/index.d.ts +1 -1
  14. package/dest/branded-types/block_number.d.ts +53 -0
  15. package/dest/branded-types/block_number.d.ts.map +1 -0
  16. package/dest/branded-types/block_number.js +75 -0
  17. package/dest/branded-types/checkpoint_number.d.ts +46 -0
  18. package/dest/branded-types/checkpoint_number.d.ts.map +1 -0
  19. package/dest/branded-types/checkpoint_number.js +68 -0
  20. package/dest/branded-types/epoch.d.ts +42 -0
  21. package/dest/branded-types/epoch.d.ts.map +1 -0
  22. package/dest/branded-types/epoch.js +59 -0
  23. package/dest/branded-types/index.d.ts +6 -0
  24. package/dest/branded-types/index.d.ts.map +1 -0
  25. package/dest/branded-types/index.js +4 -0
  26. package/dest/branded-types/slot.d.ts +42 -0
  27. package/dest/branded-types/slot.d.ts.map +1 -0
  28. package/dest/branded-types/slot.js +59 -0
  29. package/dest/branded-types/types.d.ts +5 -0
  30. package/dest/branded-types/types.d.ts.map +1 -0
  31. package/dest/branded-types/types.js +1 -0
  32. package/dest/buffer/buffer16.d.ts +2 -5
  33. package/dest/buffer/buffer16.d.ts.map +1 -1
  34. package/dest/buffer/buffer16.js +1 -1
  35. package/dest/buffer/buffer32.d.ts +2 -5
  36. package/dest/buffer/buffer32.d.ts.map +1 -1
  37. package/dest/buffer/buffer32.js +1 -1
  38. package/dest/buffer/index.d.ts +1 -1
  39. package/dest/collection/array.d.ts +1 -1
  40. package/dest/collection/index.d.ts +1 -1
  41. package/dest/collection/object.d.ts +1 -1
  42. package/dest/committable/committable.d.ts +1 -1
  43. package/dest/committable/committable.d.ts.map +1 -1
  44. package/dest/committable/index.d.ts +1 -1
  45. package/dest/config/env_var.d.ts +2 -2
  46. package/dest/config/env_var.d.ts.map +1 -1
  47. package/dest/config/index.d.ts +10 -2
  48. package/dest/config/index.d.ts.map +1 -1
  49. package/dest/config/index.js +16 -2
  50. package/dest/config/network_config.d.ts +13 -1
  51. package/dest/config/network_config.d.ts.map +1 -1
  52. package/dest/config/network_config.js +3 -1
  53. package/dest/config/network_name.d.ts +1 -1
  54. package/dest/config/secret_value.d.ts +1 -1
  55. package/dest/config/secret_value.d.ts.map +1 -1
  56. package/dest/crypto/aes128/index.d.ts +1 -1
  57. package/dest/crypto/aes128/index.d.ts.map +1 -1
  58. package/dest/crypto/aes128/index.js +2 -6
  59. package/dest/crypto/bls/bn254_keystore.d.ts +15 -15
  60. package/dest/crypto/bls/bn254_keystore.d.ts.map +1 -1
  61. package/dest/crypto/bls/bn254_keystore.js +1 -1
  62. package/dest/crypto/bls/index.d.ts +1 -1
  63. package/dest/crypto/bls/index.js +1 -1
  64. package/dest/crypto/bn254/index.d.ts +35 -51
  65. package/dest/crypto/bn254/index.d.ts.map +1 -1
  66. package/dest/crypto/bn254/index.js +51 -137
  67. package/dest/crypto/ecdsa/index.d.ts +1 -1
  68. package/dest/crypto/ecdsa/index.d.ts.map +1 -1
  69. package/dest/crypto/ecdsa/index.js +4 -12
  70. package/dest/crypto/ecdsa/signature.d.ts +2 -11
  71. package/dest/crypto/ecdsa/signature.d.ts.map +1 -1
  72. package/dest/crypto/ecdsa/signature.js +2 -2
  73. package/dest/crypto/grumpkin/index.d.ts +4 -2
  74. package/dest/crypto/grumpkin/index.d.ts.map +1 -1
  75. package/dest/crypto/grumpkin/index.js +7 -16
  76. package/dest/crypto/keccak/index.d.ts +1 -1
  77. package/dest/crypto/keys/index.d.ts +2 -2
  78. package/dest/crypto/keys/index.d.ts.map +1 -1
  79. package/dest/crypto/keys/index.js +2 -4
  80. package/dest/crypto/pedersen/index.d.ts +1 -1
  81. package/dest/crypto/pedersen/pedersen.noble.d.ts +1 -1
  82. package/dest/crypto/pedersen/pedersen.wasm.d.ts +2 -2
  83. package/dest/crypto/pedersen/pedersen.wasm.d.ts.map +1 -1
  84. package/dest/crypto/pedersen/pedersen.wasm.js +4 -10
  85. package/dest/crypto/poseidon/index.d.ts +2 -2
  86. package/dest/crypto/poseidon/index.d.ts.map +1 -1
  87. package/dest/crypto/poseidon/index.js +6 -16
  88. package/dest/crypto/random/index.d.ts +1 -1
  89. package/dest/crypto/random/index.d.ts.map +1 -1
  90. package/dest/crypto/random/randomness_singleton.d.ts +1 -1
  91. package/dest/crypto/random/randomness_singleton.d.ts.map +1 -1
  92. package/dest/crypto/schnorr/index.d.ts +3 -2
  93. package/dest/crypto/schnorr/index.d.ts.map +1 -1
  94. package/dest/crypto/schnorr/index.js +4 -10
  95. package/dest/crypto/schnorr/signature.d.ts +2 -2
  96. package/dest/crypto/schnorr/signature.d.ts.map +1 -1
  97. package/dest/crypto/schnorr/signature.js +2 -2
  98. package/dest/crypto/secp256k1/index.d.ts +1 -1
  99. package/dest/crypto/secp256k1/index.d.ts.map +1 -1
  100. package/dest/crypto/secp256k1/index.js +3 -9
  101. package/dest/crypto/secp256k1-signer/index.d.ts +1 -1
  102. package/dest/crypto/secp256k1-signer/secp256k1_signer.d.ts +1 -1
  103. package/dest/crypto/secp256k1-signer/secp256k1_signer.d.ts.map +1 -1
  104. package/dest/crypto/secp256k1-signer/utils.d.ts +1 -1
  105. package/dest/crypto/secp256k1-signer/utils.d.ts.map +1 -1
  106. package/dest/crypto/serialize.d.ts +1 -1
  107. package/dest/crypto/sha256/index.d.ts +2 -2
  108. package/dest/crypto/sha256/index.d.ts.map +1 -1
  109. package/dest/crypto/sha256/index.js +1 -1
  110. package/dest/crypto/sha512/index.d.ts +3 -3
  111. package/dest/crypto/sha512/index.d.ts.map +1 -1
  112. package/dest/crypto/sha512/index.js +1 -1
  113. package/dest/crypto/signature/index.d.ts +2 -2
  114. package/dest/crypto/signature/index.d.ts.map +1 -1
  115. package/dest/crypto/sync/index.d.ts +1 -1
  116. package/dest/crypto/sync/index.js +1 -3
  117. package/dest/crypto/sync/pedersen/index.d.ts +2 -2
  118. package/dest/crypto/sync/pedersen/index.d.ts.map +1 -1
  119. package/dest/crypto/sync/pedersen/index.js +1 -1
  120. package/dest/crypto/sync/poseidon/index.d.ts +2 -2
  121. package/dest/crypto/sync/poseidon/index.d.ts.map +1 -1
  122. package/dest/crypto/sync/poseidon/index.js +1 -1
  123. package/dest/{fields/bls12_fields.d.ts → curves/bls12/field.d.ts} +3 -3
  124. package/dest/curves/bls12/field.d.ts.map +1 -0
  125. package/dest/{fields/bls12_fields.js → curves/bls12/field.js} +6 -6
  126. package/dest/curves/bls12/index.d.ts +3 -0
  127. package/dest/curves/bls12/index.d.ts.map +1 -0
  128. package/dest/curves/bls12/index.js +2 -0
  129. package/dest/{fields/bls12_point.d.ts → curves/bls12/point.d.ts} +4 -13
  130. package/dest/curves/bls12/point.d.ts.map +1 -0
  131. package/dest/{fields/bls12_point.js → curves/bls12/point.js} +7 -7
  132. package/dest/{fields/fields.d.ts → curves/bn254/field.d.ts} +16 -15
  133. package/dest/curves/bn254/field.d.ts.map +1 -0
  134. package/dest/{fields/fields.js → curves/bn254/field.js} +44 -47
  135. package/dest/curves/bn254/index.d.ts +3 -0
  136. package/dest/curves/bn254/index.d.ts.map +1 -0
  137. package/dest/curves/bn254/index.js +2 -0
  138. package/dest/curves/bn254/point.d.ts +54 -0
  139. package/dest/curves/bn254/point.d.ts.map +1 -0
  140. package/dest/curves/bn254/point.js +143 -0
  141. package/dest/curves/grumpkin/index.d.ts +10 -0
  142. package/dest/curves/grumpkin/index.d.ts.map +1 -0
  143. package/dest/curves/grumpkin/index.js +3 -0
  144. package/dest/{fields → curves/grumpkin}/point.d.ts +13 -13
  145. package/dest/curves/grumpkin/point.d.ts.map +1 -0
  146. package/dest/{fields → curves/grumpkin}/point.js +24 -7
  147. package/dest/decorators/index.d.ts +1 -1
  148. package/dest/decorators/memoize.d.ts +1 -1
  149. package/dest/decorators/memoize.d.ts.map +1 -1
  150. package/dest/error/index.d.ts +4 -4
  151. package/dest/error/index.d.ts.map +1 -1
  152. package/dest/eth-address/index.d.ts +12 -2
  153. package/dest/eth-address/index.d.ts.map +1 -1
  154. package/dest/eth-address/index.js +23 -1
  155. package/dest/eth-signature/eth_signature.d.ts +1 -4
  156. package/dest/eth-signature/eth_signature.d.ts.map +1 -1
  157. package/dest/eth-signature/index.d.ts +1 -1
  158. package/dest/fs/index.d.ts +1 -1
  159. package/dest/fs/run_in_dir.d.ts +1 -1
  160. package/dest/fs/try_rm_dir.d.ts +1 -1
  161. package/dest/iterable/all.d.ts +1 -1
  162. package/dest/iterable/filter.d.ts +1 -1
  163. package/dest/iterable/index.d.ts +1 -1
  164. package/dest/iterable/isAsyncIt.d.ts +1 -1
  165. package/dest/iterable/map.d.ts +1 -1
  166. package/dest/iterable/peek.d.ts +1 -1
  167. package/dest/iterable/sort.d.ts +1 -1
  168. package/dest/iterable/take.d.ts +1 -1
  169. package/dest/iterable/toArray.d.ts +1 -1
  170. package/dest/iterator/filter.d.ts +3 -0
  171. package/dest/iterator/filter.d.ts.map +1 -0
  172. package/dest/iterator/filter.js +7 -0
  173. package/dest/iterator/index.d.ts +2 -0
  174. package/dest/iterator/index.d.ts.map +1 -0
  175. package/dest/iterator/index.js +1 -0
  176. package/dest/json-rpc/client/fetch.d.ts +1 -1
  177. package/dest/json-rpc/client/index.d.ts +1 -1
  178. package/dest/json-rpc/client/safe_json_rpc_client.d.ts +1 -1
  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 +1 -1
  206. package/dest/log/noir_debug_log_util.d.ts +1 -1
  207. package/dest/log/pino-logger.d.ts +2 -2
  208. package/dest/message/index.d.ts +1 -1
  209. package/dest/message/index.d.ts.map +1 -1
  210. package/dest/mutex/index.d.ts +1 -1
  211. package/dest/mutex/index.d.ts.map +1 -1
  212. package/dest/mutex/mutex_database.d.ts +1 -1
  213. package/dest/noir/index.d.ts +1 -1
  214. package/dest/noir/noir_package_config.d.ts +9 -9
  215. package/dest/number/index.d.ts +1 -1
  216. package/dest/profiler/index.d.ts +1 -1
  217. package/dest/profiler/profiler.d.ts +1 -1
  218. package/dest/promise/index.d.ts +1 -1
  219. package/dest/promise/running-promise.d.ts +1 -1
  220. package/dest/promise/running-promise.d.ts.map +1 -1
  221. package/dest/promise/utils.d.ts +1 -1
  222. package/dest/queue/base_memory_queue.d.ts +1 -1
  223. package/dest/queue/base_memory_queue.d.ts.map +1 -1
  224. package/dest/queue/batch_queue.d.ts +1 -1
  225. package/dest/queue/batch_queue.d.ts.map +1 -1
  226. package/dest/queue/bounded_serial_queue.d.ts +1 -1
  227. package/dest/queue/bounded_serial_queue.d.ts.map +1 -1
  228. package/dest/queue/fifo_memory_queue.d.ts +1 -1
  229. package/dest/queue/fifo_memory_queue.d.ts.map +1 -1
  230. package/dest/queue/index.d.ts +1 -1
  231. package/dest/queue/priority_memory_queue.d.ts +1 -1
  232. package/dest/queue/priority_memory_queue.d.ts.map +1 -1
  233. package/dest/queue/priority_queue.d.ts +1 -1
  234. package/dest/queue/priority_queue.d.ts.map +1 -1
  235. package/dest/queue/semaphore.d.ts +1 -1
  236. package/dest/queue/semaphore.d.ts.map +1 -1
  237. package/dest/queue/serial_queue.d.ts +1 -1
  238. package/dest/queue/serial_queue.d.ts.map +1 -1
  239. package/dest/retry/index.d.ts +1 -1
  240. package/dest/running-promise/index.d.ts +1 -1
  241. package/dest/schemas/api.d.ts +1 -1
  242. package/dest/schemas/index.d.ts +1 -1
  243. package/dest/schemas/parse.d.ts +1 -1
  244. package/dest/schemas/schemas.d.ts +15 -17
  245. package/dest/schemas/schemas.d.ts.map +1 -1
  246. package/dest/schemas/schemas.js +14 -10
  247. package/dest/schemas/types.d.ts +31 -1
  248. package/dest/schemas/types.d.ts.map +1 -1
  249. package/dest/schemas/types.js +25 -1
  250. package/dest/schemas/utils.d.ts +4 -4
  251. package/dest/schemas/utils.d.ts.map +1 -1
  252. package/dest/schemas/utils.js +15 -5
  253. package/dest/serialize/buffer_reader.d.ts +1 -1
  254. package/dest/serialize/buffer_reader.d.ts.map +1 -1
  255. package/dest/serialize/field_reader.d.ts +2 -2
  256. package/dest/serialize/field_reader.d.ts.map +1 -1
  257. package/dest/serialize/field_reader.js +1 -1
  258. package/dest/serialize/free_funcs.d.ts +2 -2
  259. package/dest/serialize/free_funcs.d.ts.map +1 -1
  260. package/dest/serialize/free_funcs.js +1 -1
  261. package/dest/serialize/index.d.ts +1 -1
  262. package/dest/serialize/serialize.d.ts +2 -2
  263. package/dest/serialize/serialize.d.ts.map +1 -1
  264. package/dest/serialize/serialize.js +1 -1
  265. package/dest/serialize/type_registry.d.ts +1 -1
  266. package/dest/serialize/type_registry.d.ts.map +1 -1
  267. package/dest/serialize/types.d.ts +1 -1
  268. package/dest/sleep/index.d.ts +3 -1
  269. package/dest/sleep/index.d.ts.map +1 -1
  270. package/dest/sleep/index.js +4 -0
  271. package/dest/string/index.d.ts +1 -1
  272. package/dest/testing/files/index.d.ts +2 -1
  273. package/dest/testing/files/index.d.ts.map +1 -1
  274. package/dest/testing/files/index.js +1 -1
  275. package/dest/testing/formatting.d.ts +1 -1
  276. package/dest/testing/index.d.ts +1 -1
  277. package/dest/testing/port_allocator.d.ts +1 -1
  278. package/dest/testing/snapshot_serializer.d.ts +1 -1
  279. package/dest/testing/test_data.d.ts +1 -1
  280. package/dest/timer/date.d.ts +2 -1
  281. package/dest/timer/date.d.ts.map +1 -1
  282. package/dest/timer/date.js +3 -0
  283. package/dest/timer/elapsed.d.ts +1 -1
  284. package/dest/timer/index.d.ts +1 -1
  285. package/dest/timer/timeout.d.ts +1 -1
  286. package/dest/timer/timeout.d.ts.map +1 -1
  287. package/dest/timer/timer.d.ts +1 -1
  288. package/dest/timer/timer.d.ts.map +1 -1
  289. package/dest/transport/dispatch/create_dispatch_fn.d.ts +1 -1
  290. package/dest/transport/dispatch/create_dispatch_fn.d.ts.map +1 -1
  291. package/dest/transport/dispatch/create_dispatch_proxy.d.ts +1 -1
  292. package/dest/transport/dispatch/messages.d.ts +1 -1
  293. package/dest/transport/index.d.ts +1 -1
  294. package/dest/transport/interface/connector.d.ts +1 -1
  295. package/dest/transport/interface/listener.d.ts +1 -1
  296. package/dest/transport/interface/socket.d.ts +1 -1
  297. package/dest/transport/interface/transferable.d.ts +1 -1
  298. package/dest/transport/node/index.d.ts +1 -1
  299. package/dest/transport/node/node_connector.d.ts +1 -1
  300. package/dest/transport/node/node_connector.d.ts.map +1 -1
  301. package/dest/transport/node/node_connector_socket.d.ts +1 -1
  302. package/dest/transport/node/node_connector_socket.d.ts.map +1 -1
  303. package/dest/transport/node/node_listener.d.ts +1 -1
  304. package/dest/transport/node/node_listener.d.ts.map +1 -1
  305. package/dest/transport/node/node_listener_socket.d.ts +1 -1
  306. package/dest/transport/node/node_listener_socket.d.ts.map +1 -1
  307. package/dest/transport/transport_client.d.ts +1 -1
  308. package/dest/transport/transport_client.d.ts.map +1 -1
  309. package/dest/transport/transport_server.d.ts +1 -10
  310. package/dest/transport/transport_server.d.ts.map +1 -1
  311. package/dest/trees/balanced_merkle_tree.d.ts +22 -0
  312. package/dest/trees/balanced_merkle_tree.d.ts.map +1 -0
  313. package/dest/trees/balanced_merkle_tree.js +66 -0
  314. package/dest/trees/hasher.d.ts +1 -1
  315. package/dest/trees/index.d.ts +2 -1
  316. package/dest/trees/index.d.ts.map +1 -1
  317. package/dest/trees/index.js +1 -0
  318. package/dest/trees/indexed_merkle_tree.d.ts +1 -1
  319. package/dest/trees/indexed_merkle_tree.d.ts.map +1 -1
  320. package/dest/trees/indexed_merkle_tree.js +1 -1
  321. package/dest/trees/indexed_merkle_tree_calculator.d.ts +1 -1
  322. package/dest/trees/indexed_merkle_tree_calculator.d.ts.map +1 -1
  323. package/dest/trees/indexed_tree_leaf.d.ts +1 -1
  324. package/dest/trees/membership_witness.d.ts +3 -24
  325. package/dest/trees/membership_witness.d.ts.map +1 -1
  326. package/dest/trees/membership_witness.js +1 -1
  327. package/dest/trees/merkle_tree.d.ts +1 -1
  328. package/dest/trees/merkle_tree.d.ts.map +1 -1
  329. package/dest/trees/merkle_tree_calculator.d.ts +2 -12
  330. package/dest/trees/merkle_tree_calculator.d.ts.map +1 -1
  331. package/dest/trees/merkle_tree_calculator.js +1 -31
  332. package/dest/trees/sibling_path.d.ts +5 -39
  333. package/dest/trees/sibling_path.d.ts.map +1 -1
  334. package/dest/trees/sibling_path.js +2 -2
  335. package/dest/trees/unbalanced_merkle_tree.d.ts +5 -3
  336. package/dest/trees/unbalanced_merkle_tree.d.ts.map +1 -1
  337. package/dest/trees/unbalanced_merkle_tree.js +32 -9
  338. package/dest/trees/unbalanced_merkle_tree_calculator.d.ts +6 -5
  339. package/dest/trees/unbalanced_merkle_tree_calculator.d.ts.map +1 -1
  340. package/dest/trees/unbalanced_merkle_tree_calculator.js +36 -40
  341. package/dest/trees/unbalanced_tree_store.d.ts +1 -1
  342. package/dest/trees/unbalanced_tree_store.d.ts.map +1 -1
  343. package/dest/types/index.d.ts +3 -1
  344. package/dest/types/index.d.ts.map +1 -1
  345. package/dest/types/index.js +3 -0
  346. package/dest/url/index.d.ts +1 -1
  347. package/dest/validation/index.d.ts +1 -1
  348. package/package.json +28 -8
  349. package/src/array/array.ts +0 -16
  350. package/src/array/index.ts +1 -0
  351. package/src/array/sorted_array.ts +133 -0
  352. package/src/branded-types/block_number.ts +112 -0
  353. package/src/branded-types/checkpoint_number.ts +100 -0
  354. package/src/branded-types/epoch.ts +88 -0
  355. package/src/branded-types/index.ts +6 -0
  356. package/src/branded-types/slot.ts +88 -0
  357. package/src/branded-types/types.ts +2 -0
  358. package/src/buffer/buffer16.ts +2 -2
  359. package/src/buffer/buffer32.ts +2 -2
  360. package/src/config/env_var.ts +27 -7
  361. package/src/config/index.ts +20 -2
  362. package/src/config/network_config.ts +2 -0
  363. package/src/crypto/aes128/index.ts +2 -2
  364. package/src/crypto/bls/bn254_keystore.ts +1 -1
  365. package/src/crypto/bls/index.ts +1 -1
  366. package/src/crypto/bn254/index.ts +50 -156
  367. package/src/crypto/ecdsa/index.ts +4 -4
  368. package/src/crypto/ecdsa/signature.ts +2 -2
  369. package/src/crypto/grumpkin/index.ts +8 -6
  370. package/src/crypto/keys/index.ts +2 -2
  371. package/src/crypto/pedersen/pedersen.wasm.ts +4 -4
  372. package/src/crypto/poseidon/index.ts +6 -6
  373. package/src/crypto/schnorr/index.ts +5 -4
  374. package/src/crypto/schnorr/signature.ts +2 -2
  375. package/src/crypto/secp256k1/index.ts +3 -3
  376. package/src/crypto/sha256/index.ts +1 -1
  377. package/src/crypto/sha512/index.ts +1 -1
  378. package/src/crypto/signature/index.ts +1 -1
  379. package/src/crypto/sync/index.ts +1 -1
  380. package/src/crypto/sync/pedersen/index.ts +1 -1
  381. package/src/crypto/sync/poseidon/index.ts +1 -1
  382. package/src/{fields/bls12_fields.ts → curves/bls12/field.ts} +6 -6
  383. package/src/curves/bls12/index.ts +2 -0
  384. package/src/{fields/bls12_point.ts → curves/bls12/point.ts} +7 -7
  385. package/src/{fields/fields.ts → curves/bn254/field.ts} +49 -56
  386. package/src/curves/bn254/index.ts +2 -0
  387. package/src/curves/bn254/point.ts +170 -0
  388. package/src/curves/grumpkin/index.ts +11 -0
  389. package/src/{fields → curves/grumpkin}/point.ts +26 -7
  390. package/src/eth-address/index.ts +26 -1
  391. package/src/iterator/filter.ts +11 -0
  392. package/src/iterator/index.ts +1 -0
  393. package/src/schemas/schemas.ts +24 -13
  394. package/src/schemas/types.ts +33 -0
  395. package/src/schemas/utils.ts +21 -8
  396. package/src/serialize/field_reader.ts +1 -1
  397. package/src/serialize/free_funcs.ts +1 -1
  398. package/src/serialize/serialize.ts +1 -1
  399. package/src/sleep/index.ts +6 -0
  400. package/src/testing/files/index.ts +1 -1
  401. package/src/timer/date.ts +4 -0
  402. package/src/trees/balanced_merkle_tree.ts +84 -0
  403. package/src/trees/index.ts +1 -0
  404. package/src/trees/indexed_merkle_tree.ts +1 -1
  405. package/src/trees/membership_witness.ts +1 -1
  406. package/src/trees/merkle_tree_calculator.ts +1 -34
  407. package/src/trees/sibling_path.ts +2 -2
  408. package/src/trees/unbalanced_merkle_tree.ts +54 -6
  409. package/src/trees/unbalanced_merkle_tree_calculator.ts +34 -41
  410. package/src/types/index.ts +5 -0
  411. package/dest/crypto/bn254/bn254_utils.d.ts +0 -39
  412. package/dest/crypto/bn254/bn254_utils.d.ts.map +0 -1
  413. package/dest/crypto/bn254/bn254_utils.js +0 -56
  414. package/dest/crypto/index.d.ts +0 -17
  415. package/dest/crypto/index.d.ts.map +0 -1
  416. package/dest/crypto/index.js +0 -16
  417. package/dest/fields/bls12_fields.d.ts.map +0 -1
  418. package/dest/fields/bls12_point.d.ts.map +0 -1
  419. package/dest/fields/coordinate.d.ts +0 -66
  420. package/dest/fields/coordinate.d.ts.map +0 -1
  421. package/dest/fields/coordinate.js +0 -96
  422. package/dest/fields/fields.d.ts.map +0 -1
  423. package/dest/fields/index.d.ts +0 -6
  424. package/dest/fields/index.d.ts.map +0 -1
  425. package/dest/fields/index.js +0 -5
  426. package/dest/fields/point.d.ts.map +0 -1
  427. package/dest/index.d.ts +0 -30
  428. package/dest/index.d.ts.map +0 -1
  429. package/dest/index.js +0 -30
  430. package/src/crypto/bn254/bn254_utils.ts +0 -64
  431. package/src/crypto/index.ts +0 -16
  432. package/src/fields/coordinate.ts +0 -104
  433. package/src/fields/index.ts +0 -5
  434. package/src/index.ts +0 -30
@@ -1,170 +1,64 @@
1
- import {
2
- BN254_G1_GENERATOR,
3
- BN254_G2_GENERATOR,
4
- BarretenbergSync,
5
- type Bn254G1Point as BbApiBn254G1Point,
6
- type Bn254G2Point as BbApiBn254G2Point,
7
- } from '@aztec/bb.js';
8
-
9
- import { Fq, Fr } from '../../fields/fields.js';
1
+ import { Fr } from '../../curves/bn254/field.js';
2
+ import { Bn254G1Point, Bn254G2Point } from '../../curves/bn254/point.js';
10
3
 
11
4
  /**
12
- * BN254 G1 point using foundation field classes.
13
- * Represents a point on the BN254 elliptic curve in affine coordinates.
5
+ * BN254 utility functions for point operations.
6
+ * Provides compression, decompression, and public key generation for the BN254 curve.
7
+ * Uses the bb.js Barretenberg backend for point operations.
14
8
  */
15
- export class Bn254G1Point {
16
- constructor(
17
- public readonly x: Fq,
18
- public readonly y: Fq,
19
- ) {}
20
-
21
- private toBbApiPoint(): BbApiBn254G1Point {
22
- return {
23
- x: this.x.toBuffer(),
24
- y: this.y.toBuffer(),
25
- };
26
- }
27
-
28
- private static fromBbApiPoint(point: BbApiBn254G1Point): Bn254G1Point {
29
- return new Bn254G1Point(Fq.fromBuffer(Buffer.from(point.x)), Fq.fromBuffer(Buffer.from(point.y)));
30
- }
31
-
32
- async isOnCurve(): Promise<boolean> {
33
- await BarretenbergSync.initSingleton();
34
- const api = BarretenbergSync.getSingleton();
35
-
36
- const apiPoint = this.toBbApiPoint();
37
- const response = api.bn254G1IsOnCurve({ point: apiPoint });
38
- return response.isOnCurve;
39
- }
40
-
41
- /**
42
- * Get the generator point for BN254 G1, or perform scalar multiplication.
43
- * When called without arguments, returns the base generator point.
44
- * When called with a scalar, returns scalar * generator (useful for public key derivation).
45
- */
46
- static async generator(scalar?: Fr): Promise<Bn254G1Point> {
47
- if (!scalar) {
48
- return new Bn254G1Point(
49
- Fq.fromBuffer(Buffer.from(BN254_G1_GENERATOR.x)),
50
- Fq.fromBuffer(Buffer.from(BN254_G1_GENERATOR.y)),
51
- );
52
- }
53
-
54
- await BarretenbergSync.initSingleton();
55
- const api = BarretenbergSync.getSingleton();
56
-
57
- const response = api.bn254G1Mul({
58
- point: BN254_G1_GENERATOR,
59
- scalar: scalar.toBuffer(),
60
- });
61
-
62
- return Bn254G1Point.fromBbApiPoint(response.point);
63
- }
64
-
65
- /**
66
- * Decompress a BN254 G1 point from compressed form (32 bytes).
67
- * The compressed format encodes the x-coordinate and the sign bit of the y-coordinate
68
- * in the most significant bit.
69
- */
70
- static async fromCompressed(compressed: Buffer): Promise<Bn254G1Point> {
71
- await BarretenbergSync.initSingleton();
72
- const api = BarretenbergSync.getSingleton();
73
-
74
- const response = api.bn254G1FromCompressed({
75
- compressed: new Uint8Array(compressed),
76
- });
77
-
78
- return Bn254G1Point.fromBbApiPoint(response.point);
79
- }
80
9
 
81
- /**
82
- * Compress this BN254 G1 point to 32 bytes.
83
- * The compressed format encodes the x-coordinate and the sign bit of the y-coordinate
84
- * in the most significant bit (bit 255).
85
- */
86
- compress(): Buffer {
87
- const xBytes = this.x.toBuffer();
88
- // Get the least significant bit of y to determine the sign
89
- const yLsb = this.y.toBigInt() & 1n;
90
- // If y is odd, set the most significant bit (bit 255) of the output
91
- if (yLsb === 1n) {
92
- xBytes[0] |= 0x80;
93
- }
94
- return xBytes;
95
- }
10
+ /**
11
+ * Generate a compressed BN254 G1 public key from a private key.
12
+ *
13
+ * @param privateKeyHex - Private key as 0x-prefixed hex string
14
+ * @returns Compressed G1 point (32 bytes with sign bit in MSB)
15
+ */
16
+ export async function computeBn254G1PublicKeyCompressed(privateKeyHex: string): Promise<string> {
17
+ const sk = BigInt(privateKeyHex);
18
+ const skReduced = sk % Fr.MODULUS;
96
19
 
97
- equals(other: Bn254G1Point): boolean {
98
- return this.x.equals(other.x) && this.y.equals(other.y);
99
- }
20
+ // Generate G1 point on BN254 curve using bb.js
21
+ const scalar = Fr.fromString(skReduced.toString());
22
+ const pk1 = await Bn254G1Point.generator(scalar);
100
23
 
101
- toString(): string {
102
- return `Bn254G1Point(x: ${this.x.toString()}, y: ${this.y.toString()})`;
103
- }
24
+ // Compress the point using the primitive method
25
+ return '0x' + pk1.compress().toString('hex');
104
26
  }
105
27
 
106
28
  /**
107
- * BN254 G2 point using foundation field classes.
108
- * Represents a point on the BN254 G2 curve (twist curve) in affine coordinates.
109
- * G2 points use extension field coordinates (Fq2).
29
+ * Generate uncompressed BN254 G1 public key from a private key.
30
+ *
31
+ * @param privateKeyHex - Private key as 0x-prefixed hex string
32
+ * @returns G1 point in affine coordinates
110
33
  */
111
- export class Bn254G2Point {
112
- constructor(
113
- public readonly x: [Fq, Fq],
114
- public readonly y: [Fq, Fq],
115
- ) {}
116
-
117
- private toBbApiPoint(): BbApiBn254G2Point {
118
- return {
119
- x: [this.x[0].toBuffer(), this.x[1].toBuffer()],
120
- y: [this.y[0].toBuffer(), this.y[1].toBuffer()],
121
- };
122
- }
123
-
124
- private static fromBbApiPoint(point: BbApiBn254G2Point): Bn254G2Point {
125
- return new Bn254G2Point(
126
- [Fq.fromBuffer(Buffer.from(point.x[0])), Fq.fromBuffer(Buffer.from(point.x[1]))],
127
- [Fq.fromBuffer(Buffer.from(point.y[0])), Fq.fromBuffer(Buffer.from(point.y[1]))],
128
- );
129
- }
130
-
131
- /**
132
- * Get the generator point for BN254 G2, or perform scalar multiplication.
133
- * When called without arguments, returns the base generator point.
134
- * When called with a scalar, returns scalar * generator.
135
- */
136
- static async generator(scalar?: Fr): Promise<Bn254G2Point> {
137
- if (!scalar) {
138
- return new Bn254G2Point(
139
- [Fq.fromBuffer(Buffer.from(BN254_G2_GENERATOR.x[0])), Fq.fromBuffer(Buffer.from(BN254_G2_GENERATOR.x[1]))],
140
- [Fq.fromBuffer(Buffer.from(BN254_G2_GENERATOR.y[0])), Fq.fromBuffer(Buffer.from(BN254_G2_GENERATOR.y[1]))],
141
- );
142
- }
143
-
144
- await BarretenbergSync.initSingleton();
145
- const api = BarretenbergSync.getSingleton();
34
+ export async function computeBn254G1PublicKey(privateKeyHex: string): Promise<{ x: bigint; y: bigint }> {
35
+ const sk = BigInt(privateKeyHex);
36
+ const skReduced = sk % Fr.MODULUS;
146
37
 
147
- const response = api.bn254G2Mul({
148
- point: BN254_G2_GENERATOR as BbApiBn254G2Point,
149
- scalar: scalar.toBuffer(),
150
- });
38
+ const scalar = Fr.fromString(skReduced.toString());
39
+ const pk1 = await Bn254G1Point.generator(scalar);
151
40
 
152
- return Bn254G2Point.fromBbApiPoint(response.point);
153
- }
154
-
155
- equals(other: Bn254G2Point): boolean {
156
- return (
157
- this.x[0].equals(other.x[0]) &&
158
- this.x[1].equals(other.x[1]) &&
159
- this.y[0].equals(other.y[0]) &&
160
- this.y[1].equals(other.y[1])
161
- );
162
- }
163
-
164
- toString(): string {
165
- return `Bn254G2Point(x: (${this.x[0].toString()}, ${this.x[1].toString()}), y: (${this.y[0].toString()}, ${this.y[1].toString()}))`;
166
- }
41
+ return { x: pk1.x.toBigInt(), y: pk1.y.toBigInt() };
167
42
  }
168
43
 
169
- // Re-export BN254 point utility functions
170
- export { computeBn254G1PublicKeyCompressed, computeBn254G1PublicKey, computeBn254G2PublicKey } from './bn254_utils.js';
44
+ /**
45
+ * Generate BN254 G2 public key from a private key.
46
+ *
47
+ * @param privateKeyHex - Private key as 0x-prefixed hex string
48
+ * @returns G2 point in affine coordinates
49
+ */
50
+ export async function computeBn254G2PublicKey(privateKeyHex: string): Promise<{
51
+ x: { c0: bigint; c1: bigint };
52
+ y: { c0: bigint; c1: bigint };
53
+ }> {
54
+ const sk = BigInt(privateKeyHex);
55
+ const skReduced = sk % Fr.MODULUS;
56
+
57
+ const scalar = Fr.fromString(skReduced.toString());
58
+ const pk2 = await Bn254G2Point.generator(scalar);
59
+
60
+ return {
61
+ x: { c0: pk2.x[0].toBigInt(), c1: pk2.x[1].toBigInt() },
62
+ y: { c0: pk2.y[0].toBigInt(), c1: pk2.y[1].toBigInt() },
63
+ };
64
+ }
@@ -16,7 +16,7 @@ export class Ecdsa {
16
16
  * @returns A secp256k1 public key.
17
17
  */
18
18
  public async computePublicKey(privateKey: Buffer): Promise<Buffer> {
19
- await BarretenbergSync.initSingleton({ wasmPath: process.env.BB_WASM_PATH });
19
+ await BarretenbergSync.initSingleton();
20
20
  const api = BarretenbergSync.getSingleton();
21
21
  const response =
22
22
  this.curve === 'secp256r1'
@@ -32,7 +32,7 @@ export class Ecdsa {
32
32
  * @returns An ECDSA signature of the form (r, s, v).
33
33
  */
34
34
  public async constructSignature(msg: Uint8Array, privateKey: Buffer) {
35
- await BarretenbergSync.initSingleton({ wasmPath: process.env.BB_WASM_PATH });
35
+ await BarretenbergSync.initSingleton();
36
36
  const api = BarretenbergSync.getSingleton();
37
37
  const response =
38
38
  this.curve === 'secp256r1'
@@ -48,7 +48,7 @@ export class Ecdsa {
48
48
  * @returns The secp256k1 public key of the signer.
49
49
  */
50
50
  public async recoverPublicKey(msg: Uint8Array, sig: EcdsaSignature): Promise<Buffer> {
51
- await BarretenbergSync.initSingleton({ wasmPath: process.env.BB_WASM_PATH });
51
+ await BarretenbergSync.initSingleton();
52
52
  const api = BarretenbergSync.getSingleton();
53
53
  const response =
54
54
  this.curve === 'secp256r1'
@@ -65,7 +65,7 @@ export class Ecdsa {
65
65
  * @returns True or false.
66
66
  */
67
67
  public async verifySignature(msg: Uint8Array, pubKey: Buffer, sig: EcdsaSignature) {
68
- await BarretenbergSync.initSingleton({ wasmPath: process.env.BB_WASM_PATH });
68
+ await BarretenbergSync.initSingleton();
69
69
  const api = BarretenbergSync.getSingleton();
70
70
  const response =
71
71
  this.curve === 'secp256r1'
@@ -1,6 +1,6 @@
1
1
  import { toBufferBE } from '@aztec/foundation/bigint-buffer';
2
- import { randomBytes } from '@aztec/foundation/crypto';
3
- import { Fr } from '@aztec/foundation/fields';
2
+ import { randomBytes } from '@aztec/foundation/crypto/random';
3
+ import { Fr } from '@aztec/foundation/curves/bn254';
4
4
  import { mapTuple } from '@aztec/foundation/serialize';
5
5
 
6
6
  import type { Signature } from '../signature/index.js';
@@ -1,5 +1,7 @@
1
1
  import { BarretenbergSync } from '@aztec/bb.js';
2
- import { Fr, type GrumpkinScalar, Point } from '@aztec/foundation/fields';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
+ import type { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
4
+ import { Point } from '@aztec/foundation/curves/grumpkin';
3
5
 
4
6
  /**
5
7
  * Grumpkin elliptic curve operations.
@@ -20,7 +22,7 @@ export class Grumpkin {
20
22
  * @returns Result of the multiplication.
21
23
  */
22
24
  public static async mul(point: Point, scalar: GrumpkinScalar): Promise<Point> {
23
- await BarretenbergSync.initSingleton({ wasmPath: process.env.BB_WASM_PATH });
25
+ await BarretenbergSync.initSingleton();
24
26
  const api = BarretenbergSync.getSingleton();
25
27
  const response = api.grumpkinMul({
26
28
  point: { x: point.x.toBuffer(), y: point.y.toBuffer() },
@@ -36,7 +38,7 @@ export class Grumpkin {
36
38
  * @returns Result of the addition.
37
39
  */
38
40
  public static async add(a: Point, b: Point): Promise<Point> {
39
- await BarretenbergSync.initSingleton({ wasmPath: process.env.BB_WASM_PATH });
41
+ await BarretenbergSync.initSingleton();
40
42
  const api = BarretenbergSync.getSingleton();
41
43
  const response = api.grumpkinAdd({
42
44
  pointA: { x: a.x.toBuffer(), y: a.y.toBuffer() },
@@ -52,7 +54,7 @@ export class Grumpkin {
52
54
  * @returns Points multiplied by the scalar.
53
55
  */
54
56
  public static async batchMul(points: Point[], scalar: GrumpkinScalar) {
55
- await BarretenbergSync.initSingleton({ wasmPath: process.env.BB_WASM_PATH });
57
+ await BarretenbergSync.initSingleton();
56
58
  const api = BarretenbergSync.getSingleton();
57
59
  const response = api.grumpkinBatchMul({
58
60
  points: points.map(p => ({ x: p.x.toBuffer(), y: p.y.toBuffer() })),
@@ -67,7 +69,7 @@ export class Grumpkin {
67
69
  * @returns Random field element.
68
70
  */
69
71
  public static async getRandomFr(): Promise<Fr> {
70
- await BarretenbergSync.initSingleton({ wasmPath: process.env.BB_WASM_PATH });
72
+ await BarretenbergSync.initSingleton();
71
73
  const api = BarretenbergSync.getSingleton();
72
74
  const response = api.grumpkinGetRandomFr({ dummy: 0 });
73
75
  return Fr.fromBuffer(Buffer.from(response.value));
@@ -79,7 +81,7 @@ export class Grumpkin {
79
81
  * @returns Buffer representation of the field element.
80
82
  */
81
83
  public static async reduce512BufferToFr(uint512Buf: Buffer): Promise<Fr> {
82
- await BarretenbergSync.initSingleton({ wasmPath: process.env.BB_WASM_PATH });
84
+ await BarretenbergSync.initSingleton();
83
85
  const api = BarretenbergSync.getSingleton();
84
86
  const response = api.grumpkinReduce512({ input: uint512Buf });
85
87
  return Fr.fromBuffer(Buffer.from(response.value));
@@ -1,9 +1,9 @@
1
1
  import { BarretenbergSync } from '@aztec/bb.js';
2
2
 
3
- import { Fr } from '../../fields/fields.js';
3
+ import { Fr } from '../../curves/bn254/field.js';
4
4
 
5
5
  export async function vkAsFieldsMegaHonk(input: Buffer): Promise<Fr[]> {
6
- await BarretenbergSync.initSingleton({ wasmPath: process.env.BB_WASM_PATH });
6
+ await BarretenbergSync.initSingleton();
7
7
  const api = BarretenbergSync.getSingleton();
8
8
  const response = api.megaVkAsFields({ verificationKey: input });
9
9
  return response.fields.map(field => Fr.fromBuffer(Buffer.from(field)));
@@ -1,6 +1,6 @@
1
1
  import { BarretenbergSync } from '@aztec/bb.js';
2
2
 
3
- import { Fr } from '../../fields/fields.js';
3
+ import { Fr } from '../../curves/bn254/field.js';
4
4
  import { type Fieldable, serializeToFields } from '../../serialize/serialize.js';
5
5
 
6
6
  /**
@@ -12,7 +12,7 @@ export async function pedersenCommit(input: Buffer[], offset = 0) {
12
12
  throw new Error('All Pedersen Commit input buffers must be <= 32 bytes.');
13
13
  }
14
14
  input = input.map(i => (i.length < 32 ? Buffer.concat([Buffer.alloc(32 - i.length, 0), i]) : i));
15
- await BarretenbergSync.initSingleton({ wasmPath: process.env.BB_WASM_PATH });
15
+ await BarretenbergSync.initSingleton();
16
16
  const api = BarretenbergSync.getSingleton();
17
17
  const response = api.pedersenCommit({
18
18
  inputs: input,
@@ -29,7 +29,7 @@ export async function pedersenCommit(input: Buffer[], offset = 0) {
29
29
  */
30
30
  export async function pedersenHash(input: Fieldable[], index = 0): Promise<Fr> {
31
31
  const inputFields = serializeToFields(input);
32
- await BarretenbergSync.initSingleton({ wasmPath: process.env.BB_WASM_PATH });
32
+ await BarretenbergSync.initSingleton();
33
33
  const api = BarretenbergSync.getSingleton();
34
34
  const response = api.pedersenHash({
35
35
  inputs: inputFields.map(i => i.toBuffer()),
@@ -42,7 +42,7 @@ export async function pedersenHash(input: Fieldable[], index = 0): Promise<Fr> {
42
42
  * Create a pedersen hash from an arbitrary length buffer.
43
43
  */
44
44
  export async function pedersenHashBuffer(input: Buffer, index = 0) {
45
- await BarretenbergSync.initSingleton({ wasmPath: process.env.BB_WASM_PATH });
45
+ await BarretenbergSync.initSingleton();
46
46
  const api = BarretenbergSync.getSingleton();
47
47
  const response = api.pedersenHashBuffer({
48
48
  input,
@@ -1,6 +1,6 @@
1
1
  import { BarretenbergSync } from '@aztec/bb.js';
2
2
 
3
- import { Fr } from '../../fields/fields.js';
3
+ import { Fr } from '../../curves/bn254/field.js';
4
4
  import { type Fieldable, serializeToFields } from '../../serialize/serialize.js';
5
5
 
6
6
  /**
@@ -10,7 +10,7 @@ import { type Fieldable, serializeToFields } from '../../serialize/serialize.js'
10
10
  */
11
11
  export async function poseidon2Hash(input: Fieldable[]): Promise<Fr> {
12
12
  const inputFields = serializeToFields(input);
13
- await BarretenbergSync.initSingleton({ wasmPath: process.env.BB_WASM_PATH });
13
+ await BarretenbergSync.initSingleton();
14
14
  const api = BarretenbergSync.getSingleton();
15
15
  const response = api.poseidon2Hash({
16
16
  inputs: inputFields.map(i => i.toBuffer()),
@@ -27,7 +27,7 @@ export async function poseidon2Hash(input: Fieldable[]): Promise<Fr> {
27
27
  export async function poseidon2HashWithSeparator(input: Fieldable[], separator: number): Promise<Fr> {
28
28
  const inputFields = serializeToFields(input);
29
29
  inputFields.unshift(new Fr(separator));
30
- await BarretenbergSync.initSingleton({ wasmPath: process.env.BB_WASM_PATH });
30
+ await BarretenbergSync.initSingleton();
31
31
  const api = BarretenbergSync.getSingleton();
32
32
  const response = api.poseidon2Hash({
33
33
  inputs: inputFields.map(i => i.toBuffer()),
@@ -37,7 +37,7 @@ export async function poseidon2HashWithSeparator(input: Fieldable[], separator:
37
37
 
38
38
  export async function poseidon2HashAccumulate(input: Fieldable[]): Promise<Fr> {
39
39
  const inputFields = serializeToFields(input);
40
- await BarretenbergSync.initSingleton({ wasmPath: process.env.BB_WASM_PATH });
40
+ await BarretenbergSync.initSingleton();
41
41
  const api = BarretenbergSync.getSingleton();
42
42
  const response = api.poseidon2HashAccumulate({
43
43
  inputs: inputFields.map(i => i.toBuffer()),
@@ -54,7 +54,7 @@ export async function poseidon2Permutation(input: Fieldable[]): Promise<Fr[]> {
54
54
  const inputFields = serializeToFields(input);
55
55
  // We'd like this assertion but it's not possible to use it in the browser.
56
56
  // assert(input.length === 4, 'Input state must be of size 4');
57
- await BarretenbergSync.initSingleton({ wasmPath: process.env.BB_WASM_PATH });
57
+ await BarretenbergSync.initSingleton();
58
58
  const api = BarretenbergSync.getSingleton();
59
59
  const response = api.poseidon2Permutation({
60
60
  inputs: inputFields.map(i => i.toBuffer()),
@@ -75,7 +75,7 @@ export async function poseidon2HashBytes(input: Buffer): Promise<Fr> {
75
75
  inputFields.push(Fr.fromBuffer(fieldBytes));
76
76
  }
77
77
 
78
- await BarretenbergSync.initSingleton({ wasmPath: process.env.BB_WASM_PATH });
78
+ await BarretenbergSync.initSingleton();
79
79
  const api = BarretenbergSync.getSingleton();
80
80
  const response = api.poseidon2Hash({
81
81
  inputs: inputFields.map(i => i.toBuffer()),
@@ -1,5 +1,6 @@
1
1
  import { BarretenbergSync } from '@aztec/bb.js';
2
- import { type GrumpkinScalar, Point } from '@aztec/foundation/fields';
2
+ import type { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
3
+ import { Point } from '@aztec/foundation/curves/grumpkin';
3
4
 
4
5
  import { SchnorrSignature } from './signature.js';
5
6
 
@@ -15,7 +16,7 @@ export class Schnorr {
15
16
  * @returns A grumpkin public key.
16
17
  */
17
18
  public async computePublicKey(privateKey: GrumpkinScalar): Promise<Point> {
18
- await BarretenbergSync.initSingleton({ wasmPath: process.env.BB_WASM_PATH });
19
+ await BarretenbergSync.initSingleton();
19
20
  const api = BarretenbergSync.getSingleton();
20
21
  const response = api.schnorrComputePublicKey({ privateKey: privateKey.toBuffer() });
21
22
  return Point.fromBuffer(Buffer.concat([Buffer.from(response.publicKey.x), Buffer.from(response.publicKey.y)]));
@@ -28,7 +29,7 @@ export class Schnorr {
28
29
  * @returns A Schnorr signature of the form (s, e).
29
30
  */
30
31
  public async constructSignature(msg: Uint8Array, privateKey: GrumpkinScalar) {
31
- await BarretenbergSync.initSingleton({ wasmPath: process.env.BB_WASM_PATH });
32
+ await BarretenbergSync.initSingleton();
32
33
  const api = BarretenbergSync.getSingleton();
33
34
  const response = api.schnorrConstructSignature({
34
35
  message: msg,
@@ -45,7 +46,7 @@ export class Schnorr {
45
46
  * @returns True or false.
46
47
  */
47
48
  public async verifySignature(msg: Uint8Array, pubKey: Point, sig: SchnorrSignature) {
48
- await BarretenbergSync.initSingleton({ wasmPath: process.env.BB_WASM_PATH });
49
+ await BarretenbergSync.initSingleton();
49
50
  const api = BarretenbergSync.getSingleton();
50
51
  const response = api.schnorrVerifySignature({
51
52
  message: msg,
@@ -1,5 +1,5 @@
1
- import { randomBytes } from '@aztec/foundation/crypto';
2
- import { Fr } from '@aztec/foundation/fields';
1
+ import { randomBytes } from '@aztec/foundation/crypto/random';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import { BufferReader, mapTuple } from '@aztec/foundation/serialize';
4
4
 
5
5
  import type { Signature } from '../signature/index.js';
@@ -27,7 +27,7 @@ export class Secp256k1 {
27
27
  * @returns Result of the multiplication.
28
28
  */
29
29
  public async mul(point: Uint8Array, scalar: Uint8Array) {
30
- await BarretenbergSync.initSingleton({ wasmPath: process.env.BB_WASM_PATH });
30
+ await BarretenbergSync.initSingleton();
31
31
  const api = BarretenbergSync.getSingleton();
32
32
  const response = api.secp256k1Mul({
33
33
  point: { x: point.subarray(0, 32), y: point.subarray(32, 64) },
@@ -41,7 +41,7 @@ export class Secp256k1 {
41
41
  * @returns Random field element.
42
42
  */
43
43
  public async getRandomFr() {
44
- await BarretenbergSync.initSingleton({ wasmPath: process.env.BB_WASM_PATH });
44
+ await BarretenbergSync.initSingleton();
45
45
  const api = BarretenbergSync.getSingleton();
46
46
  const response = api.secp256k1GetRandomFr({ dummy: 0 });
47
47
  return Buffer.from(response.value);
@@ -53,7 +53,7 @@ export class Secp256k1 {
53
53
  * @returns Buffer representation of the field element.
54
54
  */
55
55
  public async reduce512BufferToFr(uint512Buf: Buffer) {
56
- await BarretenbergSync.initSingleton({ wasmPath: process.env.BB_WASM_PATH });
56
+ await BarretenbergSync.initSingleton();
57
57
  const api = BarretenbergSync.getSingleton();
58
58
  const response = api.secp256k1Reduce512({ input: uint512Buf });
59
59
  return Buffer.from(response.value);
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable camelcase */
2
2
  import { default as hash } from 'hash.js';
3
3
 
4
- import { Fr } from '../../fields/fields.js';
4
+ import { Fr } from '../../curves/bn254/field.js';
5
5
  import { truncateAndPad } from '../../serialize/free_funcs.js';
6
6
  import { type Bufferable, serializeToBuffer } from '../../serialize/serialize.js';
7
7
  import type { Hasher } from '../../trees/hasher.js';
@@ -1,6 +1,6 @@
1
1
  import { default as hash } from 'hash.js';
2
2
 
3
- import { GrumpkinScalar } from '../../fields/fields.js';
3
+ import { GrumpkinScalar } from '../../curves/grumpkin/index.js';
4
4
  import { type Bufferable, serializeToBuffer } from '../../serialize/serialize.js';
5
5
 
6
6
  export const sha512 = (data: Buffer) => Buffer.from(hash.sha512().update(data).digest());
@@ -1,4 +1,4 @@
1
- import type { Fr } from '@aztec/foundation/fields';
1
+ import type { Fr } from '@aztec/foundation/curves/bn254';
2
2
 
3
3
  /**
4
4
  * Interface to represent a signature.
@@ -3,4 +3,4 @@ import { BarretenbergSync } from '@aztec/bb.js';
3
3
  export * from './poseidon/index.js';
4
4
  export * from './pedersen/index.js';
5
5
 
6
- await BarretenbergSync.initSingleton({ wasmPath: process.env.BB_WASM_PATH });
6
+ await BarretenbergSync.initSingleton();
@@ -1,6 +1,6 @@
1
1
  import { BarretenbergSync } from '@aztec/bb.js';
2
2
 
3
- import { Fr } from '../../../fields/fields.js';
3
+ import { Fr } from '../../../curves/bn254/field.js';
4
4
  import { type Fieldable, serializeToFields } from '../../../serialize/serialize.js';
5
5
 
6
6
  /**
@@ -1,6 +1,6 @@
1
1
  import { BarretenbergSync } from '@aztec/bb.js';
2
2
 
3
- import { Fr } from '../../../fields/fields.js';
3
+ import { Fr } from '../../../curves/bn254/field.js';
4
4
  import { type Fieldable, serializeToFields } from '../../../serialize/serialize.js';
5
5
 
6
6
  /**
@@ -2,12 +2,12 @@
2
2
  import { bls12_381 } from '@noble/curves/bls12-381';
3
3
  import { inspect } from 'util';
4
4
 
5
- import { toBigIntBE, toBufferBE } from '../bigint-buffer/index.js';
6
- import { randomBytes } from '../crypto/random/index.js';
7
- import { hexSchemaFor } from '../schemas/utils.js';
8
- import { BufferReader } from '../serialize/buffer_reader.js';
9
- import { TypeRegistry } from '../serialize/type_registry.js';
10
- import { Fr } from './fields.js';
5
+ import { toBigIntBE, toBufferBE } from '../../bigint-buffer/index.js';
6
+ import { randomBytes } from '../../crypto/random/index.js';
7
+ import { hexSchemaFor } from '../../schemas/utils.js';
8
+ import { BufferReader } from '../../serialize/buffer_reader.js';
9
+ import { TypeRegistry } from '../../serialize/type_registry.js';
10
+ import { Fr } from '../bn254/field.js';
11
11
 
12
12
  /**
13
13
  * Represents a field derived from BLS12Field.
@@ -0,0 +1,2 @@
1
+ export * from './field.js';
2
+ export * from './point.js';
@@ -3,13 +3,13 @@ import type { ProjPointType } from '@noble/curves/abstract/weierstrass';
3
3
  import { bls12_381 } from '@noble/curves/bls12-381';
4
4
  import { inspect } from 'util';
5
5
 
6
- import { toBufferBE } from '../bigint-buffer/index.js';
7
- import { randomBoolean } from '../crypto/random/index.js';
8
- import { hexSchemaFor } from '../schemas/utils.js';
9
- import { BufferReader, serializeToBuffer } from '../serialize/index.js';
10
- import { bufferToHex, hexToBuffer } from '../string/index.js';
11
- import { BLS12Fq, BLS12Fr } from './bls12_fields.js';
12
- import { Fr } from './fields.js';
6
+ import { toBufferBE } from '../../bigint-buffer/index.js';
7
+ import { randomBoolean } from '../../crypto/random/index.js';
8
+ import { hexSchemaFor } from '../../schemas/utils.js';
9
+ import { BufferReader, serializeToBuffer } from '../../serialize/index.js';
10
+ import { bufferToHex, hexToBuffer } from '../../string/index.js';
11
+ import { Fr } from '../bn254/field.js';
12
+ import { BLS12Fq, BLS12Fr } from './field.js';
13
13
 
14
14
  /**
15
15
  * Represents a Point on an elliptic curve with x and y coordinates.