@aztec/pxe 0.0.0-test.1 → 0.0.1-commit.03f7ef2

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 (402) hide show
  1. package/README.md +5 -5
  2. package/dest/bin/check_oracle_version.d.ts +2 -0
  3. package/dest/bin/check_oracle_version.d.ts.map +1 -0
  4. package/dest/bin/check_oracle_version.js +129 -0
  5. package/dest/block_synchronizer/block_synchronizer.d.ts +39 -0
  6. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -0
  7. package/dest/{synchronizer/synchronizer.js → block_synchronizer/block_synchronizer.js} +36 -32
  8. package/dest/block_synchronizer/index.d.ts +2 -0
  9. package/dest/block_synchronizer/index.d.ts.map +1 -0
  10. package/dest/block_synchronizer/index.js +1 -0
  11. package/dest/config/index.d.ts +11 -24
  12. package/dest/config/index.d.ts.map +1 -1
  13. package/dest/config/index.js +18 -33
  14. package/dest/config/package_info.d.ts +1 -1
  15. package/dest/config/package_info.js +1 -1
  16. package/dest/contract_function_simulator/contract_function_simulator.d.ts +83 -0
  17. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -0
  18. package/dest/contract_function_simulator/contract_function_simulator.js +325 -0
  19. package/dest/contract_function_simulator/execution_note_cache.d.ts +95 -0
  20. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -0
  21. package/dest/contract_function_simulator/execution_note_cache.js +191 -0
  22. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +16 -0
  23. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -0
  24. package/dest/contract_function_simulator/execution_tagging_index_cache.js +26 -0
  25. package/dest/contract_function_simulator/hashed_values_cache.d.ts +28 -0
  26. package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -0
  27. package/dest/contract_function_simulator/hashed_values_cache.js +36 -0
  28. package/dest/contract_function_simulator/index.d.ts +14 -0
  29. package/dest/contract_function_simulator/index.d.ts.map +1 -0
  30. package/dest/contract_function_simulator/index.js +12 -0
  31. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +20 -0
  32. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -0
  33. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +37 -0
  34. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +16 -0
  35. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -0
  36. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +26 -0
  37. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +17 -0
  38. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -0
  39. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +65 -0
  40. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +24 -0
  41. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -0
  42. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +51 -0
  43. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +22 -0
  44. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -0
  45. package/dest/contract_function_simulator/noir-structs/utility_context.js +33 -0
  46. package/dest/contract_function_simulator/oracle/index.d.ts +14 -0
  47. package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -0
  48. package/dest/contract_function_simulator/oracle/index.js +2 -0
  49. package/dest/contract_function_simulator/oracle/interfaces.d.ts +103 -0
  50. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -0
  51. package/dest/contract_function_simulator/oracle/interfaces.js +4 -0
  52. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +17 -0
  53. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -0
  54. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +24 -0
  55. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +28 -0
  56. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -0
  57. package/dest/contract_function_simulator/oracle/note_packing_utils.js +54 -0
  58. package/dest/contract_function_simulator/oracle/oracle.d.ts +58 -0
  59. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -0
  60. package/dest/contract_function_simulator/oracle/oracle.js +345 -0
  61. package/dest/contract_function_simulator/oracle/private_execution.d.ts +47 -0
  62. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -0
  63. package/dest/contract_function_simulator/oracle/private_execution.js +123 -0
  64. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +240 -0
  65. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -0
  66. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +439 -0
  67. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +195 -0
  68. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -0
  69. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +372 -0
  70. package/dest/contract_function_simulator/pick_notes.d.ts +85 -0
  71. package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -0
  72. package/dest/contract_function_simulator/pick_notes.js +51 -0
  73. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +6 -0
  74. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -0
  75. package/dest/contract_function_simulator/proxied_contract_data_source.js +80 -0
  76. package/dest/contract_function_simulator/proxied_node.d.ts +9 -0
  77. package/dest/contract_function_simulator/proxied_node.d.ts.map +1 -0
  78. package/dest/contract_function_simulator/proxied_node.js +27 -0
  79. package/dest/debug/pxe_debug_utils.d.ts +31 -0
  80. package/dest/debug/pxe_debug_utils.d.ts.map +1 -0
  81. package/dest/debug/pxe_debug_utils.js +37 -0
  82. package/dest/entrypoints/client/bundle/index.d.ts +4 -3
  83. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  84. package/dest/entrypoints/client/bundle/index.js +2 -2
  85. package/dest/entrypoints/client/bundle/utils.d.ts +10 -10
  86. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  87. package/dest/entrypoints/client/bundle/utils.js +18 -12
  88. package/dest/entrypoints/client/lazy/index.d.ts +4 -3
  89. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  90. package/dest/entrypoints/client/lazy/index.js +2 -2
  91. package/dest/entrypoints/client/lazy/utils.d.ts +9 -9
  92. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  93. package/dest/entrypoints/client/lazy/utils.js +17 -11
  94. package/dest/entrypoints/pxe_creation_options.d.ts +16 -0
  95. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -0
  96. package/dest/entrypoints/server/index.d.ts +6 -4
  97. package/dest/entrypoints/server/index.d.ts.map +1 -1
  98. package/dest/entrypoints/server/index.js +4 -3
  99. package/dest/entrypoints/server/utils.d.ts +8 -16
  100. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  101. package/dest/entrypoints/server/utils.js +31 -36
  102. package/dest/error_enriching.d.ts +11 -0
  103. package/dest/error_enriching.d.ts.map +1 -0
  104. package/dest/{pxe_service/error_enriching.js → error_enriching.js} +26 -18
  105. package/dest/events/event_service.d.ts +15 -0
  106. package/dest/events/event_service.d.ts.map +1 -0
  107. package/dest/events/event_service.js +47 -0
  108. package/dest/events/index.d.ts +2 -0
  109. package/dest/events/index.d.ts.map +1 -0
  110. package/dest/events/index.js +1 -0
  111. package/dest/events/private_event_filter_validator.d.ts +9 -0
  112. package/dest/events/private_event_filter_validator.d.ts.map +1 -0
  113. package/dest/events/private_event_filter_validator.js +39 -0
  114. package/dest/logs/log_service.d.ts +43 -0
  115. package/dest/logs/log_service.d.ts.map +1 -0
  116. package/dest/logs/log_service.js +239 -0
  117. package/dest/notes/index.d.ts +2 -0
  118. package/dest/notes/index.d.ts.map +1 -0
  119. package/dest/notes/index.js +1 -0
  120. package/dest/notes/note_service.d.ts +48 -0
  121. package/dest/notes/note_service.d.ts.map +1 -0
  122. package/dest/notes/note_service.js +152 -0
  123. package/dest/oracle_version.d.ts +3 -0
  124. package/dest/oracle_version.d.ts.map +1 -0
  125. package/dest/oracle_version.js +10 -0
  126. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +28 -0
  127. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -0
  128. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.js +271 -0
  129. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +4 -0
  130. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +1 -0
  131. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.js +41 -0
  132. package/dest/private_kernel/hints/index.d.ts +3 -0
  133. package/dest/private_kernel/hints/index.d.ts.map +1 -0
  134. package/dest/{kernel_prover → private_kernel}/hints/index.js +1 -0
  135. package/dest/private_kernel/index.d.ts +3 -0
  136. package/dest/private_kernel/index.d.ts.map +1 -0
  137. package/dest/private_kernel/index.js +2 -0
  138. package/dest/private_kernel/private_kernel_execution_prover.d.ts +44 -0
  139. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -0
  140. package/dest/private_kernel/private_kernel_execution_prover.js +286 -0
  141. package/dest/private_kernel/private_kernel_oracle.d.ts +63 -0
  142. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -0
  143. package/dest/private_kernel/private_kernel_oracle.js +4 -0
  144. package/dest/private_kernel/private_kernel_oracle_impl.d.ts +46 -0
  145. package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -0
  146. package/dest/{kernel_oracle/index.js → private_kernel/private_kernel_oracle_impl.js} +19 -9
  147. package/dest/public_storage/public_storage_service.d.ts +24 -0
  148. package/dest/public_storage/public_storage_service.d.ts.map +1 -0
  149. package/dest/public_storage/public_storage_service.js +26 -0
  150. package/dest/pxe.d.ts +231 -0
  151. package/dest/pxe.d.ts.map +1 -0
  152. package/dest/pxe.js +756 -0
  153. package/dest/storage/address_data_provider/address_data_provider.d.ts +2 -4
  154. package/dest/storage/address_data_provider/address_data_provider.d.ts.map +1 -1
  155. package/dest/storage/address_data_provider/address_data_provider.js +0 -3
  156. package/dest/storage/address_data_provider/index.d.ts +1 -1
  157. package/dest/storage/anchor_block_data_provider/anchor_block_data_provider.d.ts +9 -0
  158. package/dest/storage/anchor_block_data_provider/anchor_block_data_provider.d.ts.map +1 -0
  159. package/dest/storage/{sync_data_provider/sync_data_provider.js → anchor_block_data_provider/anchor_block_data_provider.js} +2 -12
  160. package/dest/storage/anchor_block_data_provider/index.d.ts +2 -0
  161. package/dest/storage/anchor_block_data_provider/index.d.ts.map +1 -0
  162. package/dest/storage/anchor_block_data_provider/index.js +1 -0
  163. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +48 -7
  164. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +1 -1
  165. package/dest/storage/capsule_data_provider/capsule_data_provider.js +117 -28
  166. package/dest/storage/capsule_data_provider/index.d.ts +1 -1
  167. package/dest/storage/contract_data_provider/contract_data_provider.d.ts +16 -59
  168. package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +1 -1
  169. package/dest/storage/contract_data_provider/contract_data_provider.js +121 -80
  170. package/dest/storage/contract_data_provider/index.d.ts +1 -2
  171. package/dest/storage/contract_data_provider/index.d.ts.map +1 -1
  172. package/dest/storage/contract_data_provider/index.js +0 -1
  173. package/dest/storage/contract_data_provider/private_functions_tree.d.ts +3 -42
  174. package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +1 -1
  175. package/dest/storage/contract_data_provider/private_functions_tree.js +10 -62
  176. package/dest/storage/index.d.ts +4 -5
  177. package/dest/storage/index.d.ts.map +1 -1
  178. package/dest/storage/index.js +3 -4
  179. package/dest/storage/metadata.d.ts +2 -0
  180. package/dest/storage/metadata.d.ts.map +1 -0
  181. package/dest/storage/metadata.js +1 -0
  182. package/dest/storage/note_data_provider/index.d.ts +2 -2
  183. package/dest/storage/note_data_provider/index.d.ts.map +1 -1
  184. package/dest/storage/note_data_provider/index.js +1 -1
  185. package/dest/storage/note_data_provider/note_data_provider.d.ts +75 -11
  186. package/dest/storage/note_data_provider/note_data_provider.d.ts.map +1 -1
  187. package/dest/storage/note_data_provider/note_data_provider.js +155 -82
  188. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +51 -0
  189. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +1 -0
  190. package/dest/storage/private_event_data_provider/private_event_data_provider.js +115 -0
  191. package/dest/storage/tagging_data_provider/index.d.ts +3 -2
  192. package/dest/storage/tagging_data_provider/index.d.ts.map +1 -1
  193. package/dest/storage/tagging_data_provider/index.js +2 -1
  194. package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.d.ts +31 -0
  195. package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.d.ts.map +1 -0
  196. package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.js +65 -0
  197. package/dest/storage/tagging_data_provider/sender_tagging_data_provider.d.ts +67 -0
  198. package/dest/storage/tagging_data_provider/sender_tagging_data_provider.d.ts.map +1 -0
  199. package/dest/storage/tagging_data_provider/sender_tagging_data_provider.js +196 -0
  200. package/dest/tagging/constants.d.ts +2 -0
  201. package/dest/tagging/constants.d.ts.map +1 -0
  202. package/dest/tagging/constants.js +3 -0
  203. package/dest/tagging/index.d.ts +5 -0
  204. package/dest/tagging/index.d.ts.map +1 -0
  205. package/dest/tagging/index.js +3 -0
  206. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +14 -0
  207. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -0
  208. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +99 -0
  209. package/dest/tagging/recipient_sync/new_recipient_tagging_data_provider.d.ts +21 -0
  210. package/dest/tagging/recipient_sync/new_recipient_tagging_data_provider.d.ts.map +1 -0
  211. package/dest/tagging/recipient_sync/new_recipient_tagging_data_provider.js +42 -0
  212. package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts +12 -0
  213. package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts.map +1 -0
  214. package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +20 -0
  215. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +14 -0
  216. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -0
  217. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +29 -0
  218. package/dest/tagging/sync/sync_sender_tagging_indexes.d.ts +21 -0
  219. package/dest/tagging/sync/sync_sender_tagging_indexes.d.ts.map +1 -0
  220. package/dest/tagging/sync/sync_sender_tagging_indexes.js +89 -0
  221. package/dest/tagging/sync/utils/get_status_change_of_pending.d.ts +11 -0
  222. package/dest/tagging/sync/utils/get_status_change_of_pending.d.ts.map +1 -0
  223. package/dest/tagging/sync/utils/get_status_change_of_pending.js +32 -0
  224. package/dest/tagging/sync/utils/load_and_store_new_tagging_indexes.d.ts +18 -0
  225. package/dest/tagging/sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -0
  226. package/dest/tagging/sync/utils/load_and_store_new_tagging_indexes.js +55 -0
  227. package/dest/tagging/utils.d.ts +18 -0
  228. package/dest/tagging/utils.d.ts.map +1 -0
  229. package/dest/tagging/utils.js +25 -0
  230. package/dest/tree_membership/tree_membership_service.d.ts +52 -0
  231. package/dest/tree_membership/tree_membership_service.d.ts.map +1 -0
  232. package/dest/tree_membership/tree_membership_service.js +84 -0
  233. package/package.json +37 -34
  234. package/src/bin/check_oracle_version.ts +160 -0
  235. package/src/{synchronizer/synchronizer.ts → block_synchronizer/block_synchronizer.ts} +39 -35
  236. package/src/block_synchronizer/index.ts +1 -0
  237. package/src/config/index.ts +27 -55
  238. package/src/config/package_info.ts +1 -1
  239. package/src/contract_function_simulator/contract_function_simulator.ts +618 -0
  240. package/src/contract_function_simulator/execution_note_cache.ts +233 -0
  241. package/src/contract_function_simulator/execution_tagging_index_cache.ts +32 -0
  242. package/src/contract_function_simulator/hashed_values_cache.ts +47 -0
  243. package/src/contract_function_simulator/index.ts +13 -0
  244. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +47 -0
  245. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +28 -0
  246. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +69 -0
  247. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +64 -0
  248. package/src/contract_function_simulator/noir-structs/utility_context.ts +42 -0
  249. package/src/contract_function_simulator/oracle/index.ts +16 -0
  250. package/src/contract_function_simulator/oracle/interfaces.ts +175 -0
  251. package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +23 -0
  252. package/src/contract_function_simulator/oracle/note_packing_utils.ts +68 -0
  253. package/src/contract_function_simulator/oracle/oracle.ts +605 -0
  254. package/src/contract_function_simulator/oracle/private_execution.ts +209 -0
  255. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +704 -0
  256. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +532 -0
  257. package/src/contract_function_simulator/pick_notes.ts +141 -0
  258. package/src/contract_function_simulator/proxied_contract_data_source.ts +83 -0
  259. package/src/contract_function_simulator/proxied_node.ts +33 -0
  260. package/src/debug/pxe_debug_utils.ts +48 -0
  261. package/src/entrypoints/client/bundle/index.ts +3 -2
  262. package/src/entrypoints/client/bundle/utils.ts +36 -36
  263. package/src/entrypoints/client/lazy/index.ts +3 -2
  264. package/src/entrypoints/client/lazy/utils.ts +36 -31
  265. package/src/entrypoints/pxe_creation_options.ts +12 -0
  266. package/src/entrypoints/server/index.ts +5 -3
  267. package/src/entrypoints/server/utils.ts +59 -51
  268. package/src/{pxe_service/error_enriching.ts → error_enriching.ts} +36 -27
  269. package/src/events/event_service.ts +77 -0
  270. package/src/events/index.ts +1 -0
  271. package/src/events/private_event_filter_validator.ts +48 -0
  272. package/src/logs/log_service.ts +364 -0
  273. package/src/notes/index.ts +1 -0
  274. package/src/notes/note_service.ts +200 -0
  275. package/src/oracle_version.ts +11 -0
  276. package/src/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.ts +159 -147
  277. package/src/private_kernel/hints/compute_tx_include_by_timestamp.ts +58 -0
  278. package/src/{kernel_prover → private_kernel}/hints/index.ts +1 -0
  279. package/src/private_kernel/index.ts +2 -0
  280. package/src/private_kernel/private_kernel_execution_prover.ts +432 -0
  281. package/src/{kernel_prover/proving_data_oracle.ts → private_kernel/private_kernel_oracle.ts} +19 -30
  282. package/src/{kernel_oracle/index.ts → private_kernel/private_kernel_oracle_impl.ts} +33 -17
  283. package/src/public_storage/public_storage_service.ts +33 -0
  284. package/src/pxe.ts +1063 -0
  285. package/src/storage/address_data_provider/address_data_provider.ts +1 -7
  286. package/src/storage/{sync_data_provider/sync_data_provider.ts → anchor_block_data_provider/anchor_block_data_provider.ts} +2 -17
  287. package/src/storage/anchor_block_data_provider/index.ts +1 -0
  288. package/src/storage/capsule_data_provider/capsule_data_provider.ts +130 -31
  289. package/src/storage/contract_data_provider/contract_data_provider.ts +152 -94
  290. package/src/storage/contract_data_provider/index.ts +0 -1
  291. package/src/storage/contract_data_provider/private_functions_tree.ts +12 -76
  292. package/src/storage/index.ts +3 -5
  293. package/src/storage/metadata.ts +1 -0
  294. package/src/storage/note_data_provider/index.ts +1 -1
  295. package/src/storage/note_data_provider/note_data_provider.ts +188 -121
  296. package/src/storage/private_event_data_provider/private_event_data_provider.ts +162 -0
  297. package/src/storage/tagging_data_provider/index.ts +2 -1
  298. package/src/storage/tagging_data_provider/recipient_tagging_data_provider.ts +86 -0
  299. package/src/storage/tagging_data_provider/sender_tagging_data_provider.ts +244 -0
  300. package/src/tagging/constants.ts +3 -0
  301. package/src/tagging/index.ts +4 -0
  302. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +129 -0
  303. package/src/tagging/recipient_sync/new_recipient_tagging_data_provider.ts +53 -0
  304. package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +34 -0
  305. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +43 -0
  306. package/src/tagging/sync/sync_sender_tagging_indexes.ts +112 -0
  307. package/src/tagging/sync/utils/get_status_change_of_pending.ts +44 -0
  308. package/src/tagging/sync/utils/load_and_store_new_tagging_indexes.ts +72 -0
  309. package/src/tagging/utils.ts +32 -0
  310. package/src/tree_membership/tree_membership_service.ts +112 -0
  311. package/dest/bin/index.d.ts +0 -3
  312. package/dest/bin/index.d.ts.map +0 -1
  313. package/dest/bin/index.js +0 -28
  314. package/dest/entrypoints/client/pxe_creation_options.d.ts +0 -11
  315. package/dest/entrypoints/client/pxe_creation_options.d.ts.map +0 -1
  316. package/dest/kernel_oracle/index.d.ts +0 -45
  317. package/dest/kernel_oracle/index.d.ts.map +0 -1
  318. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
  319. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
  320. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.js +0 -270
  321. package/dest/kernel_prover/hints/index.d.ts +0 -2
  322. package/dest/kernel_prover/hints/index.d.ts.map +0 -1
  323. package/dest/kernel_prover/index.d.ts +0 -3
  324. package/dest/kernel_prover/index.d.ts.map +0 -1
  325. package/dest/kernel_prover/index.js +0 -2
  326. package/dest/kernel_prover/kernel_prover.d.ts +0 -38
  327. package/dest/kernel_prover/kernel_prover.d.ts.map +0 -1
  328. package/dest/kernel_prover/kernel_prover.js +0 -217
  329. package/dest/kernel_prover/proving_data_oracle.d.ts +0 -73
  330. package/dest/kernel_prover/proving_data_oracle.d.ts.map +0 -1
  331. package/dest/kernel_prover/proving_data_oracle.js +0 -4
  332. package/dest/note_decryption_utils/add_public_values_to_payload.d.ts +0 -11
  333. package/dest/note_decryption_utils/add_public_values_to_payload.d.ts.map +0 -1
  334. package/dest/note_decryption_utils/add_public_values_to_payload.js +0 -47
  335. package/dest/pxe_http/index.d.ts +0 -2
  336. package/dest/pxe_http/index.d.ts.map +0 -1
  337. package/dest/pxe_http/index.js +0 -1
  338. package/dest/pxe_http/pxe_http_server.d.ts +0 -16
  339. package/dest/pxe_http/pxe_http_server.d.ts.map +0 -1
  340. package/dest/pxe_http/pxe_http_server.js +0 -27
  341. package/dest/pxe_oracle_interface/index.d.ts +0 -159
  342. package/dest/pxe_oracle_interface/index.d.ts.map +0 -1
  343. package/dest/pxe_oracle_interface/index.js +0 -692
  344. package/dest/pxe_oracle_interface/tagging_utils.d.ts +0 -17
  345. package/dest/pxe_oracle_interface/tagging_utils.d.ts.map +0 -1
  346. package/dest/pxe_oracle_interface/tagging_utils.js +0 -23
  347. package/dest/pxe_service/error_enriching.d.ts +0 -11
  348. package/dest/pxe_service/error_enriching.d.ts.map +0 -1
  349. package/dest/pxe_service/index.d.ts +0 -3
  350. package/dest/pxe_service/index.d.ts.map +0 -1
  351. package/dest/pxe_service/index.js +0 -2
  352. package/dest/pxe_service/pxe_service.d.ts +0 -111
  353. package/dest/pxe_service/pxe_service.d.ts.map +0 -1
  354. package/dest/pxe_service/pxe_service.js +0 -664
  355. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts +0 -11
  356. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts.map +0 -1
  357. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.js +0 -20
  358. package/dest/storage/auth_witness_data_provider/index.d.ts +0 -2
  359. package/dest/storage/auth_witness_data_provider/index.d.ts.map +0 -1
  360. package/dest/storage/auth_witness_data_provider/index.js +0 -1
  361. package/dest/storage/data_provider.d.ts +0 -4
  362. package/dest/storage/data_provider.d.ts.map +0 -1
  363. package/dest/storage/data_provider.js +0 -1
  364. package/dest/storage/note_data_provider/note_dao.d.ts +0 -106
  365. package/dest/storage/note_data_provider/note_dao.d.ts.map +0 -1
  366. package/dest/storage/note_data_provider/note_dao.js +0 -106
  367. package/dest/storage/sync_data_provider/index.d.ts +0 -2
  368. package/dest/storage/sync_data_provider/index.d.ts.map +0 -1
  369. package/dest/storage/sync_data_provider/index.js +0 -1
  370. package/dest/storage/sync_data_provider/sync_data_provider.d.ts +0 -12
  371. package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +0 -1
  372. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +0 -18
  373. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +0 -1
  374. package/dest/storage/tagging_data_provider/tagging_data_provider.js +0 -65
  375. package/dest/synchronizer/index.d.ts +0 -2
  376. package/dest/synchronizer/index.d.ts.map +0 -1
  377. package/dest/synchronizer/index.js +0 -1
  378. package/dest/synchronizer/synchronizer.d.ts +0 -37
  379. package/dest/synchronizer/synchronizer.d.ts.map +0 -1
  380. package/dest/test/pxe_test_suite.d.ts +0 -3
  381. package/dest/test/pxe_test_suite.d.ts.map +0 -1
  382. package/dest/test/pxe_test_suite.js +0 -97
  383. package/src/bin/index.ts +0 -38
  384. package/src/entrypoints/client/pxe_creation_options.ts +0 -7
  385. package/src/kernel_prover/index.ts +0 -2
  386. package/src/kernel_prover/kernel_prover.ts +0 -351
  387. package/src/note_decryption_utils/add_public_values_to_payload.ts +0 -64
  388. package/src/pxe_http/index.ts +0 -1
  389. package/src/pxe_http/pxe_http_server.ts +0 -29
  390. package/src/pxe_oracle_interface/index.ts +0 -925
  391. package/src/pxe_oracle_interface/tagging_utils.ts +0 -32
  392. package/src/pxe_service/index.ts +0 -2
  393. package/src/pxe_service/pxe_service.ts +0 -949
  394. package/src/storage/auth_witness_data_provider/auth_witness_data_provider.ts +0 -34
  395. package/src/storage/auth_witness_data_provider/index.ts +0 -1
  396. package/src/storage/data_provider.ts +0 -3
  397. package/src/storage/note_data_provider/note_dao.ts +0 -162
  398. package/src/storage/sync_data_provider/index.ts +0 -1
  399. package/src/storage/tagging_data_provider/tagging_data_provider.ts +0 -92
  400. package/src/synchronizer/index.ts +0 -1
  401. package/src/test/pxe_test_suite.ts +0 -111
  402. /package/dest/entrypoints/{client/pxe_creation_options.js → pxe_creation_options.js} +0 -0
