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

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 (309) 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 +39 -0
  5. package/dest/config/index.d.ts +10 -15
  6. package/dest/config/index.d.ts.map +1 -1
  7. package/dest/config/index.js +11 -20
  8. package/dest/config/package_info.js +1 -1
  9. package/dest/contract_function_simulator/contract_function_simulator.d.ts +56 -0
  10. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -0
  11. package/dest/contract_function_simulator/contract_function_simulator.js +301 -0
  12. package/dest/contract_function_simulator/execution_data_provider.d.ts +274 -0
  13. package/dest/contract_function_simulator/execution_data_provider.d.ts.map +1 -0
  14. package/dest/contract_function_simulator/execution_data_provider.js +14 -0
  15. package/dest/contract_function_simulator/execution_note_cache.d.ts +93 -0
  16. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -0
  17. package/dest/contract_function_simulator/execution_note_cache.js +183 -0
  18. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +16 -0
  19. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -0
  20. package/dest/contract_function_simulator/execution_tagging_index_cache.js +26 -0
  21. package/dest/contract_function_simulator/hashed_values_cache.d.ts +28 -0
  22. package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -0
  23. package/dest/contract_function_simulator/hashed_values_cache.js +36 -0
  24. package/dest/contract_function_simulator/index.d.ts +14 -0
  25. package/dest/contract_function_simulator/index.d.ts.map +1 -0
  26. package/dest/contract_function_simulator/index.js +12 -0
  27. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +20 -0
  28. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -0
  29. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +37 -0
  30. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +15 -0
  31. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -0
  32. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +25 -0
  33. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +17 -0
  34. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -0
  35. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +65 -0
  36. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +22 -0
  37. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -0
  38. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +42 -0
  39. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +22 -0
  40. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -0
  41. package/dest/contract_function_simulator/noir-structs/utility_context.js +33 -0
  42. package/dest/contract_function_simulator/oracle/index.d.ts +14 -0
  43. package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -0
  44. package/dest/contract_function_simulator/oracle/index.js +2 -0
  45. package/dest/contract_function_simulator/oracle/interfaces.d.ts +97 -0
  46. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -0
  47. package/dest/contract_function_simulator/oracle/interfaces.js +4 -0
  48. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +19 -0
  49. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -0
  50. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +24 -0
  51. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +22 -0
  52. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -0
  53. package/dest/contract_function_simulator/oracle/note_packing_utils.js +49 -0
  54. package/dest/contract_function_simulator/oracle/oracle.d.ts +57 -0
  55. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -0
  56. package/dest/contract_function_simulator/oracle/oracle.js +328 -0
  57. package/dest/contract_function_simulator/oracle/private_execution.d.ts +48 -0
  58. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -0
  59. package/dest/contract_function_simulator/oracle/private_execution.js +123 -0
  60. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +236 -0
  61. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -0
  62. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +417 -0
  63. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +154 -0
  64. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -0
  65. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +265 -0
  66. package/dest/contract_function_simulator/pick_notes.d.ts +85 -0
  67. package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -0
  68. package/dest/contract_function_simulator/pick_notes.js +51 -0
  69. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +6 -0
  70. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -0
  71. package/dest/contract_function_simulator/proxied_contract_data_source.js +62 -0
  72. package/dest/contract_function_simulator/proxied_node.d.ts +9 -0
  73. package/dest/contract_function_simulator/proxied_node.d.ts.map +1 -0
  74. package/dest/contract_function_simulator/proxied_node.js +27 -0
  75. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +122 -0
  76. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +1 -0
  77. package/dest/contract_function_simulator/pxe_oracle_interface.js +701 -0
  78. package/dest/entrypoints/client/bundle/index.d.ts +4 -2
  79. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  80. package/dest/entrypoints/client/bundle/index.js +3 -2
  81. package/dest/entrypoints/client/bundle/utils.d.ts +9 -9
  82. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  83. package/dest/entrypoints/client/bundle/utils.js +18 -12
  84. package/dest/entrypoints/client/lazy/index.d.ts +4 -2
  85. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  86. package/dest/entrypoints/client/lazy/index.js +3 -2
  87. package/dest/entrypoints/client/lazy/utils.d.ts +8 -8
  88. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  89. package/dest/entrypoints/client/lazy/utils.js +17 -11
  90. package/dest/entrypoints/{client/pxe_creation_options.d.ts → pxe_creation_options.d.ts} +4 -1
  91. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -0
  92. package/dest/entrypoints/server/index.d.ts +5 -3
  93. package/dest/entrypoints/server/index.d.ts.map +1 -1
  94. package/dest/entrypoints/server/index.js +4 -3
  95. package/dest/entrypoints/server/utils.d.ts +7 -15
  96. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  97. package/dest/entrypoints/server/utils.js +34 -28
  98. package/dest/{pxe_service/error_enriching.d.ts → error_enriching.d.ts} +1 -1
  99. package/dest/error_enriching.d.ts.map +1 -0
  100. package/dest/{pxe_service/error_enriching.js → error_enriching.js} +26 -18
  101. package/dest/oracle_version.d.ts +3 -0
  102. package/dest/oracle_version.d.ts.map +1 -0
  103. package/dest/oracle_version.js +10 -0
  104. package/dest/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.d.ts +6 -6
  105. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -0
  106. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.js +271 -0
  107. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +4 -0
  108. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +1 -0
  109. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.js +41 -0
  110. package/dest/private_kernel/hints/index.d.ts +3 -0
  111. package/dest/private_kernel/hints/index.d.ts.map +1 -0
  112. package/dest/{kernel_prover → private_kernel}/hints/index.js +1 -0
  113. package/dest/private_kernel/index.d.ts +3 -0
  114. package/dest/private_kernel/index.d.ts.map +1 -0
  115. package/dest/private_kernel/index.js +2 -0
  116. package/dest/private_kernel/private_kernel_execution_prover.d.ts +44 -0
  117. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -0
  118. package/dest/private_kernel/private_kernel_execution_prover.js +285 -0
  119. package/dest/{kernel_prover/proving_data_oracle.d.ts → private_kernel/private_kernel_oracle.d.ts} +17 -28
  120. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -0
  121. package/dest/private_kernel/private_kernel_oracle.js +4 -0
  122. package/dest/{kernel_oracle/index.d.ts → private_kernel/private_kernel_oracle_impl.d.ts} +8 -8
  123. package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -0
  124. package/dest/{kernel_oracle/index.js → private_kernel/private_kernel_oracle_impl.js} +19 -9
  125. package/dest/pxe.d.ts +233 -0
  126. package/dest/pxe.d.ts.map +1 -0
  127. package/dest/pxe.js +789 -0
  128. package/dest/storage/address_data_provider/address_data_provider.d.ts +1 -3
  129. package/dest/storage/address_data_provider/address_data_provider.d.ts.map +1 -1
  130. package/dest/storage/address_data_provider/address_data_provider.js +0 -3
  131. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +14 -5
  132. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +1 -1
  133. package/dest/storage/capsule_data_provider/capsule_data_provider.js +85 -24
  134. package/dest/storage/contract_data_provider/contract_data_provider.d.ts +12 -47
  135. package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +1 -1
  136. package/dest/storage/contract_data_provider/contract_data_provider.js +92 -70
  137. package/dest/storage/contract_data_provider/index.d.ts +0 -1
  138. package/dest/storage/contract_data_provider/index.d.ts.map +1 -1
  139. package/dest/storage/contract_data_provider/index.js +0 -1
  140. package/dest/storage/contract_data_provider/private_functions_tree.d.ts +2 -41
  141. package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +1 -1
  142. package/dest/storage/contract_data_provider/private_functions_tree.js +9 -61
  143. package/dest/storage/index.d.ts +2 -3
  144. package/dest/storage/index.d.ts.map +1 -1
  145. package/dest/storage/index.js +2 -3
  146. package/dest/storage/metadata.d.ts +2 -0
  147. package/dest/storage/metadata.d.ts.map +1 -0
  148. package/dest/storage/metadata.js +1 -0
  149. package/dest/storage/note_data_provider/note_dao.d.ts +16 -22
  150. package/dest/storage/note_data_provider/note_dao.d.ts.map +1 -1
  151. package/dest/storage/note_data_provider/note_dao.js +16 -20
  152. package/dest/storage/note_data_provider/note_data_provider.d.ts +71 -8
  153. package/dest/storage/note_data_provider/note_data_provider.d.ts.map +1 -1
  154. package/dest/storage/note_data_provider/note_data_provider.js +133 -74
  155. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +43 -0
  156. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +1 -0
  157. package/dest/storage/private_event_data_provider/private_event_data_provider.js +104 -0
  158. package/dest/storage/sync_data_provider/sync_data_provider.d.ts +2 -4
  159. package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +1 -1
  160. package/dest/storage/sync_data_provider/sync_data_provider.js +2 -5
  161. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +28 -6
  162. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +1 -1
  163. package/dest/storage/tagging_data_provider/tagging_data_provider.js +48 -24
  164. package/dest/synchronizer/synchronizer.d.ts +7 -9
  165. package/dest/synchronizer/synchronizer.d.ts.map +1 -1
  166. package/dest/synchronizer/synchronizer.js +17 -19
  167. package/dest/tagging/constants.d.ts +2 -0
  168. package/dest/tagging/constants.d.ts.map +1 -0
  169. package/dest/tagging/constants.js +2 -0
  170. package/dest/tagging/index.d.ts +7 -0
  171. package/dest/tagging/index.d.ts.map +1 -0
  172. package/dest/tagging/index.js +5 -0
  173. package/dest/tagging/siloed_tag.d.ts +14 -0
  174. package/dest/tagging/siloed_tag.d.ts.map +1 -0
  175. package/dest/tagging/siloed_tag.js +20 -0
  176. package/dest/tagging/tag.d.ts +12 -0
  177. package/dest/tagging/tag.d.ts.map +1 -0
  178. package/dest/tagging/tag.js +17 -0
  179. package/dest/tagging/utils.d.ts +18 -0
  180. package/dest/tagging/utils.d.ts.map +1 -0
  181. package/dest/tagging/utils.js +24 -0
  182. package/package.json +34 -32
  183. package/src/bin/check_oracle_version.ts +50 -0
  184. package/src/config/index.ts +20 -33
  185. package/src/config/package_info.ts +1 -1
  186. package/src/contract_function_simulator/contract_function_simulator.ts +548 -0
  187. package/src/contract_function_simulator/execution_data_provider.ts +343 -0
  188. package/src/contract_function_simulator/execution_note_cache.ts +222 -0
  189. package/src/contract_function_simulator/execution_tagging_index_cache.ts +32 -0
  190. package/src/contract_function_simulator/hashed_values_cache.ts +47 -0
  191. package/src/contract_function_simulator/index.ts +13 -0
  192. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +47 -0
  193. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +27 -0
  194. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +69 -0
  195. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +52 -0
  196. package/src/contract_function_simulator/noir-structs/utility_context.ts +42 -0
  197. package/src/contract_function_simulator/oracle/index.ts +16 -0
  198. package/src/contract_function_simulator/oracle/interfaces.ts +160 -0
  199. package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +23 -0
  200. package/src/contract_function_simulator/oracle/note_packing_utils.ts +52 -0
  201. package/src/contract_function_simulator/oracle/oracle.ts +575 -0
  202. package/src/contract_function_simulator/oracle/private_execution.ts +207 -0
  203. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +625 -0
  204. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +358 -0
  205. package/src/contract_function_simulator/pick_notes.ts +141 -0
  206. package/src/contract_function_simulator/proxied_contract_data_source.ts +66 -0
  207. package/src/contract_function_simulator/proxied_node.ts +33 -0
  208. package/src/contract_function_simulator/pxe_oracle_interface.ts +1019 -0
  209. package/src/entrypoints/client/bundle/index.ts +4 -2
  210. package/src/entrypoints/client/bundle/utils.ts +36 -36
  211. package/src/entrypoints/client/lazy/index.ts +4 -2
  212. package/src/entrypoints/client/lazy/utils.ts +36 -31
  213. package/src/entrypoints/{client/pxe_creation_options.ts → pxe_creation_options.ts} +4 -1
  214. package/src/entrypoints/server/index.ts +5 -3
  215. package/src/entrypoints/server/utils.ts +69 -47
  216. package/src/{pxe_service/error_enriching.ts → error_enriching.ts} +36 -27
  217. package/src/oracle_version.ts +11 -0
  218. package/src/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.ts +158 -142
  219. package/src/private_kernel/hints/compute_tx_include_by_timestamp.ts +58 -0
  220. package/src/{kernel_prover → private_kernel}/hints/index.ts +1 -0
  221. package/src/private_kernel/index.ts +2 -0
  222. package/src/private_kernel/private_kernel_execution_prover.ts +436 -0
  223. package/src/{kernel_prover/proving_data_oracle.ts → private_kernel/private_kernel_oracle.ts} +17 -29
  224. package/src/{kernel_oracle/index.ts → private_kernel/private_kernel_oracle_impl.ts} +30 -15
  225. package/src/pxe.ts +1113 -0
  226. package/src/storage/address_data_provider/address_data_provider.ts +1 -7
  227. package/src/storage/capsule_data_provider/capsule_data_provider.ts +97 -30
  228. package/src/storage/contract_data_provider/contract_data_provider.ts +114 -81
  229. package/src/storage/contract_data_provider/index.ts +0 -1
  230. package/src/storage/contract_data_provider/private_functions_tree.ts +11 -75
  231. package/src/storage/index.ts +2 -4
  232. package/src/storage/metadata.ts +1 -0
  233. package/src/storage/note_data_provider/note_dao.ts +19 -27
  234. package/src/storage/note_data_provider/note_data_provider.ts +161 -113
  235. package/src/storage/private_event_data_provider/private_event_data_provider.ts +148 -0
  236. package/src/storage/sync_data_provider/sync_data_provider.ts +4 -10
  237. package/src/storage/tagging_data_provider/tagging_data_provider.ts +58 -30
  238. package/src/synchronizer/synchronizer.ts +21 -22
  239. package/src/tagging/constants.ts +2 -0
  240. package/src/tagging/index.ts +6 -0
  241. package/src/tagging/siloed_tag.ts +22 -0
  242. package/src/tagging/tag.ts +16 -0
  243. package/src/tagging/utils.ts +31 -0
  244. package/dest/bin/index.d.ts +0 -3
  245. package/dest/bin/index.d.ts.map +0 -1
  246. package/dest/bin/index.js +0 -28
  247. package/dest/entrypoints/client/pxe_creation_options.d.ts.map +0 -1
  248. package/dest/kernel_oracle/index.d.ts.map +0 -1
  249. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
  250. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.js +0 -270
  251. package/dest/kernel_prover/hints/index.d.ts +0 -2
  252. package/dest/kernel_prover/hints/index.d.ts.map +0 -1
  253. package/dest/kernel_prover/index.d.ts +0 -3
  254. package/dest/kernel_prover/index.d.ts.map +0 -1
  255. package/dest/kernel_prover/index.js +0 -2
  256. package/dest/kernel_prover/kernel_prover.d.ts +0 -38
  257. package/dest/kernel_prover/kernel_prover.d.ts.map +0 -1
  258. package/dest/kernel_prover/kernel_prover.js +0 -217
  259. package/dest/kernel_prover/proving_data_oracle.d.ts.map +0 -1
  260. package/dest/kernel_prover/proving_data_oracle.js +0 -4
  261. package/dest/note_decryption_utils/add_public_values_to_payload.d.ts +0 -11
  262. package/dest/note_decryption_utils/add_public_values_to_payload.d.ts.map +0 -1
  263. package/dest/note_decryption_utils/add_public_values_to_payload.js +0 -47
  264. package/dest/pxe_http/index.d.ts +0 -2
  265. package/dest/pxe_http/index.d.ts.map +0 -1
  266. package/dest/pxe_http/index.js +0 -1
  267. package/dest/pxe_http/pxe_http_server.d.ts +0 -16
  268. package/dest/pxe_http/pxe_http_server.d.ts.map +0 -1
  269. package/dest/pxe_http/pxe_http_server.js +0 -27
  270. package/dest/pxe_oracle_interface/index.d.ts +0 -159
  271. package/dest/pxe_oracle_interface/index.d.ts.map +0 -1
  272. package/dest/pxe_oracle_interface/index.js +0 -692
  273. package/dest/pxe_oracle_interface/tagging_utils.d.ts +0 -17
  274. package/dest/pxe_oracle_interface/tagging_utils.d.ts.map +0 -1
  275. package/dest/pxe_oracle_interface/tagging_utils.js +0 -23
  276. package/dest/pxe_service/error_enriching.d.ts.map +0 -1
  277. package/dest/pxe_service/index.d.ts +0 -3
  278. package/dest/pxe_service/index.d.ts.map +0 -1
  279. package/dest/pxe_service/index.js +0 -2
  280. package/dest/pxe_service/pxe_service.d.ts +0 -111
  281. package/dest/pxe_service/pxe_service.d.ts.map +0 -1
  282. package/dest/pxe_service/pxe_service.js +0 -664
  283. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts +0 -11
  284. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts.map +0 -1
  285. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.js +0 -20
  286. package/dest/storage/auth_witness_data_provider/index.d.ts +0 -2
  287. package/dest/storage/auth_witness_data_provider/index.d.ts.map +0 -1
  288. package/dest/storage/auth_witness_data_provider/index.js +0 -1
  289. package/dest/storage/data_provider.d.ts +0 -4
  290. package/dest/storage/data_provider.d.ts.map +0 -1
  291. package/dest/storage/data_provider.js +0 -1
  292. package/dest/test/pxe_test_suite.d.ts +0 -3
  293. package/dest/test/pxe_test_suite.d.ts.map +0 -1
  294. package/dest/test/pxe_test_suite.js +0 -97
  295. package/src/bin/index.ts +0 -38
  296. package/src/kernel_prover/index.ts +0 -2
  297. package/src/kernel_prover/kernel_prover.ts +0 -351
  298. package/src/note_decryption_utils/add_public_values_to_payload.ts +0 -64
  299. package/src/pxe_http/index.ts +0 -1
  300. package/src/pxe_http/pxe_http_server.ts +0 -29
  301. package/src/pxe_oracle_interface/index.ts +0 -925
  302. package/src/pxe_oracle_interface/tagging_utils.ts +0 -32
  303. package/src/pxe_service/index.ts +0 -2
  304. package/src/pxe_service/pxe_service.ts +0 -949
  305. package/src/storage/auth_witness_data_provider/auth_witness_data_provider.ts +0 -34
  306. package/src/storage/auth_witness_data_provider/index.ts +0 -1
  307. package/src/storage/data_provider.ts +0 -3
  308. package/src/test/pxe_test_suite.ts +0 -111
  309. /package/dest/entrypoints/{client/pxe_creation_options.js → pxe_creation_options.js} +0 -0
