@aztec/pxe 0.0.0-test.1 → 0.0.1-commit.5476d83
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 +39 -0
- package/dest/config/index.d.ts +11 -24
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +18 -33
- package/dest/config/package_info.d.ts +1 -1
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +56 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -0
- package/dest/contract_function_simulator/contract_function_simulator.js +300 -0
- package/dest/contract_function_simulator/execution_data_provider.d.ts +265 -0
- package/dest/contract_function_simulator/execution_data_provider.d.ts.map +1 -0
- package/dest/contract_function_simulator/execution_data_provider.js +14 -0
- package/dest/contract_function_simulator/execution_note_cache.d.ts +94 -0
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -0
- package/dest/contract_function_simulator/execution_note_cache.js +190 -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 +20 -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 +37 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +15 -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 +25 -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 +23 -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 +48 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +22 -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 +33 -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 +100 -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 +17 -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 +24 -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 +50 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts +58 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/oracle.js +333 -0
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +48 -0
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/private_execution.js +123 -0
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +231 -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 +428 -0
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +153 -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 +265 -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 +62 -0
- package/dest/contract_function_simulator/proxied_node.d.ts +9 -0
- package/dest/contract_function_simulator/proxied_node.d.ts.map +1 -0
- package/dest/contract_function_simulator/proxied_node.js +27 -0
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +122 -0
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +1 -0
- package/dest/contract_function_simulator/pxe_oracle_interface.js +694 -0
- package/dest/entrypoints/client/bundle/index.d.ts +5 -3
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +3 -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 +18 -12
- package/dest/entrypoints/client/lazy/index.d.ts +5 -3
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +3 -2
- package/dest/entrypoints/client/lazy/utils.d.ts +9 -9
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +17 -11
- package/dest/entrypoints/pxe_creation_options.d.ts +14 -0
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -0
- package/dest/entrypoints/server/index.d.ts +6 -4
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +4 -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 +30 -35
- 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} +26 -18
- package/dest/oracle_version.d.ts +3 -0
- package/dest/oracle_version.d.ts.map +1 -0
- package/dest/oracle_version.js +10 -0
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +28 -0
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -0
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.js +271 -0
- package/dest/private_kernel/hints/compute_side_effect_uniqueness_hints.d.ts +3 -0
- package/dest/private_kernel/hints/compute_side_effect_uniqueness_hints.d.ts.map +1 -0
- package/dest/private_kernel/hints/compute_side_effect_uniqueness_hints.js +48 -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/{kernel_prover → private_kernel}/hints/index.js +1 -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 +44 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -0
- package/dest/private_kernel/private_kernel_execution_prover.js +289 -0
- package/dest/private_kernel/private_kernel_oracle.d.ts +62 -0
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -0
- package/dest/private_kernel/private_kernel_oracle.js +4 -0
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts +45 -0
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -0
- package/dest/{kernel_oracle/index.js → private_kernel/private_kernel_oracle_impl.js} +19 -9
- package/dest/pxe.d.ts +240 -0
- package/dest/pxe.d.ts.map +1 -0
- package/dest/pxe.js +771 -0
- package/dest/storage/address_data_provider/address_data_provider.d.ts +2 -4
- package/dest/storage/address_data_provider/address_data_provider.d.ts.map +1 -1
- package/dest/storage/address_data_provider/address_data_provider.js +0 -3
- package/dest/storage/address_data_provider/index.d.ts +1 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +15 -6
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +1 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.js +85 -24
- package/dest/storage/capsule_data_provider/index.d.ts +1 -1
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts +13 -58
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +1 -1
- package/dest/storage/contract_data_provider/contract_data_provider.js +89 -79
- package/dest/storage/contract_data_provider/index.d.ts +1 -2
- package/dest/storage/contract_data_provider/index.d.ts.map +1 -1
- package/dest/storage/contract_data_provider/index.js +0 -1
- package/dest/storage/contract_data_provider/private_functions_tree.d.ts +3 -42
- package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +1 -1
- package/dest/storage/contract_data_provider/private_functions_tree.js +9 -61
- package/dest/storage/index.d.ts +3 -4
- package/dest/storage/index.d.ts.map +1 -1
- package/dest/storage/index.js +2 -3
- 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_data_provider/index.d.ts +2 -2
- package/dest/storage/note_data_provider/index.d.ts.map +1 -1
- package/dest/storage/note_data_provider/index.js +1 -1
- package/dest/storage/note_data_provider/note_data_provider.d.ts +73 -10
- package/dest/storage/note_data_provider/note_data_provider.d.ts.map +1 -1
- package/dest/storage/note_data_provider/note_data_provider.js +145 -83
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +37 -0
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +1 -0
- package/dest/storage/private_event_data_provider/private_event_data_provider.js +105 -0
- package/dest/storage/sync_data_provider/index.d.ts +1 -1
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts +3 -5
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +1 -1
- package/dest/storage/sync_data_provider/sync_data_provider.js +2 -5
- package/dest/storage/tagging_data_provider/index.d.ts +1 -1
- package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +29 -7
- package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +1 -1
- package/dest/storage/tagging_data_provider/tagging_data_provider.js +48 -24
- package/dest/synchronizer/index.d.ts +1 -1
- package/dest/synchronizer/synchronizer.d.ts +8 -10
- package/dest/synchronizer/synchronizer.d.ts.map +1 -1
- package/dest/synchronizer/synchronizer.js +17 -19
- package/dest/tagging/constants.d.ts +2 -0
- package/dest/tagging/constants.d.ts.map +1 -0
- package/dest/tagging/constants.js +2 -0
- package/dest/tagging/index.d.ts +7 -0
- package/dest/tagging/index.d.ts.map +1 -0
- package/dest/tagging/index.js +5 -0
- package/dest/tagging/siloed_tag.d.ts +14 -0
- package/dest/tagging/siloed_tag.d.ts.map +1 -0
- package/dest/tagging/siloed_tag.js +20 -0
- package/dest/tagging/tag.d.ts +12 -0
- package/dest/tagging/tag.d.ts.map +1 -0
- package/dest/tagging/tag.js +17 -0
- package/dest/tagging/utils.d.ts +18 -0
- package/dest/tagging/utils.d.ts.map +1 -0
- package/dest/tagging/utils.js +24 -0
- package/package.json +37 -34
- package/src/bin/check_oracle_version.ts +50 -0
- package/src/config/index.ts +27 -55
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +553 -0
- package/src/contract_function_simulator/execution_data_provider.ts +333 -0
- package/src/contract_function_simulator/execution_note_cache.ts +229 -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 +47 -0
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +27 -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 +61 -0
- package/src/contract_function_simulator/noir-structs/utility_context.ts +42 -0
- package/src/contract_function_simulator/oracle/index.ts +16 -0
- package/src/contract_function_simulator/oracle/interfaces.ts +170 -0
- package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +23 -0
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +54 -0
- package/src/contract_function_simulator/oracle/oracle.ts +583 -0
- package/src/contract_function_simulator/oracle/private_execution.ts +207 -0
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +633 -0
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +358 -0
- package/src/contract_function_simulator/pick_notes.ts +141 -0
- package/src/contract_function_simulator/proxied_contract_data_source.ts +66 -0
- package/src/contract_function_simulator/proxied_node.ts +33 -0
- package/src/contract_function_simulator/pxe_oracle_interface.ts +1008 -0
- package/src/entrypoints/client/bundle/index.ts +4 -2
- package/src/entrypoints/client/bundle/utils.ts +36 -36
- package/src/entrypoints/client/lazy/index.ts +4 -2
- package/src/entrypoints/client/lazy/utils.ts +36 -31
- package/src/entrypoints/{client/pxe_creation_options.ts → pxe_creation_options.ts} +4 -1
- package/src/entrypoints/server/index.ts +5 -3
- package/src/entrypoints/server/utils.ts +58 -50
- package/src/{pxe_service/error_enriching.ts → error_enriching.ts} +36 -27
- package/src/oracle_version.ts +11 -0
- package/src/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.ts +158 -146
- package/src/private_kernel/hints/compute_side_effect_uniqueness_hints.ts +173 -0
- package/src/private_kernel/hints/compute_tx_include_by_timestamp.ts +58 -0
- package/src/{kernel_prover → private_kernel}/hints/index.ts +1 -0
- package/src/private_kernel/index.ts +2 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +436 -0
- package/src/{kernel_prover/proving_data_oracle.ts → private_kernel/private_kernel_oracle.ts} +17 -29
- package/src/{kernel_oracle/index.ts → private_kernel/private_kernel_oracle_impl.ts} +30 -15
- package/src/pxe.ts +1085 -0
- package/src/storage/address_data_provider/address_data_provider.ts +1 -7
- package/src/storage/capsule_data_provider/capsule_data_provider.ts +97 -30
- package/src/storage/contract_data_provider/contract_data_provider.ts +109 -93
- package/src/storage/contract_data_provider/index.ts +0 -1
- package/src/storage/contract_data_provider/private_functions_tree.ts +11 -75
- package/src/storage/index.ts +2 -4
- package/src/storage/metadata.ts +1 -0
- package/src/storage/note_data_provider/index.ts +1 -1
- package/src/storage/note_data_provider/note_data_provider.ts +176 -122
- package/src/storage/private_event_data_provider/private_event_data_provider.ts +143 -0
- package/src/storage/sync_data_provider/sync_data_provider.ts +4 -10
- package/src/storage/tagging_data_provider/tagging_data_provider.ts +58 -30
- package/src/synchronizer/synchronizer.ts +21 -22
- package/src/tagging/constants.ts +2 -0
- package/src/tagging/index.ts +6 -0
- package/src/tagging/siloed_tag.ts +22 -0
- package/src/tagging/tag.ts +16 -0
- package/src/tagging/utils.ts +31 -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_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/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/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/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/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/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/kernel_prover/index.ts +0 -2
- package/src/kernel_prover/kernel_prover.ts +0 -351
- 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/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/data_provider.ts +0 -3
- package/src/storage/note_data_provider/note_dao.ts +0 -162
- 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,173 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GLOBAL_INDEX_CONTRACT_CLASS_LOG_HASH_OFFSET,
|
|
3
|
+
GLOBAL_INDEX_L2_TO_L1_MSG_OFFSET,
|
|
4
|
+
GLOBAL_INDEX_NOTE_HASH_OFFSET,
|
|
5
|
+
GLOBAL_INDEX_NOTE_HASH_READ_REQUEST_OFFSET,
|
|
6
|
+
GLOBAL_INDEX_NULLIFIER_OFFSET,
|
|
7
|
+
GLOBAL_INDEX_NULLIFIER_READ_REQUEST_OFFSET,
|
|
8
|
+
GLOBAL_INDEX_PRIVATE_CALL_REQUEST_OFFSET,
|
|
9
|
+
GLOBAL_INDEX_PRIVATE_LOG_OFFSET,
|
|
10
|
+
GLOBAL_INDEX_PUBLIC_CALL_REQUEST_OFFSET,
|
|
11
|
+
MAX_CONTRACT_CLASS_LOGS_PER_CALL,
|
|
12
|
+
MAX_ENQUEUED_CALLS_PER_CALL,
|
|
13
|
+
MAX_L2_TO_L1_MSGS_PER_CALL,
|
|
14
|
+
MAX_NOTE_HASHES_PER_CALL,
|
|
15
|
+
MAX_NOTE_HASH_READ_REQUESTS_PER_CALL,
|
|
16
|
+
MAX_NULLIFIERS_PER_CALL,
|
|
17
|
+
MAX_NULLIFIER_READ_REQUESTS_PER_CALL,
|
|
18
|
+
MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL,
|
|
19
|
+
MAX_PRIVATE_LOGS_PER_CALL,
|
|
20
|
+
TOTAL_COUNTED_SIDE_EFFECTS_PER_CALL,
|
|
21
|
+
} from '@aztec/constants';
|
|
22
|
+
import { makeTuple } from '@aztec/foundation/array';
|
|
23
|
+
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
24
|
+
import type { Serializable } from '@aztec/foundation/serialize';
|
|
25
|
+
import {
|
|
26
|
+
ClaimedLengthArray,
|
|
27
|
+
PrivateCallRequest,
|
|
28
|
+
type PrivateCircuitPublicInputs,
|
|
29
|
+
SideEffectCounterRange,
|
|
30
|
+
SideEffectUniquenessHints,
|
|
31
|
+
} from '@aztec/stdlib/kernel';
|
|
32
|
+
|
|
33
|
+
export function computeSideEffectUniquenessHints(publicInputs: PrivateCircuitPublicInputs): SideEffectUniquenessHints {
|
|
34
|
+
let sideEffectRanges: SideEffectCounterRange[] = [];
|
|
35
|
+
|
|
36
|
+
sideEffectRanges = sideEffectRanges.concat(
|
|
37
|
+
createRangesFromClaimedLengthArray(
|
|
38
|
+
publicInputs.noteHashReadRequests,
|
|
39
|
+
GLOBAL_INDEX_NOTE_HASH_READ_REQUEST_OFFSET,
|
|
40
|
+
createRangeFromCountedItem,
|
|
41
|
+
),
|
|
42
|
+
);
|
|
43
|
+
sideEffectRanges = sideEffectRanges.concat(
|
|
44
|
+
createRangesFromClaimedLengthArray(
|
|
45
|
+
publicInputs.nullifierReadRequests,
|
|
46
|
+
GLOBAL_INDEX_NULLIFIER_READ_REQUEST_OFFSET,
|
|
47
|
+
createRangeFromCountedItem,
|
|
48
|
+
),
|
|
49
|
+
);
|
|
50
|
+
sideEffectRanges = sideEffectRanges.concat(
|
|
51
|
+
createRangesFromClaimedLengthArray(
|
|
52
|
+
publicInputs.noteHashes,
|
|
53
|
+
GLOBAL_INDEX_NOTE_HASH_OFFSET,
|
|
54
|
+
createRangeFromCountedItem,
|
|
55
|
+
),
|
|
56
|
+
);
|
|
57
|
+
sideEffectRanges = sideEffectRanges.concat(
|
|
58
|
+
createRangesFromClaimedLengthArray(
|
|
59
|
+
publicInputs.nullifiers,
|
|
60
|
+
GLOBAL_INDEX_NULLIFIER_OFFSET,
|
|
61
|
+
createRangeFromCountedItem,
|
|
62
|
+
),
|
|
63
|
+
);
|
|
64
|
+
sideEffectRanges = sideEffectRanges.concat(
|
|
65
|
+
createRangesFromClaimedLengthArray(
|
|
66
|
+
publicInputs.privateCallRequests,
|
|
67
|
+
GLOBAL_INDEX_PRIVATE_CALL_REQUEST_OFFSET,
|
|
68
|
+
createRangeFromPrivateCallRequest,
|
|
69
|
+
),
|
|
70
|
+
);
|
|
71
|
+
sideEffectRanges = sideEffectRanges.concat(
|
|
72
|
+
createRangesFromClaimedLengthArray(
|
|
73
|
+
publicInputs.publicCallRequests,
|
|
74
|
+
GLOBAL_INDEX_PUBLIC_CALL_REQUEST_OFFSET,
|
|
75
|
+
createRangeFromCountedItem,
|
|
76
|
+
),
|
|
77
|
+
);
|
|
78
|
+
sideEffectRanges = sideEffectRanges.concat(
|
|
79
|
+
createRangesFromClaimedLengthArray(
|
|
80
|
+
publicInputs.l2ToL1Msgs,
|
|
81
|
+
GLOBAL_INDEX_L2_TO_L1_MSG_OFFSET,
|
|
82
|
+
createRangeFromCountedItem,
|
|
83
|
+
),
|
|
84
|
+
);
|
|
85
|
+
sideEffectRanges = sideEffectRanges.concat(
|
|
86
|
+
createRangesFromClaimedLengthArray(
|
|
87
|
+
publicInputs.privateLogs,
|
|
88
|
+
GLOBAL_INDEX_PRIVATE_LOG_OFFSET,
|
|
89
|
+
createRangeFromCountedItem,
|
|
90
|
+
),
|
|
91
|
+
);
|
|
92
|
+
sideEffectRanges = sideEffectRanges.concat(
|
|
93
|
+
createRangesFromClaimedLengthArray(
|
|
94
|
+
publicInputs.contractClassLogsHashes,
|
|
95
|
+
GLOBAL_INDEX_CONTRACT_CLASS_LOG_HASH_OFFSET,
|
|
96
|
+
createRangeFromCountedItem,
|
|
97
|
+
),
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
sideEffectRanges.sort((a, b) => a.start - b.start);
|
|
101
|
+
|
|
102
|
+
const sideEffectRangeIndices = makeTuple(TOTAL_COUNTED_SIDE_EFFECTS_PER_CALL, () => 0);
|
|
103
|
+
for (let i = 0; i < sideEffectRanges.length; i++) {
|
|
104
|
+
const range = sideEffectRanges[i];
|
|
105
|
+
sideEffectRangeIndices[range.sideEffectGlobalIndex] = i;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const hints = SideEffectUniquenessHints.from({
|
|
109
|
+
sideEffectRanges: padArrayEnd(
|
|
110
|
+
sideEffectRanges,
|
|
111
|
+
SideEffectCounterRange.empty(),
|
|
112
|
+
TOTAL_COUNTED_SIDE_EFFECTS_PER_CALL,
|
|
113
|
+
),
|
|
114
|
+
noteHashReadRequestIndices: makeTuple(
|
|
115
|
+
MAX_NOTE_HASH_READ_REQUESTS_PER_CALL,
|
|
116
|
+
i => sideEffectRangeIndices[i + GLOBAL_INDEX_NOTE_HASH_READ_REQUEST_OFFSET],
|
|
117
|
+
),
|
|
118
|
+
nullifierReadRequestIndices: makeTuple(
|
|
119
|
+
MAX_NULLIFIER_READ_REQUESTS_PER_CALL,
|
|
120
|
+
i => sideEffectRangeIndices[i + GLOBAL_INDEX_NULLIFIER_READ_REQUEST_OFFSET],
|
|
121
|
+
),
|
|
122
|
+
noteHashesIndices: makeTuple(
|
|
123
|
+
MAX_NOTE_HASHES_PER_CALL,
|
|
124
|
+
i => sideEffectRangeIndices[i + GLOBAL_INDEX_NOTE_HASH_OFFSET],
|
|
125
|
+
),
|
|
126
|
+
nullifiersIndices: makeTuple(
|
|
127
|
+
MAX_NULLIFIERS_PER_CALL,
|
|
128
|
+
i => sideEffectRangeIndices[i + GLOBAL_INDEX_NULLIFIER_OFFSET],
|
|
129
|
+
),
|
|
130
|
+
privateCallRequestsIndices: makeTuple(
|
|
131
|
+
MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL,
|
|
132
|
+
i => sideEffectRangeIndices[i + GLOBAL_INDEX_PRIVATE_CALL_REQUEST_OFFSET],
|
|
133
|
+
),
|
|
134
|
+
publicCallRequestsIndices: makeTuple(
|
|
135
|
+
MAX_ENQUEUED_CALLS_PER_CALL,
|
|
136
|
+
i => sideEffectRangeIndices[i + GLOBAL_INDEX_PUBLIC_CALL_REQUEST_OFFSET],
|
|
137
|
+
),
|
|
138
|
+
l2ToL1MsgsIndices: makeTuple(
|
|
139
|
+
MAX_L2_TO_L1_MSGS_PER_CALL,
|
|
140
|
+
i => sideEffectRangeIndices[i + GLOBAL_INDEX_L2_TO_L1_MSG_OFFSET],
|
|
141
|
+
),
|
|
142
|
+
privateLogsIndices: makeTuple(
|
|
143
|
+
MAX_PRIVATE_LOGS_PER_CALL,
|
|
144
|
+
i => sideEffectRangeIndices[i + GLOBAL_INDEX_PRIVATE_LOG_OFFSET],
|
|
145
|
+
),
|
|
146
|
+
contractClassLogsHashesIndices: makeTuple(
|
|
147
|
+
MAX_CONTRACT_CLASS_LOGS_PER_CALL,
|
|
148
|
+
i => sideEffectRangeIndices[i + GLOBAL_INDEX_CONTRACT_CLASS_LOG_HASH_OFFSET],
|
|
149
|
+
),
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
return hints;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function createRangesFromClaimedLengthArray<T extends Serializable, N extends number>(
|
|
156
|
+
array: ClaimedLengthArray<T, N>,
|
|
157
|
+
globalIndexOffset: number,
|
|
158
|
+
rangeConstructor: (item: T, globalIndex: number) => SideEffectCounterRange,
|
|
159
|
+
): SideEffectCounterRange[] {
|
|
160
|
+
const ranges = [];
|
|
161
|
+
for (let i = 0; i < array.claimedLength; i++) {
|
|
162
|
+
ranges.push(rangeConstructor(array.array[i], globalIndexOffset + i));
|
|
163
|
+
}
|
|
164
|
+
return ranges;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function createRangeFromCountedItem(item: { counter: number }, globalIndex: number): SideEffectCounterRange {
|
|
168
|
+
return new SideEffectCounterRange(item.counter, item.counter, globalIndex);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function createRangeFromPrivateCallRequest(item: PrivateCallRequest, globalIndex: number): SideEffectCounterRange {
|
|
172
|
+
return new SideEffectCounterRange(item.startSideEffectCounter, item.endSideEffectCounter, globalIndex);
|
|
173
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { MAX_INCLUDE_BY_TIMESTAMP_DURATION } from '@aztec/constants';
|
|
2
|
+
import type { PrivateKernelCircuitPublicInputs } from '@aztec/stdlib/kernel';
|
|
3
|
+
import type { UInt64 } from '@aztec/stdlib/types';
|
|
4
|
+
|
|
5
|
+
const ROUNDED_DURATIONS = [
|
|
6
|
+
3600, // 1 hour
|
|
7
|
+
1800, // 30 mins
|
|
8
|
+
1, // 1 second
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
function roundTimestamp(blockTimestamp: bigint, includeByTimestamp: bigint): UInt64 {
|
|
12
|
+
return ROUNDED_DURATIONS.reduce((timestamp, duration) => {
|
|
13
|
+
if (timestamp <= blockTimestamp) {
|
|
14
|
+
// The timestamp must be greater than the block timestamp.
|
|
15
|
+
// If it is too small, round it down again using a smaller duration.
|
|
16
|
+
const totalDuration = includeByTimestamp - blockTimestamp;
|
|
17
|
+
const roundedDuration = totalDuration - (totalDuration % BigInt(duration));
|
|
18
|
+
return blockTimestamp + roundedDuration;
|
|
19
|
+
}
|
|
20
|
+
return timestamp;
|
|
21
|
+
}, 0n);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function computeTxIncludeByTimestamp(
|
|
25
|
+
previousKernel: PrivateKernelCircuitPublicInputs,
|
|
26
|
+
maxDuration = MAX_INCLUDE_BY_TIMESTAMP_DURATION,
|
|
27
|
+
): UInt64 {
|
|
28
|
+
if (maxDuration > MAX_INCLUDE_BY_TIMESTAMP_DURATION) {
|
|
29
|
+
throw new Error(
|
|
30
|
+
`Custom max duration cannot be greater than the max allowed. Max allowed: ${MAX_INCLUDE_BY_TIMESTAMP_DURATION}. Custom value: ${maxDuration}.`,
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const anchorBlockTimestamp = previousKernel.constants.anchorBlockHeader.globalVariables.timestamp;
|
|
35
|
+
const maxTimestamp = anchorBlockTimestamp + BigInt(maxDuration);
|
|
36
|
+
const includeByTimestamp = previousKernel.includeByTimestamp;
|
|
37
|
+
|
|
38
|
+
// If the includeByTimestamp set during the tx execution is greater than or equal to the max allowed duration,
|
|
39
|
+
// use the maximum allowed timestamp.
|
|
40
|
+
// Note: It shouldn't be larger than the max allowed duration, but we check for it anyway.
|
|
41
|
+
if (includeByTimestamp >= maxTimestamp) {
|
|
42
|
+
return maxTimestamp;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Round it down to the nearest hour/min/second to reduce precision and avoid revealing the exact value.
|
|
46
|
+
// This makes it harder for others to infer what function calls may have been used to produce a specific timestamp.
|
|
47
|
+
const roundedTimestamp = roundTimestamp(anchorBlockTimestamp, includeByTimestamp);
|
|
48
|
+
|
|
49
|
+
// The tx can't be published if the timestamp is the same or less than the anchor block's timestamp.
|
|
50
|
+
// Future blocks will have a greater timestamp, so the tx would never be included.
|
|
51
|
+
if (roundedTimestamp <= anchorBlockTimestamp) {
|
|
52
|
+
throw new Error(
|
|
53
|
+
`Include-by timestamp must be greater than the anchor block timestamp. Anchor block timestamp: ${anchorBlockTimestamp}. Include-by timestamp: ${includeByTimestamp}.`,
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return roundedTimestamp;
|
|
58
|
+
}
|
|
@@ -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 { computeSideEffectUniquenessHints } from './hints/compute_side_effect_uniqueness_hints.js';
|
|
39
|
+
import type { PrivateKernelOracle } from './private_kernel_oracle.js';
|
|
40
|
+
|
|
41
|
+
const NULL_SIMULATE_OUTPUT: PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs> = {
|
|
42
|
+
publicInputs: PrivateKernelCircuitPublicInputs.empty(),
|
|
43
|
+
verificationKey: VerificationKeyData.empty(),
|
|
44
|
+
outputWitness: new Map(),
|
|
45
|
+
bytecode: Buffer.from([]),
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export interface PrivateKernelExecutionProverConfig {
|
|
49
|
+
simulate: boolean;
|
|
50
|
+
skipFeeEnforcement: boolean;
|
|
51
|
+
profileMode: 'gates' | 'execution-steps' | 'full' | 'none';
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The PrivateKernelExecutionProver class is responsible for taking a transaction request and sequencing the
|
|
56
|
+
* the execution of the private functions within, sequenced with private kernel "glue" to check protocol rules.
|
|
57
|
+
* The result can be a chonk proof of the private transaction portion, or just a simulation that can e.g.
|
|
58
|
+
* inform state tree updates.
|
|
59
|
+
*/
|
|
60
|
+
export class PrivateKernelExecutionProver {
|
|
61
|
+
private log = createLogger('pxe:private-kernel-execution-prover');
|
|
62
|
+
|
|
63
|
+
constructor(
|
|
64
|
+
private oracle: PrivateKernelOracle,
|
|
65
|
+
private proofCreator: PrivateKernelProver,
|
|
66
|
+
private fakeProofs = false,
|
|
67
|
+
) {}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Generate a proof for a given transaction request and execution result.
|
|
71
|
+
* The function iterates through the nested executions in the execution result, creates private call data,
|
|
72
|
+
* and generates a proof using the provided ProofCreator instance. It also maintains an index of new notes
|
|
73
|
+
* created during the execution and returns them as a part of the KernelProverOutput.
|
|
74
|
+
*
|
|
75
|
+
* @param txRequest - The authenticated transaction request object.
|
|
76
|
+
* @param executionResult - The execution result object containing nested executions and preimages.
|
|
77
|
+
* @param profile - Set true to profile the gate count for each circuit
|
|
78
|
+
* @returns A Promise that resolves to a KernelProverOutput object containing proof, public inputs, and output notes.
|
|
79
|
+
*/
|
|
80
|
+
async proveWithKernels(
|
|
81
|
+
txRequest: TxRequest,
|
|
82
|
+
executionResult: PrivateExecutionResult,
|
|
83
|
+
{ simulate, skipFeeEnforcement, profileMode }: PrivateKernelExecutionProverConfig = {
|
|
84
|
+
simulate: false,
|
|
85
|
+
skipFeeEnforcement: false,
|
|
86
|
+
profileMode: 'none',
|
|
87
|
+
},
|
|
88
|
+
): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>> {
|
|
89
|
+
const skipProofGeneration = this.fakeProofs || simulate;
|
|
90
|
+
const generateWitnesses = !skipProofGeneration || profileMode !== 'none';
|
|
91
|
+
|
|
92
|
+
const timer = new Timer();
|
|
93
|
+
|
|
94
|
+
const isPrivateOnlyTx = executionResult.publicFunctionCalldata.length === 0;
|
|
95
|
+
|
|
96
|
+
// Initialize an executionStack, beginning with the PrivateCallExecutionResult
|
|
97
|
+
// of the entrypoint function of the tx.
|
|
98
|
+
const executionStack = [executionResult.entrypoint];
|
|
99
|
+
let firstIteration = true;
|
|
100
|
+
|
|
101
|
+
let output = NULL_SIMULATE_OUTPUT;
|
|
102
|
+
|
|
103
|
+
const executionSteps: PrivateExecutionStep[] = [];
|
|
104
|
+
|
|
105
|
+
const noteHashLeafIndexMap = collectNoteHashLeafIndexMap(executionResult);
|
|
106
|
+
const noteHashNullifierCounterMap = collectNoteHashNullifierCounterMap(executionResult);
|
|
107
|
+
const minRevertibleSideEffectCounter = getFinalMinRevertibleSideEffectCounter(executionResult);
|
|
108
|
+
const splitCounter = isPrivateOnlyTx ? 0 : minRevertibleSideEffectCounter;
|
|
109
|
+
|
|
110
|
+
while (executionStack.length) {
|
|
111
|
+
if (!firstIteration) {
|
|
112
|
+
let resetBuilder = new PrivateKernelResetPrivateInputsBuilder(
|
|
113
|
+
output,
|
|
114
|
+
executionStack,
|
|
115
|
+
noteHashNullifierCounterMap,
|
|
116
|
+
splitCounter,
|
|
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
|
+
splitCounter,
|
|
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
|
+
minRevertibleSideEffectCounter,
|
|
175
|
+
);
|
|
176
|
+
this.log.debug(
|
|
177
|
+
`Calling private kernel init with isPrivateOnly ${isPrivateOnlyTx} and firstNullifierHint ${proofInput.firstNullifierHint}`,
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
pushTestData('private-kernel-inputs-init', proofInput);
|
|
181
|
+
|
|
182
|
+
output = generateWitnesses
|
|
183
|
+
? await this.proofCreator.generateInitOutput(proofInput)
|
|
184
|
+
: await this.proofCreator.simulateInit(proofInput);
|
|
185
|
+
|
|
186
|
+
executionSteps.push({
|
|
187
|
+
functionName: 'private_kernel_init',
|
|
188
|
+
bytecode: output.bytecode,
|
|
189
|
+
witness: output.outputWitness,
|
|
190
|
+
vk: output.verificationKey.keyAsBytes,
|
|
191
|
+
timings: {
|
|
192
|
+
witgen: witgenTimer.ms(),
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
} else {
|
|
196
|
+
const witgenTimer = new Timer();
|
|
197
|
+
const vkData = await this.getVkData(output.verificationKey);
|
|
198
|
+
const previousKernelData = new PrivateKernelData(output.publicInputs, vkData);
|
|
199
|
+
const proofInput = new PrivateKernelInnerCircuitPrivateInputs(previousKernelData, privateCallData);
|
|
200
|
+
|
|
201
|
+
pushTestData('private-kernel-inputs-inner', proofInput);
|
|
202
|
+
output = generateWitnesses
|
|
203
|
+
? await this.proofCreator.generateInnerOutput(proofInput)
|
|
204
|
+
: await this.proofCreator.simulateInner(proofInput);
|
|
205
|
+
|
|
206
|
+
executionSteps.push({
|
|
207
|
+
functionName: 'private_kernel_inner',
|
|
208
|
+
bytecode: output.bytecode,
|
|
209
|
+
witness: output.outputWitness,
|
|
210
|
+
vk: output.verificationKey.keyAsBytes,
|
|
211
|
+
timings: {
|
|
212
|
+
witgen: witgenTimer.ms(),
|
|
213
|
+
},
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
firstIteration = false;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Reset.
|
|
220
|
+
let resetBuilder = new PrivateKernelResetPrivateInputsBuilder(
|
|
221
|
+
output,
|
|
222
|
+
[],
|
|
223
|
+
noteHashNullifierCounterMap,
|
|
224
|
+
splitCounter,
|
|
225
|
+
);
|
|
226
|
+
while (resetBuilder.needsReset()) {
|
|
227
|
+
const witgenTimer = new Timer();
|
|
228
|
+
const privateInputs = await resetBuilder.build(this.oracle, noteHashLeafIndexMap);
|
|
229
|
+
output = generateWitnesses
|
|
230
|
+
? await this.proofCreator.generateResetOutput(privateInputs)
|
|
231
|
+
: await this.proofCreator.simulateReset(privateInputs);
|
|
232
|
+
|
|
233
|
+
executionSteps.push({
|
|
234
|
+
functionName: 'private_kernel_reset',
|
|
235
|
+
bytecode: output.bytecode,
|
|
236
|
+
witness: output.outputWitness,
|
|
237
|
+
vk: output.verificationKey.keyAsBytes,
|
|
238
|
+
timings: {
|
|
239
|
+
witgen: witgenTimer.ms(),
|
|
240
|
+
},
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
resetBuilder = new PrivateKernelResetPrivateInputsBuilder(output, [], noteHashNullifierCounterMap, splitCounter);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (output.publicInputs.feePayer.isZero() && skipFeeEnforcement) {
|
|
247
|
+
if (!skipProofGeneration) {
|
|
248
|
+
throw new Error('Fee payment must be enforced when creating real proof.');
|
|
249
|
+
}
|
|
250
|
+
output.publicInputs.feePayer = new AztecAddress(Fr.MAX_FIELD_VALUE);
|
|
251
|
+
}
|
|
252
|
+
// Private tail.
|
|
253
|
+
const vkData = await this.getVkData(output.verificationKey);
|
|
254
|
+
const previousKernelData = new PrivateKernelData(output.publicInputs, vkData);
|
|
255
|
+
|
|
256
|
+
this.log.debug(
|
|
257
|
+
`Calling private kernel tail with hwm ${previousKernelData.publicInputs.minRevertibleSideEffectCounter}`,
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
// TODO: Enable padding once we better understand the final amounts to pad to.
|
|
261
|
+
const paddedSideEffectAmounts = PaddedSideEffectAmounts.empty();
|
|
262
|
+
|
|
263
|
+
// Use the aggregated includeByTimestamp set throughout the tx execution.
|
|
264
|
+
// TODO: Call `computeTxIncludeByTimestamp` to round the value down and reduce precision, improving privacy.
|
|
265
|
+
const includeByTimestampUpperBound = previousKernelData.publicInputs.includeByTimestamp;
|
|
266
|
+
const anchorBlockTimestamp = previousKernelData.publicInputs.constants.anchorBlockHeader.globalVariables.timestamp;
|
|
267
|
+
if (includeByTimestampUpperBound <= anchorBlockTimestamp) {
|
|
268
|
+
throw new Error(
|
|
269
|
+
`Include-by timestamp must be greater than the anchor block timestamp. Anchor block timestamp: ${anchorBlockTimestamp}. Include-by timestamp: ${includeByTimestampUpperBound}.`,
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const privateInputs = new PrivateKernelTailCircuitPrivateInputs(
|
|
274
|
+
previousKernelData,
|
|
275
|
+
paddedSideEffectAmounts,
|
|
276
|
+
includeByTimestampUpperBound,
|
|
277
|
+
);
|
|
278
|
+
|
|
279
|
+
const witgenTimer = new Timer();
|
|
280
|
+
const tailOutput = generateWitnesses
|
|
281
|
+
? await this.proofCreator.generateTailOutput(privateInputs)
|
|
282
|
+
: await this.proofCreator.simulateTail(privateInputs);
|
|
283
|
+
|
|
284
|
+
executionSteps.push({
|
|
285
|
+
functionName: 'private_kernel_tail',
|
|
286
|
+
bytecode: tailOutput.bytecode,
|
|
287
|
+
witness: tailOutput.outputWitness,
|
|
288
|
+
vk: tailOutput.verificationKey.keyAsBytes,
|
|
289
|
+
timings: {
|
|
290
|
+
witgen: witgenTimer.ms(),
|
|
291
|
+
},
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
// Hiding circuit is only executed if we are generating witnesses.
|
|
295
|
+
// For simulation, we can end with the tail, since the hiding circuit will simply return the same tail output.
|
|
296
|
+
if (generateWitnesses) {
|
|
297
|
+
const previousKernelVkData = await this.getVkData(tailOutput.verificationKey);
|
|
298
|
+
|
|
299
|
+
const witgenTimer = new Timer();
|
|
300
|
+
let hidingOutput: PrivateKernelSimulateOutput<PrivateKernelTailCircuitPublicInputs>;
|
|
301
|
+
if (tailOutput.publicInputs.forPublic) {
|
|
302
|
+
const privateInputs = new HidingKernelToPublicPrivateInputs(
|
|
303
|
+
tailOutput.publicInputs.toPrivateToPublicKernelCircuitPublicInputs(),
|
|
304
|
+
previousKernelVkData,
|
|
305
|
+
);
|
|
306
|
+
hidingOutput = await this.proofCreator.generateHidingToPublicOutput(privateInputs);
|
|
307
|
+
} else {
|
|
308
|
+
const privateInputs = new HidingKernelToRollupPrivateInputs(
|
|
309
|
+
tailOutput.publicInputs.toPrivateToRollupKernelCircuitPublicInputs(),
|
|
310
|
+
previousKernelVkData,
|
|
311
|
+
);
|
|
312
|
+
hidingOutput = await this.proofCreator.generateHidingToRollupOutput(privateInputs);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
executionSteps.push({
|
|
316
|
+
functionName: 'hiding_kernel',
|
|
317
|
+
bytecode: hidingOutput.bytecode,
|
|
318
|
+
witness: hidingOutput.outputWitness,
|
|
319
|
+
vk: hidingOutput.verificationKey.keyAsBytes,
|
|
320
|
+
timings: {
|
|
321
|
+
witgen: witgenTimer.ms(),
|
|
322
|
+
},
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
if (profileMode == 'gates' || profileMode == 'full') {
|
|
327
|
+
for (const entry of executionSteps) {
|
|
328
|
+
const gateCountTimer = new Timer();
|
|
329
|
+
const gateCount = await this.proofCreator.computeGateCountForCircuit(entry.bytecode, entry.functionName);
|
|
330
|
+
entry.gateCount = gateCount;
|
|
331
|
+
entry.timings.gateCount = gateCountTimer.ms();
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
if (profileMode === 'gates') {
|
|
335
|
+
for (const entry of executionSteps) {
|
|
336
|
+
// These buffers are often a few megabytes in size - prevent accidentally serializing them if not requested.
|
|
337
|
+
entry.bytecode = Buffer.from([]);
|
|
338
|
+
entry.witness = new Map();
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
if (generateWitnesses) {
|
|
343
|
+
this.log.info(`Private kernel witness generation took ${timer.ms()}ms`);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
let chonkProof: ChonkProof;
|
|
347
|
+
// TODO(#7368) how do we 'bincode' encode these inputs?
|
|
348
|
+
let provingTime;
|
|
349
|
+
if (!skipProofGeneration) {
|
|
350
|
+
const provingTimer = new Timer();
|
|
351
|
+
const proofWithPublicInputs = await this.proofCreator.createChonkProof(executionSteps);
|
|
352
|
+
provingTime = provingTimer.ms();
|
|
353
|
+
this.ensurePublicInputsMatch(proofWithPublicInputs, tailOutput.publicInputs);
|
|
354
|
+
chonkProof = proofWithPublicInputs.removePublicInputs();
|
|
355
|
+
} else {
|
|
356
|
+
chonkProof = ChonkProof.random();
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
return {
|
|
360
|
+
publicInputs: tailOutput.publicInputs,
|
|
361
|
+
executionSteps,
|
|
362
|
+
chonkProof,
|
|
363
|
+
timings: provingTime ? { proving: provingTime } : undefined,
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Checks that the public inputs of the chonk proof match the public inputs of the tail circuit.
|
|
369
|
+
* This can only mismatch if there is a circuit / noir / bb bug.
|
|
370
|
+
* @param chonkProof - The chonk proof with public inputs.
|
|
371
|
+
* @param tailPublicInputs - The public inputs resulting from witness generation of the tail circuit.
|
|
372
|
+
*/
|
|
373
|
+
private ensurePublicInputsMatch(
|
|
374
|
+
chonkProof: ChonkProofWithPublicInputs,
|
|
375
|
+
tailPublicInputs: PrivateKernelTailCircuitPublicInputs,
|
|
376
|
+
) {
|
|
377
|
+
const serializedChonkProofPublicInputs = chonkProof.getPublicInputs();
|
|
378
|
+
const serializedTailPublicInputs = tailPublicInputs.publicInputs().toFields();
|
|
379
|
+
if (serializedChonkProofPublicInputs.length !== serializedTailPublicInputs.length) {
|
|
380
|
+
throw new Error(
|
|
381
|
+
`Public inputs length mismatch: ${serializedChonkProofPublicInputs.length} !== ${serializedTailPublicInputs.length}`,
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
if (
|
|
385
|
+
!serializedChonkProofPublicInputs.every((input: Fr, index: number) =>
|
|
386
|
+
input.equals(serializedTailPublicInputs[index]),
|
|
387
|
+
)
|
|
388
|
+
) {
|
|
389
|
+
throw new Error(`Public inputs mismatch between kernel and chonk proof`);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
private async getVkData(verificationKey: VerificationKeyData) {
|
|
394
|
+
const previousVkMembershipWitness = await this.oracle.getVkMembershipWitness(verificationKey.keyAsFields);
|
|
395
|
+
return new VkData(
|
|
396
|
+
verificationKey,
|
|
397
|
+
Number(previousVkMembershipWitness.leafIndex),
|
|
398
|
+
previousVkMembershipWitness.siblingPath,
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
private async createPrivateCallData({ publicInputs, vk: vkAsBuffer }: PrivateCallExecutionResult) {
|
|
403
|
+
const { contractAddress, functionSelector } = publicInputs.callContext;
|
|
404
|
+
|
|
405
|
+
const vkAsFields = await vkAsFieldsMegaHonk(vkAsBuffer);
|
|
406
|
+
const vk = await VerificationKeyAsFields.fromKey(vkAsFields);
|
|
407
|
+
|
|
408
|
+
const { currentContractClassId, publicKeys, saltedInitializationHash } =
|
|
409
|
+
await this.oracle.getContractAddressPreimage(contractAddress);
|
|
410
|
+
const functionLeafMembershipWitness = await this.oracle.getFunctionMembershipWitness(
|
|
411
|
+
currentContractClassId,
|
|
412
|
+
functionSelector,
|
|
413
|
+
);
|
|
414
|
+
|
|
415
|
+
const { artifactHash: contractClassArtifactHash, publicBytecodeCommitment: contractClassPublicBytecodeCommitment } =
|
|
416
|
+
await this.oracle.getContractClassIdPreimage(currentContractClassId);
|
|
417
|
+
|
|
418
|
+
const updatedClassIdHints = await this.oracle.getUpdatedClassIdHints(contractAddress);
|
|
419
|
+
|
|
420
|
+
const sideEffectUniquenessHints = computeSideEffectUniquenessHints(publicInputs);
|
|
421
|
+
|
|
422
|
+
return PrivateCallData.from({
|
|
423
|
+
publicInputs,
|
|
424
|
+
vk,
|
|
425
|
+
verificationKeyHints: PrivateVerificationKeyHints.from({
|
|
426
|
+
publicKeys,
|
|
427
|
+
contractClassArtifactHash,
|
|
428
|
+
contractClassPublicBytecodeCommitment,
|
|
429
|
+
saltedInitializationHash,
|
|
430
|
+
functionLeafMembershipWitness,
|
|
431
|
+
updatedClassIdHints,
|
|
432
|
+
}),
|
|
433
|
+
sideEffectUniquenessHints,
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
}
|