@@ -0,0 +1,152 @@
1
+ import { computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
2
+ import { MAX_RPC_LEN } from '@aztec/stdlib/interfaces/client';
3
+ import { Note, NoteDao } from '@aztec/stdlib/note';
4
+ import { MerkleTreeId } from '@aztec/stdlib/trees';
5
+ export class NoteService {
6
+ noteDataProvider;
7
+ aztecNode;
8
+ anchorBlockDataProvider;
9
+ constructor(noteDataProvider, aztecNode, anchorBlockDataProvider){
10
+ this.noteDataProvider = noteDataProvider;
11
+ this.aztecNode = aztecNode;
12
+ this.anchorBlockDataProvider = anchorBlockDataProvider;
13
+ }
14
+ /**
15
+ * Retrieves a set of notes stored in the database for a given contract address and storage slot.
16
+ * The query result is paginated using 'limit' and 'offset' values.
17
+ * Returns an object containing an array of note data.
18
+ *
19
+ * @param owner - The owner of the notes. If undefined, returns notes for all known owners.
20
+ * @param status - The status of notes to fetch.
21
+ * @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
22
+ */ async getNotes(contractAddress, owner, storageSlot, status, scopes) {
23
+ const noteDaos = await this.noteDataProvider.getNotes({
24
+ contractAddress,
25
+ owner,
26
+ storageSlot,
27
+ status,
28
+ scopes
29
+ });
30
+ return noteDaos.map(({ contractAddress, owner, storageSlot, randomness, noteNonce, note, noteHash, siloedNullifier, index })=>({
31
+ contractAddress,
32
+ owner,
33
+ storageSlot,
34
+ randomness,
35
+ noteNonce,
36
+ note,
37
+ noteHash,
38
+ siloedNullifier,
39
+ // PXE can use this index to get full MembershipWitness
40
+ index
41
+ }));
42
+ }
43
+ /**
44
+ * Looks for nullifiers of active contract notes and marks them as nullified if a nullifier is found.
45
+ *
46
+ * Fetches notes from the NoteDataProvider and checks which nullifiers are present in the
47
+ * onchain nullifier Merkle tree - up to the latest locally synced block. We use the
48
+ * locally synced block instead of querying the chain's 'latest' block to ensure correctness:
49
+ * notes are only marked nullified once their corresponding nullifier has been included in a
50
+ * block up to which the PXE has synced.
51
+ * This allows recent nullifications to be processed even if the node is not an archive node.
52
+ *
53
+ * @param contractAddress - The contract whose notes should be checked and nullified.
54
+ */ async syncNoteNullifiers(contractAddress) {
55
+ const syncedBlockNumber = (await this.anchorBlockDataProvider.getBlockHeader()).getBlockNumber();
56
+ const contractNotes = await this.noteDataProvider.getNotes({
57
+ contractAddress
58
+ });
59
+ if (contractNotes.length === 0) {
60
+ return;
61
+ }
62
+ const nullifiersToCheck = contractNotes.map((note)=>note.siloedNullifier);
63
+ const nullifierBatches = nullifiersToCheck.reduce((acc, nullifier)=>{
64
+ if (acc[acc.length - 1].length < MAX_RPC_LEN) {
65
+ acc[acc.length - 1].push(nullifier);
66
+ } else {
67
+ acc.push([
68
+ nullifier
69
+ ]);
70
+ }
71
+ return acc;
72
+ }, [
73
+ []
74
+ ]);
75
+ const nullifierIndexes = (await Promise.all(nullifierBatches.map((batch)=>this.aztecNode.findLeavesIndexes(syncedBlockNumber, MerkleTreeId.NULLIFIER_TREE, batch)))).flat();
76
+ const foundNullifiers = nullifiersToCheck.map((nullifier, i)=>{
77
+ if (nullifierIndexes[i] !== undefined) {
78
+ return {
79
+ ...nullifierIndexes[i],
80
+ ...{
81
+ data: nullifier
82
+ }
83
+ };
84
+ }
85
+ }).filter((nullifier)=>nullifier !== undefined);
86
+ await this.noteDataProvider.applyNullifiers(foundNullifiers);
87
+ }
88
+ async deliverNote(contractAddress, owner, storageSlot, randomness, noteNonce, content, noteHash, nullifier, txHash, recipient) {
89
+ // We are going to store the new note in the NoteDataProvider, which will let us later return it via `getNotes`.
90
+ // There's two things we need to check before we do this however:
91
+ // - we must make sure the note does actually exist in the note hash tree
92
+ // - we need to check if the note has already been nullified
93
+ //
94
+ // Failing to do either of the above would result in circuits getting either non-existent notes and failing to
95
+ // produce inclusion proofs for them, or getting nullified notes and producing duplicate nullifiers, both of which
96
+ // are catastrophic failure modes.
97
+ //
98
+ // Note that adding a note and removing it is *not* equivalent to never adding it in the first place. A nullifier
99
+ // emitted in a block that comes after note creation might result in the note being de-nullified by a chain reorg,
100
+ // so we must store both the note hash and nullifier block information.
101
+ // We avoid making node queries at 'latest' since we don't want to process notes or nullifiers that only exist ahead
102
+ // in time of the locally synced state.
103
+ // Note that while this technically results in historical queries, we perform it at the latest locally synced block
104
+ // number which *should* be recent enough to be available, even for non-archive nodes.
105
+ // Also note that the note should never be ahead of the synced block here since `fetchTaggedLogs` only processes
106
+ // logs up to the synced block making this only an additional safety check.
107
+ const syncedBlockNumber = (await this.anchorBlockDataProvider.getBlockHeader()).getBlockNumber();
108
+ // By computing siloed and unique note hashes ourselves we prevent contracts from interfering with the note storage
109
+ // of other contracts, which would constitute a security breach.
110
+ const uniqueNoteHash = await computeUniqueNoteHash(noteNonce, await siloNoteHash(contractAddress, noteHash));
111
+ const siloedNullifier = await siloNullifier(contractAddress, nullifier);
112
+ const txEffect = await this.aztecNode.getTxEffect(txHash);
113
+ if (!txEffect) {
114
+ throw new Error(`Could not find tx effect for tx hash ${txHash}`);
115
+ }
116
+ if (txEffect.l2BlockNumber > syncedBlockNumber) {
117
+ throw new Error(`Could not find tx effect for tx hash ${txHash} as of block number ${syncedBlockNumber}`);
118
+ }
119
+ const noteInTx = txEffect.data.noteHashes.some((nh)=>nh.equals(uniqueNoteHash));
120
+ if (!noteInTx) {
121
+ throw new Error(`Note hash ${noteHash} (uniqued as ${uniqueNoteHash}) is not present in tx ${txHash}`);
122
+ }
123
+ // We store notes by their index in the global note hash tree, which has the convenient side effect of validating
124
+ // note existence in said tree. We concurrently also check if the note's nullifier exists, performing all node
125
+ // queries in a single round-trip.
126
+ const [[uniqueNoteHashTreeIndexInBlock], [nullifierIndex]] = await Promise.all([
127
+ this.aztecNode.findLeavesIndexes(syncedBlockNumber, MerkleTreeId.NOTE_HASH_TREE, [
128
+ uniqueNoteHash
129
+ ]),
130
+ this.aztecNode.findLeavesIndexes(syncedBlockNumber, MerkleTreeId.NULLIFIER_TREE, [
131
+ siloedNullifier
132
+ ])
133
+ ]);
134
+ if (uniqueNoteHashTreeIndexInBlock === undefined) {
135
+ throw new Error(`Note hash ${noteHash} (uniqued as ${uniqueNoteHash}) is not present on the tree at block ${syncedBlockNumber} (from tx ${txHash})`);
136
+ }
137
+ const noteDao = new NoteDao(new Note(content), contractAddress, owner, storageSlot, randomness, noteNonce, noteHash, siloedNullifier, txHash, uniqueNoteHashTreeIndexInBlock.l2BlockNumber, uniqueNoteHashTreeIndexInBlock.l2BlockHash.toString(), uniqueNoteHashTreeIndexInBlock.data);
138
+ // The note was found by `recipient`, so we use that as the scope when storing the note.
139
+ await this.noteDataProvider.addNotes([
140
+ noteDao
141
+ ], recipient);
142
+ if (nullifierIndex !== undefined) {
143
+ const { data: _, ...blockHashAndNum } = nullifierIndex;
144
+ await this.noteDataProvider.applyNullifiers([
145
+ {
146
+ data: siloedNullifier,
147
+ ...blockHashAndNum
148
+ }
149
+ ]);
150
+ }
151
+ }
152
+ }
@@ -0,0 +1,3 @@
1
+ export declare const ORACLE_VERSION = 5;
2
+ export declare const ORACLE_INTERFACE_HASH = "d603c17a97034d978ca453d2bce3aacae139539dee28bbc46e8f8c7177a348ec";
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3JhY2xlX3ZlcnNpb24uZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9vcmFjbGVfdmVyc2lvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFNQSxlQUFPLE1BQU0sY0FBYyxJQUFJLENBQUM7QUFJaEMsZUFBTyxNQUFNLHFCQUFxQixxRUFBcUUsQ0FBQyJ9
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oracle_version.d.ts","sourceRoot":"","sources":["../src/oracle_version.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,cAAc,IAAI,CAAC;AAIhC,eAAO,MAAM,qBAAqB,qEAAqE,CAAC"}
@@ -0,0 +1,10 @@
1
+ /// The ORACLE_VERSION constant is used to check that the oracle interface is in sync between PXE and Aztec.nr. We need
2
+ /// to version the oracle interface to ensure that developers get a reasonable error message if they use incompatible
3
+ /// versions of Aztec.nr and PXE. The Noir counterpart is in `noir-projects/aztec-nr/aztec/src/oracle/version.nr`.
4
+ ///
5
+ /// @dev Whenever a contract function or Noir test is run, the `utilityAssertCompatibleOracleVersion` oracle is called
6
+ /// and if the oracle version is incompatible an error is thrown.
7
+ export const ORACLE_VERSION = 5;
8
+ /// This hash is computed as by hashing the Oracle interface and it is used to detect when the Oracle interface changes,
9
+ /// which in turn implies that you need to update the ORACLE_VERSION constant.
10
+ export const ORACLE_INTERFACE_HASH = 'd603c17a97034d978ca453d2bce3aacae139539dee28bbc46e8f8c7177a348ec';
@@ -0,0 +1,28 @@
1
+ import { type PrivateKernelCircuitPublicInputs, PrivateKernelResetCircuitPrivateInputs, type PrivateKernelSimulateOutput } from '@aztec/stdlib/kernel';
2
+ import { type PrivateCallExecutionResult } from '@aztec/stdlib/tx';
3
+ import type { PrivateKernelOracle } from '../private_kernel_oracle.js';
4
+ export declare class PrivateKernelResetPrivateInputsBuilder {
5
+ private previousKernelOutput;
6
+ private executionStack;
7
+ private noteHashNullifierCounterMap;
8
+ private splitCounter;
9
+ private previousKernel;
10
+ private nextIteration?;
11
+ private noteHashResetActions;
12
+ private nullifierResetActions;
13
+ private numTransientData?;
14
+ private transientDataSquashingHints;
15
+ private requestedDimensions;
16
+ constructor(previousKernelOutput: PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>, executionStack: PrivateCallExecutionResult[], noteHashNullifierCounterMap: Map<number, number>, splitCounter: number);
17
+ needsReset(): boolean;
18
+ build(oracle: PrivateKernelOracle, noteHashLeafIndexMap: Map<bigint, bigint>): Promise<PrivateKernelResetCircuitPrivateInputs>;
19
+ private reduceReadRequestActions;
20
+ private needsResetNoteHashReadRequests;
21
+ private needsResetNullifierReadRequests;
22
+ private needsResetNullifierKeys;
23
+ private needsResetTransientData;
24
+ private needsSiloNoteHashes;
25
+ private needsSiloNullifiers;
26
+ private needsSiloPrivateLogs;
27
+ }
28
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVpbGRfcHJpdmF0ZV9rZXJuZWxfcmVzZXRfcHJpdmF0ZV9pbnB1dHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9wcml2YXRlX2tlcm5lbC9oaW50cy9idWlsZF9wcml2YXRlX2tlcm5lbF9yZXNldF9wcml2YXRlX2lucHV0cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFlQSxPQUFPLEVBS0wsS0FBSyxnQ0FBZ0MsRUFFckMsc0NBQXNDLEVBR3RDLEtBQUssMkJBQTJCLEVBZWpDLE1BQU0sc0JBQXNCLENBQUM7QUFDOUIsT0FBTyxFQUFFLEtBQUssMEJBQTBCLEVBQWlCLE1BQU0sa0JBQWtCLENBQUM7QUFHbEYsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQTRDdkUscUJBQWEsc0NBQXNDO0lBWS9DLE9BQU8sQ0FBQyxvQkFBb0I7SUFDNUIsT0FBTyxDQUFDLGNBQWM7SUFDdEIsT0FBTyxDQUFDLDJCQUEyQjtJQUNuQyxPQUFPLENBQUMsWUFBWTtJQWR0QixPQUFPLENBQUMsY0FBYyxDQUFtQztJQUV6RCxPQUFPLENBQUMsYUFBYSxDQUFDLENBQTZCO0lBRW5ELE9BQU8sQ0FBQyxvQkFBb0IsQ0FBcUU7SUFDakcsT0FBTyxDQUFDLHFCQUFxQixDQUFxRTtJQUNsRyxPQUFPLENBQUMsZ0JBQWdCLENBQUMsQ0FBUztJQUNsQyxPQUFPLENBQUMsMkJBQTJCLENBQWtFO0lBQ3JHLE9BQU8sQ0FBQyxtQkFBbUIsQ0FBK0I7SUFFMUQsWUFDVSxvQkFBb0IsRUFBRSwyQkFBMkIsQ0FBQyxnQ0FBZ0MsQ0FBQyxFQUNuRixjQUFjLEVBQUUsMEJBQTBCLEVBQUUsRUFDNUMsMkJBQTJCLEVBQUUsR0FBRyxDQUFDLE1BQU0sRUFBRSxNQUFNLENBQUMsRUFDaEQsWUFBWSxFQUFFLE1BQU0sRUFXN0I7SUFFRCxVQUFVLElBQUksT0FBTyxDQXNCcEI7SUFFSyxLQUFLLENBQUMsTUFBTSxFQUFFLG1CQUFtQixFQUFFLG9CQUFvQixFQUFFLEdBQUcsQ0FBQyxNQUFNLEVBQUUsTUFBTSxDQUFDLG1EQW9FakY7SUFFRCxPQUFPLENBQUMsd0JBQXdCO0lBMkJoQyxPQUFPLENBQUMsOEJBQThCO0lBdUR0QyxPQUFPLENBQUMsK0JBQStCO0lBdUR2QyxPQUFPLENBQUMsdUJBQXVCO0lBYS9CLE9BQU8sQ0FBQyx1QkFBdUI7SUFzRS9CLE9BQU8sQ0FBQyxtQkFBbUI7SUFjM0IsT0FBTyxDQUFDLG1CQUFtQjtJQWtCM0IsT0FBTyxDQUFDLG9CQUFvQjtDQXFCN0IifQ==
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build_private_kernel_reset_private_inputs.d.ts","sourceRoot":"","sources":["../../../src/private_kernel/hints/build_private_kernel_reset_private_inputs.ts"],"names":[],"mappings":"AAeA,OAAO,EAKL,KAAK,gCAAgC,EAErC,sCAAsC,EAGtC,KAAK,2BAA2B,EAejC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,KAAK,0BAA0B,EAAiB,MAAM,kBAAkB,CAAC;AAGlF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AA4CvE,qBAAa,sCAAsC;IAY/C,OAAO,CAAC,oBAAoB;IAC5B,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,2BAA2B;IACnC,OAAO,CAAC,YAAY;IAdtB,OAAO,CAAC,cAAc,CAAmC;IAEzD,OAAO,CAAC,aAAa,CAAC,CAA6B;IAEnD,OAAO,CAAC,oBAAoB,CAAqE;IACjG,OAAO,CAAC,qBAAqB,CAAqE;IAClG,OAAO,CAAC,gBAAgB,CAAC,CAAS;IAClC,OAAO,CAAC,2BAA2B,CAAkE;IACrG,OAAO,CAAC,mBAAmB,CAA+B;IAE1D,YACU,oBAAoB,EAAE,2BAA2B,CAAC,gCAAgC,CAAC,EACnF,cAAc,EAAE,0BAA0B,EAAE,EAC5C,2BAA2B,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAChD,YAAY,EAAE,MAAM,EAW7B;IAED,UAAU,IAAI,OAAO,CAsBpB;IAEK,KAAK,CAAC,MAAM,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,mDAoEjF;IAED,OAAO,CAAC,wBAAwB;IA2BhC,OAAO,CAAC,8BAA8B;IAuDtC,OAAO,CAAC,+BAA+B;IAuDvC,OAAO,CAAC,uBAAuB;IAa/B,OAAO,CAAC,uBAAuB;IAsE/B,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,mBAAmB;IAkB3B,OAAO,CAAC,oBAAoB;CAqB7B"}
@@ -0,0 +1,271 @@
1
+ import { MAX_KEY_VALIDATION_REQUESTS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_TX, MAX_PRIVATE_LOGS_PER_TX, NULLIFIER_TREE_HEIGHT } from '@aztec/constants';
2
+ import { makeTuple } from '@aztec/foundation/array';
3
+ import { padArrayEnd } from '@aztec/foundation/collection';
4
+ import { assertLength } from '@aztec/foundation/serialize';
5
+ import { MembershipWitness } from '@aztec/foundation/trees';
6
+ import { privateKernelResetDimensionsConfig } from '@aztec/noir-protocol-circuits-types/client';
7
+ import { KeyValidationHint, PaddedSideEffects, PrivateKernelData, PrivateKernelResetCircuitPrivateInputs, PrivateKernelResetDimensions, PrivateKernelResetHints, ReadRequestActionEnum, ReadRequestResetActions, ScopedNoteHash, ScopedNullifier, TransientDataSquashingHint, buildNoteHashReadRequestHintsFromResetActions, buildNullifierReadRequestHintsFromResetActions, buildTransientDataHints, findPrivateKernelResetDimensions, getNoteHashReadRequestResetActions, getNullifierReadRequestResetActions, privateKernelResetDimensionNames } from '@aztec/stdlib/kernel';
8
+ import { collectNested } from '@aztec/stdlib/tx';
9
+ import { VkData } from '@aztec/stdlib/vks';
10
+ function collectNestedReadRequests(executionStack, extractReadRequests) {
11
+ return collectNested(executionStack, (executionResult)=>{
12
+ return extractReadRequests(executionResult).getActiveItems();
13
+ });
14
+ }
15
+ function getNullifierMembershipWitnessResolver(oracle) {
16
+ return async (nullifier)=>{
17
+ const res = await oracle.getNullifierMembershipWitness(nullifier);
18
+ if (!res) {
19
+ throw new Error(`Cannot find the leaf for nullifier ${nullifier}.`);
20
+ }
21
+ const { index, siblingPath, leafPreimage } = res;
22
+ return {
23
+ membershipWitness: new MembershipWitness(NULLIFIER_TREE_HEIGHT, index, siblingPath.toTuple()),
24
+ leafPreimage
25
+ };
26
+ };
27
+ }
28
+ async function getMasterSecretKeysAndAppKeyGenerators(keyValidationRequests, numRequestsToVerify, oracle) {
29
+ const numRequestsToProcess = Math.min(keyValidationRequests.claimedLength, numRequestsToVerify);
30
+ const keysHints = await Promise.all(keyValidationRequests.array.slice(0, numRequestsToProcess).map(async ({ request })=>{
31
+ const secretKeys = await oracle.getMasterSecretKey(request.request.pkM);
32
+ return new KeyValidationHint(secretKeys);
33
+ }));
34
+ return padArrayEnd(keysHints, KeyValidationHint.empty(), MAX_KEY_VALIDATION_REQUESTS_PER_TX);
35
+ }
36
+ export class PrivateKernelResetPrivateInputsBuilder {
37
+ previousKernelOutput;
38
+ executionStack;
39
+ noteHashNullifierCounterMap;
40
+ splitCounter;
41
+ previousKernel;
42
+ // If there's no next iteration, it's the final reset.
43
+ nextIteration;
44
+ noteHashResetActions;
45
+ nullifierResetActions;
46
+ numTransientData;
47
+ transientDataSquashingHints;
48
+ requestedDimensions;
49
+ constructor(previousKernelOutput, executionStack, noteHashNullifierCounterMap, splitCounter){
50
+ this.previousKernelOutput = previousKernelOutput;
51
+ this.executionStack = executionStack;
52
+ this.noteHashNullifierCounterMap = noteHashNullifierCounterMap;
53
+ this.splitCounter = splitCounter;
54
+ this.previousKernel = previousKernelOutput.publicInputs;
55
+ this.requestedDimensions = PrivateKernelResetDimensions.empty();
56
+ this.noteHashResetActions = ReadRequestResetActions.empty(MAX_NOTE_HASH_READ_REQUESTS_PER_TX);
57
+ this.nullifierResetActions = ReadRequestResetActions.empty(MAX_NULLIFIER_READ_REQUESTS_PER_TX);
58
+ this.transientDataSquashingHints = makeTuple(MAX_NULLIFIERS_PER_TX, ()=>new TransientDataSquashingHint(MAX_NULLIFIERS_PER_TX, MAX_NOTE_HASHES_PER_TX));
59
+ this.nextIteration = executionStack[this.executionStack.length - 1]?.publicInputs;
60
+ }
61
+ needsReset() {
62
+ const fns = [
63
+ ()=>this.needsResetNoteHashReadRequests(),
64
+ ()=>this.needsResetNullifierReadRequests(),
65
+ ()=>this.needsResetNullifierKeys(),
66
+ ()=>this.needsResetTransientData()
67
+ ];
68
+ if (this.nextIteration) {
69
+ // If there's a next iteration, reset is needed only when data of a dimension is about to overflow.
70
+ // fns are executed until a dimension that needs reset is found.
71
+ return fns.some((fn)=>fn());
72
+ } else {
73
+ // Siloing is only needed after processing all iterations.
74
+ fns.push(...[
75
+ ()=>this.needsSiloNoteHashes(),
76
+ ()=>this.needsSiloNullifiers(),
77
+ ()=>this.needsSiloPrivateLogs()
78
+ ]);
79
+ // If there's no next iteration, reset is needed when any of the dimension has non empty data.
80
+ // All the fns should to be executed so that data in all dimensions will be reset.
81
+ const result = fns.map((fn)=>fn());
82
+ return result.some((r)=>r);
83
+ }
84
+ }
85
+ async build(oracle, noteHashLeafIndexMap) {
86
+ if (privateKernelResetDimensionNames.every((name)=>!this.requestedDimensions[name])) {
87
+ throw new Error('Reset is not required.');
88
+ }
89
+ const isInner = !!this.nextIteration;
90
+ // "final" reset must be done at most once.
91
+ // Because the code that silo note hashes can't be run repeatedly.
92
+ // The dimensions found must be big enough to reset all values, i.e. empty remainder.
93
+ const allowRemainder = isInner;
94
+ const dimensions = findPrivateKernelResetDimensions(this.requestedDimensions, privateKernelResetDimensionsConfig, isInner, allowRemainder);
95
+ const previousVkMembershipWitness = await oracle.getVkMembershipWitness(this.previousKernelOutput.verificationKey.keyAsFields);
96
+ const vkData = new VkData(this.previousKernelOutput.verificationKey, Number(previousVkMembershipWitness.leafIndex), previousVkMembershipWitness.siblingPath);
97
+ const previousKernelData = new PrivateKernelData(this.previousKernelOutput.publicInputs, vkData);
98
+ this.reduceReadRequestActions(this.noteHashResetActions, dimensions.NOTE_HASH_PENDING_READ, dimensions.NOTE_HASH_SETTLED_READ);
99
+ this.reduceReadRequestActions(this.nullifierResetActions, dimensions.NULLIFIER_PENDING_READ, dimensions.NULLIFIER_SETTLED_READ);
100
+ // TODO: Enable padding when we have a better idea what are the final amounts we should pad to.
101
+ const paddedSideEffects = PaddedSideEffects.empty();
102
+ return new PrivateKernelResetCircuitPrivateInputs(previousKernelData, paddedSideEffects, new PrivateKernelResetHints(await buildNoteHashReadRequestHintsFromResetActions(oracle, this.previousKernel.validationRequests.noteHashReadRequests, this.previousKernel.end.noteHashes, this.noteHashResetActions, noteHashLeafIndexMap), await buildNullifierReadRequestHintsFromResetActions({
103
+ getNullifierMembershipWitness: getNullifierMembershipWitnessResolver(oracle)
104
+ }, this.previousKernel.validationRequests.nullifierReadRequests, this.nullifierResetActions), await getMasterSecretKeysAndAppKeyGenerators(this.previousKernel.validationRequests.scopedKeyValidationRequestsAndGenerators, dimensions.KEY_VALIDATION, oracle), this.transientDataSquashingHints), dimensions);
105
+ }
106
+ reduceReadRequestActions(resetActions, maxPending, maxSettled) {
107
+ let numPending = 0;
108
+ let numSettled = 0;
109
+ for(let i = 0; i < resetActions.actions.length; i++){
110
+ const action = resetActions.actions[i];
111
+ if (action === ReadRequestActionEnum.READ_AS_PENDING) {
112
+ if (numPending < maxPending) {
113
+ numPending++;
114
+ } else {
115
+ resetActions.actions[i] = ReadRequestActionEnum.SKIP;
116
+ }
117
+ } else if (action === ReadRequestActionEnum.READ_AS_SETTLED) {
118
+ if (numSettled < maxSettled) {
119
+ numSettled++;
120
+ } else {
121
+ resetActions.actions[i] = ReadRequestActionEnum.SKIP;
122
+ }
123
+ }
124
+ }
125
+ resetActions.pendingReadHints = resetActions.pendingReadHints.slice(0, maxPending);
126
+ }
127
+ needsResetNoteHashReadRequests(forceResetAll = false) {
128
+ const numCurr = this.previousKernel.validationRequests.noteHashReadRequests.claimedLength;
129
+ const numNext = this.nextIteration ? this.nextIteration.noteHashReadRequests.claimedLength : 0;
130
+ const maxAmountToKeep = !this.nextIteration || forceResetAll ? 0 : MAX_NOTE_HASH_READ_REQUESTS_PER_TX;
131
+ if (numCurr + numNext <= maxAmountToKeep) {
132
+ return false;
133
+ }
134
+ const futureNoteHashes = collectNested(this.executionStack, (executionResult)=>{
135
+ return executionResult.publicInputs.noteHashes.getActiveItems().map((noteHash)=>new ScopedNoteHash(noteHash, executionResult.publicInputs.callContext.contractAddress));
136
+ });
137
+ const resetActions = getNoteHashReadRequestResetActions(this.previousKernel.validationRequests.noteHashReadRequests, this.previousKernel.end.noteHashes, futureNoteHashes);
138
+ const numPendingReads = resetActions.pendingReadHints.length;
139
+ const numSettledReads = resetActions.actions.reduce((accum, action)=>accum + (action === ReadRequestActionEnum.READ_AS_SETTLED ? 1 : 0), 0);
140
+ if (!this.nextIteration) {
141
+ this.noteHashResetActions = resetActions;
142
+ this.requestedDimensions.NOTE_HASH_PENDING_READ = numPendingReads;
143
+ this.requestedDimensions.NOTE_HASH_SETTLED_READ = numSettledReads;
144
+ } else {
145
+ // Pick only one dimension to reset if next iteration is not empty.
146
+ if (numPendingReads > numSettledReads) {
147
+ this.requestedDimensions.NOTE_HASH_PENDING_READ = numPendingReads;
148
+ this.noteHashResetActions.actions = assertLength(resetActions.actions.map((action)=>action === ReadRequestActionEnum.READ_AS_PENDING ? action : ReadRequestActionEnum.SKIP), MAX_NOTE_HASH_READ_REQUESTS_PER_TX);
149
+ this.noteHashResetActions.pendingReadHints = resetActions.pendingReadHints;
150
+ } else {
151
+ this.requestedDimensions.NOTE_HASH_SETTLED_READ = numSettledReads;
152
+ this.noteHashResetActions.actions = assertLength(resetActions.actions.map((action)=>action === ReadRequestActionEnum.READ_AS_SETTLED ? action : ReadRequestActionEnum.SKIP), MAX_NOTE_HASH_READ_REQUESTS_PER_TX);
153
+ }
154
+ }
155
+ return true;
156
+ }
157
+ needsResetNullifierReadRequests(forceResetAll = false) {
158
+ const numCurr = this.previousKernel.validationRequests.nullifierReadRequests.claimedLength;
159
+ const numNext = this.nextIteration ? this.nextIteration.nullifierReadRequests.claimedLength : 0;
160
+ const maxAmountToKeep = !this.nextIteration || forceResetAll ? 0 : MAX_NULLIFIER_READ_REQUESTS_PER_TX;
161
+ if (numCurr + numNext <= maxAmountToKeep) {
162
+ return false;
163
+ }
164
+ const futureNullifiers = collectNested(this.executionStack, (executionResult)=>{
165
+ return executionResult.publicInputs.nullifiers.getActiveItems().map((nullifier)=>new ScopedNullifier(nullifier, executionResult.publicInputs.callContext.contractAddress));
166
+ });
167
+ const resetActions = getNullifierReadRequestResetActions(this.previousKernel.validationRequests.nullifierReadRequests, this.previousKernel.end.nullifiers, futureNullifiers);
168
+ const numPendingReads = resetActions.pendingReadHints.length;
169
+ const numSettledReads = resetActions.actions.reduce((accum, action)=>accum + (action === ReadRequestActionEnum.READ_AS_SETTLED ? 1 : 0), 0);
170
+ if (!this.nextIteration) {
171
+ this.nullifierResetActions = resetActions;
172
+ this.requestedDimensions.NULLIFIER_PENDING_READ = numPendingReads;
173
+ this.requestedDimensions.NULLIFIER_SETTLED_READ = numSettledReads;
174
+ } else {
175
+ // Pick only one dimension to reset if next iteration is not empty.
176
+ if (numPendingReads > numSettledReads) {
177
+ this.requestedDimensions.NULLIFIER_PENDING_READ = numPendingReads;
178
+ this.nullifierResetActions.actions = assertLength(resetActions.actions.map((action)=>action === ReadRequestActionEnum.READ_AS_PENDING ? action : ReadRequestActionEnum.SKIP), MAX_NULLIFIER_READ_REQUESTS_PER_TX);
179
+ this.nullifierResetActions.pendingReadHints = resetActions.pendingReadHints;
180
+ } else {
181
+ this.requestedDimensions.NULLIFIER_SETTLED_READ = numSettledReads;
182
+ this.nullifierResetActions.actions = assertLength(resetActions.actions.map((action)=>action === ReadRequestActionEnum.READ_AS_SETTLED ? action : ReadRequestActionEnum.SKIP), MAX_NULLIFIER_READ_REQUESTS_PER_TX);
183
+ }
184
+ }
185
+ return true;
186
+ }
187
+ needsResetNullifierKeys() {
188
+ const numCurr = this.previousKernel.validationRequests.scopedKeyValidationRequestsAndGenerators.claimedLength;
189
+ const numNext = this.nextIteration ? this.nextIteration.keyValidationRequestsAndGenerators.claimedLength : 0;
190
+ const maxAmountToKeep = !this.nextIteration ? 0 : MAX_KEY_VALIDATION_REQUESTS_PER_TX;
191
+ if (numCurr + numNext <= maxAmountToKeep) {
192
+ return false;
193
+ }
194
+ this.requestedDimensions.KEY_VALIDATION = numCurr;
195
+ return true;
196
+ }
197
+ needsResetTransientData() {
198
+ // Initialize this to 0 so that needsSilo can be run.
199
+ this.numTransientData = 0;
200
+ const nextAccumNoteHashes = this.previousKernel.end.noteHashes.claimedLength + (this.nextIteration?.noteHashes.claimedLength ?? 0);
201
+ const noteHashWillOverflow = nextAccumNoteHashes > MAX_NOTE_HASHES_PER_TX;
202
+ const nextAccumNullifiers = this.previousKernel.end.nullifiers.claimedLength + (this.nextIteration?.nullifiers.claimedLength ?? 0);
203
+ const nullifierWillOverflow = nextAccumNullifiers > MAX_NULLIFIERS_PER_TX;
204
+ const nextAccumLogs = this.previousKernel.end.privateLogs.claimedLength + (this.nextIteration?.privateLogs.claimedLength ?? 0);
205
+ const logsWillOverflow = nextAccumLogs > MAX_PRIVATE_LOGS_PER_TX;
206
+ if (this.nextIteration && !noteHashWillOverflow && !nullifierWillOverflow && !logsWillOverflow) {
207
+ return false;
208
+ }
209
+ const futureNoteHashReads = collectNestedReadRequests(this.executionStack, (executionResult)=>executionResult.publicInputs.noteHashReadRequests);
210
+ const futureNullifierReads = collectNestedReadRequests(this.executionStack, (executionResult)=>executionResult.publicInputs.nullifierReadRequests);
211
+ // TODO(#15902): Collect future logs and only allow squashing a note hash when all its logs have been emitted
212
+ // (i.e. none of the future logs are linked to the to-be-squashed note hashes).
213
+ if (this.nextIteration) {
214
+ // If it's not the final reset, only one dimension will be reset at a time.
215
+ // The note hashes and nullifiers for the remaining read requests can't be squashed.
216
+ futureNoteHashReads.push(...this.previousKernel.validationRequests.noteHashReadRequests.getActiveItems());
217
+ futureNullifierReads.push(...this.previousKernel.validationRequests.nullifierReadRequests.getActiveItems());
218
+ }
219
+ const { numTransientData, hints: transientDataSquashingHints } = buildTransientDataHints(this.previousKernel.end.noteHashes, this.previousKernel.end.nullifiers, futureNoteHashReads, futureNullifierReads, this.noteHashNullifierCounterMap, this.splitCounter);
220
+ if (this.nextIteration && !numTransientData) {
221
+ const forceResetAll = true;
222
+ const canClearReadRequests = noteHashWillOverflow && this.needsResetNoteHashReadRequests(forceResetAll) || nullifierWillOverflow && this.needsResetNullifierReadRequests(forceResetAll) || logsWillOverflow && this.needsResetNoteHashReadRequests(forceResetAll);
223
+ if (!canClearReadRequests) {
224
+ const overflownData = noteHashWillOverflow ? 'note hashes' : nullifierWillOverflow ? 'nullifiers' : 'private logs';
225
+ throw new Error(`Number of ${overflownData} exceeds the limit.`);
226
+ }
227
+ // Clearing the read requests might not be enough to squash the overflown data.
228
+ // In this case, the next iteration will fail at the above check.
229
+ return true;
230
+ }
231
+ this.numTransientData = numTransientData;
232
+ this.transientDataSquashingHints = transientDataSquashingHints;
233
+ this.requestedDimensions.TRANSIENT_DATA_SQUASHING = numTransientData;
234
+ return numTransientData > 0;
235
+ }
236
+ needsSiloNoteHashes() {
237
+ if (this.numTransientData === undefined) {
238
+ throw new Error('`needsResetTransientData` must be run before `needsSiloNoteHashes`.');
239
+ }
240
+ const numNoteHashes = this.previousKernel.end.noteHashes.getActiveItems().filter((n)=>!n.contractAddress.isZero()).length;
241
+ const numToSilo = Math.max(0, numNoteHashes - this.numTransientData);
242
+ this.requestedDimensions.NOTE_HASH_SILOING = numToSilo;
243
+ return numToSilo > 0;
244
+ }
245
+ needsSiloNullifiers() {
246
+ if (this.numTransientData === undefined) {
247
+ throw new Error('`needsResetTransientData` must be run before `needsSiloNullifiers`.');
248
+ }
249
+ const numNullifiers = this.previousKernel.end.nullifiers.getActiveItems().filter((n)=>!n.contractAddress.isZero()).length;
250
+ const numToSilo = Math.max(0, numNullifiers - this.numTransientData);
251
+ // Include the first nullifier if there's something to silo.
252
+ // The reset circuit checks that capped_size must be greater than or equal to all non-empty nullifiers.
253
+ // Which includes the first nullifier, even though its contract address is always zero and doesn't need siloing.
254
+ const cappedSize = numToSilo ? numToSilo + 1 : 0;
255
+ this.requestedDimensions.NULLIFIER_SILOING = cappedSize;
256
+ return numToSilo > 0;
257
+ }
258
+ needsSiloPrivateLogs() {
259
+ if (this.numTransientData === undefined) {
260
+ throw new Error('`needsResetTransientData` must be run before `needsSiloPrivateLogs`.');
261
+ }
262
+ const privateLogs = this.previousKernel.end.privateLogs;
263
+ const numLogs = privateLogs.getActiveItems().filter((l)=>!l.contractAddress.isZero()).length;
264
+ const noteHashes = this.previousKernel.end.noteHashes;
265
+ const squashedNoteHashCounters = this.transientDataSquashingHints.filter((h)=>h.noteHashIndex < noteHashes.claimedLength).map((h)=>noteHashes.array[h.noteHashIndex].counter);
266
+ const numSquashedLogs = privateLogs.getActiveItems().filter((l)=>squashedNoteHashCounters.includes(l.inner.noteHashCounter)).length;
267
+ const numToSilo = numLogs - numSquashedLogs;
268
+ this.requestedDimensions.PRIVATE_LOG_SILOING = numToSilo;
269
+ return numToSilo > 0;
270
+ }
271
+ }
@@ -0,0 +1,4 @@
1
+ import type { PrivateKernelCircuitPublicInputs } from '@aztec/stdlib/kernel';
2
+ import type { UInt64 } from '@aztec/stdlib/types';
3
+ export declare function computeTxIncludeByTimestamp(previousKernel: PrivateKernelCircuitPublicInputs, maxDuration?: number): UInt64;
4
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tcHV0ZV90eF9pbmNsdWRlX2J5X3RpbWVzdGFtcC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3ByaXZhdGVfa2VybmVsL2hpbnRzL2NvbXB1dGVfdHhfaW5jbHVkZV9ieV90aW1lc3RhbXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxLQUFLLEVBQUUsZ0NBQWdDLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUM3RSxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQXFCbEQsd0JBQWdCLDJCQUEyQixDQUN6QyxjQUFjLEVBQUUsZ0NBQWdDLEVBQ2hELFdBQVcsU0FBb0MsR0FDOUMsTUFBTSxDQStCUiJ9
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compute_tx_include_by_timestamp.d.ts","sourceRoot":"","sources":["../../../src/private_kernel/hints/compute_tx_include_by_timestamp.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAqBlD,wBAAgB,2BAA2B,CACzC,cAAc,EAAE,gCAAgC,EAChD,WAAW,SAAoC,GAC9C,MAAM,CA+BR"}
@@ -0,0 +1,41 @@
1
+ import { MAX_INCLUDE_BY_TIMESTAMP_DURATION } from '@aztec/constants';
2
+ const ROUNDED_DURATIONS = [
3
+ 3600,
4
+ 1800,
5
+ 1
6
+ ];
7
+ function roundTimestamp(blockTimestamp, includeByTimestamp) {
8
+ return ROUNDED_DURATIONS.reduce((timestamp, duration)=>{
9
+ if (timestamp <= blockTimestamp) {
10
+ // The timestamp must be greater than the block timestamp.
11
+ // If it is too small, round it down again using a smaller duration.
12
+ const totalDuration = includeByTimestamp - blockTimestamp;
13
+ const roundedDuration = totalDuration - totalDuration % BigInt(duration);
14
+ return blockTimestamp + roundedDuration;
15
+ }
16
+ return timestamp;
17
+ }, 0n);
18
+ }
19
+ export function computeTxIncludeByTimestamp(previousKernel, maxDuration = MAX_INCLUDE_BY_TIMESTAMP_DURATION) {
20
+ if (maxDuration > MAX_INCLUDE_BY_TIMESTAMP_DURATION) {
21
+ throw new Error(`Custom max duration cannot be greater than the max allowed. Max allowed: ${MAX_INCLUDE_BY_TIMESTAMP_DURATION}. Custom value: ${maxDuration}.`);
22
+ }
23
+ const anchorBlockTimestamp = previousKernel.constants.anchorBlockHeader.globalVariables.timestamp;
24
+ const maxTimestamp = anchorBlockTimestamp + BigInt(maxDuration);
25
+ const includeByTimestamp = previousKernel.includeByTimestamp;
26
+ // If the includeByTimestamp set during the tx execution is greater than or equal to the max allowed duration,
27
+ // use the maximum allowed timestamp.
28
+ // Note: It shouldn't be larger than the max allowed duration, but we check for it anyway.
29
+ if (includeByTimestamp >= maxTimestamp) {
30
+ return maxTimestamp;
31
+ }
32
+ // Round it down to the nearest hour/min/second to reduce precision and avoid revealing the exact value.
33
+ // This makes it harder for others to infer what function calls may have been used to produce a specific timestamp.
34
+ const roundedTimestamp = roundTimestamp(anchorBlockTimestamp, includeByTimestamp);
35
+ // The tx can't be published if the timestamp is the same or less than the anchor block's timestamp.
36
+ // Future blocks will have a greater timestamp, so the tx would never be included.
37
+ if (roundedTimestamp <= anchorBlockTimestamp) {
38
+ throw new Error(`Include-by timestamp must be greater than the anchor block timestamp. Anchor block timestamp: ${anchorBlockTimestamp}. Include-by timestamp: ${includeByTimestamp}.`);
39
+ }
40
+ return roundedTimestamp;
41
+ }
@@ -0,0 +1,3 @@
1
+ export * from './build_private_kernel_reset_private_inputs.js';
2
+ export * from './compute_tx_include_by_timestamp.js';
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9wcml2YXRlX2tlcm5lbC9oaW50cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLGdEQUFnRCxDQUFDO0FBQy9ELGNBQWMsc0NBQXNDLENBQUMifQ==
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/private_kernel/hints/index.ts"],"names":[],"mappings":"AAAA,cAAc,gDAAgD,CAAC;AAC/D,cAAc,sCAAsC,CAAC"}
@@ -1 +1,2 @@
1
1
  export * from './build_private_kernel_reset_private_inputs.js';
2
+ export * from './compute_tx_include_by_timestamp.js';
@@ -0,0 +1,3 @@
1
+ export * from './private_kernel_execution_prover.js';
2
+ export * from './private_kernel_oracle.js';
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9wcml2YXRlX2tlcm5lbC9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLHNDQUFzQyxDQUFDO0FBQ3JELGNBQWMsNEJBQTRCLENBQUMifQ==
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/private_kernel/index.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAC;AACrD,cAAc,4BAA4B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './private_kernel_execution_prover.js';
2
+ export * from './private_kernel_oracle.js';
@@ -0,0 +1,44 @@
1
+ import type { PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
2
+ import { type PrivateKernelExecutionProofOutput, type PrivateKernelTailCircuitPublicInputs } from '@aztec/stdlib/kernel';
3
+ import { type PrivateExecutionResult, TxRequest } from '@aztec/stdlib/tx';
4
+ import type { PrivateKernelOracle } from './private_kernel_oracle.js';
5
+ export interface PrivateKernelExecutionProverConfig {
6
+ simulate: boolean;
7
+ skipFeeEnforcement: boolean;
8
+ profileMode: 'gates' | 'execution-steps' | 'full' | 'none';
9
+ }
10
+ /**
11
+ * The PrivateKernelExecutionProver class is responsible for taking a transaction request and sequencing the
12
+ * the execution of the private functions within, sequenced with private kernel "glue" to check protocol rules.
13
+ * The result can be a chonk proof of the private transaction portion, or just a simulation that can e.g.
14
+ * inform state tree updates.
15
+ */
16
+ export declare class PrivateKernelExecutionProver {
17
+ private oracle;
18
+ private proofCreator;
19
+ private fakeProofs;
20
+ private log;
21
+ constructor(oracle: PrivateKernelOracle, proofCreator: PrivateKernelProver, fakeProofs?: boolean);
22
+ /**
23
+ * Generate a proof for a given transaction request and execution result.
24
+ * The function iterates through the nested executions in the execution result, creates private call data,
25
+ * and generates a proof using the provided ProofCreator instance. It also maintains an index of new notes
26
+ * created during the execution and returns them as a part of the KernelProverOutput.
27
+ *
28
+ * @param txRequest - The authenticated transaction request object.
29
+ * @param executionResult - The execution result object containing nested executions and preimages.
30
+ * @param profile - Set true to profile the gate count for each circuit
31
+ * @returns A Promise that resolves to a KernelProverOutput object containing proof, public inputs, and output notes.
32
+ */
33
+ proveWithKernels(txRequest: TxRequest, executionResult: PrivateExecutionResult, { simulate, skipFeeEnforcement, profileMode }?: PrivateKernelExecutionProverConfig): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>>;
34
+ /**
35
+ * Checks that the public inputs of the chonk proof match the public inputs of the tail circuit.
36
+ * This can only mismatch if there is a circuit / noir / bb bug.
37
+ * @param chonkProof - The chonk proof with public inputs.
38
+ * @param tailPublicInputs - The public inputs resulting from witness generation of the tail circuit.
39
+ */
40
+ private ensurePublicInputsMatch;
41
+ private getVkData;
42
+ private createPrivateCallData;
43
+ }
44
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmF0ZV9rZXJuZWxfZXhlY3V0aW9uX3Byb3Zlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3ByaXZhdGVfa2VybmVsL3ByaXZhdGVfa2VybmVsX2V4ZWN1dGlvbl9wcm92ZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBUUEsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUMzRSxPQUFPLEVBUUwsS0FBSyxpQ0FBaUMsRUFLdEMsS0FBSyxvQ0FBb0MsRUFFMUMsTUFBTSxzQkFBc0IsQ0FBQztBQUU5QixPQUFPLEVBRUwsS0FBSyxzQkFBc0IsRUFDM0IsU0FBUyxFQUlWLE1BQU0sa0JBQWtCLENBQUM7QUFJMUIsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSw0QkFBNEIsQ0FBQztBQVN0RSxNQUFNLFdBQVcsa0NBQWtDO0lBQ2pELFFBQVEsRUFBRSxPQUFPLENBQUM7SUFDbEIsa0JBQWtCLEVBQUUsT0FBTyxDQUFDO0lBQzVCLFdBQVcsRUFBRSxPQUFPLEdBQUcsaUJBQWlCLEdBQUcsTUFBTSxHQUFHLE1BQU0sQ0FBQztDQUM1RDtBQUVEOzs7OztHQUtHO0FBQ0gscUJBQWEsNEJBQTRCO0lBSXJDLE9BQU8sQ0FBQyxNQUFNO0lBQ2QsT0FBTyxDQUFDLFlBQVk7SUFDcEIsT0FBTyxDQUFDLFVBQVU7SUFMcEIsT0FBTyxDQUFDLEdBQUcsQ0FBdUQ7SUFFbEUsWUFDVSxNQUFNLEVBQUUsbUJBQW1CLEVBQzNCLFlBQVksRUFBRSxtQkFBbUIsRUFDakMsVUFBVSxVQUFRLEVBQ3hCO0lBRUo7Ozs7Ozs7Ozs7T0FVRztJQUNHLGdCQUFnQixDQUNwQixTQUFTLEVBQUUsU0FBUyxFQUNwQixlQUFlLEVBQUUsc0JBQXNCLEVBQ3ZDLEVBQUUsUUFBUSxFQUFFLGtCQUFrQixFQUFFLFdBQVcsRUFBRSxHQUFFLGtDQUk5QyxHQUNBLE9BQU8sQ0FBQyxpQ0FBaUMsQ0FBQyxvQ0FBb0MsQ0FBQyxDQUFDLENBcVJsRjtJQUVEOzs7OztPQUtHO0lBQ0gsT0FBTyxDQUFDLHVCQUF1QjtZQW9CakIsU0FBUztZQVNULHFCQUFxQjtDQStCcEMifQ==
@@ -0,0 +1 @@
1
+ {"version":3,"file":"private_kernel_execution_prover.d.ts","sourceRoot":"","sources":["../../src/private_kernel/private_kernel_execution_prover.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAQL,KAAK,iCAAiC,EAKtC,KAAK,oCAAoC,EAE1C,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAEL,KAAK,sBAAsB,EAC3B,SAAS,EAIV,MAAM,kBAAkB,CAAC;AAI1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAStE,MAAM,WAAW,kCAAkC;IACjD,QAAQ,EAAE,OAAO,CAAC;IAClB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,WAAW,EAAE,OAAO,GAAG,iBAAiB,GAAG,MAAM,GAAG,MAAM,CAAC;CAC5D;AAED;;;;;GAKG;AACH,qBAAa,4BAA4B;IAIrC,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,UAAU;IALpB,OAAO,CAAC,GAAG,CAAuD;IAElE,YACU,MAAM,EAAE,mBAAmB,EAC3B,YAAY,EAAE,mBAAmB,EACjC,UAAU,UAAQ,EACxB;IAEJ;;;;;;;;;;OAUG;IACG,gBAAgB,CACpB,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,sBAAsB,EACvC,EAAE,QAAQ,EAAE,kBAAkB,EAAE,WAAW,EAAE,GAAE,kCAI9C,GACA,OAAO,CAAC,iCAAiC,CAAC,oCAAoC,CAAC,CAAC,CAqRlF;IAED;;;;;OAKG;IACH,OAAO,CAAC,uBAAuB;YAoBjB,SAAS;YAST,qBAAqB;CA+BpC"}