@aztec/pxe 0.0.0-test.1 → 0.0.1-commit.023c3e5
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.
- package/README.md +5 -5
- package/dest/bin/check_oracle_version.d.ts +2 -0
- package/dest/bin/check_oracle_version.d.ts.map +1 -0
- package/dest/bin/check_oracle_version.js +129 -0
- package/dest/block_synchronizer/block_synchronizer.d.ts +43 -0
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -0
- package/dest/block_synchronizer/block_synchronizer.js +147 -0
- package/dest/block_synchronizer/index.d.ts +2 -0
- package/dest/block_synchronizer/index.d.ts.map +1 -0
- package/dest/block_synchronizer/index.js +1 -0
- package/dest/config/index.d.ts +13 -24
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +35 -33
- package/dest/config/package_info.d.ts +1 -1
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/benchmarked_node.d.ts +9 -0
- package/dest/contract_function_simulator/benchmarked_node.d.ts.map +1 -0
- package/dest/contract_function_simulator/benchmarked_node.js +77 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +82 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -0
- package/dest/contract_function_simulator/contract_function_simulator.js +339 -0
- package/dest/contract_function_simulator/execution_note_cache.d.ts +104 -0
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -0
- package/dest/contract_function_simulator/execution_note_cache.js +208 -0
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +16 -0
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -0
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +26 -0
- package/dest/contract_function_simulator/hashed_values_cache.d.ts +28 -0
- package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -0
- package/dest/contract_function_simulator/hashed_values_cache.js +36 -0
- package/dest/contract_function_simulator/index.d.ts +14 -0
- package/dest/contract_function_simulator/index.d.ts.map +1 -0
- package/dest/contract_function_simulator/index.js +12 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +21 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +40 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +16 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +26 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +17 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +65 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +24 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +51 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +16 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.js +22 -0
- package/dest/contract_function_simulator/oracle/index.d.ts +14 -0
- package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/index.js +2 -0
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +107 -0
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/interfaces.js +4 -0
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +19 -0
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +24 -0
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +28 -0
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +54 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts +60 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/oracle.js +356 -0
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +23 -0
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/private_execution.js +87 -0
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +239 -0
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +426 -0
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +209 -0
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +376 -0
- package/dest/contract_function_simulator/pick_notes.d.ts +85 -0
- package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -0
- package/dest/contract_function_simulator/pick_notes.js +51 -0
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +6 -0
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -0
- package/dest/contract_function_simulator/proxied_contract_data_source.js +80 -0
- package/dest/contract_sync/index.d.ts +23 -0
- package/dest/contract_sync/index.d.ts.map +1 -0
- package/dest/contract_sync/index.js +54 -0
- package/dest/debug/pxe_debug_utils.d.ts +41 -0
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -0
- package/dest/debug/pxe_debug_utils.js +47 -0
- package/dest/entrypoints/client/bundle/index.d.ts +4 -3
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +2 -2
- package/dest/entrypoints/client/bundle/utils.d.ts +10 -10
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +33 -12
- package/dest/entrypoints/client/lazy/index.d.ts +4 -3
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +2 -2
- package/dest/entrypoints/client/lazy/utils.d.ts +10 -10
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +33 -12
- package/dest/entrypoints/pxe_creation_options.d.ts +18 -0
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -0
- package/dest/entrypoints/server/index.d.ts +8 -4
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +6 -3
- package/dest/entrypoints/server/utils.d.ts +8 -16
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +46 -36
- package/dest/error_enriching.d.ts +11 -0
- package/dest/error_enriching.d.ts.map +1 -0
- package/dest/{pxe_service/error_enriching.js → error_enriching.js} +30 -22
- package/dest/events/event_service.d.ts +15 -0
- package/dest/events/event_service.d.ts.map +1 -0
- package/dest/events/event_service.js +44 -0
- package/dest/events/index.d.ts +2 -0
- package/dest/events/index.d.ts.map +1 -0
- package/dest/events/index.js +1 -0
- package/dest/events/private_event_filter_validator.d.ts +9 -0
- package/dest/events/private_event_filter_validator.d.ts.map +1 -0
- package/dest/events/private_event_filter_validator.js +38 -0
- package/dest/job_coordinator/job_coordinator.d.ts +75 -0
- package/dest/job_coordinator/job_coordinator.d.ts.map +1 -0
- package/dest/job_coordinator/job_coordinator.js +94 -0
- package/dest/logs/log_service.d.ts +28 -0
- package/dest/logs/log_service.d.ts.map +1 -0
- package/dest/logs/log_service.js +125 -0
- package/dest/notes/index.d.ts +2 -0
- package/dest/notes/index.d.ts.map +1 -0
- package/dest/notes/index.js +1 -0
- package/dest/notes/note_service.d.ts +48 -0
- package/dest/notes/note_service.d.ts.map +1 -0
- package/dest/notes/note_service.js +147 -0
- package/dest/oracle_version.d.ts +3 -0
- package/dest/oracle_version.d.ts.map +1 -0
- package/dest/oracle_version.js +11 -0
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +4 -0
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +1 -0
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.js +41 -0
- package/dest/private_kernel/hints/index.d.ts +3 -0
- package/dest/private_kernel/hints/index.d.ts.map +1 -0
- package/dest/private_kernel/hints/index.js +2 -0
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +28 -0
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -0
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +277 -0
- package/dest/private_kernel/index.d.ts +3 -0
- package/dest/private_kernel/index.d.ts.map +1 -0
- package/dest/private_kernel/index.js +2 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +45 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -0
- package/dest/private_kernel/private_kernel_execution_prover.js +285 -0
- package/dest/private_kernel/private_kernel_oracle.d.ts +59 -0
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -0
- package/dest/private_kernel/private_kernel_oracle.js +92 -0
- package/dest/pxe.d.ts +204 -0
- package/dest/pxe.d.ts.map +1 -0
- package/dest/pxe.js +742 -0
- package/dest/storage/address_store/address_store.d.ts +11 -0
- package/dest/storage/address_store/address_store.d.ts.map +1 -0
- package/dest/storage/{address_data_provider/address_data_provider.js → address_store/address_store.js} +13 -15
- package/dest/storage/address_store/index.d.ts +2 -0
- package/dest/storage/address_store/index.d.ts.map +1 -0
- package/dest/storage/address_store/index.js +1 -0
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts +17 -0
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -0
- package/dest/storage/anchor_block_store/anchor_block_store.js +26 -0
- package/dest/storage/anchor_block_store/index.d.ts +2 -0
- package/dest/storage/anchor_block_store/index.d.ts.map +1 -0
- package/dest/storage/anchor_block_store/index.js +1 -0
- package/dest/storage/capsule_store/capsule_store.d.ts +72 -0
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -0
- package/dest/storage/capsule_store/capsule_store.js +253 -0
- package/dest/storage/capsule_store/index.d.ts +2 -0
- package/dest/storage/capsule_store/index.d.ts.map +1 -0
- package/dest/storage/capsule_store/index.js +1 -0
- package/dest/storage/contract_store/contract_store.d.ts +66 -0
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -0
- package/dest/storage/contract_store/contract_store.js +233 -0
- package/dest/storage/contract_store/index.d.ts +2 -0
- package/dest/storage/contract_store/index.d.ts.map +1 -0
- package/dest/storage/contract_store/index.js +1 -0
- package/dest/storage/contract_store/private_functions_tree.d.ts +27 -0
- package/dest/storage/contract_store/private_functions_tree.d.ts.map +1 -0
- package/dest/storage/contract_store/private_functions_tree.js +47 -0
- package/dest/storage/index.d.ts +9 -10
- package/dest/storage/index.d.ts.map +1 -1
- package/dest/storage/index.js +8 -9
- package/dest/storage/metadata.d.ts +2 -0
- package/dest/storage/metadata.d.ts.map +1 -0
- package/dest/storage/metadata.js +1 -0
- package/dest/storage/note_store/index.d.ts +3 -0
- package/dest/storage/note_store/index.d.ts.map +1 -0
- package/dest/storage/note_store/index.js +2 -0
- package/dest/storage/note_store/note_store.d.ts +83 -0
- package/dest/storage/note_store/note_store.d.ts.map +1 -0
- package/dest/storage/note_store/note_store.js +341 -0
- package/dest/storage/note_store/stored_note.d.ts +16 -0
- package/dest/storage/note_store/stored_note.d.ts.map +1 -0
- package/dest/storage/note_store/stored_note.js +43 -0
- package/dest/storage/private_event_store/private_event_store.d.ts +91 -0
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -0
- package/dest/storage/private_event_store/private_event_store.js +273 -0
- package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
- package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
- package/dest/storage/private_event_store/stored_private_event.js +56 -0
- package/dest/storage/tagging_store/index.d.ts +4 -0
- package/dest/storage/tagging_store/index.d.ts.map +1 -0
- package/dest/storage/tagging_store/index.js +3 -0
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +28 -0
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/recipient_tagging_store.js +111 -0
- package/dest/storage/tagging_store/sender_address_book_store.d.ts +14 -0
- package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/sender_address_book_store.js +36 -0
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +77 -0
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/sender_tagging_store.js +348 -0
- package/dest/tagging/constants.d.ts +2 -0
- package/dest/tagging/constants.d.ts.map +1 -0
- package/dest/tagging/constants.js +10 -0
- package/dest/tagging/get_all_logs_by_tags.d.ts +24 -0
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
- package/dest/tagging/get_all_logs_by_tags.js +46 -0
- package/dest/tagging/index.d.ts +17 -0
- package/dest/tagging/index.d.ts.map +1 -0
- package/dest/tagging/index.js +15 -0
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +15 -0
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -0
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +99 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts +12 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts.map +1 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +20 -0
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +15 -0
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -0
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +32 -0
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +21 -0
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -0
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +74 -0
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +11 -0
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -0
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +29 -0
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +21 -0
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -0
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +60 -0
- package/package.json +37 -34
- package/src/bin/check_oracle_version.ts +161 -0
- package/src/block_synchronizer/block_synchronizer.ts +172 -0
- package/src/block_synchronizer/index.ts +1 -0
- package/src/config/index.ts +41 -55
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/benchmarked_node.ts +103 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +633 -0
- package/src/contract_function_simulator/execution_note_cache.ts +252 -0
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +32 -0
- package/src/contract_function_simulator/hashed_values_cache.ts +47 -0
- package/src/contract_function_simulator/index.ts +13 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +51 -0
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +28 -0
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +69 -0
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +64 -0
- package/src/contract_function_simulator/noir-structs/utility_context.ts +23 -0
- package/src/contract_function_simulator/oracle/index.ts +16 -0
- package/src/contract_function_simulator/oracle/interfaces.ts +185 -0
- package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +23 -0
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +68 -0
- package/src/contract_function_simulator/oracle/oracle.ts +630 -0
- package/src/contract_function_simulator/oracle/private_execution.ts +141 -0
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +699 -0
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +554 -0
- package/src/contract_function_simulator/pick_notes.ts +141 -0
- package/src/contract_function_simulator/proxied_contract_data_source.ts +83 -0
- package/src/contract_sync/index.ts +98 -0
- package/src/debug/pxe_debug_utils.ts +63 -0
- package/src/entrypoints/client/bundle/index.ts +3 -2
- package/src/entrypoints/client/bundle/utils.ts +35 -36
- package/src/entrypoints/client/lazy/index.ts +3 -2
- package/src/entrypoints/client/lazy/utils.ts +36 -32
- package/src/entrypoints/pxe_creation_options.ts +14 -0
- package/src/entrypoints/server/index.ts +7 -3
- package/src/entrypoints/server/utils.ts +52 -52
- package/src/{pxe_service/error_enriching.ts → error_enriching.ts} +40 -39
- package/src/events/event_service.ts +71 -0
- package/src/events/index.ts +1 -0
- package/src/events/private_event_filter_validator.ts +46 -0
- package/src/job_coordinator/job_coordinator.ts +150 -0
- package/src/logs/log_service.ts +220 -0
- package/src/notes/index.ts +1 -0
- package/src/notes/note_service.ts +195 -0
- package/src/oracle_version.ts +12 -0
- package/src/private_kernel/hints/compute_tx_include_by_timestamp.ts +58 -0
- package/src/private_kernel/hints/index.ts +2 -0
- package/src/{kernel_prover/hints/build_private_kernel_reset_private_inputs.ts → private_kernel/hints/private_kernel_reset_private_inputs_builder.ts} +179 -156
- package/src/private_kernel/index.ts +2 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +433 -0
- package/src/private_kernel/private_kernel_oracle.ts +152 -0
- package/src/pxe.ts +1070 -0
- package/src/storage/{address_data_provider/address_data_provider.ts → address_store/address_store.ts} +15 -21
- package/src/storage/address_store/index.ts +1 -0
- package/src/storage/{sync_data_provider/sync_data_provider.ts → anchor_block_store/anchor_block_store.ts} +10 -17
- package/src/storage/anchor_block_store/index.ts +1 -0
- package/src/storage/capsule_store/capsule_store.ts +315 -0
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/contract_store/contract_store.ts +330 -0
- package/src/storage/contract_store/index.ts +1 -0
- package/src/storage/contract_store/private_functions_tree.ts +67 -0
- package/src/storage/index.ts +8 -10
- package/src/storage/metadata.ts +1 -0
- package/src/storage/note_store/index.ts +2 -0
- package/src/storage/note_store/note_store.ts +411 -0
- package/src/storage/note_store/stored_note.ts +48 -0
- package/src/storage/private_event_store/private_event_store.ts +384 -0
- package/src/storage/private_event_store/stored_private_event.ts +73 -0
- package/src/storage/tagging_store/index.ts +3 -0
- package/src/storage/tagging_store/recipient_tagging_store.ts +139 -0
- package/src/storage/tagging_store/sender_address_book_store.ts +48 -0
- package/src/storage/tagging_store/sender_tagging_store.ts +429 -0
- package/src/tagging/constants.ts +10 -0
- package/src/tagging/get_all_logs_by_tags.ts +68 -0
- package/src/tagging/index.ts +19 -0
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +143 -0
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +34 -0
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +49 -0
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +99 -0
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +36 -0
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +84 -0
- package/dest/bin/index.d.ts +0 -3
- package/dest/bin/index.d.ts.map +0 -1
- package/dest/bin/index.js +0 -28
- package/dest/entrypoints/client/pxe_creation_options.d.ts +0 -11
- package/dest/entrypoints/client/pxe_creation_options.d.ts.map +0 -1
- package/dest/kernel_oracle/index.d.ts +0 -45
- package/dest/kernel_oracle/index.d.ts.map +0 -1
- package/dest/kernel_oracle/index.js +0 -76
- package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
- package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
- package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.js +0 -270
- package/dest/kernel_prover/hints/index.d.ts +0 -2
- package/dest/kernel_prover/hints/index.d.ts.map +0 -1
- package/dest/kernel_prover/hints/index.js +0 -1
- package/dest/kernel_prover/index.d.ts +0 -3
- package/dest/kernel_prover/index.d.ts.map +0 -1
- package/dest/kernel_prover/index.js +0 -2
- package/dest/kernel_prover/kernel_prover.d.ts +0 -38
- package/dest/kernel_prover/kernel_prover.d.ts.map +0 -1
- package/dest/kernel_prover/kernel_prover.js +0 -217
- package/dest/kernel_prover/proving_data_oracle.d.ts +0 -73
- package/dest/kernel_prover/proving_data_oracle.d.ts.map +0 -1
- package/dest/kernel_prover/proving_data_oracle.js +0 -4
- package/dest/note_decryption_utils/add_public_values_to_payload.d.ts +0 -11
- package/dest/note_decryption_utils/add_public_values_to_payload.d.ts.map +0 -1
- package/dest/note_decryption_utils/add_public_values_to_payload.js +0 -47
- package/dest/pxe_http/index.d.ts +0 -2
- package/dest/pxe_http/index.d.ts.map +0 -1
- package/dest/pxe_http/index.js +0 -1
- package/dest/pxe_http/pxe_http_server.d.ts +0 -16
- package/dest/pxe_http/pxe_http_server.d.ts.map +0 -1
- package/dest/pxe_http/pxe_http_server.js +0 -27
- package/dest/pxe_oracle_interface/index.d.ts +0 -159
- package/dest/pxe_oracle_interface/index.d.ts.map +0 -1
- package/dest/pxe_oracle_interface/index.js +0 -692
- package/dest/pxe_oracle_interface/tagging_utils.d.ts +0 -17
- package/dest/pxe_oracle_interface/tagging_utils.d.ts.map +0 -1
- package/dest/pxe_oracle_interface/tagging_utils.js +0 -23
- package/dest/pxe_service/error_enriching.d.ts +0 -11
- package/dest/pxe_service/error_enriching.d.ts.map +0 -1
- package/dest/pxe_service/index.d.ts +0 -3
- package/dest/pxe_service/index.d.ts.map +0 -1
- package/dest/pxe_service/index.js +0 -2
- package/dest/pxe_service/pxe_service.d.ts +0 -111
- package/dest/pxe_service/pxe_service.d.ts.map +0 -1
- package/dest/pxe_service/pxe_service.js +0 -664
- package/dest/storage/address_data_provider/address_data_provider.d.ts +0 -13
- package/dest/storage/address_data_provider/address_data_provider.d.ts.map +0 -1
- package/dest/storage/address_data_provider/index.d.ts +0 -2
- package/dest/storage/address_data_provider/index.d.ts.map +0 -1
- package/dest/storage/address_data_provider/index.js +0 -1
- package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts +0 -11
- package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts.map +0 -1
- package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.js +0 -20
- package/dest/storage/auth_witness_data_provider/index.d.ts +0 -2
- package/dest/storage/auth_witness_data_provider/index.d.ts.map +0 -1
- package/dest/storage/auth_witness_data_provider/index.js +0 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +0 -16
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +0 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.js +0 -57
- package/dest/storage/capsule_data_provider/index.d.ts +0 -2
- package/dest/storage/capsule_data_provider/index.d.ts.map +0 -1
- package/dest/storage/capsule_data_provider/index.js +0 -1
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts +0 -109
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +0 -1
- package/dest/storage/contract_data_provider/contract_data_provider.js +0 -183
- package/dest/storage/contract_data_provider/index.d.ts +0 -3
- package/dest/storage/contract_data_provider/index.d.ts.map +0 -1
- package/dest/storage/contract_data_provider/index.js +0 -2
- package/dest/storage/contract_data_provider/private_functions_tree.d.ts +0 -66
- package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +0 -1
- package/dest/storage/contract_data_provider/private_functions_tree.js +0 -99
- package/dest/storage/data_provider.d.ts +0 -4
- package/dest/storage/data_provider.d.ts.map +0 -1
- package/dest/storage/data_provider.js +0 -1
- package/dest/storage/note_data_provider/index.d.ts +0 -3
- package/dest/storage/note_data_provider/index.d.ts.map +0 -1
- package/dest/storage/note_data_provider/index.js +0 -2
- package/dest/storage/note_data_provider/note_dao.d.ts +0 -106
- package/dest/storage/note_data_provider/note_dao.d.ts.map +0 -1
- package/dest/storage/note_data_provider/note_dao.js +0 -106
- package/dest/storage/note_data_provider/note_data_provider.d.ts +0 -20
- package/dest/storage/note_data_provider/note_data_provider.d.ts.map +0 -1
- package/dest/storage/note_data_provider/note_data_provider.js +0 -249
- package/dest/storage/sync_data_provider/index.d.ts +0 -2
- package/dest/storage/sync_data_provider/index.d.ts.map +0 -1
- package/dest/storage/sync_data_provider/index.js +0 -1
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts +0 -12
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +0 -1
- package/dest/storage/sync_data_provider/sync_data_provider.js +0 -29
- package/dest/storage/tagging_data_provider/index.d.ts +0 -2
- package/dest/storage/tagging_data_provider/index.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/index.js +0 -1
- package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +0 -18
- package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/tagging_data_provider.js +0 -65
- package/dest/synchronizer/index.d.ts +0 -2
- package/dest/synchronizer/index.d.ts.map +0 -1
- package/dest/synchronizer/index.js +0 -1
- package/dest/synchronizer/synchronizer.d.ts +0 -37
- package/dest/synchronizer/synchronizer.d.ts.map +0 -1
- package/dest/synchronizer/synchronizer.js +0 -103
- package/dest/test/pxe_test_suite.d.ts +0 -3
- package/dest/test/pxe_test_suite.d.ts.map +0 -1
- package/dest/test/pxe_test_suite.js +0 -97
- package/src/bin/index.ts +0 -38
- package/src/entrypoints/client/pxe_creation_options.ts +0 -7
- package/src/kernel_oracle/index.ts +0 -117
- package/src/kernel_prover/hints/index.ts +0 -1
- package/src/kernel_prover/index.ts +0 -2
- package/src/kernel_prover/kernel_prover.ts +0 -351
- package/src/kernel_prover/proving_data_oracle.ts +0 -83
- package/src/note_decryption_utils/add_public_values_to_payload.ts +0 -64
- package/src/pxe_http/index.ts +0 -1
- package/src/pxe_http/pxe_http_server.ts +0 -29
- package/src/pxe_oracle_interface/index.ts +0 -925
- package/src/pxe_oracle_interface/tagging_utils.ts +0 -32
- package/src/pxe_service/index.ts +0 -2
- package/src/pxe_service/pxe_service.ts +0 -949
- package/src/storage/address_data_provider/index.ts +0 -1
- package/src/storage/auth_witness_data_provider/auth_witness_data_provider.ts +0 -34
- package/src/storage/auth_witness_data_provider/index.ts +0 -1
- package/src/storage/capsule_data_provider/capsule_data_provider.ts +0 -80
- package/src/storage/capsule_data_provider/index.ts +0 -1
- package/src/storage/contract_data_provider/contract_data_provider.ts +0 -261
- package/src/storage/contract_data_provider/index.ts +0 -2
- package/src/storage/contract_data_provider/private_functions_tree.ts +0 -131
- package/src/storage/data_provider.ts +0 -3
- package/src/storage/note_data_provider/index.ts +0 -2
- package/src/storage/note_data_provider/note_dao.ts +0 -162
- package/src/storage/note_data_provider/note_data_provider.ts +0 -345
- package/src/storage/sync_data_provider/index.ts +0 -1
- package/src/storage/tagging_data_provider/index.ts +0 -1
- package/src/storage/tagging_data_provider/tagging_data_provider.ts +0 -92
- package/src/synchronizer/index.ts +0 -1
- package/src/synchronizer/synchronizer.ts +0 -121
- package/src/test/pxe_test_suite.ts +0 -111
- /package/dest/entrypoints/{client/pxe_creation_options.js → pxe_creation_options.js} +0 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type LoggerBindings } from '@aztec/foundation/log';
|
|
2
|
+
import type { PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
|
|
3
|
+
import { type PrivateKernelExecutionProofOutput, type PrivateKernelTailCircuitPublicInputs } from '@aztec/stdlib/kernel';
|
|
4
|
+
import { type PrivateExecutionResult, TxRequest } from '@aztec/stdlib/tx';
|
|
5
|
+
import type { PrivateKernelOracle } from './private_kernel_oracle.js';
|
|
6
|
+
export interface PrivateKernelExecutionProverConfig {
|
|
7
|
+
simulate: boolean;
|
|
8
|
+
skipFeeEnforcement: boolean;
|
|
9
|
+
profileMode: 'gates' | 'execution-steps' | 'full' | 'none';
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The PrivateKernelExecutionProver class is responsible for taking a transaction request and sequencing the
|
|
13
|
+
* the execution of the private functions within, sequenced with private kernel "glue" to check protocol rules.
|
|
14
|
+
* The result can be a chonk proof of the private transaction portion, or just a simulation that can e.g.
|
|
15
|
+
* inform state tree updates.
|
|
16
|
+
*/
|
|
17
|
+
export declare class PrivateKernelExecutionProver {
|
|
18
|
+
private oracle;
|
|
19
|
+
private proofCreator;
|
|
20
|
+
private fakeProofs;
|
|
21
|
+
private log;
|
|
22
|
+
constructor(oracle: PrivateKernelOracle, proofCreator: PrivateKernelProver, fakeProofs?: boolean, bindings?: LoggerBindings);
|
|
23
|
+
/**
|
|
24
|
+
* Generate a proof for a given transaction request and execution result.
|
|
25
|
+
* The function iterates through the nested executions in the execution result, creates private call data,
|
|
26
|
+
* and generates a proof using the provided ProofCreator instance. It also maintains an index of new notes
|
|
27
|
+
* created during the execution and returns them as a part of the KernelProverOutput.
|
|
28
|
+
*
|
|
29
|
+
* @param txRequest - The authenticated transaction request object.
|
|
30
|
+
* @param executionResult - The execution result object containing nested executions and preimages.
|
|
31
|
+
* @param profile - Set true to profile the gate count for each circuit
|
|
32
|
+
* @returns A Promise that resolves to a KernelProverOutput object containing proof, public inputs, and output notes.
|
|
33
|
+
*/
|
|
34
|
+
proveWithKernels(txRequest: TxRequest, executionResult: PrivateExecutionResult, { simulate, skipFeeEnforcement, profileMode }?: PrivateKernelExecutionProverConfig): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>>;
|
|
35
|
+
/**
|
|
36
|
+
* Checks that the public inputs of the chonk proof match the public inputs of the tail circuit.
|
|
37
|
+
* This can only mismatch if there is a circuit / noir / bb bug.
|
|
38
|
+
* @param chonkProof - The chonk proof with public inputs.
|
|
39
|
+
* @param tailPublicInputs - The public inputs resulting from witness generation of the tail circuit.
|
|
40
|
+
*/
|
|
41
|
+
private ensurePublicInputsMatch;
|
|
42
|
+
private getVkData;
|
|
43
|
+
private createPrivateCallData;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmF0ZV9rZXJuZWxfZXhlY3V0aW9uX3Byb3Zlci5kLnRzIiwic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B;IAED;;;;;;;;;;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,CAoRlF;IAED;;;;;OAKG;IACH,OAAO,CAAC,uBAAuB;YAoBjB,SAAS;YAST,qBAAqB;CA+BpC"}
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { vkAsFieldsMegaHonk } from '@aztec/foundation/crypto/keys';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
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 { HidingKernelToPublicPrivateInputs, HidingKernelToRollupPrivateInputs, PaddedSideEffectAmounts, PrivateCallData, PrivateKernelCircuitPublicInputs, PrivateKernelData, PrivateKernelInitCircuitPrivateInputs, PrivateKernelInnerCircuitPrivateInputs, PrivateKernelTailCircuitPrivateInputs, PrivateVerificationKeyHints } from '@aztec/stdlib/kernel';
|
|
10
|
+
import { ChonkProof } from '@aztec/stdlib/proofs';
|
|
11
|
+
import { collectNoteHashNullifierCounterMap, getFinalMinRevertibleSideEffectCounter } from '@aztec/stdlib/tx';
|
|
12
|
+
import { VerificationKeyAsFields, VerificationKeyData, VkData } from '@aztec/stdlib/vks';
|
|
13
|
+
import { PrivateKernelResetPrivateInputsBuilder } from './hints/private_kernel_reset_private_inputs_builder.js';
|
|
14
|
+
const NULL_SIMULATE_OUTPUT = {
|
|
15
|
+
publicInputs: PrivateKernelCircuitPublicInputs.empty(),
|
|
16
|
+
verificationKey: VerificationKeyData.empty(),
|
|
17
|
+
outputWitness: new Map(),
|
|
18
|
+
bytecode: Buffer.from([])
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* The PrivateKernelExecutionProver class is responsible for taking a transaction request and sequencing the
|
|
22
|
+
* the execution of the private functions within, sequenced with private kernel "glue" to check protocol rules.
|
|
23
|
+
* The result can be a chonk proof of the private transaction portion, or just a simulation that can e.g.
|
|
24
|
+
* inform state tree updates.
|
|
25
|
+
*/ export class PrivateKernelExecutionProver {
|
|
26
|
+
oracle;
|
|
27
|
+
proofCreator;
|
|
28
|
+
fakeProofs;
|
|
29
|
+
log;
|
|
30
|
+
constructor(oracle, proofCreator, fakeProofs = false, bindings){
|
|
31
|
+
this.oracle = oracle;
|
|
32
|
+
this.proofCreator = proofCreator;
|
|
33
|
+
this.fakeProofs = fakeProofs;
|
|
34
|
+
this.log = createLogger('pxe:private-kernel-execution-prover', bindings);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Generate a proof for a given transaction request and execution result.
|
|
38
|
+
* The function iterates through the nested executions in the execution result, creates private call data,
|
|
39
|
+
* and generates a proof using the provided ProofCreator instance. It also maintains an index of new notes
|
|
40
|
+
* created during the execution and returns them as a part of the KernelProverOutput.
|
|
41
|
+
*
|
|
42
|
+
* @param txRequest - The authenticated transaction request object.
|
|
43
|
+
* @param executionResult - The execution result object containing nested executions and preimages.
|
|
44
|
+
* @param profile - Set true to profile the gate count for each circuit
|
|
45
|
+
* @returns A Promise that resolves to a KernelProverOutput object containing proof, public inputs, and output notes.
|
|
46
|
+
*/ async proveWithKernels(txRequest, executionResult, { simulate, skipFeeEnforcement, profileMode } = {
|
|
47
|
+
simulate: false,
|
|
48
|
+
skipFeeEnforcement: false,
|
|
49
|
+
profileMode: 'none'
|
|
50
|
+
}) {
|
|
51
|
+
const skipProofGeneration = this.fakeProofs || simulate;
|
|
52
|
+
const generateWitnesses = !skipProofGeneration || profileMode !== 'none';
|
|
53
|
+
const timer = new Timer();
|
|
54
|
+
const isPrivateOnlyTx = executionResult.publicFunctionCalldata.length === 0;
|
|
55
|
+
// Initialize an executionStack, beginning with the PrivateCallExecutionResult
|
|
56
|
+
// of the entrypoint function of the tx.
|
|
57
|
+
const executionStack = [
|
|
58
|
+
executionResult.entrypoint
|
|
59
|
+
];
|
|
60
|
+
let firstIteration = true;
|
|
61
|
+
let output = NULL_SIMULATE_OUTPUT;
|
|
62
|
+
const executionSteps = [];
|
|
63
|
+
const noteHashNullifierCounterMap = collectNoteHashNullifierCounterMap(executionResult);
|
|
64
|
+
const minRevertibleSideEffectCounter = getFinalMinRevertibleSideEffectCounter(executionResult);
|
|
65
|
+
const splitCounter = isPrivateOnlyTx ? 0 : minRevertibleSideEffectCounter;
|
|
66
|
+
while(executionStack.length){
|
|
67
|
+
if (!firstIteration) {
|
|
68
|
+
let resetBuilder = new PrivateKernelResetPrivateInputsBuilder(output, executionStack, noteHashNullifierCounterMap, splitCounter);
|
|
69
|
+
while(resetBuilder.needsReset()){
|
|
70
|
+
const witgenTimer = new Timer();
|
|
71
|
+
const privateInputs = await resetBuilder.build(this.oracle);
|
|
72
|
+
output = generateWitnesses ? await this.proofCreator.generateResetOutput(privateInputs) : await this.proofCreator.simulateReset(privateInputs);
|
|
73
|
+
executionSteps.push({
|
|
74
|
+
functionName: 'private_kernel_reset',
|
|
75
|
+
bytecode: output.bytecode,
|
|
76
|
+
witness: output.outputWitness,
|
|
77
|
+
vk: output.verificationKey.keyAsBytes,
|
|
78
|
+
timings: {
|
|
79
|
+
witgen: witgenTimer.ms()
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
resetBuilder = new PrivateKernelResetPrivateInputsBuilder(output, executionStack, noteHashNullifierCounterMap, splitCounter);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const currentExecution = executionStack.pop();
|
|
86
|
+
executionStack.push(...[
|
|
87
|
+
...currentExecution.nestedExecutionResults
|
|
88
|
+
].reverse());
|
|
89
|
+
const functionName = await this.oracle.getDebugFunctionName(currentExecution.publicInputs.callContext.contractAddress, currentExecution.publicInputs.callContext.functionSelector);
|
|
90
|
+
executionSteps.push({
|
|
91
|
+
functionName: functionName,
|
|
92
|
+
bytecode: currentExecution.acir,
|
|
93
|
+
witness: currentExecution.partialWitness,
|
|
94
|
+
vk: currentExecution.vk,
|
|
95
|
+
timings: {
|
|
96
|
+
witgen: currentExecution.profileResult?.timings.witgen ?? 0,
|
|
97
|
+
oracles: currentExecution.profileResult?.timings.oracles
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
const privateCallData = await this.createPrivateCallData(currentExecution);
|
|
101
|
+
if (firstIteration) {
|
|
102
|
+
const witgenTimer = new Timer();
|
|
103
|
+
const proofInput = new PrivateKernelInitCircuitPrivateInputs(txRequest, getVKTreeRoot(), ProtocolContractsList, privateCallData, isPrivateOnlyTx, executionResult.firstNullifier, minRevertibleSideEffectCounter);
|
|
104
|
+
this.log.debug(`Calling private kernel init with isPrivateOnly ${isPrivateOnlyTx} and firstNullifierHint ${proofInput.firstNullifierHint}`);
|
|
105
|
+
pushTestData('private-kernel-inputs-init', proofInput);
|
|
106
|
+
output = generateWitnesses ? await this.proofCreator.generateInitOutput(proofInput) : await this.proofCreator.simulateInit(proofInput);
|
|
107
|
+
executionSteps.push({
|
|
108
|
+
functionName: 'private_kernel_init',
|
|
109
|
+
bytecode: output.bytecode,
|
|
110
|
+
witness: output.outputWitness,
|
|
111
|
+
vk: output.verificationKey.keyAsBytes,
|
|
112
|
+
timings: {
|
|
113
|
+
witgen: witgenTimer.ms()
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
} else {
|
|
117
|
+
const witgenTimer = new Timer();
|
|
118
|
+
const vkData = await this.getVkData(output.verificationKey);
|
|
119
|
+
const previousKernelData = new PrivateKernelData(output.publicInputs, vkData);
|
|
120
|
+
const proofInput = new PrivateKernelInnerCircuitPrivateInputs(previousKernelData, privateCallData);
|
|
121
|
+
pushTestData('private-kernel-inputs-inner', proofInput);
|
|
122
|
+
output = generateWitnesses ? await this.proofCreator.generateInnerOutput(proofInput) : await this.proofCreator.simulateInner(proofInput);
|
|
123
|
+
executionSteps.push({
|
|
124
|
+
functionName: 'private_kernel_inner',
|
|
125
|
+
bytecode: output.bytecode,
|
|
126
|
+
witness: output.outputWitness,
|
|
127
|
+
vk: output.verificationKey.keyAsBytes,
|
|
128
|
+
timings: {
|
|
129
|
+
witgen: witgenTimer.ms()
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
firstIteration = false;
|
|
134
|
+
}
|
|
135
|
+
// Reset.
|
|
136
|
+
let resetBuilder = new PrivateKernelResetPrivateInputsBuilder(output, [], noteHashNullifierCounterMap, splitCounter);
|
|
137
|
+
while(resetBuilder.needsReset()){
|
|
138
|
+
const witgenTimer = new Timer();
|
|
139
|
+
const privateInputs = await resetBuilder.build(this.oracle);
|
|
140
|
+
output = generateWitnesses ? await this.proofCreator.generateResetOutput(privateInputs) : await this.proofCreator.simulateReset(privateInputs);
|
|
141
|
+
executionSteps.push({
|
|
142
|
+
functionName: 'private_kernel_reset',
|
|
143
|
+
bytecode: output.bytecode,
|
|
144
|
+
witness: output.outputWitness,
|
|
145
|
+
vk: output.verificationKey.keyAsBytes,
|
|
146
|
+
timings: {
|
|
147
|
+
witgen: witgenTimer.ms()
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
resetBuilder = new PrivateKernelResetPrivateInputsBuilder(output, [], noteHashNullifierCounterMap, splitCounter);
|
|
151
|
+
}
|
|
152
|
+
if (output.publicInputs.feePayer.isZero() && skipFeeEnforcement) {
|
|
153
|
+
if (!skipProofGeneration) {
|
|
154
|
+
throw new Error('Fee payment must be enforced when creating real proof.');
|
|
155
|
+
}
|
|
156
|
+
output.publicInputs.feePayer = new AztecAddress(Fr.MAX_FIELD_VALUE);
|
|
157
|
+
}
|
|
158
|
+
// Private tail.
|
|
159
|
+
const vkData = await this.getVkData(output.verificationKey);
|
|
160
|
+
const previousKernelData = new PrivateKernelData(output.publicInputs, vkData);
|
|
161
|
+
this.log.debug(`Calling private kernel tail with hwm ${previousKernelData.publicInputs.minRevertibleSideEffectCounter}`);
|
|
162
|
+
// TODO: Enable padding once we better understand the final amounts to pad to.
|
|
163
|
+
const paddedSideEffectAmounts = PaddedSideEffectAmounts.empty();
|
|
164
|
+
// Use the aggregated includeByTimestamp set throughout the tx execution.
|
|
165
|
+
// TODO: Call `computeTxIncludeByTimestamp` to round the value down and reduce precision, improving privacy.
|
|
166
|
+
const includeByTimestampUpperBound = previousKernelData.publicInputs.includeByTimestamp;
|
|
167
|
+
const anchorBlockTimestamp = previousKernelData.publicInputs.constants.anchorBlockHeader.globalVariables.timestamp;
|
|
168
|
+
if (includeByTimestampUpperBound <= anchorBlockTimestamp) {
|
|
169
|
+
throw new Error(`Include-by timestamp must be greater than the anchor block timestamp. Anchor block timestamp: ${anchorBlockTimestamp}. Include-by timestamp: ${includeByTimestampUpperBound}.`);
|
|
170
|
+
}
|
|
171
|
+
const privateInputs = new PrivateKernelTailCircuitPrivateInputs(previousKernelData, paddedSideEffectAmounts, includeByTimestampUpperBound);
|
|
172
|
+
const witgenTimer = new Timer();
|
|
173
|
+
const tailOutput = generateWitnesses ? await this.proofCreator.generateTailOutput(privateInputs) : await this.proofCreator.simulateTail(privateInputs);
|
|
174
|
+
executionSteps.push({
|
|
175
|
+
functionName: 'private_kernel_tail',
|
|
176
|
+
bytecode: tailOutput.bytecode,
|
|
177
|
+
witness: tailOutput.outputWitness,
|
|
178
|
+
vk: tailOutput.verificationKey.keyAsBytes,
|
|
179
|
+
timings: {
|
|
180
|
+
witgen: witgenTimer.ms()
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
// Hiding kernel is only executed if we are generating witnesses.
|
|
184
|
+
// For simulation, we can end with the tail, since the Hiding kernel will simply return the same tail output.
|
|
185
|
+
if (generateWitnesses) {
|
|
186
|
+
const previousKernelVkData = await this.getVkData(tailOutput.verificationKey);
|
|
187
|
+
const witgenTimer = new Timer();
|
|
188
|
+
let hidingOutput;
|
|
189
|
+
if (tailOutput.publicInputs.forPublic) {
|
|
190
|
+
const privateInputs = new HidingKernelToPublicPrivateInputs(tailOutput.publicInputs.toPrivateToPublicKernelCircuitPublicInputs(), previousKernelVkData);
|
|
191
|
+
hidingOutput = await this.proofCreator.generateHidingToPublicOutput(privateInputs);
|
|
192
|
+
} else {
|
|
193
|
+
const privateInputs = new HidingKernelToRollupPrivateInputs(tailOutput.publicInputs.toPrivateToRollupKernelCircuitPublicInputs(), previousKernelVkData);
|
|
194
|
+
hidingOutput = await this.proofCreator.generateHidingToRollupOutput(privateInputs);
|
|
195
|
+
}
|
|
196
|
+
executionSteps.push({
|
|
197
|
+
functionName: 'hiding_kernel',
|
|
198
|
+
bytecode: hidingOutput.bytecode,
|
|
199
|
+
witness: hidingOutput.outputWitness,
|
|
200
|
+
vk: hidingOutput.verificationKey.keyAsBytes,
|
|
201
|
+
timings: {
|
|
202
|
+
witgen: witgenTimer.ms()
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
if (profileMode == 'gates' || profileMode == 'full') {
|
|
207
|
+
for (const entry of executionSteps){
|
|
208
|
+
const gateCountTimer = new Timer();
|
|
209
|
+
const gateCount = await this.proofCreator.computeGateCountForCircuit(entry.bytecode, entry.functionName);
|
|
210
|
+
entry.gateCount = gateCount;
|
|
211
|
+
entry.timings.gateCount = gateCountTimer.ms();
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
if (profileMode === 'gates') {
|
|
215
|
+
for (const entry of executionSteps){
|
|
216
|
+
// These buffers are often a few megabytes in size - prevent accidentally serializing them if not requested.
|
|
217
|
+
entry.bytecode = Buffer.from([]);
|
|
218
|
+
entry.witness = new Map();
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (generateWitnesses) {
|
|
222
|
+
this.log.info(`Private kernel witness generation took ${timer.ms()}ms`);
|
|
223
|
+
}
|
|
224
|
+
let chonkProof;
|
|
225
|
+
// TODO(#7368) how do we 'bincode' encode these inputs?
|
|
226
|
+
let provingTime;
|
|
227
|
+
if (!skipProofGeneration) {
|
|
228
|
+
const provingTimer = new Timer();
|
|
229
|
+
const proofWithPublicInputs = await this.proofCreator.createChonkProof(executionSteps);
|
|
230
|
+
provingTime = provingTimer.ms();
|
|
231
|
+
this.ensurePublicInputsMatch(proofWithPublicInputs, tailOutput.publicInputs);
|
|
232
|
+
chonkProof = proofWithPublicInputs.removePublicInputs();
|
|
233
|
+
} else {
|
|
234
|
+
chonkProof = ChonkProof.random();
|
|
235
|
+
}
|
|
236
|
+
return {
|
|
237
|
+
publicInputs: tailOutput.publicInputs,
|
|
238
|
+
executionSteps,
|
|
239
|
+
chonkProof,
|
|
240
|
+
timings: provingTime ? {
|
|
241
|
+
proving: provingTime
|
|
242
|
+
} : undefined
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Checks that the public inputs of the chonk proof match the public inputs of the tail circuit.
|
|
247
|
+
* This can only mismatch if there is a circuit / noir / bb bug.
|
|
248
|
+
* @param chonkProof - The chonk proof with public inputs.
|
|
249
|
+
* @param tailPublicInputs - The public inputs resulting from witness generation of the tail circuit.
|
|
250
|
+
*/ ensurePublicInputsMatch(chonkProof, tailPublicInputs) {
|
|
251
|
+
const serializedChonkProofPublicInputs = chonkProof.getPublicInputs();
|
|
252
|
+
const serializedTailPublicInputs = tailPublicInputs.publicInputs().toFields();
|
|
253
|
+
if (serializedChonkProofPublicInputs.length !== serializedTailPublicInputs.length) {
|
|
254
|
+
throw new Error(`Public inputs length mismatch: ${serializedChonkProofPublicInputs.length} !== ${serializedTailPublicInputs.length}`);
|
|
255
|
+
}
|
|
256
|
+
if (!serializedChonkProofPublicInputs.every((input, index)=>input.equals(serializedTailPublicInputs[index]))) {
|
|
257
|
+
throw new Error(`Public inputs mismatch between kernel and chonk proof`);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
async getVkData(verificationKey) {
|
|
261
|
+
const previousVkMembershipWitness = await this.oracle.getVkMembershipWitness(verificationKey.keyAsFields);
|
|
262
|
+
return new VkData(verificationKey, Number(previousVkMembershipWitness.leafIndex), previousVkMembershipWitness.siblingPath);
|
|
263
|
+
}
|
|
264
|
+
async createPrivateCallData({ publicInputs, vk: vkAsBuffer }) {
|
|
265
|
+
const { contractAddress, functionSelector } = publicInputs.callContext;
|
|
266
|
+
const vkAsFields = await vkAsFieldsMegaHonk(vkAsBuffer);
|
|
267
|
+
const vk = await VerificationKeyAsFields.fromKey(vkAsFields);
|
|
268
|
+
const { currentContractClassId, publicKeys, saltedInitializationHash } = await this.oracle.getContractAddressPreimage(contractAddress);
|
|
269
|
+
const functionLeafMembershipWitness = await this.oracle.getFunctionMembershipWitness(currentContractClassId, functionSelector);
|
|
270
|
+
const { artifactHash: contractClassArtifactHash, publicBytecodeCommitment: contractClassPublicBytecodeCommitment } = await this.oracle.getContractClassIdPreimage(currentContractClassId);
|
|
271
|
+
const updatedClassIdHints = await this.oracle.getUpdatedClassIdHints(contractAddress);
|
|
272
|
+
return PrivateCallData.from({
|
|
273
|
+
publicInputs,
|
|
274
|
+
vk,
|
|
275
|
+
verificationKeyHints: PrivateVerificationKeyHints.from({
|
|
276
|
+
publicKeys,
|
|
277
|
+
contractClassArtifactHash,
|
|
278
|
+
contractClassPublicBytecodeCommitment,
|
|
279
|
+
saltedInitializationHash,
|
|
280
|
+
functionLeafMembershipWitness,
|
|
281
|
+
updatedClassIdHints
|
|
282
|
+
})
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { FUNCTION_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
import type { GrumpkinScalar, Point } from '@aztec/foundation/curves/grumpkin';
|
|
4
|
+
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
5
|
+
import type { KeyStore } from '@aztec/key-store';
|
|
6
|
+
import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
7
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
|
+
import { BlockHash } from '@aztec/stdlib/block';
|
|
9
|
+
import { type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
10
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
11
|
+
import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
|
|
12
|
+
import type { NullifierMembershipWitness } from '@aztec/stdlib/trees';
|
|
13
|
+
import type { VerificationKeyAsFields } from '@aztec/stdlib/vks';
|
|
14
|
+
import type { ContractStore } from '../storage/contract_store/contract_store.js';
|
|
15
|
+
/**
|
|
16
|
+
* Provides functionality needed by the private kernel for interacting with our state trees.
|
|
17
|
+
*/
|
|
18
|
+
export declare class PrivateKernelOracle {
|
|
19
|
+
private contractStore;
|
|
20
|
+
private keyStore;
|
|
21
|
+
private node;
|
|
22
|
+
private blockHash;
|
|
23
|
+
constructor(contractStore: ContractStore, keyStore: KeyStore, node: AztecNode, blockHash: BlockHash);
|
|
24
|
+
/** Retrieves the preimage of a contract address from the registered contract instances db. */
|
|
25
|
+
getContractAddressPreimage(address: AztecAddress): Promise<ContractInstanceWithAddress & {
|
|
26
|
+
saltedInitializationHash: Fr;
|
|
27
|
+
}>;
|
|
28
|
+
/** Retrieves the preimage of a contract class id from the contract classes db. */
|
|
29
|
+
getContractClassIdPreimage(contractClassId: Fr): Promise<import("@aztec/stdlib/contract").ContractClassIdPreimage>;
|
|
30
|
+
/** Returns a membership witness with the sibling path and leaf index in our private functions tree. */
|
|
31
|
+
getFunctionMembershipWitness(contractClassId: Fr, selector: FunctionSelector): Promise<MembershipWitness<typeof FUNCTION_TREE_HEIGHT>>;
|
|
32
|
+
/**
|
|
33
|
+
* Returns a membership witness with the sibling path and leaf index in our protocol VK indexed merkle tree.
|
|
34
|
+
* Used to validate the previous kernel's verification key.
|
|
35
|
+
*/
|
|
36
|
+
getVkMembershipWitness(vk: VerificationKeyAsFields): Promise<MembershipWitness<typeof VK_TREE_HEIGHT>>;
|
|
37
|
+
/** Returns a membership witness with the sibling path and leaf index in our note hash tree. */
|
|
38
|
+
getNoteHashMembershipWitness(noteHash: Fr): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined>;
|
|
39
|
+
/** Returns a membership witness with the sibling path and leaf index in our nullifier indexed merkle tree. */
|
|
40
|
+
getNullifierMembershipWitness(nullifier: Fr): Promise<NullifierMembershipWitness | undefined>;
|
|
41
|
+
/** Returns the root of our note hash merkle tree. */
|
|
42
|
+
getNoteHashTreeRoot(): Promise<Fr>;
|
|
43
|
+
/**
|
|
44
|
+
* Retrieves the sk_m corresponding to the pk_m.
|
|
45
|
+
* @throws If the provided public key is not associated with any of the registered accounts.
|
|
46
|
+
* @param masterPublicKey - The master public key to get secret key for.
|
|
47
|
+
* @returns A Promise that resolves to sk_m.
|
|
48
|
+
* @dev Used when feeding the sk_m to the kernel circuit for keys verification.
|
|
49
|
+
*/
|
|
50
|
+
getMasterSecretKey(masterPublicKey: Point): Promise<GrumpkinScalar>;
|
|
51
|
+
/** Use debug data to get the function name corresponding to a selector. */
|
|
52
|
+
getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
|
|
53
|
+
/**
|
|
54
|
+
* Returns a membership witness and leaf index to our public data indexed merkle tree,
|
|
55
|
+
* along with an associated DelayedPublicMutable containing the class ID to update.
|
|
56
|
+
*/
|
|
57
|
+
getUpdatedClassIdHints(contractAddress: AztecAddress): Promise<UpdatedClassIdHints>;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmF0ZV9rZXJuZWxfb3JhY2xlLmQudHMiLCJ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CAAC,CAE5F;IAED,qDAAqD;IAC/C,mBAAmB,IAAI,OAAO,CAAC,EAAE,CAAC,CAMvC;IAED;;;;;;OAMG;IACI,kBAAkB,CAAC,eAAe,EAAE,KAAK,GAAG,OAAO,CAAC,cAAc,CAAC,CAEzE;IAED,2EAA2E;IACpE,oBAAoB,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAElH;IAED;;;OAGG;IACU,sBAAsB,CAAC,eAAe,EAAE,YAAY,GAAG,OAAO,CAAC,mBAAmB,CAAC,CA8B/F;CACF"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { PUBLIC_DATA_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
+
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
3
|
+
import { getVKIndex, getVKSiblingPath } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
4
|
+
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
5
|
+
import { computeContractClassIdPreimage, computeSaltedInitializationHash } from '@aztec/stdlib/contract';
|
|
6
|
+
import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
|
|
7
|
+
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
8
|
+
import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
|
|
9
|
+
/**
|
|
10
|
+
* Provides functionality needed by the private kernel for interacting with our state trees.
|
|
11
|
+
*/ export class PrivateKernelOracle {
|
|
12
|
+
contractStore;
|
|
13
|
+
keyStore;
|
|
14
|
+
node;
|
|
15
|
+
blockHash;
|
|
16
|
+
constructor(contractStore, keyStore, node, blockHash){
|
|
17
|
+
this.contractStore = contractStore;
|
|
18
|
+
this.keyStore = keyStore;
|
|
19
|
+
this.node = node;
|
|
20
|
+
this.blockHash = blockHash;
|
|
21
|
+
}
|
|
22
|
+
/** Retrieves the preimage of a contract address from the registered contract instances db. */ async getContractAddressPreimage(address) {
|
|
23
|
+
const instance = await this.contractStore.getContractInstance(address);
|
|
24
|
+
if (!instance) {
|
|
25
|
+
throw new Error(`Contract instance not found when getting address preimage. Contract address: ${address}.`);
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
saltedInitializationHash: await computeSaltedInitializationHash(instance),
|
|
29
|
+
...instance
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/** Retrieves the preimage of a contract class id from the contract classes db. */ async getContractClassIdPreimage(contractClassId) {
|
|
33
|
+
const contractClass = await this.contractStore.getContractClass(contractClassId);
|
|
34
|
+
if (!contractClass) {
|
|
35
|
+
throw new Error(`Contract class not found when getting class id preimage. Class id: ${contractClassId}.`);
|
|
36
|
+
}
|
|
37
|
+
return computeContractClassIdPreimage(contractClass);
|
|
38
|
+
}
|
|
39
|
+
/** Returns a membership witness with the sibling path and leaf index in our private functions tree. */ async getFunctionMembershipWitness(contractClassId, selector) {
|
|
40
|
+
const membershipWitness = await this.contractStore.getFunctionMembershipWitness(contractClassId, selector);
|
|
41
|
+
if (!membershipWitness) {
|
|
42
|
+
throw new Error(`Membership witness not found for contract class id ${contractClassId} and selector ${selector}.`);
|
|
43
|
+
}
|
|
44
|
+
return membershipWitness;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Returns a membership witness with the sibling path and leaf index in our protocol VK indexed merkle tree.
|
|
48
|
+
* Used to validate the previous kernel's verification key.
|
|
49
|
+
*/ getVkMembershipWitness(vk) {
|
|
50
|
+
const leafIndex = getVKIndex(vk);
|
|
51
|
+
return Promise.resolve(new MembershipWitness(VK_TREE_HEIGHT, BigInt(leafIndex), getVKSiblingPath(leafIndex)));
|
|
52
|
+
}
|
|
53
|
+
/** Returns a membership witness with the sibling path and leaf index in our note hash tree. */ getNoteHashMembershipWitness(noteHash) {
|
|
54
|
+
return this.node.getNoteHashMembershipWitness(this.blockHash, noteHash);
|
|
55
|
+
}
|
|
56
|
+
/** Returns a membership witness with the sibling path and leaf index in our nullifier indexed merkle tree. */ getNullifierMembershipWitness(nullifier) {
|
|
57
|
+
return this.node.getNullifierMembershipWitness(this.blockHash, nullifier);
|
|
58
|
+
}
|
|
59
|
+
/** Returns the root of our note hash merkle tree. */ async getNoteHashTreeRoot() {
|
|
60
|
+
const header = await this.node.getBlockHeader(this.blockHash);
|
|
61
|
+
if (!header) {
|
|
62
|
+
throw new Error(`No block header found for block hash ${this.blockHash}`);
|
|
63
|
+
}
|
|
64
|
+
return header.state.partial.noteHashTree.root;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Retrieves the sk_m corresponding to the pk_m.
|
|
68
|
+
* @throws If the provided public key is not associated with any of the registered accounts.
|
|
69
|
+
* @param masterPublicKey - The master public key to get secret key for.
|
|
70
|
+
* @returns A Promise that resolves to sk_m.
|
|
71
|
+
* @dev Used when feeding the sk_m to the kernel circuit for keys verification.
|
|
72
|
+
*/ getMasterSecretKey(masterPublicKey) {
|
|
73
|
+
return this.keyStore.getMasterSecretKey(masterPublicKey);
|
|
74
|
+
}
|
|
75
|
+
/** Use debug data to get the function name corresponding to a selector. */ getDebugFunctionName(contractAddress, selector) {
|
|
76
|
+
return this.contractStore.getDebugFunctionName(contractAddress, selector);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Returns a membership witness and leaf index to our public data indexed merkle tree,
|
|
80
|
+
* along with an associated DelayedPublicMutable containing the class ID to update.
|
|
81
|
+
*/ async getUpdatedClassIdHints(contractAddress) {
|
|
82
|
+
const { delayedPublicMutableSlot, delayedPublicMutableHashSlot } = await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(contractAddress);
|
|
83
|
+
const hashLeafSlot = await computePublicDataTreeLeafSlot(ProtocolContractAddress.ContractInstanceRegistry, delayedPublicMutableHashSlot);
|
|
84
|
+
const updatedClassIdWitness = await this.node.getPublicDataWitness(this.blockHash, hashLeafSlot);
|
|
85
|
+
if (!updatedClassIdWitness) {
|
|
86
|
+
throw new Error(`No public data tree witness found for ${hashLeafSlot}`);
|
|
87
|
+
}
|
|
88
|
+
const readStorage = (storageSlot)=>this.node.getPublicStorageAt(this.blockHash, ProtocolContractAddress.ContractInstanceRegistry, storageSlot);
|
|
89
|
+
const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree(delayedPublicMutableSlot, readStorage);
|
|
90
|
+
return new UpdatedClassIdHints(new MembershipWitness(PUBLIC_DATA_TREE_HEIGHT, updatedClassIdWitness.index, updatedClassIdWitness.siblingPath.toTuple()), updatedClassIdWitness.leafPreimage, delayedPublicMutableValues);
|
|
91
|
+
}
|
|
92
|
+
}
|