@@ -0,0 +1,436 @@
1
+ import { vkAsFieldsMegaHonk } from '@aztec/foundation/crypto';
2
+ import { Fr } from '@aztec/foundation/fields';
3
+ import { createLogger } from '@aztec/foundation/log';
4
+ import { pushTestData } from '@aztec/foundation/testing';
5
+ import { Timer } from '@aztec/foundation/timer';
6
+ import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
7
+ import { ProtocolContractsList } from '@aztec/protocol-contracts';
8
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
9
+ import type { PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
10
+ import {
11
+ HidingKernelToPublicPrivateInputs,
12
+ HidingKernelToRollupPrivateInputs,
13
+ PaddedSideEffectAmounts,
14
+ PrivateCallData,
15
+ type PrivateExecutionStep,
16
+ PrivateKernelCircuitPublicInputs,
17
+ PrivateKernelData,
18
+ type PrivateKernelExecutionProofOutput,
19
+ PrivateKernelInitCircuitPrivateInputs,
20
+ PrivateKernelInnerCircuitPrivateInputs,
21
+ type PrivateKernelSimulateOutput,
22
+ PrivateKernelTailCircuitPrivateInputs,
23
+ type PrivateKernelTailCircuitPublicInputs,
24
+ PrivateVerificationKeyHints,
25
+ } from '@aztec/stdlib/kernel';
26
+ import { ChonkProof, ChonkProofWithPublicInputs } from '@aztec/stdlib/proofs';
27
+ import {
28
+ type PrivateCallExecutionResult,
29
+ type PrivateExecutionResult,
30
+ TxRequest,
31
+ collectNoteHashLeafIndexMap,
32
+ collectNoteHashNullifierCounterMap,
33
+ getFinalMinRevertibleSideEffectCounter,
34
+ } from '@aztec/stdlib/tx';
35
+ import { VerificationKeyAsFields, VerificationKeyData, VkData } from '@aztec/stdlib/vks';
36
+
37
+ import { PrivateKernelResetPrivateInputsBuilder } from './hints/build_private_kernel_reset_private_inputs.js';
38
+ import type { PrivateKernelOracle } from './private_kernel_oracle.js';
39
+
40
+ const NULL_SIMULATE_OUTPUT: PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs> = {
41
+ publicInputs: PrivateKernelCircuitPublicInputs.empty(),
42
+ verificationKey: VerificationKeyData.empty(),
43
+ outputWitness: new Map(),
44
+ bytecode: Buffer.from([]),
45
+ };
46
+
47
+ export interface PrivateKernelExecutionProverConfig {
48
+ simulate: boolean;
49
+ skipFeeEnforcement: boolean;
50
+ profileMode: 'gates' | 'execution-steps' | 'full' | 'none';
51
+ }
52
+
53
+ /**
54
+ * The PrivateKernelExecutionProver class is responsible for taking a transaction request and sequencing the
55
+ * the execution of the private functions within, sequenced with private kernel "glue" to check protocol rules.
56
+ * The result can be a chonk proof of the private transaction portion, or just a simulation that can e.g.
57
+ * inform state tree updates.
58
+ */
59
+ export class PrivateKernelExecutionProver {
60
+ private log = createLogger('pxe:private-kernel-execution-prover');
61
+
62
+ constructor(
63
+ private oracle: PrivateKernelOracle,
64
+ private proofCreator: PrivateKernelProver,
65
+ private fakeProofs = false,
66
+ ) {}
67
+
68
+ /**
69
+ * Generate a proof for a given transaction request and execution result.
70
+ * The function iterates through the nested executions in the execution result, creates private call data,
71
+ * and generates a proof using the provided ProofCreator instance. It also maintains an index of new notes
72
+ * created during the execution and returns them as a part of the KernelProverOutput.
73
+ *
74
+ * @param txRequest - The authenticated transaction request object.
75
+ * @param executionResult - The execution result object containing nested executions and preimages.
76
+ * @param profile - Set true to profile the gate count for each circuit
77
+ * @returns A Promise that resolves to a KernelProverOutput object containing proof, public inputs, and output notes.
78
+ */
79
+ async proveWithKernels(
80
+ txRequest: TxRequest,
81
+ executionResult: PrivateExecutionResult,
82
+ { simulate, skipFeeEnforcement, profileMode }: PrivateKernelExecutionProverConfig = {
83
+ simulate: false,
84
+ skipFeeEnforcement: false,
85
+ profileMode: 'none',
86
+ },
87
+ ): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>> {
88
+ const skipProofGeneration = this.fakeProofs || simulate;
89
+ const generateWitnesses = !skipProofGeneration || profileMode !== 'none';
90
+
91
+ const timer = new Timer();
92
+
93
+ const isPrivateOnlyTx = executionResult.publicFunctionCalldata.length === 0;
94
+
95
+ // Initialize an executionStack, beginning with the PrivateCallExecutionResult
96
+ // of the entrypoint function of the tx.
97
+ const executionStack = [executionResult.entrypoint];
98
+ let firstIteration = true;
99
+
100
+ let output = NULL_SIMULATE_OUTPUT;
101
+
102
+ const executionSteps: PrivateExecutionStep[] = [];
103
+
104
+ const noteHashLeafIndexMap = collectNoteHashLeafIndexMap(executionResult);
105
+ const noteHashNullifierCounterMap = collectNoteHashNullifierCounterMap(executionResult);
106
+ const validationRequestsSplitCounter = isPrivateOnlyTx
107
+ ? 0
108
+ : getFinalMinRevertibleSideEffectCounter(executionResult);
109
+
110
+ while (executionStack.length) {
111
+ if (!firstIteration) {
112
+ let resetBuilder = new PrivateKernelResetPrivateInputsBuilder(
113
+ output,
114
+ executionStack,
115
+ noteHashNullifierCounterMap,
116
+ validationRequestsSplitCounter,
117
+ );
118
+ while (resetBuilder.needsReset()) {
119
+ const witgenTimer = new Timer();
120
+ const privateInputs = await resetBuilder.build(this.oracle, noteHashLeafIndexMap);
121
+ output = generateWitnesses
122
+ ? await this.proofCreator.generateResetOutput(privateInputs)
123
+ : await this.proofCreator.simulateReset(privateInputs);
124
+ executionSteps.push({
125
+ functionName: 'private_kernel_reset',
126
+ bytecode: output.bytecode,
127
+ witness: output.outputWitness,
128
+ vk: output.verificationKey.keyAsBytes,
129
+ timings: {
130
+ witgen: witgenTimer.ms(),
131
+ },
132
+ });
133
+ resetBuilder = new PrivateKernelResetPrivateInputsBuilder(
134
+ output,
135
+ executionStack,
136
+ noteHashNullifierCounterMap,
137
+ validationRequestsSplitCounter,
138
+ );
139
+ }
140
+ }
141
+
142
+ const currentExecution = executionStack.pop()!;
143
+
144
+ executionStack.push(...[...currentExecution.nestedExecutionResults].reverse());
145
+
146
+ const functionName = await this.oracle.getDebugFunctionName(
147
+ currentExecution.publicInputs.callContext.contractAddress,
148
+ currentExecution.publicInputs.callContext.functionSelector,
149
+ );
150
+
151
+ executionSteps.push({
152
+ functionName: functionName!,
153
+ bytecode: currentExecution.acir,
154
+ witness: currentExecution.partialWitness,
155
+ vk: currentExecution.vk,
156
+ timings: {
157
+ witgen: currentExecution.profileResult?.timings.witgen ?? 0,
158
+ oracles: currentExecution.profileResult?.timings.oracles,
159
+ },
160
+ });
161
+
162
+ const privateCallData = await this.createPrivateCallData(currentExecution);
163
+
164
+ if (firstIteration) {
165
+ const witgenTimer = new Timer();
166
+
167
+ const proofInput = new PrivateKernelInitCircuitPrivateInputs(
168
+ txRequest,
169
+ getVKTreeRoot(),
170
+ ProtocolContractsList,
171
+ privateCallData,
172
+ isPrivateOnlyTx,
173
+ executionResult.firstNullifier,
174
+ );
175
+ this.log.debug(
176
+ `Calling private kernel init with isPrivateOnly ${isPrivateOnlyTx} and firstNullifierHint ${proofInput.firstNullifierHint}`,
177
+ );
178
+
179
+ pushTestData('private-kernel-inputs-init', proofInput);
180
+
181
+ output = generateWitnesses
182
+ ? await this.proofCreator.generateInitOutput(proofInput)
183
+ : await this.proofCreator.simulateInit(proofInput);
184
+
185
+ executionSteps.push({
186
+ functionName: 'private_kernel_init',
187
+ bytecode: output.bytecode,
188
+ witness: output.outputWitness,
189
+ vk: output.verificationKey.keyAsBytes,
190
+ timings: {
191
+ witgen: witgenTimer.ms(),
192
+ },
193
+ });
194
+ } else {
195
+ const witgenTimer = new Timer();
196
+ const vkData = await this.getVkData(output.verificationKey);
197
+ const previousKernelData = new PrivateKernelData(output.publicInputs, vkData);
198
+ const proofInput = new PrivateKernelInnerCircuitPrivateInputs(previousKernelData, privateCallData);
199
+
200
+ pushTestData('private-kernel-inputs-inner', proofInput);
201
+ output = generateWitnesses
202
+ ? await this.proofCreator.generateInnerOutput(proofInput)
203
+ : await this.proofCreator.simulateInner(proofInput);
204
+
205
+ executionSteps.push({
206
+ functionName: 'private_kernel_inner',
207
+ bytecode: output.bytecode,
208
+ witness: output.outputWitness,
209
+ vk: output.verificationKey.keyAsBytes,
210
+ timings: {
211
+ witgen: witgenTimer.ms(),
212
+ },
213
+ });
214
+ }
215
+ firstIteration = false;
216
+ }
217
+
218
+ // Reset.
219
+ let resetBuilder = new PrivateKernelResetPrivateInputsBuilder(
220
+ output,
221
+ [],
222
+ noteHashNullifierCounterMap,
223
+ validationRequestsSplitCounter,
224
+ );
225
+ while (resetBuilder.needsReset()) {
226
+ const witgenTimer = new Timer();
227
+ const privateInputs = await resetBuilder.build(this.oracle, noteHashLeafIndexMap);
228
+ output = generateWitnesses
229
+ ? await this.proofCreator.generateResetOutput(privateInputs)
230
+ : await this.proofCreator.simulateReset(privateInputs);
231
+
232
+ executionSteps.push({
233
+ functionName: 'private_kernel_reset',
234
+ bytecode: output.bytecode,
235
+ witness: output.outputWitness,
236
+ vk: output.verificationKey.keyAsBytes,
237
+ timings: {
238
+ witgen: witgenTimer.ms(),
239
+ },
240
+ });
241
+
242
+ resetBuilder = new PrivateKernelResetPrivateInputsBuilder(
243
+ output,
244
+ [],
245
+ noteHashNullifierCounterMap,
246
+ validationRequestsSplitCounter,
247
+ );
248
+ }
249
+
250
+ if (output.publicInputs.feePayer.isZero() && skipFeeEnforcement) {
251
+ if (!skipProofGeneration) {
252
+ throw new Error('Fee payment must be enforced when creating real proof.');
253
+ }
254
+ output.publicInputs.feePayer = new AztecAddress(Fr.MAX_FIELD_VALUE);
255
+ }
256
+ // Private tail.
257
+ const vkData = await this.getVkData(output.verificationKey);
258
+ const previousKernelData = new PrivateKernelData(output.publicInputs, vkData);
259
+
260
+ this.log.debug(
261
+ `Calling private kernel tail with hwm ${previousKernelData.publicInputs.minRevertibleSideEffectCounter}`,
262
+ );
263
+
264
+ // TODO: Enable padding once we better understand the final amounts to pad to.
265
+ const paddedSideEffectAmounts = PaddedSideEffectAmounts.empty();
266
+
267
+ // Use the aggregated includeByTimestamp set throughout the tx execution.
268
+ // TODO: Call `computeTxIncludeByTimestamp` to round the value down and reduce precision, improving privacy.
269
+ const includeByTimestampUpperBound = previousKernelData.publicInputs.includeByTimestamp;
270
+ const anchorBlockTimestamp = previousKernelData.publicInputs.constants.anchorBlockHeader.globalVariables.timestamp;
271
+ if (includeByTimestampUpperBound <= anchorBlockTimestamp) {
272
+ throw new Error(
273
+ `Include-by timestamp must be greater than the anchor block timestamp. Anchor block timestamp: ${anchorBlockTimestamp}. Include-by timestamp: ${includeByTimestampUpperBound}.`,
274
+ );
275
+ }
276
+
277
+ const privateInputs = new PrivateKernelTailCircuitPrivateInputs(
278
+ previousKernelData,
279
+ paddedSideEffectAmounts,
280
+ includeByTimestampUpperBound,
281
+ );
282
+
283
+ const witgenTimer = new Timer();
284
+ const tailOutput = generateWitnesses
285
+ ? await this.proofCreator.generateTailOutput(privateInputs)
286
+ : await this.proofCreator.simulateTail(privateInputs);
287
+
288
+ executionSteps.push({
289
+ functionName: 'private_kernel_tail',
290
+ bytecode: tailOutput.bytecode,
291
+ witness: tailOutput.outputWitness,
292
+ vk: tailOutput.verificationKey.keyAsBytes,
293
+ timings: {
294
+ witgen: witgenTimer.ms(),
295
+ },
296
+ });
297
+
298
+ // Hiding circuit is only executed if we are generating witnesses.
299
+ // For simulation, we can end with the tail, since the hiding circuit will simply return the same tail output.
300
+ if (generateWitnesses) {
301
+ const previousKernelVkData = await this.getVkData(tailOutput.verificationKey);
302
+
303
+ const witgenTimer = new Timer();
304
+ let hidingOutput: PrivateKernelSimulateOutput<PrivateKernelTailCircuitPublicInputs>;
305
+ if (tailOutput.publicInputs.forPublic) {
306
+ const privateInputs = new HidingKernelToPublicPrivateInputs(
307
+ tailOutput.publicInputs.toPrivateToPublicKernelCircuitPublicInputs(),
308
+ previousKernelVkData,
309
+ );
310
+ hidingOutput = await this.proofCreator.generateHidingToPublicOutput(privateInputs);
311
+ } else {
312
+ const privateInputs = new HidingKernelToRollupPrivateInputs(
313
+ tailOutput.publicInputs.toPrivateToRollupKernelCircuitPublicInputs(),
314
+ previousKernelVkData,
315
+ );
316
+ hidingOutput = await this.proofCreator.generateHidingToRollupOutput(privateInputs);
317
+ }
318
+
319
+ executionSteps.push({
320
+ functionName: 'hiding_kernel',
321
+ bytecode: hidingOutput.bytecode,
322
+ witness: hidingOutput.outputWitness,
323
+ vk: hidingOutput.verificationKey.keyAsBytes,
324
+ timings: {
325
+ witgen: witgenTimer.ms(),
326
+ },
327
+ });
328
+ }
329
+
330
+ if (profileMode == 'gates' || profileMode == 'full') {
331
+ for (const entry of executionSteps) {
332
+ const gateCountTimer = new Timer();
333
+ const gateCount = await this.proofCreator.computeGateCountForCircuit(entry.bytecode, entry.functionName);
334
+ entry.gateCount = gateCount;
335
+ entry.timings.gateCount = gateCountTimer.ms();
336
+ }
337
+ }
338
+ if (profileMode === 'gates') {
339
+ for (const entry of executionSteps) {
340
+ // These buffers are often a few megabytes in size - prevent accidentally serializing them if not requested.
341
+ entry.bytecode = Buffer.from([]);
342
+ entry.witness = new Map();
343
+ }
344
+ }
345
+
346
+ if (generateWitnesses) {
347
+ this.log.info(`Private kernel witness generation took ${timer.ms()}ms`);
348
+ }
349
+
350
+ let chonkProof: ChonkProof;
351
+ // TODO(#7368) how do we 'bincode' encode these inputs?
352
+ let provingTime;
353
+ if (!skipProofGeneration) {
354
+ const provingTimer = new Timer();
355
+ const proofWithPublicInputs = await this.proofCreator.createChonkProof(executionSteps);
356
+ provingTime = provingTimer.ms();
357
+ this.ensurePublicInputsMatch(proofWithPublicInputs, tailOutput.publicInputs);
358
+ chonkProof = proofWithPublicInputs.removePublicInputs();
359
+ } else {
360
+ chonkProof = ChonkProof.random();
361
+ }
362
+
363
+ return {
364
+ publicInputs: tailOutput.publicInputs,
365
+ executionSteps,
366
+ chonkProof,
367
+ timings: provingTime ? { proving: provingTime } : undefined,
368
+ };
369
+ }
370
+
371
+ /**
372
+ * Checks that the public inputs of the chonk proof match the public inputs of the tail circuit.
373
+ * This can only mismatch if there is a circuit / noir / bb bug.
374
+ * @param chonkProof - The chonk proof with public inputs.
375
+ * @param tailPublicInputs - The public inputs resulting from witness generation of the tail circuit.
376
+ */
377
+ private ensurePublicInputsMatch(
378
+ chonkProof: ChonkProofWithPublicInputs,
379
+ tailPublicInputs: PrivateKernelTailCircuitPublicInputs,
380
+ ) {
381
+ const serializedChonkProofPublicInputs = chonkProof.getPublicInputs();
382
+ const serializedTailPublicInputs = tailPublicInputs.publicInputs().toFields();
383
+ if (serializedChonkProofPublicInputs.length !== serializedTailPublicInputs.length) {
384
+ throw new Error(
385
+ `Public inputs length mismatch: ${serializedChonkProofPublicInputs.length} !== ${serializedTailPublicInputs.length}`,
386
+ );
387
+ }
388
+ if (
389
+ !serializedChonkProofPublicInputs.every((input: Fr, index: number) =>
390
+ input.equals(serializedTailPublicInputs[index]),
391
+ )
392
+ ) {
393
+ throw new Error(`Public inputs mismatch between kernel and chonk proof`);
394
+ }
395
+ }
396
+
397
+ private async getVkData(verificationKey: VerificationKeyData) {
398
+ const previousVkMembershipWitness = await this.oracle.getVkMembershipWitness(verificationKey.keyAsFields);
399
+ return new VkData(
400
+ verificationKey,
401
+ Number(previousVkMembershipWitness.leafIndex),
402
+ previousVkMembershipWitness.siblingPath,
403
+ );
404
+ }
405
+
406
+ private async createPrivateCallData({ publicInputs, vk: vkAsBuffer }: PrivateCallExecutionResult) {
407
+ const { contractAddress, functionSelector } = publicInputs.callContext;
408
+
409
+ const vkAsFields = await vkAsFieldsMegaHonk(vkAsBuffer);
410
+ const vk = await VerificationKeyAsFields.fromKey(vkAsFields);
411
+
412
+ const { currentContractClassId, publicKeys, saltedInitializationHash } =
413
+ await this.oracle.getContractAddressPreimage(contractAddress);
414
+ const functionLeafMembershipWitness = await this.oracle.getFunctionMembershipWitness(
415
+ currentContractClassId,
416
+ functionSelector,
417
+ );
418
+
419
+ const { artifactHash: contractClassArtifactHash, publicBytecodeCommitment: contractClassPublicBytecodeCommitment } =
420
+ await this.oracle.getContractClassIdPreimage(currentContractClassId);
421
+
422
+ const updatedClassIdHints = await this.oracle.getUpdatedClassIdHints(contractAddress);
423
+ return PrivateCallData.from({
424
+ publicInputs,
425
+ vk,
426
+ verificationKeyHints: PrivateVerificationKeyHints.from({
427
+ publicKeys,
428
+ contractClassArtifactHash,
429
+ contractClassPublicBytecodeCommitment,
430
+ saltedInitializationHash,
431
+ functionLeafMembershipWitness,
432
+ updatedClassIdHints,
433
+ }),
434
+ });
435
+ }
436
+ }
@@ -1,6 +1,6 @@
1
- import type { FUNCTION_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants';
1
+ import { FUNCTION_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants';
2
2
  import type { Fr, GrumpkinScalar, Point } from '@aztec/foundation/fields';
3
- import type { MembershipWitness } from '@aztec/foundation/trees';
3
+ import { MembershipWitness } from '@aztec/foundation/trees';
4
4
  import type { FunctionSelector } from '@aztec/stdlib/abi';
5
5
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
6
6
  import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
@@ -9,10 +9,10 @@ import type { NullifierMembershipWitness } from '@aztec/stdlib/trees';
9
9
  import type { VerificationKeyAsFields } from '@aztec/stdlib/vks';
10
10
 
11
11
  /**
12
- * Provides functionality to fetch membership witnesses for verification keys,
13
- * contract addresses, and function selectors in their respective merkle trees.
12
+ * Provides functionality needed by the private kernel for interacting with our state trees.
13
+ * This is either PrivateKernelOracleImpl, or a mocked test implementation.
14
14
  */
15
- export interface ProvingDataOracle {
15
+ export interface PrivateKernelOracle {
16
16
  /** Retrieves the preimage of a contract address from the registered contract instances db. */
17
17
  getContractAddressPreimage(address: AztecAddress): Promise<{
18
18
  saltedInitializationHash: Fr;
@@ -27,13 +27,7 @@ export interface ProvingDataOracle {
27
27
  ): Promise<{ artifactHash: Fr; publicBytecodeCommitment: Fr; privateFunctionsRoot: Fr }>;
28
28
 
29
29
  /**
30
- * Retrieve the function membership witness for the given contract class and function selector.
31
- * The function membership witness represents a proof that the function belongs to the specified contract.
32
- * Throws an error if the contract address or function selector is unknown.
33
- *
34
- * @param contractClassId - The id of the class.
35
- * @param selector - The function selector.
36
- * @returns A promise that resolves with the MembershipWitness instance for the specified contract's function.
30
+ * Returns a membership witness with the sibling path and leaf index in our private functions tree.
37
31
  */
38
32
  getFunctionMembershipWitness(
39
33
  contractClassId: Fr,
@@ -41,30 +35,21 @@ export interface ProvingDataOracle {
41
35
  ): Promise<MembershipWitness<typeof FUNCTION_TREE_HEIGHT>>;
42
36
 
43
37
  /**
44
- * Retrieve the membership witness corresponding to a verification key.
45
- * This function currently returns a random membership witness of the specified height,
46
- * which is a placeholder implementation until a concrete membership witness calculation
47
- * is implemented.
48
- *
49
- * @param vk - The VerificationKey for which the membership witness is needed.
50
- * @returns A Promise that resolves to the MembershipWitness instance.
38
+ * Returns a membership witness with the sibling path and leaf index in our protocol VK indexed merkle tree.
39
+ * Used to validate the previous kernel's verification key.
51
40
  */
52
41
  getVkMembershipWitness(vk: VerificationKeyAsFields): Promise<MembershipWitness<typeof VK_TREE_HEIGHT>>;
53
42
 
54
43
  /**
55
- * Get the note membership witness for a note in the note hash tree at the given leaf index.
56
- *
57
- * @param leafIndex - The leaf index of the note in the note hash tree.
58
- * @returns the MembershipWitness for the note.
59
- */
60
- getNoteHashMembershipWitness(leafIndex: bigint): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT>>;
44
+ * Returns a membership witness with the sibling path and leaf index in our private function indexed merkle tree.
45
+ */ getNoteHashMembershipWitness(leafIndex: bigint): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT>>;
61
46
 
47
+ /**
48
+ * Returns a membership witness with the sibling path and leaf index in our nullifier indexed merkle tree.
49
+ */
62
50
  getNullifierMembershipWitness(nullifier: Fr): Promise<NullifierMembershipWitness | undefined>;
63
-
64
51
  /**
65
- * Get the root of the note hash tree.
66
- *
67
- * @returns the root of the note hash tree.
52
+ * Returns the root of our note hash merkle tree.
68
53
  */
69
54
  getNoteHashTreeRoot(): Promise<Fr>;
70
55
 
@@ -77,7 +62,10 @@ export interface ProvingDataOracle {
77
62
  */
78
63
  getMasterSecretKey(masterPublicKey: Point): Promise<GrumpkinScalar>;
79
64
 
65
+ /** Use debug data to get the function name corresponding to a selector. */
80
66
  getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
81
67
 
68
+ /** Returns a membership witness and leaf index to our public data indexed merkle tree,
69
+ * along with an associated DelayedPublicMutable containing the class ID to update. */
82
70
  getUpdatedClassIdHints(contractAddress: AztecAddress): Promise<UpdatedClassIdHints>;
83
71
  }
@@ -1,4 +1,4 @@
1
- import { type NOTE_HASH_TREE_HEIGHT, PUBLIC_DATA_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants';
1
+ import { NOTE_HASH_TREE_HEIGHT, PUBLIC_DATA_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants';
2
2
  import type { Fr, GrumpkinScalar, Point } from '@aztec/foundation/fields';
3
3
  import { createLogger } from '@aztec/foundation/log';
4
4
  import type { Tuple } from '@aztec/foundation/serialize';
@@ -10,22 +10,23 @@ import type { FunctionSelector } from '@aztec/stdlib/abi';
10
10
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
11
11
  import type { L2BlockNumber } from '@aztec/stdlib/block';
12
12
  import { computeContractClassIdPreimage, computeSaltedInitializationHash } from '@aztec/stdlib/contract';
13
+ import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
13
14
  import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
14
15
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
15
16
  import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
16
- import { SharedMutableValues, SharedMutableValuesWithHash } from '@aztec/stdlib/shared-mutable';
17
17
  import type { NullifierMembershipWitness } from '@aztec/stdlib/trees';
18
18
  import type { VerificationKeyAsFields } from '@aztec/stdlib/vks';
19
19
 
20
- import type { ContractDataProvider } from '../storage/contract_data_provider/contract_data_provider.js';
21
- import type { ProvingDataOracle } from './../kernel_prover/proving_data_oracle.js';
20
+ import type { ContractDataProvider } from '../storage/index.js';
21
+ import type { PrivateKernelOracle } from './private_kernel_oracle.js';
22
22
 
23
23
  // TODO: Block number should not be "latest".
24
24
  // It should be fixed at the time the proof is being simulated. I.e., it should be the same as the value defined in the constant data.
25
+
25
26
  /**
26
27
  * A data oracle that provides information needed for simulating a transaction.
27
28
  */
28
- export class KernelOracle implements ProvingDataOracle {
29
+ export class PrivateKernelOracleImpl implements PrivateKernelOracle {
29
30
  constructor(
30
31
  private contractDataProvider: ContractDataProvider,
31
32
  private keyStore: KeyStore,
@@ -36,6 +37,9 @@ export class KernelOracle implements ProvingDataOracle {
36
37
 
37
38
  public async getContractAddressPreimage(address: AztecAddress) {
38
39
  const instance = await this.contractDataProvider.getContractInstance(address);
40
+ if (!instance) {
41
+ throw new Error(`Contract instance not found when getting address preimage. Contract address: ${address}.`);
42
+ }
39
43
  return {
40
44
  saltedInitializationHash: await computeSaltedInitializationHash(instance),
41
45
  ...instance,
@@ -44,11 +48,20 @@ export class KernelOracle implements ProvingDataOracle {
44
48
 
45
49
  public async getContractClassIdPreimage(contractClassId: Fr) {
46
50
  const contractClass = await this.contractDataProvider.getContractClass(contractClassId);
51
+ if (!contractClass) {
52
+ throw new Error(`Contract class not found when getting class id preimage. Class id: ${contractClassId}.`);
53
+ }
47
54
  return computeContractClassIdPreimage(contractClass);
48
55
  }
49
56
 
50
57
  public async getFunctionMembershipWitness(contractClassId: Fr, selector: FunctionSelector) {
51
- return await this.contractDataProvider.getFunctionMembershipWitness(contractClassId, selector);
58
+ const membershipWitness = await this.contractDataProvider.getFunctionMembershipWitness(contractClassId, selector);
59
+ if (!membershipWitness) {
60
+ throw new Error(
61
+ `Membership witness not found for contract class id ${contractClassId} and selector ${selector}.`,
62
+ );
63
+ }
64
+ return membershipWitness;
52
65
  }
53
66
 
54
67
  public getVkMembershipWitness(vk: VerificationKeyAsFields) {
@@ -86,23 +99,25 @@ export class KernelOracle implements ProvingDataOracle {
86
99
  }
87
100
 
88
101
  public async getUpdatedClassIdHints(contractAddress: AztecAddress): Promise<UpdatedClassIdHints> {
89
- const { sharedMutableSlot, sharedMutableHashSlot } = await SharedMutableValuesWithHash.getContractUpdateSlots(
90
- contractAddress,
91
- );
102
+ const { delayedPublicMutableSlot, delayedPublicMutableHashSlot } =
103
+ await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(contractAddress);
92
104
 
93
105
  const hashLeafSlot = await computePublicDataTreeLeafSlot(
94
- ProtocolContractAddress.ContractInstanceDeployer,
95
- sharedMutableHashSlot,
106
+ ProtocolContractAddress.ContractInstanceRegistry,
107
+ delayedPublicMutableHashSlot,
96
108
  );
97
- const updatedClassIdWitness = await this.node.getPublicDataTreeWitness(this.blockNumber, hashLeafSlot);
109
+ const updatedClassIdWitness = await this.node.getPublicDataWitness(this.blockNumber, hashLeafSlot);
98
110
 
99
111
  if (!updatedClassIdWitness) {
100
112
  throw new Error(`No public data tree witness found for ${hashLeafSlot}`);
101
113
  }
102
114
 
103
115
  const readStorage = (storageSlot: Fr) =>
104
- this.node.getPublicStorageAt(this.blockNumber, ProtocolContractAddress.ContractInstanceDeployer, storageSlot);
105
- const sharedMutableValues = await SharedMutableValues.readFromTree(sharedMutableSlot, readStorage);
116
+ this.node.getPublicStorageAt(this.blockNumber, ProtocolContractAddress.ContractInstanceRegistry, storageSlot);
117
+ const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree(
118
+ delayedPublicMutableSlot,
119
+ readStorage,
120
+ );
106
121
 
107
122
  return new UpdatedClassIdHints(
108
123
  new MembershipWitness(
@@ -111,7 +126,7 @@ export class KernelOracle implements ProvingDataOracle {
111
126
  updatedClassIdWitness.siblingPath.toTuple(),
112
127
  ),
113
128
  updatedClassIdWitness.leafPreimage,
114
- sharedMutableValues,
129
+ delayedPublicMutableValues,
115
130
  );
116
131
  }
117
132
  }