@aztec/pxe 0.0.0-test.1 → 0.0.1-commit.b655e406
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +10 -15
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +11 -20
- 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 +301 -0
- package/dest/contract_function_simulator/execution_data_provider.d.ts +274 -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 +93 -0
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -0
- package/dest/contract_function_simulator/execution_note_cache.js +183 -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 +22 -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 +42 -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 +97 -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 +22 -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 +49 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts +57 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/oracle.js +328 -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 +236 -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 +417 -0
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +154 -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 +701 -0
- package/dest/entrypoints/client/bundle/index.d.ts +4 -2
- 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 +9 -9
- 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 +4 -2
- 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 +8 -8
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +17 -11
- package/dest/entrypoints/{client/pxe_creation_options.d.ts → pxe_creation_options.d.ts} +4 -1
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -0
- package/dest/entrypoints/server/index.d.ts +5 -3
- 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 +7 -15
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +34 -28
- package/dest/{pxe_service/error_enriching.d.ts → error_enriching.d.ts} +1 -1
- 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/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.d.ts +6 -6
- 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_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 +285 -0
- package/dest/{kernel_prover/proving_data_oracle.d.ts → private_kernel/private_kernel_oracle.d.ts} +17 -28
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -0
- package/dest/private_kernel/private_kernel_oracle.js +4 -0
- package/dest/{kernel_oracle/index.d.ts → private_kernel/private_kernel_oracle_impl.d.ts} +8 -8
- 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 +233 -0
- package/dest/pxe.d.ts.map +1 -0
- package/dest/pxe.js +789 -0
- package/dest/storage/address_data_provider/address_data_provider.d.ts +1 -3
- 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/capsule_data_provider/capsule_data_provider.d.ts +14 -5
- 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/contract_data_provider/contract_data_provider.d.ts +12 -47
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +1 -1
- package/dest/storage/contract_data_provider/contract_data_provider.js +92 -70
- package/dest/storage/contract_data_provider/index.d.ts +0 -1
- 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 +2 -41
- 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 +2 -3
- 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/note_dao.d.ts +16 -22
- package/dest/storage/note_data_provider/note_dao.d.ts.map +1 -1
- package/dest/storage/note_data_provider/note_dao.js +16 -20
- package/dest/storage/note_data_provider/note_data_provider.d.ts +71 -8
- package/dest/storage/note_data_provider/note_data_provider.d.ts.map +1 -1
- package/dest/storage/note_data_provider/note_data_provider.js +133 -74
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +43 -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 +104 -0
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts +2 -4
- 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/tagging_data_provider.d.ts +28 -6
- 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/synchronizer.d.ts +7 -9
- 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 +34 -32
- package/src/bin/check_oracle_version.ts +50 -0
- package/src/config/index.ts +20 -33
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +548 -0
- package/src/contract_function_simulator/execution_data_provider.ts +343 -0
- package/src/contract_function_simulator/execution_note_cache.ts +222 -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 +52 -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 +160 -0
- package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +23 -0
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +52 -0
- package/src/contract_function_simulator/oracle/oracle.ts +575 -0
- package/src/contract_function_simulator/oracle/private_execution.ts +207 -0
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +625 -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 +1019 -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 +69 -47
- 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 -142
- 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 +1113 -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 +114 -81
- 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/note_dao.ts +19 -27
- package/src/storage/note_data_provider/note_data_provider.ts +161 -113
- package/src/storage/private_event_data_provider/private_event_data_provider.ts +148 -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.map +0 -1
- package/dest/kernel_oracle/index.d.ts.map +0 -1
- 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.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.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/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/test/pxe_test_suite.ts +0 -111
- /package/dest/entrypoints/{client/pxe_creation_options.js → pxe_creation_options.js} +0 -0
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
import { MAX_KEY_VALIDATION_REQUESTS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_TX, NULLIFIER_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
-
import { makeTuple } from '@aztec/foundation/array';
|
|
3
|
-
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
4
|
-
import { assertLength } from '@aztec/foundation/serialize';
|
|
5
|
-
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
6
|
-
import { privateKernelResetDimensionsConfig } from '@aztec/noir-protocol-circuits-types/client';
|
|
7
|
-
import { KeyValidationHint, PrivateKernelData, PrivateKernelResetCircuitPrivateInputs, PrivateKernelResetDimensions, PrivateKernelResetHints, ReadRequestResetStates, ReadRequestState, ScopedNoteHash, ScopedNullifier, ScopedReadRequest, TransientDataIndexHint, buildNoteHashReadRequestHintsFromResetStates, buildNullifierReadRequestHintsFromResetStates, buildTransientDataHints, countAccumulatedItems, findPrivateKernelResetDimensions, getNonEmptyItems, getNoteHashReadRequestResetStates, getNullifierReadRequestResetStates, privateKernelResetDimensionNames } from '@aztec/stdlib/kernel';
|
|
8
|
-
import { collectNested } from '@aztec/stdlib/tx';
|
|
9
|
-
function collectNestedReadRequests(executionStack, extractReadRequests) {
|
|
10
|
-
return collectNested(executionStack, (executionResult)=>{
|
|
11
|
-
const nonEmptyReadRequests = getNonEmptyItems(extractReadRequests(executionResult));
|
|
12
|
-
return nonEmptyReadRequests.map((readRequest)=>new ScopedReadRequest(readRequest, executionResult.publicInputs.callContext.contractAddress));
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
function getNullifierMembershipWitnessResolver(oracle) {
|
|
16
|
-
return async (nullifier)=>{
|
|
17
|
-
const res = await oracle.getNullifierMembershipWitness(nullifier);
|
|
18
|
-
if (!res) {
|
|
19
|
-
throw new Error(`Cannot find the leaf for nullifier ${nullifier}.`);
|
|
20
|
-
}
|
|
21
|
-
const { index, siblingPath, leafPreimage } = res;
|
|
22
|
-
return {
|
|
23
|
-
membershipWitness: new MembershipWitness(NULLIFIER_TREE_HEIGHT, index, siblingPath.toTuple()),
|
|
24
|
-
leafPreimage
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
async function getMasterSecretKeysAndAppKeyGenerators(keyValidationRequests, oracle) {
|
|
29
|
-
const keysHints = [];
|
|
30
|
-
for(let i = 0; i < keyValidationRequests.length; ++i){
|
|
31
|
-
const request = keyValidationRequests[i].request;
|
|
32
|
-
if (request.isEmpty()) {
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
const secretKeys = await oracle.getMasterSecretKey(request.request.pkM);
|
|
36
|
-
keysHints.push(new KeyValidationHint(secretKeys, i));
|
|
37
|
-
}
|
|
38
|
-
return padArrayEnd(keysHints, KeyValidationHint.nada(MAX_KEY_VALIDATION_REQUESTS_PER_TX), MAX_KEY_VALIDATION_REQUESTS_PER_TX);
|
|
39
|
-
}
|
|
40
|
-
export class PrivateKernelResetPrivateInputsBuilder {
|
|
41
|
-
previousKernelOutput;
|
|
42
|
-
executionStack;
|
|
43
|
-
noteHashNullifierCounterMap;
|
|
44
|
-
validationRequestsSplitCounter;
|
|
45
|
-
previousKernel;
|
|
46
|
-
// If there's no next iteration, it's the final reset.
|
|
47
|
-
nextIteration;
|
|
48
|
-
noteHashResetStates;
|
|
49
|
-
nullifierResetStates;
|
|
50
|
-
numTransientData;
|
|
51
|
-
transientDataIndexHints;
|
|
52
|
-
requestedDimensions;
|
|
53
|
-
constructor(previousKernelOutput, executionStack, noteHashNullifierCounterMap, validationRequestsSplitCounter){
|
|
54
|
-
this.previousKernelOutput = previousKernelOutput;
|
|
55
|
-
this.executionStack = executionStack;
|
|
56
|
-
this.noteHashNullifierCounterMap = noteHashNullifierCounterMap;
|
|
57
|
-
this.validationRequestsSplitCounter = validationRequestsSplitCounter;
|
|
58
|
-
this.previousKernel = previousKernelOutput.publicInputs;
|
|
59
|
-
this.requestedDimensions = PrivateKernelResetDimensions.empty();
|
|
60
|
-
this.noteHashResetStates = ReadRequestResetStates.empty(MAX_NOTE_HASH_READ_REQUESTS_PER_TX);
|
|
61
|
-
this.nullifierResetStates = ReadRequestResetStates.empty(MAX_NULLIFIER_READ_REQUESTS_PER_TX);
|
|
62
|
-
this.transientDataIndexHints = makeTuple(MAX_NULLIFIERS_PER_TX, ()=>new TransientDataIndexHint(MAX_NULLIFIERS_PER_TX, MAX_NOTE_HASHES_PER_TX));
|
|
63
|
-
this.nextIteration = executionStack[this.executionStack.length - 1]?.publicInputs;
|
|
64
|
-
}
|
|
65
|
-
needsReset() {
|
|
66
|
-
const fns = [
|
|
67
|
-
()=>this.needsResetNoteHashReadRequests(),
|
|
68
|
-
()=>this.needsResetNullifierReadRequests(),
|
|
69
|
-
()=>this.needsResetNullifierKeys(),
|
|
70
|
-
()=>this.needsResetTransientData()
|
|
71
|
-
];
|
|
72
|
-
if (this.nextIteration) {
|
|
73
|
-
// If there's a next iteration, reset is needed only when data of a dimension is about to overflow.
|
|
74
|
-
// fns are executed until a dimension that needs reset is found.
|
|
75
|
-
return fns.some((fn)=>fn());
|
|
76
|
-
} else {
|
|
77
|
-
// Siloing is only needed after processing all iterations.
|
|
78
|
-
fns.push(...[
|
|
79
|
-
()=>this.needsSiloNoteHashes(),
|
|
80
|
-
()=>this.needsSiloNullifiers(),
|
|
81
|
-
()=>this.needsSiloPrivateLogs()
|
|
82
|
-
]);
|
|
83
|
-
// If there's no next iteration, reset is needed when any of the dimension has non empty data.
|
|
84
|
-
// All the fns should to be executed so that data in all dimensions will be reset.
|
|
85
|
-
const result = fns.map((fn)=>fn());
|
|
86
|
-
return result.some((r)=>r);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
async build(oracle, noteHashLeafIndexMap) {
|
|
90
|
-
if (privateKernelResetDimensionNames.every((name)=>!this.requestedDimensions[name])) {
|
|
91
|
-
throw new Error('Reset is not required.');
|
|
92
|
-
}
|
|
93
|
-
const isInner = !!this.nextIteration;
|
|
94
|
-
// "final" reset must be done at most once.
|
|
95
|
-
// Because the code that silo note hashes can't be run repeatedly.
|
|
96
|
-
// The dimensions found must be big enough to reset all values, i.e. empty remainder.
|
|
97
|
-
const allowRemainder = isInner;
|
|
98
|
-
const dimensions = findPrivateKernelResetDimensions(this.requestedDimensions, privateKernelResetDimensionsConfig, isInner, allowRemainder);
|
|
99
|
-
const previousVkMembershipWitness = await oracle.getVkMembershipWitness(this.previousKernelOutput.verificationKey);
|
|
100
|
-
const previousKernelData = new PrivateKernelData(this.previousKernelOutput.publicInputs, this.previousKernelOutput.verificationKey, Number(previousVkMembershipWitness.leafIndex), assertLength(previousVkMembershipWitness.siblingPath, VK_TREE_HEIGHT));
|
|
101
|
-
this.reduceReadRequestStates(this.noteHashResetStates, dimensions.NOTE_HASH_PENDING_AMOUNT, dimensions.NOTE_HASH_SETTLED_AMOUNT);
|
|
102
|
-
this.reduceReadRequestStates(this.nullifierResetStates, dimensions.NULLIFIER_PENDING_AMOUNT, dimensions.NULLIFIER_SETTLED_AMOUNT);
|
|
103
|
-
return new PrivateKernelResetCircuitPrivateInputs(previousKernelData, new PrivateKernelResetHints(await buildNoteHashReadRequestHintsFromResetStates(oracle, this.previousKernel.validationRequests.noteHashReadRequests, this.previousKernel.end.noteHashes, this.noteHashResetStates, noteHashLeafIndexMap), await buildNullifierReadRequestHintsFromResetStates({
|
|
104
|
-
getNullifierMembershipWitness: getNullifierMembershipWitnessResolver(oracle)
|
|
105
|
-
}, this.previousKernel.validationRequests.nullifierReadRequests, this.nullifierResetStates), await getMasterSecretKeysAndAppKeyGenerators(this.previousKernel.validationRequests.scopedKeyValidationRequestsAndGenerators, oracle), this.transientDataIndexHints, this.validationRequestsSplitCounter), dimensions);
|
|
106
|
-
}
|
|
107
|
-
reduceReadRequestStates(resetStates, maxPending, maxSettled) {
|
|
108
|
-
let numPending = 0;
|
|
109
|
-
let numSettled = 0;
|
|
110
|
-
for(let i = 0; i < resetStates.states.length; i++){
|
|
111
|
-
const state = resetStates.states[i];
|
|
112
|
-
if (state === ReadRequestState.PENDING) {
|
|
113
|
-
if (numPending < maxPending) {
|
|
114
|
-
numPending++;
|
|
115
|
-
} else {
|
|
116
|
-
resetStates.states[i] = ReadRequestState.NADA;
|
|
117
|
-
}
|
|
118
|
-
} else if (state === ReadRequestState.SETTLED) {
|
|
119
|
-
if (numSettled < maxSettled) {
|
|
120
|
-
numSettled++;
|
|
121
|
-
} else {
|
|
122
|
-
resetStates.states[i] = ReadRequestState.NADA;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
resetStates.pendingReadHints = resetStates.pendingReadHints.slice(0, maxPending);
|
|
127
|
-
}
|
|
128
|
-
needsResetNoteHashReadRequests(forceResetAll = false) {
|
|
129
|
-
const numCurr = countAccumulatedItems(this.previousKernel.validationRequests.noteHashReadRequests);
|
|
130
|
-
const numNext = this.nextIteration ? countAccumulatedItems(this.nextIteration.noteHashReadRequests) : 0;
|
|
131
|
-
const maxAmountToKeep = !this.nextIteration || forceResetAll ? 0 : MAX_NOTE_HASH_READ_REQUESTS_PER_TX;
|
|
132
|
-
if (numCurr + numNext <= maxAmountToKeep) {
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
|
-
const futureNoteHashes = collectNested(this.executionStack, (executionResult)=>{
|
|
136
|
-
const nonEmptyNoteHashes = getNonEmptyItems(executionResult.publicInputs.noteHashes);
|
|
137
|
-
return nonEmptyNoteHashes.map((noteHash)=>new ScopedNoteHash(noteHash, executionResult.publicInputs.callContext.contractAddress));
|
|
138
|
-
});
|
|
139
|
-
const resetStates = getNoteHashReadRequestResetStates(this.previousKernel.validationRequests.noteHashReadRequests, this.previousKernel.end.noteHashes, futureNoteHashes);
|
|
140
|
-
const numPendingReads = resetStates.pendingReadHints.length;
|
|
141
|
-
const numSettledReads = resetStates.states.reduce((accum, state)=>accum + (state === ReadRequestState.SETTLED ? 1 : 0), 0);
|
|
142
|
-
if (!this.nextIteration) {
|
|
143
|
-
this.noteHashResetStates = resetStates;
|
|
144
|
-
this.requestedDimensions.NOTE_HASH_PENDING_AMOUNT = numPendingReads;
|
|
145
|
-
this.requestedDimensions.NOTE_HASH_SETTLED_AMOUNT = numSettledReads;
|
|
146
|
-
} else {
|
|
147
|
-
// Pick only one dimension to reset if next iteration is not empty.
|
|
148
|
-
if (numPendingReads > numSettledReads) {
|
|
149
|
-
this.requestedDimensions.NOTE_HASH_PENDING_AMOUNT = numPendingReads;
|
|
150
|
-
this.noteHashResetStates.states = assertLength(resetStates.states.map((state)=>state === ReadRequestState.PENDING ? state : ReadRequestState.NADA), MAX_NOTE_HASH_READ_REQUESTS_PER_TX);
|
|
151
|
-
this.noteHashResetStates.pendingReadHints = resetStates.pendingReadHints;
|
|
152
|
-
} else {
|
|
153
|
-
this.requestedDimensions.NOTE_HASH_SETTLED_AMOUNT = numSettledReads;
|
|
154
|
-
this.noteHashResetStates.states = assertLength(resetStates.states.map((state)=>state === ReadRequestState.SETTLED ? state : ReadRequestState.NADA), MAX_NOTE_HASH_READ_REQUESTS_PER_TX);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return true;
|
|
158
|
-
}
|
|
159
|
-
needsResetNullifierReadRequests(forceResetAll = false) {
|
|
160
|
-
const numCurr = countAccumulatedItems(this.previousKernel.validationRequests.nullifierReadRequests);
|
|
161
|
-
const numNext = this.nextIteration ? countAccumulatedItems(this.nextIteration.nullifierReadRequests) : 0;
|
|
162
|
-
const maxAmountToKeep = !this.nextIteration || forceResetAll ? 0 : MAX_NULLIFIER_READ_REQUESTS_PER_TX;
|
|
163
|
-
if (numCurr + numNext <= maxAmountToKeep) {
|
|
164
|
-
return false;
|
|
165
|
-
}
|
|
166
|
-
const futureNullifiers = collectNested(this.executionStack, (executionResult)=>{
|
|
167
|
-
const nonEmptyNullifiers = getNonEmptyItems(executionResult.publicInputs.nullifiers);
|
|
168
|
-
return nonEmptyNullifiers.map((nullifier)=>new ScopedNullifier(nullifier, executionResult.publicInputs.callContext.contractAddress));
|
|
169
|
-
});
|
|
170
|
-
const resetStates = getNullifierReadRequestResetStates(this.previousKernel.validationRequests.nullifierReadRequests, this.previousKernel.end.nullifiers, futureNullifiers);
|
|
171
|
-
const numPendingReads = resetStates.pendingReadHints.length;
|
|
172
|
-
const numSettledReads = resetStates.states.reduce((accum, state)=>accum + (state === ReadRequestState.SETTLED ? 1 : 0), 0);
|
|
173
|
-
if (!this.nextIteration) {
|
|
174
|
-
this.nullifierResetStates = resetStates;
|
|
175
|
-
this.requestedDimensions.NULLIFIER_PENDING_AMOUNT = numPendingReads;
|
|
176
|
-
this.requestedDimensions.NULLIFIER_SETTLED_AMOUNT = numSettledReads;
|
|
177
|
-
} else {
|
|
178
|
-
// Pick only one dimension to reset if next iteration is not empty.
|
|
179
|
-
if (numPendingReads > numSettledReads) {
|
|
180
|
-
this.requestedDimensions.NULLIFIER_PENDING_AMOUNT = numPendingReads;
|
|
181
|
-
this.nullifierResetStates.states = assertLength(resetStates.states.map((state)=>state === ReadRequestState.PENDING ? state : ReadRequestState.NADA), MAX_NULLIFIER_READ_REQUESTS_PER_TX);
|
|
182
|
-
this.nullifierResetStates.pendingReadHints = resetStates.pendingReadHints;
|
|
183
|
-
} else {
|
|
184
|
-
this.requestedDimensions.NULLIFIER_SETTLED_AMOUNT = numSettledReads;
|
|
185
|
-
this.nullifierResetStates.states = assertLength(resetStates.states.map((state)=>state === ReadRequestState.SETTLED ? state : ReadRequestState.NADA), MAX_NULLIFIER_READ_REQUESTS_PER_TX);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
return true;
|
|
189
|
-
}
|
|
190
|
-
needsResetNullifierKeys() {
|
|
191
|
-
const numCurr = countAccumulatedItems(this.previousKernel.validationRequests.scopedKeyValidationRequestsAndGenerators);
|
|
192
|
-
const numNext = this.nextIteration ? countAccumulatedItems(this.nextIteration.keyValidationRequestsAndGenerators) : 0;
|
|
193
|
-
const maxAmountToKeep = !this.nextIteration ? 0 : MAX_KEY_VALIDATION_REQUESTS_PER_TX;
|
|
194
|
-
if (numCurr + numNext <= maxAmountToKeep) {
|
|
195
|
-
return false;
|
|
196
|
-
}
|
|
197
|
-
this.requestedDimensions.NULLIFIER_KEYS = numCurr;
|
|
198
|
-
return true;
|
|
199
|
-
}
|
|
200
|
-
needsResetTransientData() {
|
|
201
|
-
// Initialize this to 0 so that needsSilo can be run.
|
|
202
|
-
this.numTransientData = 0;
|
|
203
|
-
const nextAccumNoteHashes = countAccumulatedItems(this.previousKernel.end.noteHashes) + countAccumulatedItems(this.nextIteration?.noteHashes ?? []);
|
|
204
|
-
const noteHashWillOverflow = nextAccumNoteHashes > MAX_NOTE_HASHES_PER_TX;
|
|
205
|
-
const nextAccumNullifiers = countAccumulatedItems(this.previousKernel.end.nullifiers) + countAccumulatedItems(this.nextIteration?.nullifiers ?? []);
|
|
206
|
-
const nullifierWillOverflow = nextAccumNullifiers > MAX_NULLIFIERS_PER_TX;
|
|
207
|
-
if (this.nextIteration && !noteHashWillOverflow && !nullifierWillOverflow) {
|
|
208
|
-
return false;
|
|
209
|
-
}
|
|
210
|
-
const futureNoteHashReads = collectNestedReadRequests(this.executionStack, (executionResult)=>executionResult.publicInputs.noteHashReadRequests);
|
|
211
|
-
const futureNullifierReads = collectNestedReadRequests(this.executionStack, (executionResult)=>executionResult.publicInputs.nullifierReadRequests);
|
|
212
|
-
if (this.nextIteration) {
|
|
213
|
-
// If it's not the final reset, only one dimension will be reset at a time.
|
|
214
|
-
// The note hashes and nullifiers for the remaining read requests can't be squashed.
|
|
215
|
-
futureNoteHashReads.push(...this.previousKernel.validationRequests.noteHashReadRequests.filter((r)=>!r.isEmpty()));
|
|
216
|
-
futureNullifierReads.push(...this.previousKernel.validationRequests.nullifierReadRequests.filter((r)=>!r.isEmpty()));
|
|
217
|
-
}
|
|
218
|
-
const { numTransientData, hints: transientDataIndexHints } = buildTransientDataHints(this.previousKernel.end.noteHashes, this.previousKernel.end.nullifiers, futureNoteHashReads, futureNullifierReads, this.noteHashNullifierCounterMap, this.validationRequestsSplitCounter, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX);
|
|
219
|
-
if (this.nextIteration && !numTransientData) {
|
|
220
|
-
const forceResetAll = true;
|
|
221
|
-
const canClearReadRequests = noteHashWillOverflow && this.needsResetNoteHashReadRequests(forceResetAll) || nullifierWillOverflow && this.needsResetNullifierReadRequests(forceResetAll);
|
|
222
|
-
if (!canClearReadRequests) {
|
|
223
|
-
const overflownData = noteHashWillOverflow ? 'note hashes' : 'nullifiers';
|
|
224
|
-
throw new Error(`Number of ${overflownData} exceeds the limit.`);
|
|
225
|
-
}
|
|
226
|
-
// Clearing the read requests might not be enough to squash the overflown data.
|
|
227
|
-
// In this case, the next iteration will fail at the above check.
|
|
228
|
-
return true;
|
|
229
|
-
}
|
|
230
|
-
this.numTransientData = numTransientData;
|
|
231
|
-
this.transientDataIndexHints = transientDataIndexHints;
|
|
232
|
-
this.requestedDimensions.TRANSIENT_DATA_AMOUNT = numTransientData;
|
|
233
|
-
return numTransientData > 0;
|
|
234
|
-
}
|
|
235
|
-
needsSiloNoteHashes() {
|
|
236
|
-
if (this.numTransientData === undefined) {
|
|
237
|
-
throw new Error('`needsResetTransientData` must be run before `needsSiloNoteHashes`.');
|
|
238
|
-
}
|
|
239
|
-
const numNoteHashes = this.previousKernel.end.noteHashes.filter((n)=>!n.contractAddress.isZero()).length;
|
|
240
|
-
const numToSilo = Math.max(0, numNoteHashes - this.numTransientData);
|
|
241
|
-
this.requestedDimensions.NOTE_HASH_SILOING_AMOUNT = numToSilo;
|
|
242
|
-
return numToSilo > 0;
|
|
243
|
-
}
|
|
244
|
-
needsSiloNullifiers() {
|
|
245
|
-
if (this.numTransientData === undefined) {
|
|
246
|
-
throw new Error('`needsResetTransientData` must be run before `needsSiloNullifiers`.');
|
|
247
|
-
}
|
|
248
|
-
const numNullifiers = this.previousKernel.end.nullifiers.filter((n)=>!n.contractAddress.isZero()).length;
|
|
249
|
-
const numToSilo = Math.max(0, numNullifiers - this.numTransientData);
|
|
250
|
-
// Include the first nullifier if there's something to silo.
|
|
251
|
-
// The reset circuit checks that capped_size must be greater than or equal to all non-empty nullifiers.
|
|
252
|
-
// Which includes the first nullifier, even though its contract address is always zero and doesn't need siloing.
|
|
253
|
-
const cappedSize = numToSilo ? numToSilo + 1 : 0;
|
|
254
|
-
this.requestedDimensions.NULLIFIER_SILOING_AMOUNT = cappedSize;
|
|
255
|
-
return numToSilo > 0;
|
|
256
|
-
}
|
|
257
|
-
needsSiloPrivateLogs() {
|
|
258
|
-
if (this.numTransientData === undefined) {
|
|
259
|
-
throw new Error('`needsResetTransientData` must be run before `needsSiloPrivateLogs`.');
|
|
260
|
-
}
|
|
261
|
-
const privateLogs = this.previousKernel.end.privateLogs;
|
|
262
|
-
const numLogs = privateLogs.filter((l)=>!l.contractAddress.isZero()).length;
|
|
263
|
-
const noteHashes = this.previousKernel.end.noteHashes;
|
|
264
|
-
const squashedNoteHashCounters = this.transientDataIndexHints.filter((h)=>h.noteHashIndex < noteHashes.length).map((h)=>noteHashes[h.noteHashIndex].counter);
|
|
265
|
-
const numSquashedLogs = privateLogs.filter((l)=>squashedNoteHashCounters.includes(l.inner.noteHashCounter)).length;
|
|
266
|
-
const numToSilo = numLogs - numSquashedLogs;
|
|
267
|
-
this.requestedDimensions.PRIVATE_LOG_SILOING_AMOUNT = numToSilo;
|
|
268
|
-
return numToSilo > 0;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/kernel_prover/hints/index.ts"],"names":[],"mappings":"AAAA,cAAc,gDAAgD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/kernel_prover/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
|
|
2
|
-
import { type PrivateKernelSimulateOutput, type PrivateKernelTailCircuitPublicInputs } from '@aztec/stdlib/kernel';
|
|
3
|
-
import { type PrivateExecutionResult, TxRequest } from '@aztec/stdlib/tx';
|
|
4
|
-
import type { ProvingDataOracle } from './proving_data_oracle.js';
|
|
5
|
-
export type ProvingConfig = {
|
|
6
|
-
simulate: boolean;
|
|
7
|
-
skipFeeEnforcement: boolean;
|
|
8
|
-
profile: boolean;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* The KernelProver class is responsible for generating kernel proofs.
|
|
12
|
-
* It takes a transaction request, its signature, and the simulation result as inputs, and outputs a proof
|
|
13
|
-
* along with output notes. The class interacts with a ProvingDataOracle to fetch membership witnesses and
|
|
14
|
-
* constructs private call data based on the execution results.
|
|
15
|
-
*/
|
|
16
|
-
export declare class KernelProver {
|
|
17
|
-
private oracle;
|
|
18
|
-
private proofCreator;
|
|
19
|
-
private fakeProofs;
|
|
20
|
-
private log;
|
|
21
|
-
constructor(oracle: ProvingDataOracle, proofCreator: PrivateKernelProver, fakeProofs?: boolean);
|
|
22
|
-
/**
|
|
23
|
-
* Generate a proof for a given transaction request and execution result.
|
|
24
|
-
* The function iterates through the nested executions in the execution result, creates private call data,
|
|
25
|
-
* and generates a proof using the provided ProofCreator instance. It also maintains an index of new notes
|
|
26
|
-
* created during the execution and returns them as a part of the KernelProverOutput.
|
|
27
|
-
*
|
|
28
|
-
* @param txRequest - The authenticated transaction request object.
|
|
29
|
-
* @param executionResult - The execution result object containing nested executions and preimages.
|
|
30
|
-
* @param profile - Set true to profile the gate count for each circuit
|
|
31
|
-
* @returns A Promise that resolves to a KernelProverOutput object containing proof, public inputs, and output notes.
|
|
32
|
-
* TODO(#7368) this should be refactored to not recreate the ACIR bytecode now that it operates on a program stack
|
|
33
|
-
*/
|
|
34
|
-
prove(txRequest: TxRequest, executionResult: PrivateExecutionResult, { simulate, skipFeeEnforcement, profile }?: ProvingConfig): Promise<PrivateKernelSimulateOutput<PrivateKernelTailCircuitPublicInputs>>;
|
|
35
|
-
private createPrivateCallData;
|
|
36
|
-
private isPrivateOnly;
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=kernel_prover.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"kernel_prover.d.ts","sourceRoot":"","sources":["../../src/kernel_prover/kernel_prover.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAML,KAAK,2BAA2B,EAEhC,KAAK,oCAAoC,EAE1C,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAEL,KAAK,sBAAsB,EAC3B,SAAS,EAMV,MAAM,kBAAkB,CAAC;AAM1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AASlE,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE,OAAO,CAAC;IAClB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF;;;;;GAKG;AACH,qBAAa,YAAY;IAIrB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,UAAU;IALpB,OAAO,CAAC,GAAG,CAAqC;gBAGtC,MAAM,EAAE,iBAAiB,EACzB,YAAY,EAAE,mBAAmB,EACjC,UAAU,UAAQ;IAG5B;;;;;;;;;;;OAWG;IACG,KAAK,CACT,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,sBAAsB,EACvC,EAAE,QAAQ,EAAE,kBAAkB,EAAE,OAAO,EAAE,GAAE,aAI1C,GACA,OAAO,CAAC,2BAA2B,CAAC,oCAAoC,CAAC,CAAC;YA4M/D,qBAAqB;IA4CnC,OAAO,CAAC,aAAa;CAYtB"}
|
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
import { CLIENT_IVC_VERIFICATION_KEY_LENGTH_IN_FIELDS, VK_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
-
import { vkAsFieldsMegaHonk } from '@aztec/foundation/crypto';
|
|
3
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
4
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
5
|
-
import { assertLength } from '@aztec/foundation/serialize';
|
|
6
|
-
import { pushTestData } from '@aztec/foundation/testing';
|
|
7
|
-
import { Timer } from '@aztec/foundation/timer';
|
|
8
|
-
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
9
|
-
import { getProtocolContractLeafAndMembershipWitness, protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
10
|
-
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
11
|
-
import { computeContractAddressFromInstance } from '@aztec/stdlib/contract';
|
|
12
|
-
import { hashVK } from '@aztec/stdlib/hash';
|
|
13
|
-
import { PrivateCallData, PrivateKernelCircuitPublicInputs, PrivateKernelData, PrivateKernelInitCircuitPrivateInputs, PrivateKernelInnerCircuitPrivateInputs, PrivateKernelTailCircuitPrivateInputs, PrivateVerificationKeyHints } from '@aztec/stdlib/kernel';
|
|
14
|
-
import { ClientIvcProof } from '@aztec/stdlib/proofs';
|
|
15
|
-
import { collectEnqueuedPublicFunctionCalls, collectNoteHashLeafIndexMap, collectNoteHashNullifierCounterMap, collectPublicTeardownFunctionCall, getFinalMinRevertibleSideEffectCounter } from '@aztec/stdlib/tx';
|
|
16
|
-
import { VerificationKeyAsFields } from '@aztec/stdlib/vks';
|
|
17
|
-
import { PrivateKernelResetPrivateInputsBuilder } from './hints/build_private_kernel_reset_private_inputs.js';
|
|
18
|
-
const NULL_PROVE_OUTPUT = {
|
|
19
|
-
publicInputs: PrivateKernelCircuitPublicInputs.empty(),
|
|
20
|
-
verificationKey: VerificationKeyAsFields.makeEmpty(CLIENT_IVC_VERIFICATION_KEY_LENGTH_IN_FIELDS),
|
|
21
|
-
outputWitness: new Map(),
|
|
22
|
-
bytecode: Buffer.from([])
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* The KernelProver class is responsible for generating kernel proofs.
|
|
26
|
-
* It takes a transaction request, its signature, and the simulation result as inputs, and outputs a proof
|
|
27
|
-
* along with output notes. The class interacts with a ProvingDataOracle to fetch membership witnesses and
|
|
28
|
-
* constructs private call data based on the execution results.
|
|
29
|
-
*/ export class KernelProver {
|
|
30
|
-
oracle;
|
|
31
|
-
proofCreator;
|
|
32
|
-
fakeProofs;
|
|
33
|
-
log;
|
|
34
|
-
constructor(oracle, proofCreator, fakeProofs = false){
|
|
35
|
-
this.oracle = oracle;
|
|
36
|
-
this.proofCreator = proofCreator;
|
|
37
|
-
this.fakeProofs = fakeProofs;
|
|
38
|
-
this.log = createLogger('pxe:kernel-prover');
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Generate a proof for a given transaction request and execution result.
|
|
42
|
-
* The function iterates through the nested executions in the execution result, creates private call data,
|
|
43
|
-
* and generates a proof using the provided ProofCreator instance. It also maintains an index of new notes
|
|
44
|
-
* created during the execution and returns them as a part of the KernelProverOutput.
|
|
45
|
-
*
|
|
46
|
-
* @param txRequest - The authenticated transaction request object.
|
|
47
|
-
* @param executionResult - The execution result object containing nested executions and preimages.
|
|
48
|
-
* @param profile - Set true to profile the gate count for each circuit
|
|
49
|
-
* @returns A Promise that resolves to a KernelProverOutput object containing proof, public inputs, and output notes.
|
|
50
|
-
* TODO(#7368) this should be refactored to not recreate the ACIR bytecode now that it operates on a program stack
|
|
51
|
-
*/ async prove(txRequest, executionResult, { simulate, skipFeeEnforcement, profile } = {
|
|
52
|
-
simulate: false,
|
|
53
|
-
skipFeeEnforcement: false,
|
|
54
|
-
profile: false
|
|
55
|
-
}) {
|
|
56
|
-
const skipProofGeneration = this.fakeProofs || simulate;
|
|
57
|
-
const generateWitnesses = !skipProofGeneration || profile;
|
|
58
|
-
const timer = new Timer();
|
|
59
|
-
const isPrivateOnlyTx = this.isPrivateOnly(executionResult);
|
|
60
|
-
const executionStack = [
|
|
61
|
-
executionResult.entrypoint
|
|
62
|
-
];
|
|
63
|
-
let firstIteration = true;
|
|
64
|
-
let output = NULL_PROVE_OUTPUT;
|
|
65
|
-
const gateCounts = [];
|
|
66
|
-
const addGateCount = async (circuitName, bytecode)=>{
|
|
67
|
-
const gateCount = await this.proofCreator.computeGateCountForCircuit(bytecode, circuitName);
|
|
68
|
-
gateCounts.push({
|
|
69
|
-
circuitName,
|
|
70
|
-
gateCount
|
|
71
|
-
});
|
|
72
|
-
this.log.debug(`Gate count for ${circuitName} - ${gateCount}`);
|
|
73
|
-
};
|
|
74
|
-
const noteHashLeafIndexMap = collectNoteHashLeafIndexMap(executionResult);
|
|
75
|
-
const noteHashNullifierCounterMap = collectNoteHashNullifierCounterMap(executionResult);
|
|
76
|
-
const enqueuedPublicFunctions = collectEnqueuedPublicFunctionCalls(executionResult);
|
|
77
|
-
const hasPublicCalls = enqueuedPublicFunctions.length > 0 || !collectPublicTeardownFunctionCall(executionResult).isEmpty();
|
|
78
|
-
const validationRequestsSplitCounter = hasPublicCalls ? getFinalMinRevertibleSideEffectCounter(executionResult) : 0;
|
|
79
|
-
// vector of gzipped bincode acirs
|
|
80
|
-
const acirs = [];
|
|
81
|
-
const witnessStack = [];
|
|
82
|
-
while(executionStack.length){
|
|
83
|
-
if (!firstIteration) {
|
|
84
|
-
let resetBuilder = new PrivateKernelResetPrivateInputsBuilder(output, executionStack, noteHashNullifierCounterMap, validationRequestsSplitCounter);
|
|
85
|
-
while(resetBuilder.needsReset()){
|
|
86
|
-
const privateInputs = await resetBuilder.build(this.oracle, noteHashLeafIndexMap);
|
|
87
|
-
output = generateWitnesses ? await this.proofCreator.generateResetOutput(privateInputs) : await this.proofCreator.simulateReset(privateInputs);
|
|
88
|
-
// TODO(#7368) consider refactoring this redundant bytecode pushing
|
|
89
|
-
acirs.push(output.bytecode);
|
|
90
|
-
witnessStack.push(output.outputWitness);
|
|
91
|
-
if (profile) {
|
|
92
|
-
await addGateCount('private_kernel_reset', output.bytecode);
|
|
93
|
-
}
|
|
94
|
-
resetBuilder = new PrivateKernelResetPrivateInputsBuilder(output, executionStack, noteHashNullifierCounterMap, validationRequestsSplitCounter);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
const currentExecution = executionStack.pop();
|
|
98
|
-
executionStack.push(...[
|
|
99
|
-
...currentExecution.nestedExecutions
|
|
100
|
-
].reverse());
|
|
101
|
-
const functionName = await this.oracle.getDebugFunctionName(currentExecution.publicInputs.callContext.contractAddress, currentExecution.publicInputs.callContext.functionSelector);
|
|
102
|
-
// TODO(#7368): This used to be associated with getDebugFunctionName
|
|
103
|
-
// TODO(#7368): Is there any way to use this with client IVC proving?
|
|
104
|
-
acirs.push(currentExecution.acir);
|
|
105
|
-
witnessStack.push(currentExecution.partialWitness);
|
|
106
|
-
if (profile) {
|
|
107
|
-
await addGateCount(functionName, currentExecution.acir);
|
|
108
|
-
}
|
|
109
|
-
const privateCallData = await this.createPrivateCallData(currentExecution);
|
|
110
|
-
if (firstIteration) {
|
|
111
|
-
const proofInput = new PrivateKernelInitCircuitPrivateInputs(txRequest, getVKTreeRoot(), protocolContractTreeRoot, privateCallData, isPrivateOnlyTx, executionResult.firstNullifier);
|
|
112
|
-
this.log.debug(`Calling private kernel init with isPrivateOnly ${isPrivateOnlyTx} and firstNullifierHint ${proofInput.firstNullifierHint}`);
|
|
113
|
-
pushTestData('private-kernel-inputs-init', proofInput);
|
|
114
|
-
output = generateWitnesses ? await this.proofCreator.generateInitOutput(proofInput) : await this.proofCreator.simulateInit(proofInput);
|
|
115
|
-
acirs.push(output.bytecode);
|
|
116
|
-
witnessStack.push(output.outputWitness);
|
|
117
|
-
if (profile) {
|
|
118
|
-
await addGateCount('private_kernel_init', output.bytecode);
|
|
119
|
-
}
|
|
120
|
-
} else {
|
|
121
|
-
const previousVkMembershipWitness = await this.oracle.getVkMembershipWitness(output.verificationKey);
|
|
122
|
-
const previousKernelData = new PrivateKernelData(output.publicInputs, output.verificationKey, Number(previousVkMembershipWitness.leafIndex), assertLength(previousVkMembershipWitness.siblingPath, VK_TREE_HEIGHT));
|
|
123
|
-
const proofInput = new PrivateKernelInnerCircuitPrivateInputs(previousKernelData, privateCallData);
|
|
124
|
-
pushTestData('private-kernel-inputs-inner', proofInput);
|
|
125
|
-
output = generateWitnesses ? await this.proofCreator.generateInnerOutput(proofInput) : await this.proofCreator.simulateInner(proofInput);
|
|
126
|
-
acirs.push(output.bytecode);
|
|
127
|
-
witnessStack.push(output.outputWitness);
|
|
128
|
-
if (profile) {
|
|
129
|
-
await addGateCount('private_kernel_inner', output.bytecode);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
firstIteration = false;
|
|
133
|
-
}
|
|
134
|
-
// Reset.
|
|
135
|
-
let resetBuilder = new PrivateKernelResetPrivateInputsBuilder(output, [], noteHashNullifierCounterMap, validationRequestsSplitCounter);
|
|
136
|
-
while(resetBuilder.needsReset()){
|
|
137
|
-
const privateInputs = await resetBuilder.build(this.oracle, noteHashLeafIndexMap);
|
|
138
|
-
output = generateWitnesses ? await this.proofCreator.generateResetOutput(privateInputs) : await this.proofCreator.simulateReset(privateInputs);
|
|
139
|
-
acirs.push(output.bytecode);
|
|
140
|
-
witnessStack.push(output.outputWitness);
|
|
141
|
-
if (profile) {
|
|
142
|
-
await addGateCount('private_kernel_reset', output.bytecode);
|
|
143
|
-
}
|
|
144
|
-
resetBuilder = new PrivateKernelResetPrivateInputsBuilder(output, [], noteHashNullifierCounterMap, validationRequestsSplitCounter);
|
|
145
|
-
}
|
|
146
|
-
if (output.publicInputs.feePayer.isZero() && skipFeeEnforcement) {
|
|
147
|
-
if (!skipProofGeneration) {
|
|
148
|
-
throw new Error('Fee payment must be enforced when creating real proof.');
|
|
149
|
-
}
|
|
150
|
-
output.publicInputs.feePayer = new AztecAddress(Fr.MAX_FIELD_VALUE);
|
|
151
|
-
}
|
|
152
|
-
// Private tail.
|
|
153
|
-
const previousVkMembershipWitness = await this.oracle.getVkMembershipWitness(output.verificationKey);
|
|
154
|
-
const previousKernelData = new PrivateKernelData(output.publicInputs, output.verificationKey, Number(previousVkMembershipWitness.leafIndex), assertLength(previousVkMembershipWitness.siblingPath, VK_TREE_HEIGHT));
|
|
155
|
-
this.log.debug(`Calling private kernel tail with hwm ${previousKernelData.publicInputs.minRevertibleSideEffectCounter}`);
|
|
156
|
-
const privateInputs = new PrivateKernelTailCircuitPrivateInputs(previousKernelData);
|
|
157
|
-
pushTestData('private-kernel-inputs-ordering', privateInputs);
|
|
158
|
-
const tailOutput = generateWitnesses ? await this.proofCreator.generateTailOutput(privateInputs) : await this.proofCreator.simulateTail(privateInputs);
|
|
159
|
-
acirs.push(tailOutput.bytecode);
|
|
160
|
-
witnessStack.push(tailOutput.outputWitness);
|
|
161
|
-
if (profile) {
|
|
162
|
-
await addGateCount('private_kernel_tail', tailOutput.bytecode);
|
|
163
|
-
tailOutput.profileResult = {
|
|
164
|
-
gateCounts
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
if (generateWitnesses) {
|
|
168
|
-
this.log.info(`Private kernel witness generation took ${timer.ms()}ms`);
|
|
169
|
-
}
|
|
170
|
-
// TODO(#7368) how do we 'bincode' encode these inputs?
|
|
171
|
-
if (!skipProofGeneration) {
|
|
172
|
-
const ivcProof = await this.proofCreator.createClientIvcProof(acirs, witnessStack);
|
|
173
|
-
tailOutput.clientIvcProof = ivcProof;
|
|
174
|
-
} else {
|
|
175
|
-
tailOutput.clientIvcProof = ClientIvcProof.random();
|
|
176
|
-
}
|
|
177
|
-
return tailOutput;
|
|
178
|
-
}
|
|
179
|
-
async createPrivateCallData({ publicInputs, vk: vkAsBuffer }) {
|
|
180
|
-
const { contractAddress, functionSelector } = publicInputs.callContext;
|
|
181
|
-
const vkAsFields = await vkAsFieldsMegaHonk(vkAsBuffer);
|
|
182
|
-
const vk = new VerificationKeyAsFields(vkAsFields, await hashVK(vkAsFields));
|
|
183
|
-
const { currentContractClassId, publicKeys, saltedInitializationHash } = await this.oracle.getContractAddressPreimage(contractAddress);
|
|
184
|
-
const functionLeafMembershipWitness = await this.oracle.getFunctionMembershipWitness(currentContractClassId, functionSelector);
|
|
185
|
-
const { artifactHash: contractClassArtifactHash, publicBytecodeCommitment: contractClassPublicBytecodeCommitment } = await this.oracle.getContractClassIdPreimage(currentContractClassId);
|
|
186
|
-
// This will be the address computed in the kernel by the executed class. We need to provide non membership of it in the protocol contract tree.
|
|
187
|
-
// This would only be equal to contractAddress if the currentClassId is equal to the original class id (no update happened).
|
|
188
|
-
const computedAddress = await computeContractAddressFromInstance({
|
|
189
|
-
originalContractClassId: currentContractClassId,
|
|
190
|
-
saltedInitializationHash,
|
|
191
|
-
publicKeys
|
|
192
|
-
});
|
|
193
|
-
const { lowLeaf: protocolContractLeaf, witness: protocolContractMembershipWitness } = await getProtocolContractLeafAndMembershipWitness(contractAddress, computedAddress);
|
|
194
|
-
const updatedClassIdHints = await this.oracle.getUpdatedClassIdHints(contractAddress);
|
|
195
|
-
return PrivateCallData.from({
|
|
196
|
-
publicInputs,
|
|
197
|
-
vk,
|
|
198
|
-
verificationKeyHints: PrivateVerificationKeyHints.from({
|
|
199
|
-
publicKeys,
|
|
200
|
-
contractClassArtifactHash,
|
|
201
|
-
contractClassPublicBytecodeCommitment,
|
|
202
|
-
saltedInitializationHash,
|
|
203
|
-
functionLeafMembershipWitness,
|
|
204
|
-
protocolContractMembershipWitness,
|
|
205
|
-
protocolContractLeaf,
|
|
206
|
-
updatedClassIdHints
|
|
207
|
-
})
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
isPrivateOnly(executionResult) {
|
|
211
|
-
const isPrivateOnlyRecursive = (callResult)=>{
|
|
212
|
-
const makesPublicCalls = callResult.enqueuedPublicFunctionCalls.some((enqueuedCall)=>!enqueuedCall.isEmpty()) || !callResult.publicTeardownFunctionCall.isEmpty();
|
|
213
|
-
return !makesPublicCalls && callResult.nestedExecutions.every((nestedExecution)=>isPrivateOnlyRecursive(nestedExecution));
|
|
214
|
-
};
|
|
215
|
-
return isPrivateOnlyRecursive(executionResult.entrypoint);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"proving_data_oracle.d.ts","sourceRoot":"","sources":["../../src/kernel_prover/proving_data_oracle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACpG,OAAO,KAAK,EAAE,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAEjE;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,8FAA8F;IAC9F,0BAA0B,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC;QACzD,wBAAwB,EAAE,EAAE,CAAC;QAC7B,UAAU,EAAE,UAAU,CAAC;QACvB,sBAAsB,EAAE,EAAE,CAAC;QAC3B,uBAAuB,EAAE,EAAE,CAAC;KAC7B,CAAC,CAAC;IAEH,kFAAkF;IAClF,0BAA0B,CACxB,eAAe,EAAE,EAAE,GAClB,OAAO,CAAC;QAAE,YAAY,EAAE,EAAE,CAAC;QAAC,wBAAwB,EAAE,EAAE,CAAC;QAAC,oBAAoB,EAAE,EAAE,CAAA;KAAE,CAAC,CAAC;IAEzF;;;;;;;;OAQG;IACH,4BAA4B,CAC1B,eAAe,EAAE,EAAE,EACnB,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,iBAAiB,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC;IAE3D;;;;;;;;OAQG;IACH,sBAAsB,CAAC,EAAE,EAAE,uBAAuB,GAAG,OAAO,CAAC,iBAAiB,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC;IAEvG;;;;;OAKG;IACH,4BAA4B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,OAAO,qBAAqB,CAAC,CAAC,CAAC;IAE1G,6BAA6B,CAAC,SAAS,EAAE,EAAE,GAAG,OAAO,CAAC,0BAA0B,GAAG,SAAS,CAAC,CAAC;IAE9F;;;;OAIG;IACH,mBAAmB,IAAI,OAAO,CAAC,EAAE,CAAC,CAAC;IAEnC;;;;;;OAMG;IACH,kBAAkB,CAAC,eAAe,EAAE,KAAK,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAEpE,oBAAoB,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAE7G,sBAAsB,CAAC,eAAe,EAAE,YAAY,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACrF"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { L1NotePayload } from '@aztec/stdlib/logs';
|
|
2
|
-
import { Note } from '@aztec/stdlib/note';
|
|
3
|
-
import type { ContractDataProvider } from '../storage/contract_data_provider/contract_data_provider.js';
|
|
4
|
-
/**
|
|
5
|
-
* Merges privately and publicly delivered note values.
|
|
6
|
-
* @param db - PXE database used to fetch contract instance and artifact.
|
|
7
|
-
* @param payload - Payload corresponding to the note.
|
|
8
|
-
* @returns Note payload with public fields added.
|
|
9
|
-
*/
|
|
10
|
-
export declare function getOrderedNoteItems(contractDataProvider: ContractDataProvider, { contractAddress, noteTypeId, privateNoteValues, publicNoteValues }: L1NotePayload): Promise<Note>;
|
|
11
|
-
//# sourceMappingURL=add_public_values_to_payload.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"add_public_values_to_payload.d.ts","sourceRoot":"","sources":["../../src/note_decryption_utils/add_public_values_to_payload.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6DAA6D,CAAC;AAExG;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,oBAAoB,EAAE,oBAAoB,EAC1C,EAAE,eAAe,EAAE,UAAU,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,EAAE,aAAa,GAClF,OAAO,CAAC,IAAI,CAAC,CAgDf"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { ContractNotFoundError } from '@aztec/simulator/client';
|
|
2
|
-
import { Note } from '@aztec/stdlib/note';
|
|
3
|
-
/**
|
|
4
|
-
* Merges privately and publicly delivered note values.
|
|
5
|
-
* @param db - PXE database used to fetch contract instance and artifact.
|
|
6
|
-
* @param payload - Payload corresponding to the note.
|
|
7
|
-
* @returns Note payload with public fields added.
|
|
8
|
-
*/ export async function getOrderedNoteItems(contractDataProvider, { contractAddress, noteTypeId, privateNoteValues, publicNoteValues }) {
|
|
9
|
-
if (publicNoteValues.length === 0) {
|
|
10
|
-
return new Note(privateNoteValues);
|
|
11
|
-
}
|
|
12
|
-
const instance = await contractDataProvider.getContractInstance(contractAddress);
|
|
13
|
-
if (!instance) {
|
|
14
|
-
throw new ContractNotFoundError(`Could not find instance for ${contractAddress.toString()}. This should never happen here as the partial notes flow should be triggered only for non-deferred notes.`);
|
|
15
|
-
}
|
|
16
|
-
const artifact = await contractDataProvider.getContractArtifact(instance.currentContractClassId);
|
|
17
|
-
if (!artifact) {
|
|
18
|
-
throw new Error(`Could not find artifact for contract class ${instance.currentContractClassId.toString()}. This should never happen here as the partial notes flow should be triggered only for non-deferred notes.`);
|
|
19
|
-
}
|
|
20
|
-
const noteFields = Object.values(artifact.notes).find((note)=>note.id.equals(noteTypeId))?.fields;
|
|
21
|
-
if (!noteFields) {
|
|
22
|
-
throw new Error(`Could not find note fields for note type ${noteTypeId.toString()}.`);
|
|
23
|
-
}
|
|
24
|
-
// We sort note fields by index so that we can iterate over them in order.
|
|
25
|
-
noteFields.sort((a, b)=>a.index - b.index);
|
|
26
|
-
// Now we insert the public fields into the note based on its indices defined in the ABI.
|
|
27
|
-
const modifiedNoteItems = [
|
|
28
|
-
...privateNoteValues
|
|
29
|
-
];
|
|
30
|
-
let indexInPublicValues = 0;
|
|
31
|
-
for(let i = 0; i < noteFields.length; i++){
|
|
32
|
-
const noteField = noteFields[i];
|
|
33
|
-
if (noteField.nullable) {
|
|
34
|
-
if (i == noteFields.length - 1) {
|
|
35
|
-
// We are processing the last field so we simply insert the rest of the public fields at the end
|
|
36
|
-
modifiedNoteItems.push(...publicNoteValues.slice(indexInPublicValues));
|
|
37
|
-
} else {
|
|
38
|
-
const noteFieldLength = noteFields[i + 1].index - noteField.index;
|
|
39
|
-
const publicValuesToInsert = publicNoteValues.slice(indexInPublicValues, indexInPublicValues + noteFieldLength);
|
|
40
|
-
indexInPublicValues += noteFieldLength;
|
|
41
|
-
// Now we insert the public fields at the note field index
|
|
42
|
-
modifiedNoteItems.splice(noteField.index, 0, ...publicValuesToInsert);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return new Note(modifiedNoteItems);
|
|
47
|
-
}
|
package/dest/pxe_http/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pxe_http/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
|
package/dest/pxe_http/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './pxe_http_server.js';
|