From 7bb2a382e83bf422f90b3b144ae5c1d4e7adf227 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Venturo?= Date: Wed, 25 Sep 2024 04:27:49 -0300 Subject: [PATCH] chore: make structs pub (#8760) This makes all structs `pub` to remove the warnings associated with them being private and therefore not available. Some structs we may wish to keep private, or to only make them available inside the crate, but I find that the vast majority should simply be public, and that's the current behavior anyway since any module can import anything. We can later make the exports more strict if desired. --- .../aztec-nr/address-note/src/address_note.nr | 2 +- noir-projects/aztec-nr/authwit/src/account.nr | 2 +- .../aztec-nr/authwit/src/entrypoint/app.nr | 2 +- .../aztec-nr/authwit/src/entrypoint/fee.nr | 2 +- .../authwit/src/entrypoint/function_call.nr | 2 +- .../aztec/src/context/call_interfaces.nr | 18 +- .../aztec-nr/aztec/src/context/gas.nr | 2 +- .../context/inputs/private_context_inputs.nr | 2 +- .../context/inputs/public_context_inputs.nr | 2 +- .../aztec/src/context/packed_returns.nr | 2 +- .../aztec/src/context/public_context.nr | 4 +- .../src/context/unconstrained_context.nr | 2 +- .../aztec/src/encrypted_logs/header.nr | 2 +- .../aztec/src/encrypted_logs/incoming_body.nr | 4 +- .../aztec/src/encrypted_logs/outgoing_body.nr | 2 +- noir-projects/aztec-nr/aztec/src/hash.nr | 2 +- .../aztec-nr/aztec/src/keys/public_keys.nr | 12 +- .../aztec/src/macros/functions/interfaces.nr | 2 +- .../aztec-nr/aztec/src/note/note_emission.nr | 6 +- .../aztec/src/note/note_getter_options.nr | 13 +- .../aztec/src/note/note_viewer_options.nr | 2 +- .../src/oracle/get_membership_witness.nr | 2 +- .../get_nullifier_membership_witness.nr | 2 +- .../src/oracle/get_public_data_witness.nr | 2 +- .../aztec-nr/aztec/src/oracle/logs_traits.nr | 6 +- .../aztec-nr/aztec/src/state_vars/map.nr | 3 +- .../aztec/src/state_vars/private_immutable.nr | 2 +- .../aztec/src/state_vars/private_mutable.nr | 2 +- .../aztec/src/state_vars/private_set.nr | 2 +- .../aztec/src/state_vars/public_immutable.nr | 2 +- .../aztec/src/state_vars/public_mutable.nr | 2 +- .../aztec/src/state_vars/shared_immutable.nr | 2 +- .../shared_mutable/scheduled_delay_change.nr | 2 +- .../shared_mutable/scheduled_value_change.nr | 2 +- .../shared_mutable/shared_mutable.nr | 2 +- .../shared_mutable_private_getter.nr | 2 +- .../src/test/helpers/test_environment.nr | 4 +- .../aztec-nr/aztec/src/test/helpers/utils.nr | 4 +- .../aztec/src/test/mocks/mock_note.nr | 4 +- .../aztec/src/test/mocks/mock_struct.nr | 2 +- .../src/compressed_string.nr | 2 +- .../src/field_compressed_string.nr | 2 +- .../src/easy_private_uint.nr | 2 +- .../aztec-nr/uint-note/src/uint_note.nr | 2 +- .../src/dapp_payload.nr | 2 +- .../src/subscription_note.nr | 2 +- .../contracts/avm_test_contract/src/main.nr | 2 +- .../contracts/card_game_contract/src/cards.nr | 6 +- .../contracts/card_game_contract/src/game.nr | 4 +- .../src/events/class_registered.nr | 2 +- .../events/private_function_broadcasted.nr | 6 +- .../unconstrained_function_broadcasted.nr | 6 +- .../src/types/card_note.nr | 2 +- .../docs_example_contract/src/types/leader.nr | 3 +- .../ecdsa_public_key_note/src/lib.nr | 2 +- .../import_test_contract/src/main.nr | 1 - .../contracts/lending_contract/src/asset.nr | 2 +- .../contracts/lending_contract/src/helpers.nr | 2 +- .../lending_contract/src/position.nr | 2 +- .../nft_contract/src/types/nft_note.nr | 2 +- .../price_feed_contract/src/asset.nr | 2 +- .../private_fpc_contract/src/settings.nr | 2 +- .../src/public_key_note.nr | 2 +- .../src/auth_oracle.nr | 2 +- .../spam_contract/src/types/balance_set.nr | 2 +- .../spam_contract/src/types/token_note.nr | 2 +- .../contracts/test_contract/src/main.nr | 4 +- .../contracts/test_contract/src/test_note.nr | 8 +- .../src/types/balances_map.nr | 2 +- .../src/types/roles.nr | 2 +- .../src/types/token_note.nr | 2 +- .../src/types/transparent_note.nr | 2 +- .../bug-collecting-crate/devex-turbo-fish.nr | 6 +- .../type-alias-shorthand.nr | 6 +- .../typechain-type-alias.nr | 6 +- .../parity-lib/src/base/base_parity_inputs.nr | 2 +- .../parity-lib/src/parity_public_inputs.nr | 6 +- .../parity-lib/src/root/root_parity_input.nr | 2 +- .../parity-lib/src/root/root_parity_inputs.nr | 2 +- .../src/root/root_rollup_parity_input.nr | 2 +- .../src/utils/sha256_merkle_tree.nr | 2 +- .../components/previous_kernel_validator.nr | 2 +- .../previous_kernel_validator_hints.nr | 2 +- .../components/private_call_data_validator.nr | 2 +- ...private_kernel_circuit_output_validator.nr | 2 +- ...e_kernel_circuit_public_inputs_composer.nr | 4 +- .../src/components/reset_output_composer.nr | 2 +- .../reset_output_hints.nr | 2 +- .../src/components/reset_output_validator.nr | 2 +- .../src/components/tail_output_composer.nr | 2 +- .../src/components/tail_output_validator.nr | 2 +- .../tail_output_hints.nr | 2 +- .../tail_to_public_output_composer.nr | 2 +- .../tail_to_public_output_validator.nr | 2 +- .../tail_to_public_output_hints.nr | 2 +- .../src/private_kernel_empty.nr | 4 +- .../src/private_kernel_init.nr | 2 +- .../src/private_kernel_inner.nr | 2 +- .../src/private_kernel_reset.nr | 4 +- .../src/private_kernel_tail.nr | 2 +- .../src/private_kernel_tail_to_public.nr | 2 +- .../previous_kernel_validator_builder/mod.nr | 4 +- .../mod.nr | 2 +- .../mod.nr | 2 +- .../mod.nr | 2 +- .../reset_output_validator_builder/mod.nr | 2 +- .../tests/tail_output_composer_builder/mod.nr | 4 +- .../tail_output_validator_builder/mod.nr | 2 +- .../mod.nr | 2 +- ...tail_to_public_output_validator_builder.nr | 4 +- .../enqueued_call_data_validator.nr | 2 +- .../components/previous_kernel_validator.nr | 2 +- .../components/public_call_data_validator.nr | 2 +- .../public_kernel_output_composer.nr | 2 +- .../public_kernel_output_validator.nr | 2 +- .../components/public_tail_output_composer.nr | 2 +- .../generate_output_hints.nr | 4 +- ...generate_overridable_public_data_writes.nr | 2 +- .../generate_public_data_leaves.nr | 2 +- .../public_tail_output_validator.nr | 2 +- .../components/vm_circuit_output_composer.nr | 2 +- .../src/public_kernel_app_logic.nr | 523 ++++++++++++++++++ .../src/public_kernel_inner.nr | 2 +- .../src/public_kernel_merge.nr | 2 +- .../src/public_kernel_setup.nr | 512 +++++++++++++++++ .../src/public_kernel_tail.nr | 2 +- .../src/public_kernel_teardown.nr | 434 +++++++++++++++ .../src/note_hash_read_request_reset.nr | 5 +- ...llifier_non_existent_read_request_reset.nr | 4 +- .../src/nullifier_read_request_reset.nr | 5 +- .../private_validation_request_processor.nr | 2 +- .../src/public_data_read_request_hints.nr | 2 +- .../public_validation_request_processor.nr | 2 +- .../src/reset/key_validation_hint.nr | 2 +- .../src/reset/mutable_data_read_request.nr | 2 +- .../src/reset/read_request.nr | 7 +- .../src/reset/transient_data.nr | 2 +- .../src/reset/tree_leaf_read_request.nr | 3 +- .../note_hash_read_request_hints_builder.nr | 2 +- ...non_existent_read_request_hints_builder.nr | 2 +- .../nullifier_read_request_hints_builder.nr | 2 +- .../base_or_merge_rollup_public_inputs.nr | 2 +- ...block_root_or_block_merge_public_inputs.nr | 4 +- .../src/abis/constant_rollup_data.nr | 2 +- .../src/abis/previous_rollup_block_data.nr | 2 +- .../src/abis/previous_rollup_data.nr | 2 +- .../rollup-lib/src/base/base_rollup_inputs.nr | 2 +- .../rollup-lib/src/base/state_diff_hints.nr | 2 +- .../block_merge/block_merge_rollup_inputs.nr | 2 +- .../block_root/block_root_rollup_inputs.nr | 2 +- .../src/merge/merge_rollup_inputs.nr | 2 +- .../rollup-lib/src/root/root_rollup_inputs.nr | 2 +- .../src/root/root_rollup_public_inputs.nr | 2 +- .../combined_accumulated_data.nr | 4 +- .../private_accumulated_data.nr | 2 +- .../private_accumulated_data_builder.nr | 2 +- .../public_accumulated_data.nr | 4 +- .../public_accumulated_data_builder.nr | 2 +- .../src/abis/append_only_tree_snapshot.nr | 2 +- .../crates/types/src/abis/call_context.nr | 2 +- .../types/src/abis/combined_constant_data.nr | 2 +- .../contract_class_function_leaf_preimage.nr | 2 +- .../types/src/abis/enqueued_call_data.nr | 4 +- .../crates/types/src/abis/function_data.nr | 2 +- .../types/src/abis/function_selector.nr | 2 +- .../crates/types/src/abis/gas.nr | 3 +- .../crates/types/src/abis/gas_fees.nr | 2 +- .../crates/types/src/abis/gas_settings.nr | 2 +- .../crates/types/src/abis/global_variables.nr | 2 +- .../kernel_circuit_public_inputs.nr | 2 +- .../private_kernel_circuit_public_inputs.nr | 4 +- ...te_kernel_circuit_public_inputs_builder.nr | 2 +- .../public_kernel_circuit_public_inputs.nr | 2 +- ...ic_kernel_circuit_public_inputs_builder.nr | 2 +- .../vm_circuit_public_inputs.nr | 2 +- .../crates/types/src/abis/kernel_data.nr | 2 +- .../crates/types/src/abis/log_hash.nr | 10 +- .../crates/types/src/abis/max_block_number.nr | 2 +- .../crates/types/src/abis/note_hash.nr | 4 +- .../types/src/abis/note_hash_leaf_preimage.nr | 2 +- .../crates/types/src/abis/nullifier.nr | 4 +- .../types/src/abis/nullifier_leaf_preimage.nr | 2 +- .../types/src/abis/private_call_request.nr | 2 +- .../types/src/abis/private_call_stack_item.nr | 2 +- .../src/abis/private_circuit_public_inputs.nr | 2 +- .../abis/private_kernel/private_call_data.nr | 2 +- .../types/src/abis/private_kernel_data.nr | 2 +- .../crates/types/src/abis/public_call_data.nr | 4 +- .../types/src/abis/public_call_request.nr | 2 +- .../types/src/abis/public_call_stack_item.nr | 2 +- .../abis/public_call_stack_item_compressed.nr | 10 +- .../src/abis/public_circuit_public_inputs.nr | 2 +- .../crates/types/src/abis/public_data_read.nr | 2 +- .../src/abis/public_data_update_request.nr | 2 +- .../types/src/abis/public_data_write.nr | 2 +- .../src/abis/public_inner_call_request.nr | 2 +- .../types/src/abis/public_kernel_data.nr | 3 +- .../src/abis/public_kernel_inner_data.nr | 2 +- .../crates/types/src/abis/read_request.nr | 4 +- .../crates/types/src/abis/side_effect.nr | 14 +- .../types/src/abis/tree_leaf_read_request.nr | 2 +- .../key_validation_request.nr | 3 +- .../key_validation_request_and_generator.nr | 2 +- .../private_validation_requests.nr | 2 +- .../private_validation_requests_builder.nr | 2 +- .../public_validation_requests.nr | 4 +- .../public_validation_requests_builder.nr | 2 +- .../rollup_validation_requests.nr | 5 +- ...ed_key_validation_request_and_generator.nr | 2 +- .../crates/types/src/address/eth_address.nr | 2 +- .../types/src/address/partial_address.nr | 2 +- .../types/src/address/public_keys_hash.nr | 2 +- .../src/address/salted_initialization_hash.nr | 2 +- .../crates/types/src/content_commitment.nr | 2 +- .../crates/types/src/contract_class_id.nr | 2 +- .../crates/types/src/contract_instance.nr | 2 +- .../crates/types/src/contrakt/storage_read.nr | 2 +- .../src/contrakt/storage_update_request.nr | 2 +- .../crates/types/src/data/public_data_hint.nr | 2 +- .../types/src/data/public_data_leaf_hint.nr | 2 +- .../types/src/data/public_data_tree_leaf.nr | 5 +- .../data/public_data_tree_leaf_preimage.nr | 2 +- .../crates/types/src/header.nr | 2 +- .../types/src/merkle_tree/leaf_preimage.nr | 4 +- .../types/src/merkle_tree/membership.nr | 2 +- .../types/src/merkle_tree/merkle_tree.nr | 3 +- .../src/merkle_tree/variable_merkle_tree.nr | 3 +- .../types/src/messaging/l2_to_l1_message.nr | 4 +- .../crates/types/src/meta/mod.nr | 6 +- .../types/src/partial_state_reference.nr | 2 +- .../crates/types/src/recursion/proof.nr | 4 +- .../crates/types/src/recursion/traits.nr | 2 +- .../types/src/recursion/verification_key.nr | 2 +- .../crates/types/src/state_reference.nr | 2 +- .../crates/types/src/tests/fixture_builder.nr | 2 +- .../src/tests/fixtures/contract_functions.nr | 3 +- .../types/src/tests/fixtures/contracts.nr | 2 +- .../types/src/tests/merkle_tree_utils.nr | 2 +- .../crates/types/src/tests/types.nr | 6 +- .../crates/types/src/traits.nr | 2 +- .../types/src/transaction/tx_context.nr | 2 +- .../types/src/transaction/tx_request.nr | 2 +- .../get_combined_order_hints.nr | 3 +- .../get_order_hints.nr | 3 +- .../get_split_order_hints.nr | 3 +- .../src/utils/arrays/get_sorted_result.nr | 2 +- .../src/utils/arrays/get_sorted_tuple.nr | 2 +- .../crates/types/src/utils/reader.nr | 2 +- .../crates/types/src/utils/uint256.nr | 18 +- 249 files changed, 1814 insertions(+), 362 deletions(-) create mode 100644 noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_app_logic.nr create mode 100644 noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_setup.nr create mode 100644 noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_teardown.nr diff --git a/noir-projects/aztec-nr/address-note/src/address_note.nr b/noir-projects/aztec-nr/address-note/src/address_note.nr index e8724d50e14..310c94b3f51 100644 --- a/noir-projects/aztec-nr/address-note/src/address_note.nr +++ b/noir-projects/aztec-nr/address-note/src/address_note.nr @@ -9,7 +9,7 @@ use dep::aztec::{ // docs:start:address_note_struct // Stores an address #[note] -struct AddressNote { +pub struct AddressNote { address: AztecAddress, // The nullifying public key hash is used with the nsk_app to ensure that the note can be privately spent. npk_m_hash: Field, diff --git a/noir-projects/aztec-nr/authwit/src/account.nr b/noir-projects/aztec-nr/authwit/src/account.nr index c4cc7976167..e0adbb797e7 100644 --- a/noir-projects/aztec-nr/authwit/src/account.nr +++ b/noir-projects/aztec-nr/authwit/src/account.nr @@ -7,7 +7,7 @@ use dep::aztec::{ use crate::entrypoint::{app::AppPayload, fee::FeePayload}; use crate::auth::{IS_VALID_SELECTOR, compute_authwit_message_hash}; -struct AccountActions { +pub struct AccountActions { context: Context, is_valid_impl: fn(&mut PrivateContext, Field) -> bool, } diff --git a/noir-projects/aztec-nr/authwit/src/entrypoint/app.nr b/noir-projects/aztec-nr/authwit/src/entrypoint/app.nr index b74d6637f9b..1bab254dcae 100644 --- a/noir-projects/aztec-nr/authwit/src/entrypoint/app.nr +++ b/noir-projects/aztec-nr/authwit/src/entrypoint/app.nr @@ -15,7 +15,7 @@ global ACCOUNT_MAX_CALLS: u32 = 4; // Note: If you change the following struct you have to update default_entrypoint.ts // docs:start:app-payload-struct -struct AppPayload { +pub struct AppPayload { function_calls: [FunctionCall; ACCOUNT_MAX_CALLS], nonce: Field, } diff --git a/noir-projects/aztec-nr/authwit/src/entrypoint/fee.nr b/noir-projects/aztec-nr/authwit/src/entrypoint/fee.nr index 6465584f56b..75de54e7427 100644 --- a/noir-projects/aztec-nr/authwit/src/entrypoint/fee.nr +++ b/noir-projects/aztec-nr/authwit/src/entrypoint/fee.nr @@ -14,7 +14,7 @@ global FEE_PAYLOAD_SIZE_IN_BYTES: u32 = 228; global MAX_FEE_FUNCTION_CALLS: u32 = 2; // docs:start:fee-payload-struct -struct FeePayload { +pub struct FeePayload { function_calls: [FunctionCall; MAX_FEE_FUNCTION_CALLS], nonce: Field, is_fee_payer: bool, diff --git a/noir-projects/aztec-nr/authwit/src/entrypoint/function_call.nr b/noir-projects/aztec-nr/authwit/src/entrypoint/function_call.nr index 4ff0dd2c8f2..38e943f95f4 100644 --- a/noir-projects/aztec-nr/authwit/src/entrypoint/function_call.nr +++ b/noir-projects/aztec-nr/authwit/src/entrypoint/function_call.nr @@ -5,7 +5,7 @@ global FUNCTION_CALL_SIZE: u32 = 5; // 3 * 32 + 2 global FUNCTION_CALL_SIZE_IN_BYTES: u32 = 98; -struct FunctionCall { +pub struct FunctionCall { args_hash: Field, function_selector: FunctionSelector, target_address: AztecAddress, diff --git a/noir-projects/aztec-nr/aztec/src/context/call_interfaces.nr b/noir-projects/aztec-nr/aztec/src/context/call_interfaces.nr index 0c818e3ac7b..27cabd91cff 100644 --- a/noir-projects/aztec-nr/aztec/src/context/call_interfaces.nr +++ b/noir-projects/aztec-nr/aztec/src/context/call_interfaces.nr @@ -11,7 +11,7 @@ use crate::context::{ use crate::oracle::arguments::pack_arguments; use crate::hash::hash_args; -trait CallInterface { +pub trait CallInterface { fn get_original(self) -> fn[Env](T) -> P; fn get_args(self) -> [Field] { @@ -41,7 +41,7 @@ impl CallInterface { +pub struct PrivateCallInterface { target_contract: AztecAddress, selector: FunctionSelector, name: str, @@ -84,7 +84,7 @@ impl CallInterface { +pub struct PrivateVoidCallInterface { target_contract: AztecAddress, selector: FunctionSelector, name: str, @@ -123,7 +123,7 @@ impl CallInterface { +pub struct PrivateStaticCallInterface { target_contract: AztecAddress, selector: FunctionSelector, name: str, @@ -147,7 +147,7 @@ impl CallInterface { +pub struct PrivateStaticVoidCallInterface { target_contract: AztecAddress, selector: FunctionSelector, name: str, @@ -170,7 +170,7 @@ impl CallInterface for Pu } } -struct PublicCallInterface { +pub struct PublicCallInterface { target_contract: AztecAddress, selector: FunctionSelector, name: str, @@ -244,7 +244,7 @@ impl CallInterface for P } } -struct PublicVoidCallInterface { +pub struct PublicVoidCallInterface { target_contract: AztecAddress, selector: FunctionSelector, name: str, @@ -318,7 +318,7 @@ impl CallInterface for Pu } } -struct PublicStaticCallInterface { +pub struct PublicStaticCallInterface { target_contract: AztecAddress, selector: FunctionSelector, name: str, @@ -359,7 +359,7 @@ impl CallInterface for P } } -struct PublicStaticVoidCallInterface { +pub struct PublicStaticVoidCallInterface { target_contract: AztecAddress, selector: FunctionSelector, name: str, diff --git a/noir-projects/aztec-nr/aztec/src/context/gas.nr b/noir-projects/aztec-nr/aztec/src/context/gas.nr index 835a78664eb..5742cbd9549 100644 --- a/noir-projects/aztec-nr/aztec/src/context/gas.nr +++ b/noir-projects/aztec-nr/aztec/src/context/gas.nr @@ -1,4 +1,4 @@ -struct GasOpts { +pub struct GasOpts { l2_gas: Option, da_gas: Option, } diff --git a/noir-projects/aztec-nr/aztec/src/context/inputs/private_context_inputs.nr b/noir-projects/aztec-nr/aztec/src/context/inputs/private_context_inputs.nr index a1398c50c9f..274112b1194 100644 --- a/noir-projects/aztec-nr/aztec/src/context/inputs/private_context_inputs.nr +++ b/noir-projects/aztec-nr/aztec/src/context/inputs/private_context_inputs.nr @@ -2,7 +2,7 @@ use dep::protocol_types::{transaction::tx_context::TxContext, abis::{call_contex // PrivateContextInputs are expected to be provided to each private function // docs:start:private-context-inputs -struct PrivateContextInputs { +pub struct PrivateContextInputs { call_context : CallContext, historical_header: Header, tx_context: TxContext, diff --git a/noir-projects/aztec-nr/aztec/src/context/inputs/public_context_inputs.nr b/noir-projects/aztec-nr/aztec/src/context/inputs/public_context_inputs.nr index 80b3456918b..811bebfbd51 100644 --- a/noir-projects/aztec-nr/aztec/src/context/inputs/public_context_inputs.nr +++ b/noir-projects/aztec-nr/aztec/src/context/inputs/public_context_inputs.nr @@ -1,7 +1,7 @@ use dep::protocol_types::traits::Empty; // These inputs will likely go away once the AVM processes 1 public kernel per enqueued call. -struct PublicContextInputs { +pub struct PublicContextInputs { // TODO: Remove this structure and get calldata size at compile time. calldata_length: Field, // This is currently unused but it's here to avoid changing serialization. diff --git a/noir-projects/aztec-nr/aztec/src/context/packed_returns.nr b/noir-projects/aztec-nr/aztec/src/context/packed_returns.nr index 418320270f1..abf2ee7ea39 100644 --- a/noir-projects/aztec-nr/aztec/src/context/packed_returns.nr +++ b/noir-projects/aztec-nr/aztec/src/context/packed_returns.nr @@ -1,7 +1,7 @@ use crate::{hash::hash_args_array, oracle::returns::unpack_returns}; use dep::protocol_types::traits::Deserialize; -struct PackedReturns { +pub struct PackedReturns { packed_returns: Field, } diff --git a/noir-projects/aztec-nr/aztec/src/context/public_context.nr b/noir-projects/aztec-nr/aztec/src/context/public_context.nr index 4afce98c2ec..fcf1f056aae 100644 --- a/noir-projects/aztec-nr/aztec/src/context/public_context.nr +++ b/noir-projects/aztec-nr/aztec/src/context/public_context.nr @@ -7,7 +7,7 @@ use crate::context::inputs::public_context_inputs::PublicContextInputs; use crate::context::gas::GasOpts; use crate::hash::ArgsHasher; -struct PublicContext { +pub struct PublicContext { inputs: PublicContextInputs, args_hash: Option } @@ -418,7 +418,7 @@ unconstrained fn storage_read_opcode(storage_slot: Field) -> Field {} #[oracle(avmOpcodeStorageWrite)] unconstrained fn storage_write_opcode(storage_slot: Field, value: Field) {} -struct FunctionReturns { +pub struct FunctionReturns { values: [Field; N] } diff --git a/noir-projects/aztec-nr/aztec/src/context/unconstrained_context.nr b/noir-projects/aztec-nr/aztec/src/context/unconstrained_context.nr index 8ce6591dd39..cc0cc68f08c 100644 --- a/noir-projects/aztec-nr/aztec/src/context/unconstrained_context.nr +++ b/noir-projects/aztec-nr/aztec/src/context/unconstrained_context.nr @@ -1,7 +1,7 @@ use dep::protocol_types::{address::AztecAddress, traits::Deserialize}; use crate::oracle::{execution::{get_chain_id, get_version, get_contract_address, get_block_number}, storage::storage_read}; -struct UnconstrainedContext { +pub struct UnconstrainedContext { block_number: u32, contract_address: AztecAddress, version: Field, diff --git a/noir-projects/aztec-nr/aztec/src/encrypted_logs/header.nr b/noir-projects/aztec-nr/aztec/src/encrypted_logs/header.nr index c4962380f92..b3f96898f2c 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/header.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/header.nr @@ -4,7 +4,7 @@ use crate::keys::{point_to_symmetric_key::point_to_symmetric_key, public_keys::T use std::aes128::aes128_encrypt; -struct EncryptedLogHeader { +pub struct EncryptedLogHeader { address: AztecAddress, } diff --git a/noir-projects/aztec-nr/aztec/src/encrypted_logs/incoming_body.nr b/noir-projects/aztec-nr/aztec/src/encrypted_logs/incoming_body.nr index 99f84f33bf8..20510681cd7 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/incoming_body.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/incoming_body.nr @@ -5,7 +5,7 @@ use dep::protocol_types::{scalar::Scalar}; use std::aes128::aes128_encrypt; use crate::keys::{point_to_symmetric_key::point_to_symmetric_key, public_keys::IvpkM}; -struct EncryptedLogIncomingBody { +pub struct EncryptedLogIncomingBody { plaintext: [u8; N * 32 + 64] } @@ -121,7 +121,7 @@ mod test { buffer } - fn compute_note_hash(self) -> Field { + fn compute_note_hash(_self: Self) -> Field { crate::generators::Ga1.x } } diff --git a/noir-projects/aztec-nr/aztec/src/encrypted_logs/outgoing_body.nr b/noir-projects/aztec-nr/aztec/src/encrypted_logs/outgoing_body.nr index a722904c541..bbe5add17bf 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/outgoing_body.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/outgoing_body.nr @@ -6,7 +6,7 @@ use std::aes128::aes128_encrypt; use crate::{keys::public_keys::IvpkM, utils::point::point_to_bytes}; -struct EncryptedLogOutgoingBody { +pub struct EncryptedLogOutgoingBody { eph_sk: Scalar, recipient: AztecAddress, recipient_ivpk: IvpkM, diff --git a/noir-projects/aztec-nr/aztec/src/hash.nr b/noir-projects/aztec-nr/aztec/src/hash.nr index 1d5f750f2d5..ec99d424310 100644 --- a/noir-projects/aztec-nr/aztec/src/hash.nr +++ b/noir-projects/aztec-nr/aztec/src/hash.nr @@ -77,7 +77,7 @@ pub fn compute_message_nullifier(message_hash: Field, secret: Field, leaf_index: ) } -struct ArgsHasher { +pub struct ArgsHasher { fields: [Field], } diff --git a/noir-projects/aztec-nr/aztec/src/keys/public_keys.nr b/noir-projects/aztec-nr/aztec/src/keys/public_keys.nr index c4114e030b5..860079534bd 100644 --- a/noir-projects/aztec-nr/aztec/src/keys/public_keys.nr +++ b/noir-projects/aztec-nr/aztec/src/keys/public_keys.nr @@ -6,18 +6,18 @@ use dep::protocol_types::{ global PUBLIC_KEYS_LENGTH: u32 = 12; -struct PublicKeys { +pub struct PublicKeys { npk_m: NpkM, ivpk_m: IvpkM, ovpk_m: OvpkM, tpk_m: TpkM, } -trait ToPoint { +pub trait ToPoint { fn to_point(self) -> Point; } -struct NpkM { +pub struct NpkM { inner: Point } @@ -40,7 +40,7 @@ impl Hash for NpkM { } } -struct IvpkM { +pub struct IvpkM { inner: Point } @@ -56,7 +56,7 @@ impl Serialize for IvpkM { } } -struct OvpkM { +pub struct OvpkM { inner: Point } @@ -78,7 +78,7 @@ impl Serialize for OvpkM { } } -struct TpkM { +pub struct TpkM { inner: Point } diff --git a/noir-projects/aztec-nr/aztec/src/macros/functions/interfaces.nr b/noir-projects/aztec-nr/aztec/src/macros/functions/interfaces.nr index 1f39f05c4fb..a015e899766 100644 --- a/noir-projects/aztec-nr/aztec/src/macros/functions/interfaces.nr +++ b/noir-projects/aztec-nr/aztec/src/macros/functions/interfaces.nr @@ -36,7 +36,7 @@ pub(crate) comptime fn create_fn_abi_export(f: FunctionDefinition) -> Quoted { $parameters #[abi(functions)] - struct $abi_struct_name { + pub struct $abi_struct_name { parameters: $parameters_struct_name, $return_type } diff --git a/noir-projects/aztec-nr/aztec/src/note/note_emission.nr b/noir-projects/aztec-nr/aztec/src/note/note_emission.nr index dd2622ff5eb..2c89b39b7e8 100644 --- a/noir-projects/aztec-nr/aztec/src/note/note_emission.nr +++ b/noir-projects/aztec-nr/aztec/src/note/note_emission.nr @@ -2,7 +2,7 @@ * A note emission struct containing the information required for emitting a note. * The exact `emit` logic is passed in by the application code */ -struct NoteEmission { +pub struct NoteEmission { note: Note } @@ -23,10 +23,10 @@ impl NoteEmission { * This is the struct provided to application codes, which can be used to emit * only when a note was actually inserted. * It is fairly common to have cases where a function conditionally inserts, - * and this allows us to keep the same API for emission in both cases (e.g. inserting + * and this allows us to keep the same API for emission in both cases (e.g. inserting * a change note in a token's transfer function only when there is "change" left). */ -struct OuterNoteEmission { +pub struct OuterNoteEmission { emission: Option>, } diff --git a/noir-projects/aztec-nr/aztec/src/note/note_getter_options.nr b/noir-projects/aztec-nr/aztec/src/note/note_getter_options.nr index af928ee88b0..01145a45860 100644 --- a/noir-projects/aztec-nr/aztec/src/note/note_getter_options.nr +++ b/noir-projects/aztec-nr/aztec/src/note/note_getter_options.nr @@ -2,13 +2,13 @@ use std::option::Option; use dep::protocol_types::{constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, traits::ToField}; use crate::note::note_interface::NoteInterface; -struct PropertySelector { +pub struct PropertySelector { index: u8, // index of the field in the serialized note array offset: u8, // offset in the byte representation of the field (selected with index above) from which to reading length: u8, // number of bytes to read after the offset } -struct Select { +pub struct Select { property_selector: PropertySelector, comparator: u8, value: Field, @@ -22,7 +22,7 @@ impl Select { } } -struct SortOrderEnum { +pub struct SortOrderEnum { DESC: u8, ASC: u8, } @@ -32,7 +32,7 @@ global SortOrder = SortOrderEnum { ASC: 2, }; -struct Sort { +pub struct Sort { property_selector: PropertySelector, order: u8, } @@ -43,7 +43,7 @@ impl Sort { } } -struct NoteStatusEnum { +pub struct NoteStatusEnum { ACTIVE: u8, ACTIVE_OR_NULLIFIED: u8, } @@ -54,6 +54,7 @@ global NoteStatus = NoteStatusEnum { // TODO 4217: add 'NULLIFIED' }; +// This is the default filter and preprocessor, which does nothing fn return_all_notes( notes: [Option; MAX_NOTE_HASH_READ_REQUESTS_PER_CALL], _p: Field @@ -62,7 +63,7 @@ fn return_all_notes( } // docs:start:NoteGetterOptions -struct NoteGetterOptions { +pub struct NoteGetterOptions { selects: BoundedVec, N>, sorts: BoundedVec, N>, limit: u32, diff --git a/noir-projects/aztec-nr/aztec/src/note/note_viewer_options.nr b/noir-projects/aztec-nr/aztec/src/note/note_viewer_options.nr index 677e6936dfd..0e5769b6fe1 100644 --- a/noir-projects/aztec-nr/aztec/src/note/note_viewer_options.nr +++ b/noir-projects/aztec-nr/aztec/src/note/note_viewer_options.nr @@ -5,7 +5,7 @@ use crate::note::note_interface::NoteInterface; use crate::note::constants::MAX_NOTES_PER_PAGE; // docs:start:NoteViewerOptions -struct NoteViewerOptions { +pub struct NoteViewerOptions { selects: BoundedVec, N>, sorts: BoundedVec, N>, limit: u32, diff --git a/noir-projects/aztec-nr/aztec/src/oracle/get_membership_witness.nr b/noir-projects/aztec-nr/aztec/src/oracle/get_membership_witness.nr index 125848fd25d..9aeb08f8265 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/get_membership_witness.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/get_membership_witness.nr @@ -10,7 +10,7 @@ global ARCHIVE_TREE_ID = 4; // // Another way to do it would be to add "type_hint: [Field; T]" as argument to `get_membership_witness` but that's // a bit too boilerplatey for my taste. -struct MembershipWitness { +pub struct MembershipWitness { index: Field, path: [Field; N], } diff --git a/noir-projects/aztec-nr/aztec/src/oracle/get_nullifier_membership_witness.nr b/noir-projects/aztec-nr/aztec/src/oracle/get_nullifier_membership_witness.nr index 986507b1e3c..92031f28785 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/get_nullifier_membership_witness.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/get_nullifier_membership_witness.nr @@ -6,7 +6,7 @@ use dep::protocol_types::{ // INDEX_LENGTH + NULLIFIER_LEAF_PREIMAGE_LENGTH + NULLIFIER_TREE_HEIGHT global NULLIFIER_MEMBERSHIP_WITNESS: u32 = 24; -struct NullifierMembershipWitness { +pub struct NullifierMembershipWitness { index: Field, leaf_preimage: NullifierLeafPreimage, path: [Field; NULLIFIER_TREE_HEIGHT], diff --git a/noir-projects/aztec-nr/aztec/src/oracle/get_public_data_witness.nr b/noir-projects/aztec-nr/aztec/src/oracle/get_public_data_witness.nr index 4f567868dcd..1db5554f9aa 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/get_public_data_witness.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/get_public_data_witness.nr @@ -3,7 +3,7 @@ use dep::protocol_types::{constants::PUBLIC_DATA_TREE_HEIGHT, data::PublicDataTr global LEAF_PREIMAGE_LENGTH: u32 = 4; global PUBLIC_DATA_WITNESS: u32 = 45; -struct PublicDataWitness { +pub struct PublicDataWitness { index: Field, leaf_preimage: PublicDataTreeLeafPreimage, path: [Field; PUBLIC_DATA_TREE_HEIGHT], diff --git a/noir-projects/aztec-nr/aztec/src/oracle/logs_traits.nr b/noir-projects/aztec-nr/aztec/src/oracle/logs_traits.nr index 4640068d054..c8de6c54971 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/logs_traits.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/logs_traits.nr @@ -10,7 +10,7 @@ use dep::protocol_types::address::AztecAddress; // I could have omitted N from the trait, but wanted to keep it strictly for field arrs // TODO(1139): Once we enc inside the circuit, we will no longer need the oracle to return // anything, so we can remove this trait -trait LensForEncryptedLog { +pub trait LensForEncryptedLog { // N = note preimage input in fields // M = encryption output len in bytes (= 417 + N * 32) fn output_fields(self: [Field; N]) -> [Field; N]; @@ -114,7 +114,7 @@ impl LensForEncryptedLog<12, 801> for [Field; 12] { } } -trait LensForEncryptedEvent { +pub trait LensForEncryptedEvent { // N = event preimage input in bytes // M = encryption output len in bytes (= 416 + M) fn output(self: [u8; N]) -> [u8; M]; @@ -154,7 +154,7 @@ impl LensForEncryptedEvent<256, 608> for [u8; 256] { // This trait defines the length of the inputs in bytes to // the unencrypted log hash fn, where the log can be any type T // as long as the ACVM can convert to fields. -trait ToBytesForUnencryptedLog { +pub trait ToBytesForUnencryptedLog { // N = preimage input in bytes (32 * num fields or chars) // M = full log input in bytes ( = N + 40 = N + 32 for addr, + 4 for selector, + 4 for len) fn to_be_bytes_arr(self) -> [u8; N]; diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/map.nr b/noir-projects/aztec-nr/aztec/src/state_vars/map.nr index 5ca79f852b9..e4db34b7c18 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/map.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/map.nr @@ -2,7 +2,7 @@ use dep::protocol_types::{storage::map::derive_storage_slot_in_map, traits::ToFi use crate::state_vars::storage::Storage; // docs:start:map -struct Map { +pub struct Map { context: Context, storage_slot: Field, state_var_constructor: fn(Context, Field) -> V, @@ -33,4 +33,3 @@ impl Map { } // docs:end:at } - diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/private_immutable.nr b/noir-projects/aztec-nr/aztec/src/state_vars/private_immutable.nr index 798d3dc4205..37e23170beb 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/private_immutable.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/private_immutable.nr @@ -10,7 +10,7 @@ use crate::oracle::notes::check_nullifier_exists; use crate::state_vars::storage::Storage; // docs:start:struct -struct PrivateImmutable { +pub struct PrivateImmutable { context: Context, storage_slot: Field, } diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/private_mutable.nr b/noir-projects/aztec-nr/aztec/src/state_vars/private_mutable.nr index c41dbbaaa68..453f46b5515 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/private_mutable.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/private_mutable.nr @@ -10,7 +10,7 @@ use crate::oracle::notes::check_nullifier_exists; use crate::state_vars::storage::Storage; // docs:start:struct -struct PrivateMutable { +pub struct PrivateMutable { context: Context, storage_slot: Field } diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/private_set.nr b/noir-projects/aztec-nr/aztec/src/state_vars/private_set.nr index 0eb7822218f..282a11c58aa 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/private_set.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/private_set.nr @@ -10,7 +10,7 @@ use crate::note::{ use crate::state_vars::storage::Storage; // docs:start:struct -struct PrivateSet { +pub struct PrivateSet { context: Context, storage_slot: Field, } diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/public_immutable.nr b/noir-projects/aztec-nr/aztec/src/state_vars/public_immutable.nr index 9c7b82231b9..745f3d9eefc 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/public_immutable.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/public_immutable.nr @@ -3,7 +3,7 @@ use dep::protocol_types::{constants::INITIALIZATION_SLOT_SEPARATOR, traits::{Des // Just like SharedImmutable but without the ability to read from private functions. // docs:start:public_immutable_struct -struct PublicImmutable { +pub struct PublicImmutable { context: Context, storage_slot: Field, } diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/public_mutable.nr b/noir-projects/aztec-nr/aztec/src/state_vars/public_mutable.nr index 5cb02b44635..1e8840db7cf 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/public_mutable.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/public_mutable.nr @@ -3,7 +3,7 @@ use dep::protocol_types::traits::{Deserialize, Serialize}; use crate::state_vars::storage::Storage; // docs:start:public_mutable_struct -struct PublicMutable { +pub struct PublicMutable { context: Context, storage_slot: Field, } diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/shared_immutable.nr b/noir-projects/aztec-nr/aztec/src/state_vars/shared_immutable.nr index 16d7a77bf5c..2fa82e94a08 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/shared_immutable.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/shared_immutable.nr @@ -2,7 +2,7 @@ use crate::{context::{PrivateContext, PublicContext, UnconstrainedContext}, stat use dep::protocol_types::{constants::INITIALIZATION_SLOT_SEPARATOR, traits::{Deserialize, Serialize}}; // Just like PublicImmutable but with the ability to read from private functions. -struct SharedImmutable{ +pub struct SharedImmutable{ context: Context, storage_slot: Field, } diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/scheduled_delay_change.nr b/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/scheduled_delay_change.nr index a2be6062513..682a04febdd 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/scheduled_delay_change.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/scheduled_delay_change.nr @@ -9,7 +9,7 @@ mod test; // is performed via `schedule_change` in order to satisfy ScheduleValueChange constraints: if e.g. we allowed for the // delay to be decreased immediately then it'd be possible for the state variable to schedule a value change with a // reduced delay, invalidating prior private reads. -struct ScheduledDelayChange { +pub struct ScheduledDelayChange { // Both pre and post are stored in public storage, so by default they are zeroed. By wrapping them in an Option, // they default to Option::none(), which we detect and replace with INITIAL_DELAY. The end result is that a // ScheduledDelayChange that has not been initialized has a delay equal to INITIAL_DELAY, which is the desired diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/scheduled_value_change.nr b/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/scheduled_value_change.nr index 91c13f21f33..8c4ebe8c863 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/scheduled_value_change.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/scheduled_value_change.nr @@ -8,7 +8,7 @@ mod test; // of change after some minimum delay measured in blocks has elapsed. This means that at any given block number we know // both the current value and the smallest block number at which the value might change - this is called the // 'block horizon'. -struct ScheduledValueChange { +pub struct ScheduledValueChange { pre: T, post: T, // Block at which `post` value is used instead of `pre` diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/shared_mutable.nr b/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/shared_mutable.nr index dfd458c3915..2b72072aa97 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/shared_mutable.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/shared_mutable.nr @@ -13,7 +13,7 @@ use dep::std::mem::zeroed; mod test; -struct SharedMutable { +pub struct SharedMutable { context: Context, storage_slot: Field, } diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/shared_mutable_private_getter.nr b/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/shared_mutable_private_getter.nr index 443fdf10973..a5078d9cb95 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/shared_mutable_private_getter.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/shared_mutable_private_getter.nr @@ -2,7 +2,7 @@ use dep::protocol_types::{traits::{FromField, ToField}, address::AztecAddress, h use crate::{context::PrivateContext, state_vars::shared_mutable::shared_mutable::SharedMutable}; -struct SharedMutablePrivateGetter { +pub struct SharedMutablePrivateGetter { context: &mut PrivateContext, // The contract address of the contract we want to read from other_contract_address: AztecAddress, diff --git a/noir-projects/aztec-nr/aztec/src/test/helpers/test_environment.nr b/noir-projects/aztec-nr/aztec/src/test/helpers/test_environment.nr index 302cd1215f3..5f051b3733f 100644 --- a/noir-projects/aztec-nr/aztec/src/test/helpers/test_environment.nr +++ b/noir-projects/aztec-nr/aztec/src/test/helpers/test_environment.nr @@ -86,11 +86,11 @@ impl TestEnvironment { address } - fn deploy(self, path: str, name: str) -> Deployer { + fn deploy(_self: Self, path: str, name: str) -> Deployer { Deployer { path, name, public_keys_hash: 0 } } - fn deploy_self(self, name: str) -> Deployer<0, M> { + fn deploy_self(_self: Self, name: str) -> Deployer<0, M> { Deployer { path: "", name, public_keys_hash: 0 } } diff --git a/noir-projects/aztec-nr/aztec/src/test/helpers/utils.nr b/noir-projects/aztec-nr/aztec/src/test/helpers/utils.nr index 046c48e5473..44717180592 100644 --- a/noir-projects/aztec-nr/aztec/src/test/helpers/utils.nr +++ b/noir-projects/aztec-nr/aztec/src/test/helpers/utils.nr @@ -28,7 +28,7 @@ pub fn apply_side_effects_private(contract_address: AztecAddress, public_inputs: cheatcodes::add_note_hashes(contract_address, note_hashes); } -struct Deployer { +pub struct Deployer { path: str, name: str, public_keys_hash: Field @@ -110,7 +110,7 @@ impl Deployer { // Keys length + address global TEST_ACCOUNT_LENGTH = PUBLIC_KEYS_LENGTH + 1; -struct TestAccount { +pub struct TestAccount { address: AztecAddress, keys: PublicKeys } diff --git a/noir-projects/aztec-nr/aztec/src/test/mocks/mock_note.nr b/noir-projects/aztec-nr/aztec/src/test/mocks/mock_note.nr index 3243409da9b..ff7d61d03b2 100644 --- a/noir-projects/aztec-nr/aztec/src/test/mocks/mock_note.nr +++ b/noir-projects/aztec-nr/aztec/src/test/mocks/mock_note.nr @@ -9,7 +9,7 @@ use crate::note::note_interface::NullifiableNote; global MOCK_NOTE_LENGTH: u32 = 1; -struct MockNote { +pub(crate) struct MockNote { header: NoteHeader, value: Field, } @@ -93,7 +93,7 @@ impl Eq for MockNote { } } -struct MockNoteBuilder { +pub struct MockNoteBuilder { value: Field, contract_address: Option, storage_slot: Option, diff --git a/noir-projects/aztec-nr/aztec/src/test/mocks/mock_struct.nr b/noir-projects/aztec-nr/aztec/src/test/mocks/mock_struct.nr index 8df0dd4cac3..b9b94d0b5e8 100644 --- a/noir-projects/aztec-nr/aztec/src/test/mocks/mock_struct.nr +++ b/noir-projects/aztec-nr/aztec/src/test/mocks/mock_struct.nr @@ -1,6 +1,6 @@ use dep::protocol_types::traits::{Serialize, Deserialize}; -struct MockStruct { +pub(crate) struct MockStruct { a: Field, b: Field, } diff --git a/noir-projects/aztec-nr/compressed-string/src/compressed_string.nr b/noir-projects/aztec-nr/compressed-string/src/compressed_string.nr index 3211c3d89db..ed98a3e6815 100644 --- a/noir-projects/aztec-nr/compressed-string/src/compressed_string.nr +++ b/noir-projects/aztec-nr/compressed-string/src/compressed_string.nr @@ -4,7 +4,7 @@ use dep::aztec::protocol_types::{utils::field::field_from_bytes, traits::{Serial // Compresses M bytes into N fields. // Can be used for longer strings that don't fit in a single field. // Each field can store 31 characters, so N should be M/31 rounded up. -struct CompressedString { +pub struct CompressedString { value: [Field; N] } diff --git a/noir-projects/aztec-nr/compressed-string/src/field_compressed_string.nr b/noir-projects/aztec-nr/compressed-string/src/field_compressed_string.nr index 9b02c6419f8..9ee35aa9099 100644 --- a/noir-projects/aztec-nr/compressed-string/src/field_compressed_string.nr +++ b/noir-projects/aztec-nr/compressed-string/src/field_compressed_string.nr @@ -2,7 +2,7 @@ use dep::aztec::protocol_types::{utils::field::field_from_bytes, traits::{Serial // A Fixedsize Compressed String. // Essentially a special version of Compressed String for practical use. -struct FieldCompressedString{ +pub struct FieldCompressedString{ value: Field } diff --git a/noir-projects/aztec-nr/easy-private-state/src/easy_private_uint.nr b/noir-projects/aztec-nr/easy-private-state/src/easy_private_uint.nr index 3ec42149937..8863b8e9699 100644 --- a/noir-projects/aztec-nr/easy-private-state/src/easy_private_uint.nr +++ b/noir-projects/aztec-nr/easy-private-state/src/easy_private_uint.nr @@ -6,7 +6,7 @@ use dep::aztec::{ }; use dep::value_note::{filter::filter_notes_min_sum, value_note::ValueNote}; -struct EasyPrivateUint { +pub struct EasyPrivateUint { context: Context, set: PrivateSet, storage_slot: Field, diff --git a/noir-projects/aztec-nr/uint-note/src/uint_note.nr b/noir-projects/aztec-nr/uint-note/src/uint_note.nr index 1062566fa7a..4998e957371 100644 --- a/noir-projects/aztec-nr/uint-note/src/uint_note.nr +++ b/noir-projects/aztec-nr/uint-note/src/uint_note.nr @@ -5,7 +5,7 @@ use dep::aztec::{ }; #[note] -struct UintNote { +pub struct UintNote { // The integer stored by the note value: U128, // The nullifying public key hash is used with the nsk_app to ensure that the note can be privately spent. diff --git a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/dapp_payload.nr b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/dapp_payload.nr index 6b938ea6bc5..dbdcf349ca8 100644 --- a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/dapp_payload.nr +++ b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/dapp_payload.nr @@ -14,7 +14,7 @@ global DAPP_PAYLOAD_SIZE_IN_BYTES: u32 = 130; // Note: If you change the following struct you have to update default_entrypoint.ts // docs:start:app-payload-struct -struct DAppPayload { +pub struct DAppPayload { function_calls: [FunctionCall; DAPP_MAX_CALLS], nonce: Field, } diff --git a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/subscription_note.nr b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/subscription_note.nr index 39b0c2d040f..67cf85873a9 100644 --- a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/subscription_note.nr +++ b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/subscription_note.nr @@ -6,7 +6,7 @@ use dep::aztec::{ }; #[note] -struct SubscriptionNote { +pub struct SubscriptionNote { // The nullifying public key hash is used with the nsk_app to ensure that the note can be privately spent. npk_m_hash: Field, expiry_block_number: Field, diff --git a/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr index e6861d4cc58..435edbbc497 100644 --- a/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr @@ -1,6 +1,6 @@ use dep::aztec::protocol_types::traits::{Serialize, Deserialize}; -struct Note { +pub struct Note { a: Field, b: Field, } diff --git a/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr b/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr index b16aa566248..4d575eae01e 100644 --- a/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr +++ b/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr @@ -8,7 +8,7 @@ use dep::aztec::{ }; use dep::value_note::value_note::ValueNote; -struct Card { +pub struct Card { // We use u32s since u16s are unsupported strength: u32, points: u32, @@ -44,7 +44,7 @@ fn test_to_from_field() { } // docs:end:pure_noir_testing -struct CardNote { +pub struct CardNote { card: Card, note: ValueNote, } @@ -64,7 +64,7 @@ impl CardNote { } } -struct Deck { +pub struct Deck { set: PrivateSet, } diff --git a/noir-projects/noir-contracts/contracts/card_game_contract/src/game.nr b/noir-projects/noir-contracts/contracts/card_game_contract/src/game.nr index 4eb8d5879de..49c55c12c32 100644 --- a/noir-projects/noir-contracts/contracts/card_game_contract/src/game.nr +++ b/noir-projects/noir-contracts/contracts/card_game_contract/src/game.nr @@ -4,7 +4,7 @@ use crate::cards::Card; global NUMBER_OF_PLAYERS: u32 = 2; global NUMBER_OF_CARDS_DECK: u32 = 2; -struct PlayerEntry { +pub struct PlayerEntry { address: AztecAddress, deck_strength: u32, points: u64, @@ -38,7 +38,7 @@ impl Eq for PlayerEntry { global PLAYABLE_CARDS: u32 = 4; -struct Game { +pub struct Game { players: [PlayerEntry; NUMBER_OF_PLAYERS], rounds_cards: [Card; PLAYABLE_CARDS], started: bool, diff --git a/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/events/class_registered.nr b/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/events/class_registered.nr index 5705f9378d1..3a67ffbf2e0 100644 --- a/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/events/class_registered.nr +++ b/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/events/class_registered.nr @@ -5,7 +5,7 @@ use dep::aztec::protocol_types::{ }; // #[event] -struct ContractClassRegistered { +pub struct ContractClassRegistered { contract_class_id: ContractClassId, version: Field, artifact_hash: Field, diff --git a/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/events/private_function_broadcasted.nr b/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/events/private_function_broadcasted.nr index 11735b33316..edd7d9855e3 100644 --- a/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/events/private_function_broadcasted.nr +++ b/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/events/private_function_broadcasted.nr @@ -11,7 +11,7 @@ use dep::aztec::protocol_types::{ traits::Serialize }; -struct InnerPrivateFunction { +pub struct InnerPrivateFunction { selector: FunctionSelector, metadata_hash: Field, vk_hash: Field, @@ -23,7 +23,7 @@ impl Serialize<3> for InnerPrivateFunction { } } -struct PrivateFunction { +pub struct PrivateFunction { selector: FunctionSelector, metadata_hash: Field, vk_hash: Field, @@ -44,7 +44,7 @@ impl Serialize for } // #[event] -struct ClassPrivateFunctionBroadcasted { +pub struct ClassPrivateFunctionBroadcasted { contract_class_id: ContractClassId, artifact_metadata_hash: Field, unconstrained_functions_artifact_tree_root: Field, diff --git a/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/events/unconstrained_function_broadcasted.nr b/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/events/unconstrained_function_broadcasted.nr index 28a6e791e85..504024207ac 100644 --- a/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/events/unconstrained_function_broadcasted.nr +++ b/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/events/unconstrained_function_broadcasted.nr @@ -10,7 +10,7 @@ use dep::aztec::protocol_types::{ traits::Serialize }; -struct InnerUnconstrainedFunction { +pub struct InnerUnconstrainedFunction { selector: FunctionSelector, metadata_hash: Field, } @@ -21,7 +21,7 @@ impl Serialize<2> for InnerUnconstrainedFunction { } } -struct UnconstrainedFunction { +pub struct UnconstrainedFunction { selector: FunctionSelector, metadata_hash: Field, bytecode: [Field; MAX_PACKED_BYTECODE_SIZE_PER_UNCONSTRAINED_FUNCTION_IN_FIELDS], @@ -40,7 +40,7 @@ impl Serialize for Leader { [self.account.to_field(), self.points as Field] } } - diff --git a/noir-projects/noir-contracts/contracts/ecdsa_public_key_note/src/lib.nr b/noir-projects/noir-contracts/contracts/ecdsa_public_key_note/src/lib.nr index cec2dab9a5e..d3fbc101101 100644 --- a/noir-projects/noir-contracts/contracts/ecdsa_public_key_note/src/lib.nr +++ b/noir-projects/noir-contracts/contracts/ecdsa_public_key_note/src/lib.nr @@ -14,7 +14,7 @@ global ECDSA_PUBLIC_KEY_NOTE_LEN: u32 = 5; // Stores an ECDSA public key composed of two 32-byte elements // TODO: Do we need to include a nonce, in case we want to read/nullify/recreate with the same pubkey value? #[note_custom_interface] -struct EcdsaPublicKeyNote { +pub struct EcdsaPublicKeyNote { x: [u8; 32], y: [u8; 32], // We store the npk_m_hash only to get the secret key to compute the nullifier diff --git a/noir-projects/noir-contracts/contracts/import_test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/import_test_contract/src/main.nr index df4ad22d792..6f5a19f3fda 100644 --- a/noir-projects/noir-contracts/contracts/import_test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/import_test_contract/src/main.nr @@ -59,4 +59,3 @@ contract ImportTest { Test::at(target).emit_nullifier_public(1).call(&mut context); } } - diff --git a/noir-projects/noir-contracts/contracts/lending_contract/src/asset.nr b/noir-projects/noir-contracts/contracts/lending_contract/src/asset.nr index fe0f0153048..bbee9ba545e 100644 --- a/noir-projects/noir-contracts/contracts/lending_contract/src/asset.nr +++ b/noir-projects/noir-contracts/contracts/lending_contract/src/asset.nr @@ -6,7 +6,7 @@ use dep::aztec::protocol_types::traits::{Deserialize, Serialize}; // and last time it was updated. // In practice, it should also point to an oracle and have more fields related to // loan to value ratios and other things, but we did not have enough reads/writes for this. -struct Asset { +pub struct Asset { interest_accumulator: U128, last_updated_ts: u64, loan_to_value: U128, diff --git a/noir-projects/noir-contracts/contracts/lending_contract/src/helpers.nr b/noir-projects/noir-contracts/contracts/lending_contract/src/helpers.nr index 750b6dff607..c5e537e88ed 100644 --- a/noir-projects/noir-contracts/contracts/lending_contract/src/helpers.nr +++ b/noir-projects/noir-contracts/contracts/lending_contract/src/helpers.nr @@ -31,7 +31,7 @@ pub fn covered_by_collateral( debt_covered } -struct DebtReturn { +pub struct DebtReturn { debt_value: U128, static_debt: U128, } diff --git a/noir-projects/noir-contracts/contracts/lending_contract/src/position.nr b/noir-projects/noir-contracts/contracts/lending_contract/src/position.nr index 2e575428e1c..052f935d025 100644 --- a/noir-projects/noir-contracts/contracts/lending_contract/src/position.nr +++ b/noir-projects/noir-contracts/contracts/lending_contract/src/position.nr @@ -1,6 +1,6 @@ use dep::aztec::protocol_types::traits::{Deserialize, Serialize}; -struct Position { +pub struct Position { collateral: Field, static_debt: Field, debt: Field, diff --git a/noir-projects/noir-contracts/contracts/nft_contract/src/types/nft_note.nr b/noir-projects/noir-contracts/contracts/nft_contract/src/types/nft_note.nr index 2d982a55ea7..e4960ee4f71 100644 --- a/noir-projects/noir-contracts/contracts/nft_contract/src/types/nft_note.nr +++ b/noir-projects/noir-contracts/contracts/nft_contract/src/types/nft_note.nr @@ -6,7 +6,7 @@ use dep::aztec::{ }; #[partial_note(quote { token_id})] -struct NFTNote { +pub struct NFTNote { // ID of the token token_id: Field, // The nullifying public key hash is used with the nsk_app to ensure that the note can be privately spent. diff --git a/noir-projects/noir-contracts/contracts/price_feed_contract/src/asset.nr b/noir-projects/noir-contracts/contracts/price_feed_contract/src/asset.nr index 86ecc9a90fc..f28fc928259 100644 --- a/noir-projects/noir-contracts/contracts/price_feed_contract/src/asset.nr +++ b/noir-projects/noir-contracts/contracts/price_feed_contract/src/asset.nr @@ -1,6 +1,6 @@ use dep::aztec::protocol_types::traits::{Serialize, Deserialize}; -struct Asset { +pub struct Asset { price: U128, } diff --git a/noir-projects/noir-contracts/contracts/private_fpc_contract/src/settings.nr b/noir-projects/noir-contracts/contracts/private_fpc_contract/src/settings.nr index 934b44dd476..3a3ea50030b 100644 --- a/noir-projects/noir-contracts/contracts/private_fpc_contract/src/settings.nr +++ b/noir-projects/noir-contracts/contracts/private_fpc_contract/src/settings.nr @@ -2,7 +2,7 @@ use dep::aztec::protocol_types::{address::AztecAddress, traits::{Serialize, Dese global SETTINGS_LENGTH: u32 = 2; -struct Settings { +pub struct Settings { other_asset: AztecAddress, admin: AztecAddress, } diff --git a/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr b/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr index 49e4a1f3916..9082b48d49e 100644 --- a/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr +++ b/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr @@ -8,7 +8,7 @@ use dep::aztec::{ // Stores a public key composed of two fields // TODO: Do we need to include a nonce, in case we want to read/nullify/recreate with the same pubkey value? #[note] -struct PublicKeyNote { +pub struct PublicKeyNote { x: Field, y: Field, // We store the npk_m_hash only to get the secret key to compute the nullifier diff --git a/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/auth_oracle.nr b/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/auth_oracle.nr index 00c2f96bfe6..f9f4f3f4bd2 100644 --- a/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/auth_oracle.nr +++ b/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/auth_oracle.nr @@ -4,7 +4,7 @@ use dep::aztec::{ keys::{PublicKeys, PUBLIC_KEYS_LENGTH} }; -struct AuthWitness { +pub struct AuthWitness { keys: PublicKeys, signature: [u8; 64], partial_address: PartialAddress, diff --git a/noir-projects/noir-contracts/contracts/spam_contract/src/types/balance_set.nr b/noir-projects/noir-contracts/contracts/spam_contract/src/types/balance_set.nr index a6496ac4c85..d6a17fe5ab5 100644 --- a/noir-projects/noir-contracts/contracts/spam_contract/src/types/balance_set.nr +++ b/noir-projects/noir-contracts/contracts/spam_contract/src/types/balance_set.nr @@ -7,7 +7,7 @@ use dep::aztec::{ }; use crate::types::token_note::OwnedNote; -struct BalanceSet { +pub struct BalanceSet { set: PrivateSet, } diff --git a/noir-projects/noir-contracts/contracts/spam_contract/src/types/token_note.nr b/noir-projects/noir-contracts/contracts/spam_contract/src/types/token_note.nr index 0e544373b09..33a85b27e7b 100644 --- a/noir-projects/noir-contracts/contracts/spam_contract/src/types/token_note.nr +++ b/noir-projects/noir-contracts/contracts/spam_contract/src/types/token_note.nr @@ -11,7 +11,7 @@ trait OwnedNote { } // docs:start:TokenNote #[note] -struct TokenNote { +pub struct TokenNote { // The amount of tokens in the note amount: U128, // The nullifying public key hash is used with the nsk_app to ensure that the note can be privately spent. diff --git a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr index c5afcfbfaec..f1298cc100d 100644 --- a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr @@ -513,7 +513,7 @@ contract Test { kinda_seed * unsafe_rand() } - struct DummyNote { + pub struct DummyNote { amount: Field, secret_hash: Field } @@ -534,7 +534,7 @@ contract Test { } } - struct DeepStruct { + pub struct DeepStruct { a_field: Field, a_bool: bool, a_note: DummyNote, diff --git a/noir-projects/noir-contracts/contracts/test_contract/src/test_note.nr b/noir-projects/noir-contracts/contracts/test_contract/src/test_note.nr index 2adc5bf355a..72fec9b015f 100644 --- a/noir-projects/noir-contracts/contracts/test_contract/src/test_note.nr +++ b/noir-projects/noir-contracts/contracts/test_contract/src/test_note.nr @@ -8,18 +8,18 @@ use dep::aztec::{ // serialized_note attack on it. This note has been developed purely for testing purposes so that it can easily be // manually added to PXE. Do not use for real applications. #[note] -struct TestNote { +pub struct TestNote { value: Field, } impl NullifiableNote for TestNote { - fn compute_nullifier(self, _context: &mut PrivateContext, _note_hash_for_nullify: Field) -> Field { - // This note is expected to be shared between users and for this reason can't be nullified using a secret. + fn compute_nullifier(_self: Self, _context: &mut PrivateContext, _note_hash_for_nullify: Field) -> Field { + // This note is expected to be shared between users and fstructor this reason can't be nullified using a secret. 0 } - fn compute_nullifier_without_context(self) -> Field { + fn compute_nullifier_without_context(_self: Self) -> Field { // This note is expected to be shared between users and for this reason can't be nullified using a secret. 0 } diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/balances_map.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/balances_map.nr index 78ebac2f496..6fb9f33271b 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/balances_map.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/balances_map.nr @@ -6,7 +6,7 @@ use dep::aztec::{ }; use crate::types::{token_note::OwnedNote}; -struct BalancesMap { +pub struct BalancesMap { map: Map, Context> } diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/roles.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/roles.nr index 687feee2cc4..565f709cb8d 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/roles.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/roles.nr @@ -4,7 +4,7 @@ global ADMIN_FLAG: u64 = 1; global MINTER_FLAG: u64 = 2; global BLACKLIST_FLAG: u64 = 4; -struct UserFlags { +pub struct UserFlags { is_admin: bool, is_minter: bool, is_blacklisted: bool, diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr index f48c5d090be..ad19de9860f 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr @@ -11,7 +11,7 @@ trait OwnedNote { } #[note] -struct TokenNote { +pub struct TokenNote { // The amount of tokens in the note amount: U128, // The nullifying public key hash is used with the nsk_app to ensure that the note can be privately spent. diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr index 3d297e6ab7c..d5007d83b2a 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr @@ -11,7 +11,7 @@ use dep::aztec::{ // Owner of the tokens provides a "secret_hash" as an argument to the public "shield" function and then the tokens // can be redeemed in private by presenting the preimage of the "secret_hash" (the secret). #[note] -struct TransparentNote { +pub struct TransparentNote { amount: Field, secret_hash: Field, } diff --git a/noir-projects/noir-protocol-circuits/crates/bug-collecting-crate/devex-turbo-fish.nr b/noir-projects/noir-protocol-circuits/crates/bug-collecting-crate/devex-turbo-fish.nr index 67b2f933b57..b283f25d605 100644 --- a/noir-projects/noir-protocol-circuits/crates/bug-collecting-crate/devex-turbo-fish.nr +++ b/noir-projects/noir-protocol-circuits/crates/bug-collecting-crate/devex-turbo-fish.nr @@ -10,10 +10,10 @@ fn main(){ }; } -struct Foo { +pub struct Foo { x : N, } -struct Bar { +pub struct Bar { x : FooField, -} \ No newline at end of file +} diff --git a/noir-projects/noir-protocol-circuits/crates/bug-collecting-crate/type-alias-shorthand.nr b/noir-projects/noir-protocol-circuits/crates/bug-collecting-crate/type-alias-shorthand.nr index 8f7e92a2cb3..d7facd14e83 100644 --- a/noir-projects/noir-protocol-circuits/crates/bug-collecting-crate/type-alias-shorthand.nr +++ b/noir-projects/noir-protocol-circuits/crates/bug-collecting-crate/type-alias-shorthand.nr @@ -1,6 +1,6 @@ use X as Y; -struct X{ +pub struct X{ x :u32 } @@ -8,7 +8,7 @@ fn main() { let z= Y{20}; } -error: cannot find `Y` in this scope +error: cannot find `Y` in this scope ┌─ main.nr:8:12 │ 8 │ let z= Y{20}; @@ -22,4 +22,4 @@ error: Expected a ; separating these two statements │ - │ -// Note not using shorthand and doing Y{x : 20} will fix this. \ No newline at end of file +// Note not using shorthand and doing Y{x : 20} will fix this. diff --git a/noir-projects/noir-protocol-circuits/crates/bug-collecting-crate/typechain-type-alias.nr b/noir-projects/noir-protocol-circuits/crates/bug-collecting-crate/typechain-type-alias.nr index c2d2c3fa624..e5a7e55ba36 100644 --- a/noir-projects/noir-protocol-circuits/crates/bug-collecting-crate/typechain-type-alias.nr +++ b/noir-projects/noir-protocol-circuits/crates/bug-collecting-crate/typechain-type-alias.nr @@ -1,15 +1,15 @@ -The typescript binding generator has a bug when we use type aliases because +The typescript binding generator has a bug when we use type aliases because the abi says that they have the same struct path. For example: -struct Generic { +pub struct Generic { x : [Field; N] } -struct Concrete { +pub struct Concrete { gen2 : Generic<2>, gen4 : Generic<4>, diff --git a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/base/base_parity_inputs.nr b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/base/base_parity_inputs.nr index e2214d23e0b..d9bbcdab794 100644 --- a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/base/base_parity_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/base/base_parity_inputs.nr @@ -1,7 +1,7 @@ use crate::{parity_public_inputs::ParityPublicInputs, utils::sha256_merkle_tree::Sha256MerkleTree}; use dep::types::{constants::NUM_MSGS_PER_BASE_PARITY, merkle_tree::MerkleTree}; -struct BaseParityInputs { +pub struct BaseParityInputs { msgs: [Field; NUM_MSGS_PER_BASE_PARITY], vk_tree_root: Field, } diff --git a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/parity_public_inputs.nr b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/parity_public_inputs.nr index 6adbdaf250e..20b645c4050 100644 --- a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/parity_public_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/parity_public_inputs.nr @@ -1,9 +1,9 @@ use dep::types::{traits::{Empty, Serialize, Deserialize}}; -struct ParityPublicInputs { - sha_root: Field, +pub struct ParityPublicInputs { + sha_root: Field, converted_root: Field, - vk_tree_root: Field, + vk_tree_root: Field, } impl Empty for ParityPublicInputs { diff --git a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_parity_input.nr b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_parity_input.nr index c84894e21c5..61c89698191 100644 --- a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_parity_input.nr +++ b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_parity_input.nr @@ -5,7 +5,7 @@ use dep::types::{ }; use crate::parity_public_inputs::ParityPublicInputs; -struct RootParityInput { +pub struct RootParityInput { proof: RecursiveProof, verification_key: VerificationKey, vk_path: [Field; VK_TREE_HEIGHT], diff --git a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_parity_inputs.nr b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_parity_inputs.nr index 997d2f95972..4473cb2a6ba 100644 --- a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_parity_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_parity_inputs.nr @@ -6,7 +6,7 @@ use crate::{ global NUM_BASE_PARITY_PER_ROOT_PARITY: u32 = 4; -struct RootParityInputs { +pub struct RootParityInputs { children: [RootParityInput; NUM_BASE_PARITY_PER_ROOT_PARITY], } diff --git a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_rollup_parity_input.nr b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_rollup_parity_input.nr index da20609f839..b4156754378 100644 --- a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_rollup_parity_input.nr +++ b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_rollup_parity_input.nr @@ -5,7 +5,7 @@ use dep::types::{ }; use crate::parity_public_inputs::ParityPublicInputs; -struct RootRollupParityInput { +pub struct RootRollupParityInput { proof: NestedRecursiveProof, verification_key: VerificationKey, vk_path: [Field; VK_TREE_HEIGHT], diff --git a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/utils/sha256_merkle_tree.nr b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/utils/sha256_merkle_tree.nr index 318cf1c9511..8e9ace41647 100644 --- a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/utils/sha256_merkle_tree.nr +++ b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/utils/sha256_merkle_tree.nr @@ -4,7 +4,7 @@ use dep::types::{hash::accumulate_sha256}; // hash functions. // TODO(Miranda): This is an interim version with 1 field sha256 - ideally we remove this and use accumulate_sha256 inside // the general MT -struct Sha256MerkleTree { +pub struct Sha256MerkleTree { leaves: [Field; N], nodes: [Field; N], } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/previous_kernel_validator.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/previous_kernel_validator.nr index 626355ec44f..a3a6f2f0882 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/previous_kernel_validator.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/previous_kernel_validator.nr @@ -6,7 +6,7 @@ use dep::types::{ address::AztecAddress, traits::is_empty, utils::arrays::array_length }; -struct PreviousKernelValidator { +pub struct PreviousKernelValidator { previous_kernel: PrivateKernelCircuitPublicInputs, hints: PreviousKernelValidatorHints, } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/previous_kernel_validator/previous_kernel_validator_hints.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/previous_kernel_validator/previous_kernel_validator_hints.nr index dc6bc18aae5..4a213530454 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/previous_kernel_validator/previous_kernel_validator_hints.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/previous_kernel_validator/previous_kernel_validator_hints.nr @@ -3,7 +3,7 @@ use dep::types::{ constants::{MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX}, utils::arrays::find_index_hint }; -struct PreviousKernelValidatorHints { +pub struct PreviousKernelValidatorHints { note_hash_indexes_for_nullifiers: [u32; MAX_NULLIFIERS_PER_TX], } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_call_data_validator.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_call_data_validator.nr index 5c9a62e7d15..eb2cdc5364d 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_call_data_validator.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_call_data_validator.nr @@ -83,7 +83,7 @@ fn validate_incrementing_counter_ranges_within_range(counter_star ); } -struct PrivateCallDataValidator { +pub struct PrivateCallDataValidator { data: PrivateCallData, array_lengths: PrivateCircuitPublicInputsArrayLengths, } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_output_validator.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_output_validator.nr index a026f75cd4e..770c33e6d8d 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_output_validator.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_output_validator.nr @@ -12,7 +12,7 @@ use dep::types::{ } }; -struct PrivateKernelCircuitOutputValidator { +pub struct PrivateKernelCircuitOutputValidator { output: PrivateKernelCircuitPublicInputs, } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_public_inputs_composer.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_public_inputs_composer.nr index 1f935ba9ec3..10e8f2da5c5 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_public_inputs_composer.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_public_inputs_composer.nr @@ -9,7 +9,7 @@ use dep::types::{ utils::arrays::{array_length, array_to_bounded_vec, sort_by_counter_asc, sort_by_counter_desc} }; -struct DataSource { +pub struct DataSource { private_call_public_inputs: PrivateCircuitPublicInputs, contract_address: AztecAddress, storage_contract_address: AztecAddress, @@ -19,7 +19,7 @@ pub fn create_first_nullifier(tx_request: TxRequest) -> ScopedNullifier { Nullifier { value: tx_request.hash(), note_hash: 0, counter: 0 }.scope(AztecAddress::zero()) } -struct PrivateKernelCircuitPublicInputsComposer { +pub struct PrivateKernelCircuitPublicInputsComposer { public_inputs: PrivateKernelCircuitPublicInputsBuilder, } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer.nr index bbaf6dbbc0f..cb10b27ed85 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer.nr @@ -18,7 +18,7 @@ use dep::types::{ hash::{mask_encrypted_log_hash, silo_note_hash, silo_nullifier}, utils::arrays::sort_by_counter_asc }; -struct ResetOutputComposer< +pub struct ResetOutputComposer< let NH_RR_PENDING: u32, let NH_RR_SETTLED: u32, let NLL_RR_PENDING: u32, diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer/reset_output_hints.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer/reset_output_hints.nr index 6def209f88b..bd165f2f7b4 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer/reset_output_hints.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer/reset_output_hints.nr @@ -18,7 +18,7 @@ use dep::types::{ utils::arrays::{OrderHint, get_order_hints_asc} }; -struct ResetOutputHints { +pub struct ResetOutputHints { // note_hashes kept_note_hashes: [ScopedNoteHash; MAX_NOTE_HASHES_PER_TX], sorted_note_hash_indexes: [u32; MAX_NOTE_HASHES_PER_TX], diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_validator.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_validator.nr index 7897c85c1e8..9d2c6682f90 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_validator.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_validator.nr @@ -10,7 +10,7 @@ use dep::types::{ utils::arrays::{assert_sorted_transformed_value_array, assert_sorted_transformed_value_array_capped_size} }; -struct ResetOutputValidator< +pub struct ResetOutputValidator< let NH_RR_PENDING: u32, let NH_RR_SETTLED: u32, let NLL_RR_PENDING: u32, diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_composer.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_composer.nr index 02d32768979..5dc692b568c 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_composer.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_composer.nr @@ -14,7 +14,7 @@ use dep::types::{ messaging::l2_to_l1_message::ScopedL2ToL1Message }; -struct TailOutputComposer { +pub struct TailOutputComposer { output_composer: PrivateKernelCircuitPublicInputsComposer, } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_validator.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_validator.nr index 205819bf0b4..a4071b50910 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_validator.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_validator.nr @@ -13,7 +13,7 @@ use dep::types::{ utils::arrays::assert_exposed_sorted_transformed_value_array }; -struct TailOutputValidator { +pub struct TailOutputValidator { output: KernelCircuitPublicInputs, previous_kernel: PrivateKernelCircuitPublicInputs, hints: TailOutputHints, diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_validator/tail_output_hints.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_validator/tail_output_hints.nr index 814fed215e7..5a6325c5b69 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_validator/tail_output_hints.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_validator/tail_output_hints.nr @@ -4,7 +4,7 @@ use dep::types::{ utils::arrays::{OrderHint, sort_by_counter_asc, get_order_hints_asc} }; -struct TailOutputHints { +pub struct TailOutputHints { // L2 to l1 msgs. sorted_l2_to_l1_msg_hints: [OrderHint; MAX_L2_TO_L1_MSGS_PER_TX], // Unencrypted log hashes. diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_composer.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_composer.nr index 2ebc92c1b7a..0d1bc18226a 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_composer.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_composer.nr @@ -13,7 +13,7 @@ use dep::types::abis::{ validation_requests::PublicValidationRequests }; -struct TailToPublicOutputComposer { +pub struct TailToPublicOutputComposer { output_composer: PrivateKernelCircuitPublicInputsComposer, } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_validator.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_validator.nr index 40b03f563e5..bbb1058d44f 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_validator.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_validator.nr @@ -17,7 +17,7 @@ use dep::types::{ } }; -struct TailToPublicOutputValidator { +pub struct TailToPublicOutputValidator { output: PublicKernelCircuitPublicInputs, previous_kernel: PrivateKernelCircuitPublicInputs, hints: TailToPublicOutputHints, diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_validator/tail_to_public_output_hints.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_validator/tail_to_public_output_hints.nr index 9342441434c..3c829e4b559 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_validator/tail_to_public_output_hints.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_validator/tail_to_public_output_hints.nr @@ -4,7 +4,7 @@ use dep::types::{ utils::arrays::{get_split_order_hints_asc, get_split_order_hints_desc, SplitOrderHints} }; -struct TailToPublicOutputHints { +pub struct TailToPublicOutputHints { // L2 to l1 msgs. sorted_l2_to_l1_msg_hints: SplitOrderHints, // Unencrypted log hashes. diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_empty.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_empty.nr index 453663f5e2b..2e3d677e0b8 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_empty.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_empty.nr @@ -3,7 +3,7 @@ use dep::types::{ recursion::{verification_key::VerificationKey, proof::RecursiveProof, traits::Verifiable} }; -struct EmptyNestedCircuitPublicInputs { +pub struct EmptyNestedCircuitPublicInputs { proof: RecursiveProof, vk: VerificationKey, } @@ -20,7 +20,7 @@ impl Empty for EmptyNestedCircuitPublicInputs { } } -struct PrivateKernelEmptyPrivateInputs { +pub struct PrivateKernelEmptyPrivateInputs { empty_nested: EmptyNestedCircuitPublicInputs, historical_header: Header, chain_id: Field, diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_init.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_init.nr index da34dc55e7d..8bd9f9d4a15 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_init.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_init.nr @@ -14,7 +14,7 @@ use dep::types::{ }; // Initialization struct for private inputs to the private kernel -struct PrivateKernelInitCircuitPrivateInputs { +pub struct PrivateKernelInitCircuitPrivateInputs { tx_request: TxRequest, vk_tree_root: Field, private_call: PrivateCallData, diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_inner.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_inner.nr index 7168efc5a7a..f5e70ebe1d2 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_inner.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_inner.nr @@ -27,7 +27,7 @@ global ALLOWED_PREVIOUS_CIRCUITS = [ PRIVATE_KERNEL_RESET_TINY_INDEX, ]; -struct PrivateKernelInnerCircuitPrivateInputs { +pub struct PrivateKernelInnerCircuitPrivateInputs { previous_kernel: PrivateKernelData, private_call: PrivateCallData, } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_reset.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_reset.nr index b06e27d3c64..2a3532fe1e5 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_reset.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_reset.nr @@ -16,7 +16,7 @@ global ALLOWED_PREVIOUS_CIRCUITS = [ PRIVATE_KERNEL_INNER_INDEX, ]; -struct PrivateKernelResetHints { +pub struct PrivateKernelResetHints { note_hash_read_request_hints: NoteHashReadRequestHints, nullifier_read_request_hints: NullifierReadRequestHints, key_validation_hints: [KeyValidationHint; KEY_VALIDATION_REQUESTS], @@ -24,7 +24,7 @@ struct PrivateKernelResetHints { +pub struct PrivateKernelResetCircuitPrivateInputs { previous_kernel: PrivateKernelData, hints: PrivateKernelResetHints, } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail.nr index 57c53142eca..a64716f8c3c 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail.nr @@ -21,7 +21,7 @@ global ALLOWED_PREVIOUS_CIRCUITS = [ PRIVATE_KERNEL_RESET_TINY_INDEX, ]; -struct PrivateKernelTailCircuitPrivateInputs { +pub struct PrivateKernelTailCircuitPrivateInputs { previous_kernel: PrivateKernelData, } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail_to_public.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail_to_public.nr index 87643e23eea..56b90114239 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail_to_public.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail_to_public.nr @@ -22,7 +22,7 @@ global ALLOWED_PREVIOUS_CIRCUITS = [ PRIVATE_KERNEL_RESET_TINY_INDEX, ]; -struct PrivateKernelTailToPublicCircuitPrivateInputs { +pub struct PrivateKernelTailToPublicCircuitPrivateInputs { previous_kernel: PrivateKernelData, } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/previous_kernel_validator_builder/mod.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/previous_kernel_validator_builder/mod.nr index 9b61eb4f637..4c3cd2c336d 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/previous_kernel_validator_builder/mod.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/previous_kernel_validator_builder/mod.nr @@ -3,7 +3,7 @@ mod validate_no_transient_data; use crate::components::previous_kernel_validator::PreviousKernelValidator; use dep::types::tests::fixture_builder::FixtureBuilder; -struct PreviousKernelValidatorBuilder { +pub struct PreviousKernelValidatorBuilder { previous_kernel: FixtureBuilder } @@ -20,4 +20,4 @@ impl PreviousKernelValidatorBuilder { } } -// TODO: Add tests. \ No newline at end of file +// TODO: Add tests. diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_call_data_validator_builder/mod.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_call_data_validator_builder/mod.nr index 3e395b9843b..afecb1bbc42 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_call_data_validator_builder/mod.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_call_data_validator_builder/mod.nr @@ -19,7 +19,7 @@ use dep::types::{ tests::fixture_builder::FixtureBuilder, transaction::tx_request::TxRequest }; -struct PrivateCallDataValidatorBuilder { +pub struct PrivateCallDataValidatorBuilder { private_call: FixtureBuilder, previous_note_hashes: BoundedVec, } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_output_validator_builder/mod.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_output_validator_builder/mod.nr index 621fc3f494e..70070359b7b 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_output_validator_builder/mod.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_output_validator_builder/mod.nr @@ -19,7 +19,7 @@ use dep::types::{ constants::PRIVATE_KERNEL_INIT_INDEX }; -struct PrivateKernelCircuitOutputValidatorBuilder { +pub struct PrivateKernelCircuitOutputValidatorBuilder { previous_kernel: FixtureBuilder, private_call: FixtureBuilder, output: FixtureBuilder, diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_public_inputs_composer_builder/mod.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_public_inputs_composer_builder/mod.nr index 3b1bbec4d12..5e6e86b9118 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_public_inputs_composer_builder/mod.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_public_inputs_composer_builder/mod.nr @@ -11,7 +11,7 @@ use dep::types::{ tests::fixture_builder::FixtureBuilder, transaction::tx_request::TxRequest }; -struct PrivateKernelCircuitPublicInputsComposerBuilder { +pub struct PrivateKernelCircuitPublicInputsComposerBuilder { tx_request: TxRequest, previous_kernel: FixtureBuilder, private_call: FixtureBuilder, diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/reset_output_validator_builder/mod.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/reset_output_validator_builder/mod.nr index 83632225e34..dc58d472d73 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/reset_output_validator_builder/mod.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/reset_output_validator_builder/mod.nr @@ -14,7 +14,7 @@ use dep::types::{ tests::fixture_builder::FixtureBuilder }; -struct ResetOutputValidatorBuilder { +pub struct ResetOutputValidatorBuilder { output: FixtureBuilder, previous_kernel: FixtureBuilder, note_hash_read_request_hints_builder: NoteHashReadRequestHintsBuilder<6, 3>, diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_output_composer_builder/mod.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_output_composer_builder/mod.nr index 1b974ed4897..0e82c914a67 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_output_composer_builder/mod.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_output_composer_builder/mod.nr @@ -3,7 +3,7 @@ mod meter_gas_used; use crate::components::tail_output_composer::TailOutputComposer; use dep::types::{abis::kernel_circuit_public_inputs::KernelCircuitPublicInputs, tests::fixture_builder::FixtureBuilder}; -struct TailOutputComposerBuilder { +pub struct TailOutputComposerBuilder { previous_kernel: FixtureBuilder, } @@ -23,4 +23,4 @@ impl TailOutputComposerBuilder { } } -// TODO: Add tests. \ No newline at end of file +// TODO: Add tests. diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_output_validator_builder/mod.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_output_validator_builder/mod.nr index a1c3159deb7..98f146d5288 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_output_validator_builder/mod.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_output_validator_builder/mod.nr @@ -12,7 +12,7 @@ use dep::types::{ tests::fixture_builder::FixtureBuilder }; -struct TailOutputValidatorBuilder { +pub struct TailOutputValidatorBuilder { output: FixtureBuilder, previous_kernel: FixtureBuilder, } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_to_public_output_composer_builder/mod.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_to_public_output_composer_builder/mod.nr index 25d7b776f26..db217294f16 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_to_public_output_composer_builder/mod.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_to_public_output_composer_builder/mod.nr @@ -8,7 +8,7 @@ use dep::types::{ tests::fixture_builder::FixtureBuilder }; -struct TailToPublicOutputComposerBuilder { +pub struct TailToPublicOutputComposerBuilder { previous_kernel: FixtureBuilder, } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_to_public_output_validator_builder.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_to_public_output_validator_builder.nr index 27ddb515eb7..d1a6a03b034 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_to_public_output_validator_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_to_public_output_validator_builder.nr @@ -1,7 +1,7 @@ use crate::components::{tail_to_public_output_validator::TailToPublicOutputValidator}; use dep::types::tests::fixture_builder::FixtureBuilder; -struct TailToPublicOutputValidatorBuilder { +pub struct TailToPublicOutputValidatorBuilder { output: FixtureBuilder, previous_kernel: FixtureBuilder } @@ -24,4 +24,4 @@ impl TailToPublicOutputValidatorBuilder { } } -// TODO: Add tests. \ No newline at end of file +// TODO: Add tests. diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/enqueued_call_data_validator.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/enqueued_call_data_validator.nr index 3ebd4d0a034..7688f780885 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/enqueued_call_data_validator.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/enqueued_call_data_validator.nr @@ -8,7 +8,7 @@ use dep::types::{ utils::arrays::array_length }; -struct EnqueuedCallDataValidator { +pub struct EnqueuedCallDataValidator { enqueued_call: EnqueuedCallData, phase: u8, } diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/previous_kernel_validator.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/previous_kernel_validator.nr index b5b6157b583..3a53b0febcd 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/previous_kernel_validator.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/previous_kernel_validator.nr @@ -1,7 +1,7 @@ use crate::public_kernel_phase::PublicKernelPhase; use dep::types::abis::public_kernel_data::PublicKernelData; -struct PreviousKernelValidator { +pub struct PreviousKernelValidator { previous_kernel: PublicKernelData, } diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_call_data_validator.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_call_data_validator.nr index e00ce70fa13..0969265f3dd 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_call_data_validator.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_call_data_validator.nr @@ -7,7 +7,7 @@ use dep::types::{ constants::MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, utils::arrays::array_length }; -struct PublicCallDataValidator { +pub struct PublicCallDataValidator { data: PublicCallData, phase: u8, } diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_kernel_output_composer.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_kernel_output_composer.nr index 01cbeb36bbc..7f9964cacd2 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_kernel_output_composer.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_kernel_output_composer.nr @@ -13,7 +13,7 @@ use dep::types::{ traits::is_empty }; -struct PublicKernelOutputComposer { +pub struct PublicKernelOutputComposer { output_builder: PublicKernelCircuitPublicInputsBuilder, } diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_kernel_output_validator.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_kernel_output_validator.nr index 04036c7c478..9894230f6fc 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_kernel_output_validator.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_kernel_output_validator.nr @@ -8,7 +8,7 @@ use dep::types::{ traits::is_empty, utils::arrays::{array_length, assert_array_appended, assert_array_prepended} }; -struct PublicKernelOutputValidator { +pub struct PublicKernelOutputValidator { output: PublicKernelCircuitPublicInputs, previous_kernel: PublicKernelCircuitPublicInputs, enqueued_call: VMCircuitPublicInputs, diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer.nr index f107f99ad11..e3756c8304d 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer.nr @@ -12,7 +12,7 @@ use dep::types::{ data::PublicDataLeafHint, partial_state_reference::PartialStateReference }; -struct PublicTailOutputComposer { +pub struct PublicTailOutputComposer { previous_kernel: PublicKernelCircuitPublicInputs, start_state: PartialStateReference, public_data_leaf_hints: [PublicDataLeafHint; NUM_PUBLIC_DATA_LEAVES], diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_output_hints.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_output_hints.nr index 8938c0e166c..f73a491339b 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_output_hints.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_output_hints.nr @@ -16,7 +16,7 @@ use dep::types::{ utils::arrays::{array_merge, CombinedOrderHint, get_combined_order_hints_asc, sort_by_counter_asc, SortedResult} }; -struct SiloedNoteHashHint { +pub struct SiloedNoteHashHint { siloed_note_hash: Field, index: u32, } @@ -33,7 +33,7 @@ impl Eq for SiloedNoteHashHint { } } -struct OutputHints { +pub struct OutputHints { siloed_note_hashes: [Field; MAX_NOTE_HASHES_PER_TX], siloed_note_hash_hints: [SiloedNoteHashHint; MAX_NOTE_HASHES_PER_TX], sorted_note_hash_hints: [CombinedOrderHint; MAX_NOTE_HASHES_PER_TX], diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_overridable_public_data_writes.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_overridable_public_data_writes.nr index 9ecb9d69902..143214a6b22 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_overridable_public_data_writes.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_overridable_public_data_writes.nr @@ -3,7 +3,7 @@ use dep::types::{ data::OverridablePublicDataTreeLeaf, traits::Empty, utils::arrays::{array_length, find_index_hint} }; -struct LinkedIndexHint { +pub struct LinkedIndexHint { is_first_write: bool, prev_index: u32, } diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_public_data_leaves.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_public_data_leaves.nr index 6df5c91dc6d..d3eeb603d92 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_public_data_leaves.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_public_data_leaves.nr @@ -4,7 +4,7 @@ use dep::types::{ utils::arrays::{get_sorted_result, SortedResult} }; -struct SlotIndex { +pub struct SlotIndex { slot: Field, index: u32, counter: u32, diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_validator.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_validator.nr index 4f6afcd9f52..97601499165 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_validator.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_validator.nr @@ -24,7 +24,7 @@ use dep::types::{ } }; -struct PublicTailOutputValidator { +pub struct PublicTailOutputValidator { output: KernelCircuitPublicInputs, previous_kernel: PublicKernelCircuitPublicInputs, start_state: PartialStateReference, diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/vm_circuit_output_composer.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/vm_circuit_output_composer.nr index 36e88cf7d39..eddc54ea0c2 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/vm_circuit_output_composer.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/vm_circuit_output_composer.nr @@ -18,7 +18,7 @@ use dep::types::{ }; // TODO(#7124): To be deprecated. -struct VMCircuitOutputComposer { +pub struct VMCircuitOutputComposer { constants: CombinedConstantData, call_request: PublicCallRequest, public_call_stack: BoundedVec, diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_app_logic.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_app_logic.nr new file mode 100644 index 00000000000..4bcb3ad9d9d --- /dev/null +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_app_logic.nr @@ -0,0 +1,523 @@ +use crate::{ + components::{ + previous_kernel_validator::PreviousKernelValidator, + public_call_data_validator::PublicCallDataValidator, + public_kernel_output_composer::PublicKernelOutputComposer +}, + public_kernel_phase::PublicKernelPhase +}; +use dep::types::{ + abis::{ + kernel_circuit_public_inputs::PublicKernelCircuitPublicInputs, public_kernel_data::PublicKernelData, + public_call_data::PublicCallData +}, + constants::{PUBLIC_KERNEL_SETUP_INDEX, PUBLIC_KERNEL_APP_LOGIC_INDEX, PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX} +}; + +global ALLOWED_PREVIOUS_CIRCUITS = [ + PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX, + PUBLIC_KERNEL_SETUP_INDEX, + PUBLIC_KERNEL_APP_LOGIC_INDEX, +]; + +pub struct PublicKernelAppLogicCircuitPrivateInputs { + previous_kernel: PublicKernelData, + public_call: PublicCallData, +} + +impl PublicKernelAppLogicCircuitPrivateInputs { + fn execute(self) -> PublicKernelCircuitPublicInputs { + let phase = PublicKernelPhase.APP_LOGIC; + + let previous_kernel_validator = PreviousKernelValidator::new(self.previous_kernel); + previous_kernel_validator.validate_phase(phase); + previous_kernel_validator.validate_proof(ALLOWED_PREVIOUS_CIRCUITS); + + let call_data_validator = PublicCallDataValidator::new(self.public_call, PublicKernelPhase.APP_LOGIC); + call_data_validator.validate(); + call_data_validator.validate_against_previous_kernel(self.previous_kernel.public_inputs); + + // noir-fmt:ignore + PublicKernelOutputComposer::new_from_previous_kernel(self.previous_kernel.public_inputs) + .remove_top_call_request(phase) + .propagate_from_public_call(self.public_call.call_stack_item.public_inputs, phase) + .finish() + } +} + +mod tests { + use crate::{public_kernel_app_logic::{PublicKernelAppLogicCircuitPrivateInputs, ALLOWED_PREVIOUS_CIRCUITS}}; + use dep::types::{ + abis::{ + gas::Gas, kernel_circuit_public_inputs::PublicKernelCircuitPublicInputs, + nullifier::{Nullifier, ScopedNullifier}, + public_call_stack_item_compressed::PublicCallStackItemCompressed, + public_data_read::PublicDataRead, public_data_update_request::PublicDataUpdateRequest + }, + constants::{PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX, PUBLIC_KERNEL_APP_LOGIC_INDEX}, + contrakt::{storage_read::StorageRead, storage_update_request::StorageUpdateRequest}, + address::AztecAddress, hash::compute_siloed_nullifier, + tests::{fixture_builder::FixtureBuilder, utils::assert_array_eq}, traits::is_empty + }; + + struct PublicKernelAppLogicCircuitPrivateInputsBuilder { + previous_kernel: FixtureBuilder, + previous_non_revertible: FixtureBuilder, + public_call: FixtureBuilder, + } + + impl PublicKernelAppLogicCircuitPrivateInputsBuilder { + pub fn new() -> Self { + let previous_kernel = FixtureBuilder::new().as_parent_contract().in_vk_tree(PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX); + let previous_non_revertible = FixtureBuilder::new().as_parent_contract(); + let mut public_call = FixtureBuilder::new().is_public_function(); + public_call.value_offset = 9999; // Add an offset so that the mock data won't be the same as the values in previous_kernel. + + PublicKernelAppLogicCircuitPrivateInputsBuilder { previous_kernel, previous_non_revertible, public_call } + } + + pub fn is_delegate_call(&mut self) -> Self { + let _ = self.public_call.is_delegate_call(); + *self + } + + pub fn to_public_data_reads(self, contract_storage_reads: [StorageRead; N]) -> [PublicDataRead; N] { + let storage_contract_address = self.public_call.storage_contract_address; + contract_storage_reads.map(|r: StorageRead| PublicDataRead::from_contract_storage_read(storage_contract_address, r)) + } + + pub fn to_public_data_update_requests( + self, + storage_update_requests: [StorageUpdateRequest; N] + ) -> [PublicDataUpdateRequest; N] { + let storage_contract_address = self.public_call.storage_contract_address; + storage_update_requests.map( + |r: StorageUpdateRequest| + PublicDataUpdateRequest::from_contract_storage_update_request(storage_contract_address, r) + ) + } + + pub fn to_siloed_nullifiers(self, nullifiers: [ScopedNullifier; N]) -> [Nullifier; N] { + let storage_contract_address = self.public_call.storage_contract_address; + nullifiers.map( + |n: ScopedNullifier| Nullifier { + value: compute_siloed_nullifier(storage_contract_address, n.value()), + note_hash: n.nullifier.note_hash, + counter: n.counter() + } + ) + } + + pub fn execute(&mut self) -> PublicKernelCircuitPublicInputs { + let public_call = self.public_call.to_public_call_data(); + // Adjust the call stack item hash for the current call in the previous iteration. + let compressed = public_call.call_stack_item.get_compressed(); + self.previous_kernel.push_public_call_request(compressed); + let mut previous_kernel = self.previous_kernel.to_public_kernel_data(true); + previous_kernel.public_inputs.end_non_revertible = self.previous_non_revertible.to_public_accumulated_data(); + + let kernel = PublicKernelAppLogicCircuitPrivateInputs { previous_kernel, public_call }; + + kernel.execute() + } + + pub fn get_call_request_item(self) -> PublicCallStackItemCompressed { + self.public_call.to_public_call_stack_item().get_compressed() + } + + pub fn failed_with_call_request_item(&mut self, item: PublicCallStackItemCompressed) { + let public_call = self.public_call.to_public_call_data(); + self.previous_kernel.push_public_call_request(item); + let previous_kernel = self.previous_kernel.to_public_kernel_data(true); + let kernel = PublicKernelAppLogicCircuitPrivateInputs { previous_kernel, public_call }; + let _ = kernel.execute(); + } + + pub fn succeeded(&mut self) { + let _ = self.execute(); + } + + pub fn failed(&mut self) { + let _ = self.execute(); + } + } + + #[test] + fn public_kernel_circuit_with_public_previous_kernel_should_succeed() { + let mut builder = PublicKernelAppLogicCircuitPrivateInputsBuilder::new(); + builder.succeeded(); + } + + #[test(should_fail_with="Cannot run unnecessary app logic circuit")] + fn public_previous_kernel_private_previous_kernel_should_fail() { + let mut builder = PublicKernelAppLogicCircuitPrivateInputsBuilder::new(); + builder.previous_kernel = FixtureBuilder::new().in_vk_tree(PUBLIC_KERNEL_APP_LOGIC_INDEX); + let public_call = builder.public_call.to_public_call_data(); + + // the key difference in this test versus those that use builder.execute() + // is that we do not add a public call request to the previous kernel. + // this means that when we call `to_public_kernel_data` below, + // it will say needs_app_logic is false + + let previous_kernel = builder.previous_kernel.to_public_kernel_data(true); + + let kernel = PublicKernelAppLogicCircuitPrivateInputs { previous_kernel, public_call }; + + let _ = kernel.execute(); + } + + #[test] + fn circuit_outputs_should_be_correctly_populated_with_previous_commitments() { + let mut builder = PublicKernelAppLogicCircuitPrivateInputsBuilder::new(); + + // Setup 1 non-revertible note hash and log on the previous kernel. + builder.previous_non_revertible.append_note_hashes_with_logs(1); + let prev_non_rev_notes = builder.previous_non_revertible.note_hashes.storage; + let prev_non_rev_logs = builder.previous_non_revertible.to_public_accumulated_data().note_encrypted_logs_hashes; + + // Setup 2 revertible note hashes and logs on the previous kernel. + builder.previous_kernel.append_note_hashes_with_logs(2); + let prev_notes = builder.previous_kernel.note_hashes.storage; + let prev_logs = builder.previous_kernel.to_public_accumulated_data().note_encrypted_logs_hashes; + + // Setup 2 note hashes and logs on the current public call. + builder.public_call.append_note_hashes(2); + let curr_notes = builder.public_call.note_hashes.storage; + + let public_inputs = builder.execute(); + + assert_array_eq( + public_inputs.end_non_revertible.note_hashes, + [prev_non_rev_notes[0]] + ); + assert_array_eq( + public_inputs.end.note_hashes, + [prev_notes[0], prev_notes[1], curr_notes[0], curr_notes[1]] + ); + assert_array_eq( + public_inputs.end_non_revertible.note_encrypted_logs_hashes, + [prev_non_rev_logs[0]] + ); + assert_array_eq( + public_inputs.end.note_encrypted_logs_hashes, + [prev_logs[0], prev_logs[1]] + ); + } + + #[test] + fn circuit_outputs_should_be_correctly_populated_with_previous_update_requests() { + let mut builder = PublicKernelAppLogicCircuitPrivateInputsBuilder::new(); + + // Setup 2 data writes on the previous kernel. + builder.previous_kernel.append_public_data_update_requests(2); + let previous = builder.previous_kernel.public_data_update_requests.storage; + // Setup 2 data writes on the current public inputs. + builder.public_call.append_contract_storage_update_requests(2); + let current = builder.to_public_data_update_requests(builder.public_call.contract_storage_update_requests.storage); + + let public_inputs = builder.execute(); + + assert_array_eq( + public_inputs.end.public_data_update_requests, + [previous[0], previous[1], current[0], current[1]] + ); + } + + #[test] + fn circuit_outputs_should_be_correctly_populated_with_previous_read_requests() { + let mut builder = PublicKernelAppLogicCircuitPrivateInputsBuilder::new(); + + // Setup 2 data reads on the previous kernel. + builder.previous_kernel.append_public_data_read_requests(2); + let previous = builder.previous_kernel.public_data_reads.storage; + // Setup 2 data reads on the current public inputs. + builder.public_call.append_contract_storage_read_requests(2); + let current = builder.to_public_data_reads(builder.public_call.contract_storage_reads.storage); + + let public_inputs = builder.execute(); + + assert_array_eq( + public_inputs.validation_requests.public_data_reads, + [previous[0], previous[1], current[0], current[1]] + ); + } + + #[test] + fn circuit_outputs_should_be_correctly_populated_with_previous_nullifiers() { + let mut builder = PublicKernelAppLogicCircuitPrivateInputsBuilder::new(); + + // Setup 2 new nullifiers on the previous kernel. + builder.previous_kernel.append_nullifiers(2); + let previous = builder.previous_kernel.nullifiers.storage.map(|n: ScopedNullifier| n.nullifier); + // Setup 2 new nullifiers on the current public call. + builder.public_call.append_nullifiers(2); + let siloed = builder.to_siloed_nullifiers(builder.public_call.nullifiers.storage); + + let public_inputs = builder.execute(); + + assert_array_eq( + public_inputs.end.nullifiers, + [previous[0], previous[1], siloed[0], siloed[1]] + ); + } + + #[test] + fn circuit_outputs_should_be_correctly_populated_with_previous_l2_to_l1_msg() { + let mut builder = PublicKernelAppLogicCircuitPrivateInputsBuilder::new(); + + builder.previous_kernel.append_l2_to_l1_msgs(1); + let previous = builder.previous_kernel.l2_to_l1_msgs.storage; + // Setup 1 new l2 to l1 message on the current public inputs. + builder.public_call.append_l2_to_l1_msgs(1); + let current = builder.public_call.l2_to_l1_msgs.storage; + + let public_inputs = builder.execute(); + + assert_array_eq(public_inputs.end.l2_to_l1_msgs, [previous[0], current[0]]); + } + // TODO: Break up this test into smaller tests. + #[test] + fn circuit_outputs_should_be_correctly_populated_with_previous_public_kernel_logs() { + let mut builder = PublicKernelAppLogicCircuitPrivateInputsBuilder::new(); + // Logs for the current call stack. + builder.public_call.append_unencrypted_log_hashes(1); + let curr_data = builder.public_call.to_public_accumulated_data(); + + // Logs for the previous call stack. + builder.previous_kernel.append_encrypted_log_hashes(1); + builder.previous_kernel.append_unencrypted_log_hashes(1); + let prev_data = builder.previous_kernel.to_public_accumulated_data(); + let expected_unencrypted_logs = [prev_data.unencrypted_logs_hashes[0], curr_data.unencrypted_logs_hashes[0]]; + // we assume the encrypted log is already siloed from private kernels + let expected_encrypted_logs = [prev_data.encrypted_logs_hashes[0]]; + + let public_inputs = builder.execute(); + + assert_array_eq( + public_inputs.end.encrypted_logs_hashes, + expected_encrypted_logs + ); + assert_array_eq( + public_inputs.end.unencrypted_logs_hashes, + expected_unencrypted_logs + ); + } + + #[test(should_fail_with="No contract storage update requests are allowed for static calls")] + fn previous_public_kernel_fails_if_contract_storage_update_requests_on_static_call() { + let mut builder = PublicKernelAppLogicCircuitPrivateInputsBuilder::new(); + builder.public_call.is_static_call = true; + builder.public_call.append_contract_storage_update_requests(1); + + builder.failed(); + } + + #[test(should_fail_with="curent contract address must not match storage contract address for delegate calls")] + fn previous_public_kernel_fails_if_incorrect_storage_contract_on_delegate_call() { + let mut builder = PublicKernelAppLogicCircuitPrivateInputsBuilder::new().is_delegate_call(); + + builder.public_call.contract_address = builder.public_call.storage_contract_address; + + builder.failed(); + } + + #[test(should_fail_with="note_hashes must be empty for static calls")] + fn public_kernel_fails_creating_note_hashes_on_static_call() { + let mut builder = PublicKernelAppLogicCircuitPrivateInputsBuilder::new(); + builder.public_call.is_static_call = true; + builder.public_call.append_note_hashes(1); + + builder.failed(); + } + + #[test(should_fail_with="nullifiers must be empty for static calls")] + fn public_kernel_fails_creating_nullifiers_on_static_call() { + let mut builder = PublicKernelAppLogicCircuitPrivateInputsBuilder::new(); + builder.public_call.is_static_call = true; + builder.public_call.append_nullifiers(1); + + builder.failed(); + } + + #[test(should_fail_with="call stack item does not match item at the top of the call stack")] + fn public_kernel_circuit_fails_on_incorrect_storage_contract_in_delegate_call() { + let mut builder = PublicKernelAppLogicCircuitPrivateInputsBuilder::new().is_delegate_call(); + + let mut item = builder.get_call_request_item(); + // Set the storage contract address to be the contract address. + item.call_context.storage_contract_address = builder.public_call.contract_address; + + builder.failed_with_call_request_item(item); + } + + #[test] + fn circuit_outputs_should_be_correctly_populated_with_public_call_requests() { + let mut builder = PublicKernelAppLogicCircuitPrivateInputsBuilder::new(); + + builder.previous_kernel.append_public_call_requests(2); + let prev_calls = builder.previous_kernel.public_call_requests.storage; + + builder.public_call.append_public_call_requests(2); + let curr_calls = builder.public_call.public_call_requests.storage; + + let public_inputs = builder.execute(); + + assert_array_eq( + public_inputs.end.public_call_stack, + [prev_calls[0], prev_calls[1], curr_calls[0], curr_calls[1]] + ); + } + + #[test(should_fail_with="Cannot run app logic circuit before setup circuit")] + fn previous_kernel_non_empty_non_revertible_public_call_requests_should_fail() { + let mut builder = PublicKernelAppLogicCircuitPrivateInputsBuilder::new(); + + builder.previous_non_revertible.append_public_call_requests(1); + builder.public_call.append_public_call_requests(1); + + builder.failed(); + } + + #[test] + fn propagate_nullifier_non_existent_read_requests() { + let mut builder = PublicKernelAppLogicCircuitPrivateInputsBuilder::new(); + + builder.public_call.append_nullifier_non_existent_read_requests(2); + let requests = builder.public_call.nullifier_non_existent_read_requests.storage; + + let public_inputs = builder.execute(); + + let end_requests = public_inputs.validation_requests.nullifier_non_existent_read_requests; + assert_array_eq(end_requests, [requests[0], requests[1]]); + } + + #[test] + fn updates_revertible_gas_used() { + let mut builder = PublicKernelAppLogicCircuitPrivateInputsBuilder::new(); + + // Transaction gas limit is 1k + builder.previous_kernel.tx_context.gas_settings.gas_limits = Gas::new(1000, 1000); + + // Revertible has already used 300 + builder.previous_kernel.gas_used = Gas::new(300, 300); + + // This call starts with 700 gas left + builder.public_call.start_gas_left = Gas::new(700, 700); + + // And uses 200, ending with 500 left + builder.public_call.end_gas_left = Gas::new(500, 500); + + // So the updated gas used by revertible must go up by 200, and non-revertible must stay the same + let output = builder.execute(); + assert_eq(output.end.gas_used, Gas::new(500, 500)); + assert_eq(output.end_non_revertible.gas_used, Gas::new(0, 0)); + } + + #[test(should_fail_with="Start gas for public phase does not match transaction gas left")] + fn validates_start_gas() { + let mut builder = PublicKernelAppLogicCircuitPrivateInputsBuilder::new(); + + builder.public_call.is_execution_request = true; // don't need to check start gas for nested calls + builder.public_call.start_gas_left = Gas::new(100, 100); + + builder.failed(); + } + + #[test(should_fail_with="Transaction fee must be zero on setup and app phases")] + fn validates_transaction_fee() { + let mut builder = PublicKernelAppLogicCircuitPrivateInputsBuilder::new(); + + builder.public_call.transaction_fee = 10; + + builder.failed(); + } + + #[test] + fn propagates_global_variables_if_empty() { + let mut builder = PublicKernelAppLogicCircuitPrivateInputsBuilder::new(); + + builder.public_call.global_variables.block_number = 11; + + let public_inputs = builder.execute(); + + assert_eq(public_inputs.constants.global_variables.block_number, 11); + } + + #[test(should_fail_with="Global variables injected into the public call do not match constants")] + fn validates_global_variables() { + let mut builder = PublicKernelAppLogicCircuitPrivateInputsBuilder::new(); + + builder.previous_kernel.global_variables.block_number = 10; + builder.public_call.global_variables.block_number = 11; + + builder.failed(); + } + + #[test] + unconstrained fn propagate_fee_payer() { + let mut builder = PublicKernelAppLogicCircuitPrivateInputsBuilder::new(); + let fee_payer = AztecAddress::from_field(123); + builder.previous_kernel.set_fee_payer(fee_payer); + let public_inputs = builder.execute(); + assert_eq(public_inputs.fee_payer, fee_payer); + + // Check that the fee payer is not set if is_fee_payer is false + let mut builder = PublicKernelAppLogicCircuitPrivateInputsBuilder::new(); + assert_eq(is_empty(builder.previous_kernel.fee_payer), true); + let public_inputs = builder.execute(); + assert_eq(public_inputs.fee_payer, AztecAddress::empty()); + } + + #[test] + unconstrained fn correctly_updates_revert_code() { + let mut builder = PublicKernelAppLogicCircuitPrivateInputsBuilder::new(); + let public_inputs = builder.execute(); + assert_eq(public_inputs.revert_code, 0); + + let mut builder = PublicKernelAppLogicCircuitPrivateInputsBuilder::new(); + builder.public_call.revert_code = 1; + let public_inputs = builder.execute(); + assert_eq(public_inputs.revert_code, 1); + + let mut builder = PublicKernelAppLogicCircuitPrivateInputsBuilder::new(); + builder.previous_kernel.revert_code = 1; + let public_inputs = builder.execute(); + assert_eq(public_inputs.revert_code, 1); + } + + #[test] + fn clears_stack_if_current_call_revert_code_is_set() { + let mut builder = PublicKernelAppLogicCircuitPrivateInputsBuilder::new(); + builder.public_call.revert_code = 1; + + builder.previous_kernel.append_public_call_requests(2); + + builder.previous_kernel.append_public_teardown_call_requests(2); + let teardown_calls = builder.previous_kernel.public_teardown_call_stack.storage; + + let public_inputs = builder.execute(); + + assert_array_eq(public_inputs.end.public_call_stack, []); + assert_array_eq( + public_inputs.public_teardown_call_stack, + [teardown_calls[0], teardown_calls[1]] + ); + } + + #[test] + fn valid_previous_kernel() { + for i in 0..ALLOWED_PREVIOUS_CIRCUITS.len() { + let mut builder = PublicKernelAppLogicCircuitPrivateInputsBuilder::new(); + builder.previous_kernel = builder.previous_kernel.in_vk_tree(ALLOWED_PREVIOUS_CIRCUITS[i]); + + let _res = builder.execute(); + } + } + // TODO(#7410) we need the tube vk to reinstate this + // #[test(should_fail_with="Invalid vk index")] + // fn invalid_previous_kernel() { + // let mut builder = PublicKernelAppLogicCircuitPrivateInputsBuilder::new(); + // builder.previous_kernel = builder.previous_kernel.in_vk_tree(BASE_ROLLUP_INDEX); + // let _res = builder.execute(); + // } +} diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_inner.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_inner.nr index c08d5b0f026..eaff4176460 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_inner.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_inner.nr @@ -7,7 +7,7 @@ use dep::types::{ }; // TODO(#7124): To be deprecated. -struct PublicKernelInnerCircuitPrivateInputs { +pub struct PublicKernelInnerCircuitPrivateInputs { previous_kernel: PublicKernelInnerData, public_call: PublicCallData, } diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_merge.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_merge.nr index ad2b4a14df4..ebfd605cee7 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_merge.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_merge.nr @@ -20,7 +20,7 @@ global ALLOWED_PREVIOUS_CIRCUITS = [ PUBLIC_KERNEL_MERGE_INDEX, ]; -struct PublicKernelMergeCircuitPrivateInputs { +pub struct PublicKernelMergeCircuitPrivateInputs { previous_kernel: PublicKernelData, enqueued_call: EnqueuedCallData, } diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_setup.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_setup.nr new file mode 100644 index 00000000000..04a1fdbe9da --- /dev/null +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_setup.nr @@ -0,0 +1,512 @@ +use crate::{ + components::{ + previous_kernel_validator::PreviousKernelValidator, + public_call_data_validator::PublicCallDataValidator, + public_kernel_output_composer::PublicKernelOutputComposer +}, + public_kernel_phase::PublicKernelPhase +}; +use dep::types::{ + abis::{ + kernel_circuit_public_inputs::PublicKernelCircuitPublicInputs, public_kernel_data::PublicKernelData, + public_call_data::PublicCallData +}, + constants::{PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX, PUBLIC_KERNEL_SETUP_INDEX} +}; + +global ALLOWED_PREVIOUS_CIRCUITS = [ + PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX, + PUBLIC_KERNEL_SETUP_INDEX, +]; + +pub struct PublicKernelSetupCircuitPrivateInputs { + // Note: One might think that our previous_kernel ought to be + // a PrivateKernelTailData. However, we instead supply a PublicKernelData. + // This is because PrivateKernelTailData is a subset of PublicKernelData. + // And we just initialize the missing values to zero in TS before passing it to the circuit, + // except for the constants.global_variables which we populate with the current block values. + // This is a bit of a hack, but it allows us to reuse the setup circuit until + // the setup phase of the public kernel is complete. Maybe in a perfect world we would + // have a SetupInit, SetupInner, etc, but this will change anyway once the public VM is able to + // consume entire enqueued public calls. + previous_kernel: PublicKernelData, + public_call: PublicCallData, +} + +impl PublicKernelSetupCircuitPrivateInputs { + fn execute(self) -> PublicKernelCircuitPublicInputs { + let phase = PublicKernelPhase.SETUP; + + let previous_kernel_validator = PreviousKernelValidator::new(self.previous_kernel); + previous_kernel_validator.validate_phase(phase); + previous_kernel_validator.validate_proof(ALLOWED_PREVIOUS_CIRCUITS); + + let call_data_validator = PublicCallDataValidator::new(self.public_call, phase); + call_data_validator.validate(); + call_data_validator.validate_against_previous_kernel(self.previous_kernel.public_inputs); + + // noir-fmt:ignore + PublicKernelOutputComposer::new_from_previous_kernel(self.previous_kernel.public_inputs) + .remove_top_call_request(phase) + .propagate_from_public_call(self.public_call.call_stack_item.public_inputs, phase) + .finish() + } +} + +mod tests { + use crate::{public_kernel_setup::{PublicKernelSetupCircuitPrivateInputs, ALLOWED_PREVIOUS_CIRCUITS}}; + use dep::types::{ + abis::{ + function_selector::FunctionSelector, gas::Gas, + kernel_circuit_public_inputs::PublicKernelCircuitPublicInputs, max_block_number::MaxBlockNumber, + public_call_stack_item_compressed::PublicCallStackItemCompressed, + public_data_read::PublicDataRead, public_data_update_request::PublicDataUpdateRequest, + read_request::ReadRequest + }, + address::AztecAddress, constants::PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX, + contrakt::{storage_read::StorageRead, storage_update_request::StorageUpdateRequest}, + tests::{fixture_builder::FixtureBuilder, utils::assert_array_eq}, traits::is_empty + }; + + struct PublicKernelSetupCircuitPrivateInputsBuilder { + previous_kernel: FixtureBuilder, + previous_revertible: FixtureBuilder, + public_call: FixtureBuilder, + } + + impl PublicKernelSetupCircuitPrivateInputsBuilder { + pub fn new() -> Self { + let previous_kernel = FixtureBuilder::new().as_parent_contract().in_vk_tree(PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX); + let previous_revertible = FixtureBuilder::new(); + let mut public_call = FixtureBuilder::new().is_public_function(); + public_call.value_offset = 9999; // Add an offset so that the mock data won't be the same as the values in previous_kernel. + + PublicKernelSetupCircuitPrivateInputsBuilder { previous_kernel, previous_revertible, public_call } + } + + pub fn is_delegate_call(&mut self) -> Self { + let _ = self.public_call.is_delegate_call(); + *self + } + + pub fn to_public_data_reads(self, contract_storage_reads: [StorageRead; N]) -> [PublicDataRead; N] { + let storage_contract_address = self.public_call.storage_contract_address; + contract_storage_reads.map(|r: StorageRead| PublicDataRead::from_contract_storage_read(storage_contract_address, r)) + } + + pub fn to_public_data_update_requests( + self, + storage_update_requests: [StorageUpdateRequest; N] + ) -> [PublicDataUpdateRequest; N] { + let storage_contract_address = self.public_call.storage_contract_address; + storage_update_requests.map( + |r: StorageUpdateRequest| + PublicDataUpdateRequest::from_contract_storage_update_request(storage_contract_address, r) + ) + } + + pub fn execute(&mut self) -> PublicKernelCircuitPublicInputs { + let public_call = self.public_call.to_public_call_data(); + + // In order to run the setup circuit, we must have an enqueued public call for setup. + let compressed_item = public_call.call_stack_item.get_compressed(); + self.previous_kernel.push_public_call_request(compressed_item); + + let mut previous_kernel = self.previous_kernel.to_public_kernel_data(false); + + previous_kernel.public_inputs.end = self.previous_revertible.to_public_accumulated_data(); + + // Run the kernel on the setup call + let kernel = PublicKernelSetupCircuitPrivateInputs { previous_kernel, public_call }; + kernel.execute() + } + + pub fn get_call_request_item(self) -> PublicCallStackItemCompressed { + self.public_call.to_public_call_stack_item().get_compressed() + } + + pub fn failed_with_call_request_item(&mut self, item: PublicCallStackItemCompressed) { + let public_call = self.public_call.to_public_call_data(); + self.previous_kernel.push_public_call_request(item); + let previous_kernel = self.previous_kernel.to_public_kernel_data(false); + + let kernel = PublicKernelSetupCircuitPrivateInputs { previous_kernel, public_call }; + let _ = kernel.execute(); + } + + pub fn succeeded(&mut self) { + let _ = self.execute(); + } + + pub fn failed(&mut self) { + let _ = self.execute(); + } + } + + #[test(should_fail_with="Bytecode hash cannot be zero")] + fn no_bytecode_hash_should_fail() { + let mut builder = PublicKernelSetupCircuitPrivateInputsBuilder::new(); + builder.public_call.bytecode_hash = 0; + + builder.failed(); + } + + #[test(should_fail_with="Contract address cannot be zero")] + fn contract_address_must_be_valid() { + let mut builder = PublicKernelSetupCircuitPrivateInputsBuilder::new(); + + builder.previous_kernel.append_public_call_requests(1); + builder.public_call.contract_address = AztecAddress::zero(); + + builder.failed(); + } + + #[test(should_fail_with="Function signature cannot be zero")] + fn function_selector_must_be_valid() { + let mut builder = PublicKernelSetupCircuitPrivateInputsBuilder::new(); + builder.public_call.function_data.selector = FunctionSelector::zero(); + + builder.failed(); + } + + #[test(should_fail_with="Cannot execute a private function with the public kernel circuit")] + fn private_call_should_fail() { + let mut builder = PublicKernelSetupCircuitPrivateInputsBuilder::new(); + builder.public_call.function_data.is_private = true; + + builder.failed(); + } + + #[test(should_fail_with="call stack item does not match item at the top of the call stack")] + fn inconsistent_call_request_item_should_fail() { + let mut builder = PublicKernelSetupCircuitPrivateInputsBuilder::new(); + + let mut item = builder.get_call_request_item(); + // Tweak the call stack item. + item.args_hash += 1; + + builder.failed_with_call_request_item(item); + } + + #[test(should_fail_with="call stack item does not match item at the top of the call stack")] + fn incorrect_msg_sender_fails_for_regular_calls() { + let mut builder = PublicKernelSetupCircuitPrivateInputsBuilder::new(); + + let mut item = builder.get_call_request_item(); + // Set the msg_sender to a wrong value. + item.call_context.msg_sender.inner += 1; + + builder.failed_with_call_request_item(item); + } + + #[test(should_fail_with="call stack storage address does not match expected contract address")] + fn incorrect_storage_contract_address_fails_for_regular_calls() { + let mut builder = PublicKernelSetupCircuitPrivateInputsBuilder::new(); + + // Set the storage contract address to a wrong value. + builder.public_call.storage_contract_address.inner += 1; + + builder.failed(); + } + + #[test] + fn delegate_call_succeeds() { + let mut builder = PublicKernelSetupCircuitPrivateInputsBuilder::new().is_delegate_call(); + builder.succeeded(); + } + + #[test(should_fail_with="call stack item does not match item at the top of the call stack")] + fn incorrect_msg_sender_for_delegate_calls_fails() { + let mut builder = PublicKernelSetupCircuitPrivateInputsBuilder::new().is_delegate_call(); + + let mut item = builder.get_call_request_item(); + // Set the msg_sender to be the caller contract. + item.call_context.msg_sender = builder.previous_kernel.contract_address; + + builder.failed_with_call_request_item(item); + } + + #[test(should_fail_with="curent contract address must not match storage contract address for delegate calls")] + fn previous_private_kernel_fails_if_incorrect_storage_contract_on_delegate_call() { + let mut builder = PublicKernelSetupCircuitPrivateInputsBuilder::new().is_delegate_call(); + + builder.public_call.contract_address = builder.public_call.storage_contract_address; + + builder.failed(); + } + + #[test(should_fail_with = "incorrect storage_contract_address for call request")] + fn incorrect_storage_contract_address_for_call_request_fails() { + let mut builder = PublicKernelSetupCircuitPrivateInputsBuilder::new(); + + builder.public_call.append_public_call_requests(1); + let mut call_request = builder.public_call.public_call_requests.pop(); + // Change the caller contract address to be a different value. + call_request.item.call_context.storage_contract_address.inner += 1; + builder.public_call.public_call_requests.push(call_request); + + builder.failed(); + } + + #[test(should_fail_with="incorrect storage_contract_address for delegate call request")] + fn incorrect_call_context_for_delegate_call_request_fails() { + let mut builder = PublicKernelSetupCircuitPrivateInputsBuilder::new(); + + builder.public_call.append_public_call_requests_delegate(1); + let mut call_request = builder.public_call.public_call_requests.pop(); + // Change the storage contract address to be the contract address. + call_request.item.call_context.storage_contract_address = call_request.item.contract_address; + builder.public_call.public_call_requests.push(call_request); + + builder.failed(); + } + + #[test] + fn public_kernel_circuit_with_private_previous_kernel_should_succeed() { + let mut builder = PublicKernelSetupCircuitPrivateInputsBuilder::new(); + builder.succeeded(); + } + + #[test] + fn circuit_outputs_should_be_correctly_populated_with_previous_private_kernel() { + let mut builder = PublicKernelSetupCircuitPrivateInputsBuilder::new(); + + builder.previous_kernel.max_block_number = MaxBlockNumber::new(13); + + builder.public_call.append_public_call_requests(2); + let curr_calls = builder.public_call.public_call_requests.storage; + + builder.previous_kernel.append_public_call_requests(1); + let prev_calls = builder.previous_kernel.public_call_requests.storage; + + builder.public_call.append_contract_storage_update_requests(2); + let update_requests = builder.public_call.contract_storage_update_requests.storage; + + builder.public_call.append_contract_storage_read_requests(3); + let read_requests = builder.public_call.contract_storage_reads.storage; + + let public_inputs = builder.execute(); + + assert_eq(public_inputs.validation_requests.for_rollup.max_block_number.unwrap(), 13); + assert_array_eq( + public_inputs.end_non_revertible.public_call_stack, + [prev_calls[0], curr_calls[0], curr_calls[1]] + ); + assert_array_eq( + public_inputs.end_non_revertible.public_data_update_requests, + builder.to_public_data_update_requests([update_requests[0], update_requests[1]]) + ); + assert_array_eq( + public_inputs.validation_requests.public_data_reads, + builder.to_public_data_reads([read_requests[0], read_requests[1], read_requests[2]]) + ); + } + + #[test(should_fail_with="Cannot run unnecessary setup circuit")] + fn previous_kernel_empty_public_call_stack_should_fail() { + let builder = PublicKernelSetupCircuitPrivateInputsBuilder::new(); + let previous_kernel = builder.previous_kernel.to_public_kernel_data(false); + let public_call = builder.public_call.to_public_call_data(); + let kernel = PublicKernelSetupCircuitPrivateInputs { previous_kernel, public_call }; + let _ = kernel.execute(); + } + + #[test(should_fail_with="No contract storage update requests are allowed for static calls")] + fn previous_private_kernel_fails_if_contract_storage_update_requests_on_static_call() { + let mut builder = PublicKernelSetupCircuitPrivateInputsBuilder::new(); + builder.public_call.is_static_call = true; + builder.public_call.append_contract_storage_update_requests(1); + + builder.failed(); + } + + #[test] + fn logs_are_handled_as_expected() { + let mut builder = PublicKernelSetupCircuitPrivateInputsBuilder::new(); + + // Logs for the current call stack. + let unencrypted_logs_hash = 26; + let unencrypted_log_preimages_length = 50; + builder.public_call.add_unencrypted_log_hash(unencrypted_logs_hash, unencrypted_log_preimages_length); + + // Logs for the previous call stack. + let prev_encrypted_logs_hash = 80; + let prev_encrypted_log_preimages_length = 13; + let prev_unencrypted_logs_hash = 956; + let prev_unencrypted_log_preimages_length = 24; + builder.previous_kernel.add_encrypted_log_hash(prev_encrypted_logs_hash, prev_encrypted_log_preimages_length); + builder.previous_kernel.add_unencrypted_log_hash( + prev_unencrypted_logs_hash, + prev_unencrypted_log_preimages_length + ); + let prev_data = builder.previous_kernel.to_public_accumulated_data(); + + let expected_unencrypted_logs = [prev_data.unencrypted_logs_hashes[0], builder.public_call.unencrypted_logs_hashes.storage[0]]; + // we assume the encrypted log is already siloed from private kernels + let expected_encrypted_logs = [prev_data.encrypted_logs_hashes[0]]; + + let public_inputs = builder.execute(); + + assert_array_eq( + public_inputs.end_non_revertible.encrypted_logs_hashes, + expected_encrypted_logs + ); + assert_array_eq( + public_inputs.end_non_revertible.unencrypted_logs_hashes, + expected_unencrypted_logs + ); + } + + #[test] + fn propagate_nullifier_non_existent_read_requests() { + let mut builder = PublicKernelSetupCircuitPrivateInputsBuilder::new(); + let storage_contract_address = builder.public_call.storage_contract_address; + + let request_0 = ReadRequest { value: 123, counter: 4567 }.scope(storage_contract_address); + builder.public_call.nullifier_non_existent_read_requests.push(request_0); + let request_1 = ReadRequest { value: 777888, counter: 90 }.scope(storage_contract_address); + builder.public_call.nullifier_non_existent_read_requests.push(request_1); + + let public_inputs = builder.execute(); + + let end_requests = public_inputs.validation_requests.nullifier_non_existent_read_requests; + assert_array_eq(end_requests, [request_0, request_1]); + } + + #[test(should_fail_with="Public call cannot be reverted")] + fn fails_if_public_call_reverted() { + let mut builder = PublicKernelSetupCircuitPrivateInputsBuilder::new(); + builder.public_call.revert_code = 1; + + builder.failed(); + } + + #[test] + fn updates_non_revertible_gas_used() { + let mut builder = PublicKernelSetupCircuitPrivateInputsBuilder::new(); + + // Transaction gas limit is 1k + builder.previous_kernel.tx_context.gas_settings.gas_limits = Gas::new(1000, 1000); + + // Revertible has already used 100 + builder.previous_revertible.gas_used = Gas::new(100, 100); + + // And non-revertible has used another 200 + builder.previous_kernel.gas_used = Gas::new(200, 200); + + // So this call starts with 700 gas left + builder.public_call.start_gas_left = Gas::new(700, 700); + + // And uses 300, ending with 400 left + builder.public_call.end_gas_left = Gas::new(400, 400); + + // So the updated gas used by non-revertible must go up by 300, and revertible must stay the same + let output = builder.execute(); + assert_eq(output.end_non_revertible.gas_used, Gas::new(500, 500)); + assert_eq(output.end.gas_used, Gas::new(100, 100)); + } + + #[test(should_fail_with="Start gas for public phase does not match transaction gas left")] + fn validates_start_gas() { + let mut builder = PublicKernelSetupCircuitPrivateInputsBuilder::new(); + + builder.public_call.is_execution_request = true; // don't need to check start gas for nested calls + builder.public_call.start_gas_left = Gas::new(100, 100); + + builder.failed(); + } + + #[test(should_fail_with="Transaction fee must be zero on setup and app phases")] + fn validates_transaction_fee() { + let mut builder = PublicKernelSetupCircuitPrivateInputsBuilder::new(); + + builder.public_call.transaction_fee = 10; + + builder.failed(); + } + + #[test] + fn propagates_global_variables_if_empty() { + let mut builder = PublicKernelSetupCircuitPrivateInputsBuilder::new(); + + builder.public_call.global_variables.block_number = 11; + + let public_inputs = builder.execute(); + + assert_eq(public_inputs.constants.global_variables.block_number, 11); + } + + #[test(should_fail_with="Global variables injected into the public call do not match constants")] + fn validates_global_variables() { + let mut builder = PublicKernelSetupCircuitPrivateInputsBuilder::new(); + + builder.previous_kernel.global_variables.block_number = 10; + builder.public_call.global_variables.block_number = 11; + + builder.failed(); + } + + #[test] + unconstrained fn propagate_fee_payer() { + let mut builder = PublicKernelSetupCircuitPrivateInputsBuilder::new(); + let fee_payer = AztecAddress::from_field(123); + builder.previous_kernel.set_fee_payer(fee_payer); + let public_inputs = builder.execute(); + assert_eq(public_inputs.fee_payer, fee_payer); + + // Check that the fee payer is not set if is_fee_payer is false + let mut builder = PublicKernelSetupCircuitPrivateInputsBuilder::new(); + assert_eq(is_empty(builder.previous_kernel.fee_payer), true); + let public_inputs = builder.execute(); + assert_eq(public_inputs.fee_payer, AztecAddress::empty()); + } + + #[test] + fn propagate_call_stacks_on_success() { + let mut builder = PublicKernelSetupCircuitPrivateInputsBuilder::new(); + + builder.previous_kernel.append_public_call_requests(1); + let prev_non_rev_calls = builder.previous_kernel.public_call_requests.storage; + + builder.previous_revertible.append_public_call_requests(2); + let prev_rev_calls = builder.previous_revertible.public_call_requests.storage; + + builder.previous_kernel.append_public_teardown_call_requests(1); + let prev_teardoen_calls = builder.previous_kernel.public_teardown_call_stack.storage; + + builder.public_call.append_public_call_requests(2); + let curr_calls = builder.public_call.public_call_requests.storage; + + let public_inputs = builder.execute(); + + assert_array_eq( + public_inputs.end_non_revertible.public_call_stack, + [prev_non_rev_calls[0], curr_calls[0], curr_calls[1]] + ); + assert_array_eq( + public_inputs.end.public_call_stack, + [prev_rev_calls[0], prev_rev_calls[1]] + ); + assert_array_eq( + public_inputs.public_teardown_call_stack, + [prev_teardoen_calls[0]] + ); + } + + #[test] + fn valid_previous_kernel() { + for i in 0..ALLOWED_PREVIOUS_CIRCUITS.len() { + let mut builder = PublicKernelSetupCircuitPrivateInputsBuilder::new(); + builder.previous_kernel = builder.previous_kernel.in_vk_tree(ALLOWED_PREVIOUS_CIRCUITS[i]); + + let _res = builder.execute(); + } + } + // TODO(#7410) we need the tube vk to reinstate this + // #[test(should_fail_with="Invalid vk index")] + // fn invalid_previous_kernel() { + // let mut builder = PublicKernelSetupCircuitPrivateInputsBuilder::new(); + // builder.previous_kernel = builder.previous_kernel.in_vk_tree(BASE_ROLLUP_INDEX); + // let _res = builder.execute(); + // } +} diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_tail.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_tail.nr index f25d73d4173..6dc88bee1c0 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_tail.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_tail.nr @@ -25,7 +25,7 @@ global ALLOWED_PREVIOUS_CIRCUITS = [ PUBLIC_KERNEL_MERGE_INDEX, ]; -struct PublicKernelTailCircuitPrivateInputs { +pub struct PublicKernelTailCircuitPrivateInputs { previous_kernel: PublicKernelData, note_hash_read_request_hints: [TreeLeafReadRequestHint; MAX_NOTE_HASH_READ_REQUESTS_PER_TX], nullifier_read_request_hints: NullifierReadRequestHints, diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_teardown.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_teardown.nr new file mode 100644 index 00000000000..23150b26090 --- /dev/null +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_teardown.nr @@ -0,0 +1,434 @@ +use crate::{ + components::{ + previous_kernel_validator::PreviousKernelValidator, + public_call_data_validator::PublicCallDataValidator, + public_kernel_output_composer::PublicKernelOutputComposer +}, + public_kernel_phase::PublicKernelPhase +}; +use dep::types::{ + abis::{ + kernel_circuit_public_inputs::PublicKernelCircuitPublicInputs, public_kernel_data::PublicKernelData, + public_call_data::PublicCallData +}, + constants::{ + PUBLIC_KERNEL_SETUP_INDEX, PUBLIC_KERNEL_APP_LOGIC_INDEX, PUBLIC_KERNEL_TEARDOWN_INDEX, + PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX +} +}; + +pub struct PublicKernelTeardownCircuitPrivateInputs { + previous_kernel: PublicKernelData, + public_call: PublicCallData, +} + +global ALLOWED_PREVIOUS_CIRCUITS = [ + PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX, + PUBLIC_KERNEL_SETUP_INDEX, + PUBLIC_KERNEL_APP_LOGIC_INDEX, + PUBLIC_KERNEL_TEARDOWN_INDEX, +]; + +impl PublicKernelTeardownCircuitPrivateInputs { + fn execute(self) -> PublicKernelCircuitPublicInputs { + let phase = PublicKernelPhase.TEARDOWN; + + let previous_kernel_validator = PreviousKernelValidator::new(self.previous_kernel); + previous_kernel_validator.validate_phase(phase); + previous_kernel_validator.validate_proof(ALLOWED_PREVIOUS_CIRCUITS); + + let call_data_validator = PublicCallDataValidator::new(self.public_call, phase); + call_data_validator.validate(); + call_data_validator.validate_against_previous_kernel(self.previous_kernel.public_inputs); + + // noir-fmt:ignore + PublicKernelOutputComposer::new_from_previous_kernel(self.previous_kernel.public_inputs) + .remove_top_call_request(phase) + .propagate_from_public_call(self.public_call.call_stack_item.public_inputs, phase) + .finish() + } +} + +mod tests { + use crate::{public_kernel_teardown::{ALLOWED_PREVIOUS_CIRCUITS, PublicKernelTeardownCircuitPrivateInputs}}; + use dep::types::{ + abis::{ + function_selector::FunctionSelector, gas::Gas, + kernel_circuit_public_inputs::PublicKernelCircuitPublicInputs, + public_call_stack_item_compressed::PublicCallStackItemCompressed + }, + address::AztecAddress, constants::PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX, + tests::{fixture_builder::FixtureBuilder, utils::assert_array_eq}, traits::is_empty + }; + + struct PublicKernelTeardownCircuitPrivateInputsBuilder { + previous_kernel: FixtureBuilder, + public_call: FixtureBuilder, + } + + impl PublicKernelTeardownCircuitPrivateInputsBuilder { + pub fn new() -> Self { + let previous_kernel = FixtureBuilder::new().as_parent_contract().in_vk_tree(PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX); + let mut public_call = FixtureBuilder::new().is_public_function(); + public_call.value_offset = 9999; // Add an offset so that the mock data won't be the same as the values in previous_kernel. + + PublicKernelTeardownCircuitPrivateInputsBuilder { previous_kernel, public_call } + } + + pub fn is_delegate_call(&mut self) -> Self { + let _ = self.public_call.is_delegate_call(); + *self + } + + pub fn execute(&mut self) -> PublicKernelCircuitPublicInputs { + let public_call = self.public_call.to_public_call_data(); + // Adjust the call stack item hash for the current call in the previous iteration. + let compressed = public_call.call_stack_item.get_compressed(); + self.previous_kernel.push_public_teardown_call_request(compressed); + let mut previous_kernel = self.previous_kernel.to_public_kernel_data(true); + + let kernel = PublicKernelTeardownCircuitPrivateInputs { previous_kernel, public_call }; + + kernel.execute() + } + + pub fn get_call_request_item(self) -> PublicCallStackItemCompressed { + self.public_call.to_public_call_stack_item().get_compressed() + } + + pub fn failed_with_call_request_item(&mut self, item: PublicCallStackItemCompressed) { + let public_call = self.public_call.to_public_call_data(); + self.previous_kernel.push_public_teardown_call_request(item); + let previous_kernel = self.previous_kernel.to_public_kernel_data(true); + let kernel = PublicKernelTeardownCircuitPrivateInputs { previous_kernel, public_call }; + let _ = kernel.execute(); + } + + pub fn succeeded(&mut self) { + let _ = self.execute(); + } + + pub fn failed(&mut self) { + let _ = self.execute(); + } + } + + #[test(should_fail_with="Bytecode hash cannot be zero")] + fn no_bytecode_hash_should_fail() { + let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new(); + builder.public_call.bytecode_hash = 0; + + builder.failed(); + } + + #[test(should_fail_with="Contract address cannot be zero")] + fn contract_address_must_be_valid() { + let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new(); + + builder.previous_kernel.append_public_teardown_call_requests(1); + builder.public_call.contract_address = AztecAddress::zero(); + + builder.failed(); + } + + #[test(should_fail_with="Function signature cannot be zero")] + fn function_selector_must_be_valid() { + let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new(); + builder.public_call.function_data.selector = FunctionSelector::zero(); + + builder.failed(); + } + + #[test(should_fail_with="Cannot execute a private function with the public kernel circuit")] + fn private_call_should_fail() { + let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new(); + builder.public_call.function_data.is_private = true; + + builder.failed(); + } + + #[test(should_fail_with="call stack item does not match item at the top of the call stack")] + fn inconsistent_call_request_item_should_fail() { + let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new(); + + let mut item = builder.get_call_request_item(); + // Tweak the call stack item. + item.args_hash += 1; + + builder.failed_with_call_request_item(item); + } + + #[test(should_fail_with="call stack item does not match item at the top of the call stack")] + fn incorrect_msg_sender_fails_for_regular_calls() { + let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new(); + + let mut item = builder.get_call_request_item(); + // Set the msg_sender to a wrong value. + item.call_context.msg_sender.inner += 1; + + builder.failed_with_call_request_item(item); + } + + #[test(should_fail_with="call stack storage address does not match expected contract address")] + fn incorrect_storage_contract_address_fails_for_regular_calls() { + let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new(); + + // Set the storage contract address to a wrong value. + builder.public_call.storage_contract_address.inner += 1; + + builder.failed(); + } + + #[test] + fn delegate_call_succeeds() { + let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new().is_delegate_call(); + builder.succeeded(); + } + + #[test(should_fail_with="call stack item does not match item at the top of the call stack")] + fn incorrect_msg_sender_for_delegate_calls_fails() { + let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new().is_delegate_call(); + + let mut item = builder.get_call_request_item(); + // Set the msg_sender to be the caller contract. + item.call_context.msg_sender = builder.previous_kernel.contract_address; + + builder.failed_with_call_request_item(item); + } + + #[test(should_fail_with="call stack item does not match item at the top of the call stack")] + fn public_kernel_circuit_fails_on_incorrect_storage_contract_in_delegate_call() { + let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new().is_delegate_call(); + + let mut item = builder.get_call_request_item(); + // Set the storage contract address to be the contract address. + item.call_context.storage_contract_address = builder.public_call.contract_address; + + builder.failed_with_call_request_item(item); + } + + #[test(should_fail_with="curent contract address must not match storage contract address for delegate calls")] + fn previous_private_kernel_fails_if_incorrect_storage_contract_on_delegate_call() { + let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new().is_delegate_call(); + + builder.public_call.contract_address = builder.public_call.storage_contract_address; + + builder.failed(); + } + + #[test(should_fail_with="incorrect storage_contract_address for call request")] + fn incorrect_storage_contract_address_for_call_request_fails() { + let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new(); + + builder.public_call.append_public_call_requests(1); + let mut call_request = builder.public_call.public_call_requests.pop(); + // Change the caller contract address to be a different value. + call_request.item.call_context.storage_contract_address.inner += 1; + builder.public_call.public_call_requests.push(call_request); + + builder.failed(); + } + + #[test(should_fail_with="incorrect storage_contract_address for delegate call request")] + fn incorrect_call_context_for_delegate_call_request_fails() { + let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new(); + + builder.public_call.append_public_call_requests_delegate(1); + let mut call_request = builder.public_call.public_call_requests.pop(); + // Change the storage contract address to be the target contract address. + call_request.item.call_context.storage_contract_address = call_request.item.contract_address; + builder.public_call.public_call_requests.push(call_request); + + builder.failed(); + } + + #[test] + fn public_kernel_circuit_teardown_with_no_setup_and_no_app_logic_succeeds() { + let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new(); + builder.succeeded(); + } + + #[test(should_fail_with="Cannot run unnecessary teardown circuit")] + fn private_previous_kernel_non_empty_private_call_stack_should_fail() { + let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new(); + + let public_call = builder.public_call.to_public_call_data(); + // Don't push a call for teardown + let previous_kernel = builder.previous_kernel.to_public_kernel_data(true); + + let kernel = PublicKernelTeardownCircuitPrivateInputs { previous_kernel, public_call }; + + let _ = kernel.execute(); + } + + #[test(should_fail_with="No contract storage update requests are allowed for static calls")] + fn previous_private_kernel_fails_if_contract_storage_update_requests_on_static_call() { + let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new(); + builder.public_call.is_static_call = true; + builder.public_call.append_contract_storage_update_requests(1); + + builder.failed(); + } + + #[test] + fn logs_are_handled_as_expected() { + let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new(); + + // Logs for the current call stack. + builder.public_call.append_unencrypted_log_hashes(1); + let curr_data = builder.public_call.to_public_accumulated_data(); + + // Logs for the previous call stack. + builder.previous_kernel.append_encrypted_log_hashes(1); + builder.previous_kernel.append_unencrypted_log_hashes(1); + let prev_data = builder.previous_kernel.to_public_accumulated_data(); + + let expected_unencrypted_logs = [prev_data.unencrypted_logs_hashes[0], curr_data.unencrypted_logs_hashes[0]]; + // we assume the encrypted log is already siloed from private kernels + let expected_encrypted_logs = [prev_data.encrypted_logs_hashes[0]]; + + let public_inputs = builder.execute(); + + assert_array_eq( + public_inputs.end.encrypted_logs_hashes, + expected_encrypted_logs + ); + assert_array_eq( + public_inputs.end.unencrypted_logs_hashes, + expected_unencrypted_logs + ); + } + + #[test(should_fail_with="Start gas for teardown phase does not match teardown gas allocation")] + fn validates_start_gas() { + let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new(); + + builder.public_call.is_execution_request = true; // don't need to check start gas for nested calls + builder.public_call.start_gas_left = Gas::new(10, 30); + + builder.failed(); + } + + #[test(should_fail_with="Transaction fee on teardown phase does not match expected value")] + fn validates_transaction_fee() { + let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new(); + builder.public_call.transaction_fee = 1234; + + builder.failed(); + } + + #[test] + fn propagates_global_variables_if_empty() { + let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new(); + + builder.public_call.global_variables.block_number = 11; + + let public_inputs = builder.execute(); + + assert_eq(public_inputs.constants.global_variables.block_number, 11); + } + + #[test(should_fail_with="Global variables injected into the public call do not match constants")] + fn validates_global_variables() { + let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new(); + + builder.previous_kernel.global_variables.block_number = 10; + builder.public_call.global_variables.block_number = 11; + + builder.failed(); + } + + #[test] + unconstrained fn propagate_fee_payer() { + let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new(); + let fee_payer = AztecAddress::from_field(123); + builder.previous_kernel.set_fee_payer(fee_payer); + let public_inputs = builder.execute(); + assert_eq(public_inputs.fee_payer, fee_payer); + + // Check that the fee payer is not set if is_fee_payer is false + let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new(); + assert_eq(is_empty(builder.previous_kernel.fee_payer), true); + let public_inputs = builder.execute(); + assert_eq(public_inputs.fee_payer, AztecAddress::empty()); + } + + #[test] + fn clears_stack_if_current_call_revert_code_is_set() { + let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new(); + builder.public_call.revert_code = 1; + + builder.previous_kernel.append_public_teardown_call_requests(2); + + let public_inputs = builder.execute(); + + assert_array_eq(public_inputs.public_teardown_call_stack, []); + } + + #[test] + fn retains_stack_if_fail_in_app_logic() { + let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new(); + builder.previous_kernel.revert_code = 1; + + builder.previous_kernel.append_public_teardown_call_requests(2); + let teardown_calls = builder.previous_kernel.public_teardown_call_stack.storage; + + let public_inputs = builder.execute(); + + assert_array_eq( + public_inputs.public_teardown_call_stack, + [teardown_calls[0], teardown_calls[1]] + ); + } + + #[test] + unconstrained fn correctly_updates_revert_code_0() { + let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new(); + let public_inputs = builder.execute(); + assert_eq(public_inputs.revert_code, 0); + } + + #[test] + unconstrained fn correctly_updates_revert_code_1() { + // Case where we carry forward a revert code from app logic + let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new(); + builder.previous_kernel.revert_code = 1; + let public_inputs = builder.execute(); + assert_eq(public_inputs.revert_code, 1); + } + + #[test] + unconstrained fn correctly_updates_revert_code_2() { + // Case where there is a new error in teardown + let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new(); + builder.public_call.revert_code = 1; + let public_inputs = builder.execute(); + assert_eq(public_inputs.revert_code, 2); + } + + #[test] + unconstrained fn correctly_updates_revert_code_3() { + // Case where there is an error in both app logic and teardown + let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new(); + builder.previous_kernel.revert_code = 1; + builder.public_call.revert_code = 1; + let public_inputs = builder.execute(); + assert_eq(public_inputs.revert_code, 3); + } + + #[test] + fn valid_previous_kernel() { + for i in 0..ALLOWED_PREVIOUS_CIRCUITS.len() { + let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new(); + builder.previous_kernel = builder.previous_kernel.in_vk_tree(ALLOWED_PREVIOUS_CIRCUITS[i]); + + let _res = builder.execute(); + } + } + // #[test(should_fail_with="Invalid vk index")] + // fn invalid_previous_kernel() { + // let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new(); + // builder.previous_kernel = builder.previous_kernel.in_vk_tree(BASE_ROLLUP_INDEX); + // let _res = builder.execute(); + // } +} diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/note_hash_read_request_reset.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/note_hash_read_request_reset.nr index 8c53b9be7de..928e4693eea 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/note_hash_read_request_reset.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/note_hash_read_request_reset.nr @@ -6,7 +6,7 @@ use dep::types::{ merkle_tree::MembershipWitness }; -struct NoteHashSettledReadHint { +pub struct NoteHashSettledReadHint { read_request_index: u32, membership_witness: MembershipWitness, leaf_preimage: NoteHashLeafPreimage, @@ -36,7 +36,7 @@ impl SettledReadHint for NoteHashSe } } -struct NoteHashReadRequestHints { +pub struct NoteHashReadRequestHints { read_request_statuses: [ReadRequestStatus; MAX_NOTE_HASH_READ_REQUESTS_PER_TX], pending_read_hints: [PendingReadHint; NUM_PENDING_HINTS], settled_read_hints: [NoteHashSettledReadHint; NUM_SETTLED_HINTS], @@ -245,4 +245,3 @@ mod tests { builder.verify(); } } - diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/nullifier_non_existent_read_request_reset.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/nullifier_non_existent_read_request_reset.nr index fef20b6eeb9..82fe8c04b55 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/nullifier_non_existent_read_request_reset.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/nullifier_non_existent_read_request_reset.nr @@ -5,7 +5,7 @@ use dep::types::{ constants::{MAX_NULLIFIERS_PER_TX, MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX, NULLIFIER_TREE_HEIGHT} }; -struct NullifierNonMembershipHint { +pub struct NullifierNonMembershipHint { low_leaf_preimage: NullifierLeafPreimage, membership_witness: MembershipWitness, } @@ -20,7 +20,7 @@ impl NonMembershipHint for Nullifi } } -struct NullifierNonExistentReadRequestHints { +pub struct NullifierNonExistentReadRequestHints { non_membership_hints: [NullifierNonMembershipHint; MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX], sorted_pending_values: [Nullifier; MAX_NULLIFIERS_PER_TX], sorted_pending_value_index_hints: [u32; MAX_NULLIFIERS_PER_TX], diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/nullifier_read_request_reset.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/nullifier_read_request_reset.nr index 1f9088af5f5..c9f780d05b5 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/nullifier_read_request_reset.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/nullifier_read_request_reset.nr @@ -6,7 +6,7 @@ use dep::types::{ merkle_tree::MembershipWitness }; -struct NullifierSettledReadHint { +pub struct NullifierSettledReadHint { read_request_index: u32, membership_witness: MembershipWitness, leaf_preimage: NullifierLeafPreimage, @@ -36,7 +36,7 @@ impl SettledReadHint for Nullifier } } -struct NullifierReadRequestHints { +pub struct NullifierReadRequestHints { read_request_statuses: [ReadRequestStatus; MAX_NULLIFIER_READ_REQUESTS_PER_TX], pending_read_hints: [PendingReadHint; NUM_PENDING_HINTS], settled_read_hints: [NullifierSettledReadHint; NUM_SETTLED_HINTS], @@ -237,4 +237,3 @@ mod tests { builder.verify(); } } - diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/private_validation_request_processor.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/private_validation_request_processor.nr index 42a49a84ebc..76dfd18db7b 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/private_validation_request_processor.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/private_validation_request_processor.nr @@ -9,7 +9,7 @@ use dep::types::{ constants::{MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX} }; -struct PrivateValidationRequestProcessor { +pub struct PrivateValidationRequestProcessor { validation_requests: PrivateValidationRequests, note_hash_read_request_hints: NoteHashReadRequestHints, pending_note_hashes: [ScopedNoteHash; MAX_NOTE_HASHES_PER_TX], diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/public_data_read_request_hints.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/public_data_read_request_hints.nr index 3f1eebc06cc..962e8ce3e0b 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/public_data_read_request_hints.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/public_data_read_request_hints.nr @@ -4,7 +4,7 @@ use dep::types::{ data::OverridablePublicDataTreeLeaf, utils::arrays::find_index_hint }; -struct PublicDataReadRequestHints { +pub struct PublicDataReadRequestHints { read_request_statuses: [ReadRequestStatus; NUM_READS], pending_read_hints: [ReadIndexHint; NUM_READS], leaf_data_read_hints: [ReadIndexHint; NUM_READS], diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/public_validation_request_processor.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/public_validation_request_processor.nr index a07fbef6114..6c843db2760 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/public_validation_request_processor.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/public_validation_request_processor.nr @@ -25,7 +25,7 @@ use dep::types::{ utils::arrays::{array_to_bounded_vec, assert_combined_array, assert_sorted_array, combine_arrays} }; -struct PublicValidationRequestProcessor { +pub struct PublicValidationRequestProcessor { validation_requests: PublicValidationRequests, note_hash_read_request_hints: [TreeLeafReadRequestHint; MAX_NOTE_HASH_READ_REQUESTS_PER_TX], note_hash_tree_root: Field, diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/key_validation_hint.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/key_validation_hint.nr index e0c4de9dc1b..78119974eea 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/key_validation_hint.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/key_validation_hint.nr @@ -4,7 +4,7 @@ use dep::types::{ }; use std::embedded_curve_ops::fixed_base_scalar_mul as derive_public_key; -struct KeyValidationHint { +pub struct KeyValidationHint { sk_m: Scalar, request_index: u32, } diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/mutable_data_read_request.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/mutable_data_read_request.nr index 848a8818878..6c953eb0d61 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/mutable_data_read_request.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/mutable_data_read_request.nr @@ -1,7 +1,7 @@ use crate::reset::{read_request::{ReadRequestState, ReadRequestStatus}}; use dep::types::{abis::side_effect::{Ordered, Overridable, Readable}}; -struct ReadIndexHint { +pub struct ReadIndexHint { read_request_index: u32, value_index: u32, } diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/read_request.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/read_request.nr index 5411441bfa2..04dda504841 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/read_request.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/read_request.nr @@ -4,7 +4,7 @@ use dep::types::{ merkle_tree::{assert_check_membership, LeafPreimage, MembershipWitness}, traits::Empty }; -struct ReadRequestStateEnum { +pub struct ReadRequestStateEnum { NADA: u8, PENDING: u8, SETTLED: u8, @@ -16,7 +16,7 @@ global ReadRequestState = ReadRequestStateEnum { SETTLED: 2, }; -struct ReadRequestStatus { +pub struct ReadRequestStatus { state: u8, hint_index: u32, } @@ -41,7 +41,7 @@ trait ReadValueHint { fn read_request_index(self) -> u32; } -struct PendingReadHint { +pub struct PendingReadHint { read_request_index: u32, pending_value_index: u32, } @@ -566,4 +566,3 @@ mod tests { builder.verify(); } } - diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/transient_data.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/transient_data.nr index d0c1f2c7f37..0fe0c0dbdad 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/transient_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/transient_data.nr @@ -3,7 +3,7 @@ use dep::types::{ traits::is_empty }; -struct TransientDataIndexHint { +pub struct TransientDataIndexHint { nullifier_index: u32, note_hash_index: u32, } diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/tree_leaf_read_request.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/tree_leaf_read_request.nr index bca4161020c..75ac5ab045a 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/tree_leaf_read_request.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/tree_leaf_read_request.nr @@ -3,7 +3,7 @@ use dep::types::{ merkle_tree::assert_check_membership }; -struct TreeLeafReadRequestHint { +pub struct TreeLeafReadRequestHint { sibling_path: [Field; N] } @@ -24,4 +24,3 @@ pub fn validate_tree_leaf_read_requests { +pub struct NoteHashReadRequestHintsBuilder { read_request_statuses: [ReadRequestStatus; MAX_NOTE_HASH_READ_REQUESTS_PER_TX], pending_read_hints: BoundedVec, settled_read_hints: BoundedVec, diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/tests/nullifier_non_existent_read_request_hints_builder.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/tests/nullifier_non_existent_read_request_hints_builder.nr index 27f2fc56b1e..25c6fd0f1b2 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/tests/nullifier_non_existent_read_request_hints_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/tests/nullifier_non_existent_read_request_hints_builder.nr @@ -9,7 +9,7 @@ use dep::types::{ utils::{arrays::{find_index_hint, get_sorted_result}} }; -struct NullifierNonExistentReadRequestHintsBuilder { +pub struct NullifierNonExistentReadRequestHintsBuilder { nullifier_tree: NonEmptyMerkleTree, non_membership_hints: BoundedVec, read_values: BoundedVec, diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/tests/nullifier_read_request_hints_builder.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/tests/nullifier_read_request_hints_builder.nr index a6691f45eaa..4b9462e01ce 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/tests/nullifier_read_request_hints_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/tests/nullifier_read_request_hints_builder.nr @@ -4,7 +4,7 @@ use crate::{ }; use dep::types::constants::MAX_NULLIFIER_READ_REQUESTS_PER_TX; -struct NullifierReadRequestHintsBuilder { +pub struct NullifierReadRequestHintsBuilder { read_request_statuses: [ReadRequestStatus; MAX_NULLIFIER_READ_REQUESTS_PER_TX], pending_read_hints: BoundedVec, settled_read_hints: BoundedVec, diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/base_or_merge_rollup_public_inputs.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/base_or_merge_rollup_public_inputs.nr index 440272f7ba1..109ea39bf4e 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/base_or_merge_rollup_public_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/base_or_merge_rollup_public_inputs.nr @@ -7,7 +7,7 @@ use crate::abis::constant_rollup_data::ConstantRollupData; global BASE_ROLLUP_TYPE = 0; global MERGE_ROLLUP_TYPE = 1; -struct BaseOrMergeRollupPublicInputs { +pub struct BaseOrMergeRollupPublicInputs { // rollup_type is either 0 (base) or 1 (merge) // TODO(Kev): Why is this a u32 instead of a u8/u16? rollup_type : u32, diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/block_root_or_block_merge_public_inputs.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/block_root_or_block_merge_public_inputs.nr index 4c5fb902225..7fede7a1c1b 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/block_root_or_block_merge_public_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/block_root_or_block_merge_public_inputs.nr @@ -4,7 +4,7 @@ use dep::types::{ utils::reader::Reader, address::EthAddress }; -struct FeeRecipient { +pub struct FeeRecipient { recipient: EthAddress, value: Field, } @@ -36,7 +36,7 @@ impl Eq for FeeRecipient { // TODO: instead of archives + global vars, use ConstantRollupData x2? It also includes vk root // may be confusing as new_constant.last_archive would actually be the new_archive -struct BlockRootOrBlockMergePublicInputs { +pub struct BlockRootOrBlockMergePublicInputs { previous_archive: AppendOnlyTreeSnapshot, // Archive tree root immediately before this block range new_archive: AppendOnlyTreeSnapshot, // Archive tree root after adding this block range previous_block_hash: Field, // Identifier of the previous block before the range diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/constant_rollup_data.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/constant_rollup_data.nr index c41ed12c297..beea85cc4b9 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/constant_rollup_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/constant_rollup_data.nr @@ -4,7 +4,7 @@ use dep::types::{ utils::reader::Reader }; -struct ConstantRollupData { +pub struct ConstantRollupData { // Archive tree snapshot at the very beginning of the entire rollup. last_archive : AppendOnlyTreeSnapshot, diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/previous_rollup_block_data.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/previous_rollup_block_data.nr index 02c3c126c4b..b235ce5de9a 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/previous_rollup_block_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/previous_rollup_block_data.nr @@ -6,7 +6,7 @@ use dep::types::{ utils::arrays::find_index_hint }; -struct PreviousRollupBlockData { +pub struct PreviousRollupBlockData { block_root_or_block_merge_public_inputs: BlockRootOrBlockMergePublicInputs, proof: NestedRecursiveProof, vk: VerificationKey, diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/previous_rollup_data.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/previous_rollup_data.nr index 39ba99e4406..e2d3be7dc41 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/previous_rollup_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/previous_rollup_data.nr @@ -6,7 +6,7 @@ use dep::types::{ utils::arrays::find_index_hint }; -struct PreviousRollupData{ +pub struct PreviousRollupData{ base_or_merge_rollup_public_inputs : BaseOrMergeRollupPublicInputs, proof : NestedRecursiveProof, vk : VerificationKey, diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/base_rollup_inputs.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/base_rollup_inputs.nr index ffaf9527fc2..6ff7470d81d 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/base_rollup_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/base_rollup_inputs.nr @@ -40,7 +40,7 @@ global ALLOWED_PREVIOUS_CIRCUITS = [ PUBLIC_KERNEL_TAIL_INDEX, ]; -struct BaseRollupInputs { +pub struct BaseRollupInputs { kernel_data: KernelData, start: PartialStateReference, diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/state_diff_hints.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/state_diff_hints.nr index 91f2cc0a31b..a214e0d816c 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/state_diff_hints.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/state_diff_hints.nr @@ -7,7 +7,7 @@ use dep::types::{ merkle_tree::MembershipWitness }; -struct StateDiffHints { +pub struct StateDiffHints { nullifier_predecessor_preimages: [NullifierLeafPreimage; MAX_NULLIFIERS_PER_TX], nullifier_predecessor_membership_witnesses: [MembershipWitness; MAX_NULLIFIERS_PER_TX], diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_merge/block_merge_rollup_inputs.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_merge/block_merge_rollup_inputs.nr index d13216d391f..d6c7ea1633f 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_merge/block_merge_rollup_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_merge/block_merge_rollup_inputs.nr @@ -8,7 +8,7 @@ global ALLOWED_PREVIOUS_CIRCUITS = [ BLOCK_MERGE_ROLLUP_INDEX, ]; -struct BlockMergeRollupInputs { +pub struct BlockMergeRollupInputs { previous_rollup_data : [PreviousRollupBlockData; 2] } diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_root/block_root_rollup_inputs.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_root/block_root_rollup_inputs.nr index f32c144b9cc..c09efc21967 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_root/block_root_rollup_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_root/block_root_rollup_inputs.nr @@ -22,7 +22,7 @@ global ALLOWED_PREVIOUS_CIRCUITS = [ MERGE_ROLLUP_INDEX, ]; -struct BlockRootRollupInputs { +pub struct BlockRootRollupInputs { // All below are shared between the base and merge rollups previous_rollup_data: [PreviousRollupData; 2], diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/merge/merge_rollup_inputs.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/merge/merge_rollup_inputs.nr index 785d471e668..ee10a70d852 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/merge/merge_rollup_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/merge/merge_rollup_inputs.nr @@ -8,7 +8,7 @@ global ALLOWED_PREVIOUS_CIRCUITS = [ MERGE_ROLLUP_INDEX, ]; -struct MergeRollupInputs { +pub struct MergeRollupInputs { // TODO(Kev): Why is this 2? previous_rollup_data : [PreviousRollupData; 2] } diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/root/root_rollup_inputs.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/root/root_rollup_inputs.nr index e27538d300c..3bd35c0a372 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/root/root_rollup_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/root/root_rollup_inputs.nr @@ -9,7 +9,7 @@ global ALLOWED_PREVIOUS_CIRCUITS = [ BLOCK_MERGE_ROLLUP_INDEX, ]; -struct RootRollupInputs { +pub struct RootRollupInputs { previous_rollup_data: [PreviousRollupBlockData; 2], prover_id: Field, } diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/root/root_rollup_public_inputs.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/root/root_rollup_public_inputs.nr index 15b239b8714..4a27117d79a 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/root/root_rollup_public_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/root/root_rollup_public_inputs.nr @@ -1,7 +1,7 @@ use dep::types::abis::append_only_tree_snapshot::AppendOnlyTreeSnapshot; use crate::abis::block_root_or_block_merge_public_inputs::FeeRecipient; // TODO(#7346): Currently unused! Will be used when batch rollup circuits are integrated. -struct RootRollupPublicInputs { +pub struct RootRollupPublicInputs { // Snapshot of archive tree before/after this rollup has been processed previous_archive: AppendOnlyTreeSnapshot, end_archive: AppendOnlyTreeSnapshot, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/combined_accumulated_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/combined_accumulated_data.nr index b142411d12d..6d712c88add 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/combined_accumulated_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/combined_accumulated_data.nr @@ -9,13 +9,13 @@ use crate::{ utils::reader::Reader, traits::{Empty, Serialize, Deserialize} }; -struct CombinedAccumulatedData { +pub struct CombinedAccumulatedData { note_hashes: [Field; MAX_NOTE_HASHES_PER_TX], nullifiers: [Field; MAX_NULLIFIERS_PER_TX], l2_to_l1_msgs: [ScopedL2ToL1Message; MAX_L2_TO_L1_MSGS_PER_TX], note_encrypted_logs_hashes: [LogHash; MAX_NOTE_ENCRYPTED_LOGS_PER_TX], - encrypted_logs_hashes: [ScopedLogHash; MAX_ENCRYPTED_LOGS_PER_TX], + encrypted_logs_hashes: [ScopedLogHash; MAX_ENCRYPTED_LOGS_PER_TX], unencrypted_logs_hashes: [ScopedLogHash; MAX_UNENCRYPTED_LOGS_PER_TX], // Here so that the gas cost of this request can be measured by circuits, without actually needing to feed in the diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_accumulated_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_accumulated_data.nr index bfa47b82795..75d0abd27ba 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_accumulated_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_accumulated_data.nr @@ -13,7 +13,7 @@ use crate::constants::{ MAX_UNENCRYPTED_LOGS_PER_TX, MAX_NOTE_ENCRYPTED_LOGS_PER_TX, PRIVATE_ACCUMULATED_DATA_LENGTH }; -struct PrivateAccumulatedData { +pub struct PrivateAccumulatedData { note_hashes: [ScopedNoteHash; MAX_NOTE_HASHES_PER_TX], nullifiers: [ScopedNullifier; MAX_NULLIFIERS_PER_TX], l2_to_l1_msgs: [ScopedL2ToL1Message; MAX_L2_TO_L1_MSGS_PER_TX], diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_accumulated_data_builder.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_accumulated_data_builder.nr index 7f8441bd464..d0d3c841f63 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_accumulated_data_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_accumulated_data_builder.nr @@ -13,7 +13,7 @@ use crate::{ messaging::l2_to_l1_message::ScopedL2ToL1Message, traits::Empty }; -struct PrivateAccumulatedDataBuilder { +pub struct PrivateAccumulatedDataBuilder { note_hashes: BoundedVec, nullifiers: BoundedVec, l2_to_l1_msgs: BoundedVec, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/public_accumulated_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/public_accumulated_data.nr index 15cc40d8a49..1eec6ab169e 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/public_accumulated_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/public_accumulated_data.nr @@ -13,7 +13,7 @@ use crate::{ traits::{Empty, Serialize, Deserialize}, utils::{arrays::array_length, reader::Reader} }; -struct PublicAccumulatedData { +pub struct PublicAccumulatedData { note_hashes: [ScopedNoteHash; MAX_NOTE_HASHES_PER_TX], nullifiers: [Nullifier; MAX_NULLIFIERS_PER_TX], l2_to_l1_msgs: [ScopedL2ToL1Message; MAX_L2_TO_L1_MSGS_PER_TX], @@ -148,7 +148,7 @@ impl Eq for PublicAccumulatedData { } } -struct PublicAccumulatedDataArrayLengths { +pub struct PublicAccumulatedDataArrayLengths { note_hashes: u32, nullifiers: u32, l2_to_l1_msgs: u32, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/public_accumulated_data_builder.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/public_accumulated_data_builder.nr index b1f768852a1..e69d6dc7432 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/public_accumulated_data_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/public_accumulated_data_builder.nr @@ -13,7 +13,7 @@ use crate::{ traits::Empty, utils::arrays::array_to_bounded_vec }; -struct PublicAccumulatedDataBuilder { +pub struct PublicAccumulatedDataBuilder { note_hashes: BoundedVec, nullifiers: BoundedVec, l2_to_l1_msgs: BoundedVec, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/append_only_tree_snapshot.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/append_only_tree_snapshot.nr index a4527980e83..5967effa446 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/append_only_tree_snapshot.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/append_only_tree_snapshot.nr @@ -1,4 +1,4 @@ -struct AppendOnlyTreeSnapshot { +pub struct AppendOnlyTreeSnapshot { root : Field, // TODO(Alvaro) change this to a u64 next_available_leaf_index : u32 diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/call_context.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/call_context.nr index 269a8cf15cb..64da68a2ac5 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/call_context.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/call_context.nr @@ -4,7 +4,7 @@ use crate::{ }; // docs:start:call-context -struct CallContext { +pub struct CallContext { msg_sender: AztecAddress, storage_contract_address: AztecAddress, function_selector: FunctionSelector, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/combined_constant_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/combined_constant_data.nr index 8d0f074c353..fc5b478fa24 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/combined_constant_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/combined_constant_data.nr @@ -5,7 +5,7 @@ use crate::abis::global_variables::GlobalVariables; use crate::constants::COMBINED_CONSTANT_DATA_LENGTH; use crate::utils::reader::Reader; -struct CombinedConstantData { +pub struct CombinedConstantData { historical_header: Header, // Note: `chain_id` and `version` in tx_context are not redundant to the values in // self.historical_header.global_variables because they can be different in case of a protocol upgrade. In such diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/contract_class_function_leaf_preimage.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/contract_class_function_leaf_preimage.nr index 2e2097bc9be..9a6349b4e6d 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/contract_class_function_leaf_preimage.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/contract_class_function_leaf_preimage.nr @@ -3,7 +3,7 @@ use crate::constants::GENERATOR_INDEX__FUNCTION_LEAF; use crate::traits::Hash; use crate::hash::poseidon2_hash_with_separator; -struct ContractClassFunctionLeafPreimage { +pub struct ContractClassFunctionLeafPreimage { selector : FunctionSelector, vk_hash : Field, } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/enqueued_call_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/enqueued_call_data.nr index 1330a493b9d..8aa99d22665 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/enqueued_call_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/enqueued_call_data.nr @@ -1,9 +1,9 @@ use crate::abis::{kernel_circuit_public_inputs::vm_circuit_public_inputs::VMCircuitPublicInputs}; // Mocked here as the only remaining non-recursive proof -struct Proof {} +pub struct Proof {} -struct EnqueuedCallData { +pub struct EnqueuedCallData { data: VMCircuitPublicInputs, proof: Proof, } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/function_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/function_data.nr index a32c9fc9907..2e62c732e46 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/function_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/function_data.nr @@ -3,7 +3,7 @@ use crate::{ traits::{Serialize, Deserialize, Empty} }; -struct FunctionData { +pub struct FunctionData { selector : FunctionSelector, is_private : bool, } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/function_selector.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/function_selector.nr index eda80e000a0..f5a81195504 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/function_selector.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/function_selector.nr @@ -3,7 +3,7 @@ use crate::traits::{Serialize, Deserialize, FromField, ToField, Empty}; global SELECTOR_SIZE: u32 = 4; -struct FunctionSelector { +pub struct FunctionSelector { // 1st 4-bytes of abi-encoding of function. inner: u32, } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/gas.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/gas.nr index d0622d27cde..3225fdbc51d 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/gas.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/gas.nr @@ -4,7 +4,7 @@ use crate::{ }; use std::ops::{Add, Sub}; -struct Gas { +pub struct Gas { da_gas: u32, l2_gas: u32, } @@ -74,4 +74,3 @@ fn serialization_of_empty() { let deserialized = Gas::deserialize(serialized); assert(item.eq(deserialized)); } - diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/gas_fees.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/gas_fees.nr index f87ca6f31e2..86a1280e433 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/gas_fees.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/gas_fees.nr @@ -1,6 +1,6 @@ use crate::{constants::GAS_FEES_LENGTH, traits::{Deserialize, Serialize, Empty}}; -struct GasFees { +pub struct GasFees { fee_per_da_gas: Field, fee_per_l2_gas: Field, } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/gas_settings.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/gas_settings.nr index ec380971601..004e7321a27 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/gas_settings.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/gas_settings.nr @@ -7,7 +7,7 @@ use crate::{ traits::{Deserialize, Serialize, Empty}, utils::reader::Reader }; -struct GasSettings { +pub struct GasSettings { gas_limits: Gas, teardown_gas_limits: Gas, max_fees_per_gas: GasFees, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/global_variables.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/global_variables.nr index 7dde548565e..799c9617c75 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/global_variables.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/global_variables.nr @@ -4,7 +4,7 @@ use crate::{ }; // docs:start:global-variables -struct GlobalVariables { +pub struct GlobalVariables { chain_id : Field, version : Field, block_number : Field, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/kernel_circuit_public_inputs.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/kernel_circuit_public_inputs.nr index ffa2bc7ab45..e1fa46b77e8 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/kernel_circuit_public_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/kernel_circuit_public_inputs.nr @@ -8,7 +8,7 @@ use crate::{ utils::reader::Reader }; -struct KernelCircuitPublicInputs { +pub struct KernelCircuitPublicInputs { rollup_validation_requests: RollupValidationRequests, end: CombinedAccumulatedData, constants: CombinedConstantData, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/private_kernel_circuit_public_inputs.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/private_kernel_circuit_public_inputs.nr index ff93719dd87..a84b06e1a21 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/private_kernel_circuit_public_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/private_kernel_circuit_public_inputs.nr @@ -7,7 +7,7 @@ use crate::{ traits::{Serialize, Deserialize, Empty}, utils::{arrays::array_length, reader::Reader} }; -struct PrivateKernelCircuitPublicInputsArrayLengths { +pub struct PrivateKernelCircuitPublicInputsArrayLengths { note_hash_read_requests: u32, nullifier_read_requests: u32, scoped_key_validation_requests_and_generators: u32, @@ -73,7 +73,7 @@ impl Eq for PrivateKernelCircuitPublicInputsArrayLengths { } } -struct PrivateKernelCircuitPublicInputs { +pub struct PrivateKernelCircuitPublicInputs { min_revertible_side_effect_counter: u32, validation_requests: PrivateValidationRequests, end: PrivateAccumulatedData, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/private_kernel_circuit_public_inputs_builder.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/private_kernel_circuit_public_inputs_builder.nr index add7c553b6e..8c84cf9b8b8 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/private_kernel_circuit_public_inputs_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/private_kernel_circuit_public_inputs_builder.nr @@ -7,7 +7,7 @@ use crate::{ address::AztecAddress, traits::Empty }; -struct PrivateKernelCircuitPublicInputsBuilder { +pub struct PrivateKernelCircuitPublicInputsBuilder { min_revertible_side_effect_counter: u32, validation_requests: PrivateValidationRequestsBuilder, end: PrivateAccumulatedDataBuilder, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/public_kernel_circuit_public_inputs.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/public_kernel_circuit_public_inputs.nr index a3154896bb6..5f3351423e5 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/public_kernel_circuit_public_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/public_kernel_circuit_public_inputs.nr @@ -7,7 +7,7 @@ use crate::{ traits::{Empty, Serialize, Deserialize}, utils::reader::Reader }; -struct PublicKernelCircuitPublicInputs { +pub struct PublicKernelCircuitPublicInputs { constants: CombinedConstantData, validation_requests: PublicValidationRequests, end_non_revertible: PublicAccumulatedData, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/public_kernel_circuit_public_inputs_builder.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/public_kernel_circuit_public_inputs_builder.nr index d42164f6666..e40de7784e9 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/public_kernel_circuit_public_inputs_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/public_kernel_circuit_public_inputs_builder.nr @@ -7,7 +7,7 @@ use crate::{ address::AztecAddress, traits::Empty }; -struct PublicKernelCircuitPublicInputsBuilder { +pub struct PublicKernelCircuitPublicInputsBuilder { constants: CombinedConstantData, validation_requests: PublicValidationRequestsBuilder, end_non_revertible: PublicAccumulatedDataBuilder, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/vm_circuit_public_inputs.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/vm_circuit_public_inputs.nr index c877c645a40..8aec60ac157 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/vm_circuit_public_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/vm_circuit_public_inputs.nr @@ -9,7 +9,7 @@ use crate::{ traits::{Deserialize, Empty, Serialize}, utils::reader::Reader }; -struct VMCircuitPublicInputs { +pub struct VMCircuitPublicInputs { constants: CombinedConstantData, call_request: PublicCallRequest, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_data.nr index 49390ded212..82934bf8360 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_data.nr @@ -5,7 +5,7 @@ use crate::{ utils::arrays::find_index_hint }; -struct KernelData { +pub struct KernelData { public_inputs: KernelCircuitPublicInputs, proof: NestedRecursiveProof, vk: VerificationKey, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/log_hash.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/log_hash.nr index 034b99e8e15..48de98abbc5 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/log_hash.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/log_hash.nr @@ -7,7 +7,7 @@ use crate::{ traits::{Empty, Serialize, Deserialize}, utils::{arrays::array_concat, reader::Reader} }; -struct LogHash { +pub struct LogHash { value: Field, counter: u32, length: Field, @@ -60,7 +60,7 @@ impl LogHash { } } -struct ScopedLogHash { +pub struct ScopedLogHash { log_hash: LogHash, contract_address: AztecAddress, } @@ -129,7 +129,7 @@ impl ScopedLogHash { } } -struct EncryptedLogHash { +pub struct EncryptedLogHash { value: Field, counter: u32, length: Field, @@ -184,7 +184,7 @@ impl EncryptedLogHash { } } -struct ScopedEncryptedLogHash { +pub struct ScopedEncryptedLogHash { log_hash: EncryptedLogHash, contract_address: AztecAddress, } @@ -254,7 +254,7 @@ impl Deserialize for ScopedEncryptedLogHash { } } -struct NoteLogHash { +pub struct NoteLogHash { value: Field, counter: u32, length: Field, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/max_block_number.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/max_block_number.nr index 05aafd9b80c..f9d6a09c372 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/max_block_number.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/max_block_number.nr @@ -1,6 +1,6 @@ use crate::{constants::MAX_BLOCK_NUMBER_LENGTH, traits::{Deserialize, Serialize, Empty}}; -struct MaxBlockNumber { +pub struct MaxBlockNumber { _opt: Option } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/note_hash.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/note_hash.nr index ad3ed114ab6..22a2c7e5238 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/note_hash.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/note_hash.nr @@ -5,7 +5,7 @@ use crate::{ utils::{arrays::array_concat, reader::Reader} }; -struct NoteHash { +pub struct NoteHash { value: Field, counter: u32, } @@ -46,7 +46,7 @@ impl NoteHash { } } -struct ScopedNoteHash { +pub struct ScopedNoteHash { note_hash: NoteHash, contract_address: AztecAddress, } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/note_hash_leaf_preimage.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/note_hash_leaf_preimage.nr index db29fe89171..deebd8fb118 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/note_hash_leaf_preimage.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/note_hash_leaf_preimage.nr @@ -5,7 +5,7 @@ use crate::{ merkle_tree::leaf_preimage::LeafPreimage, traits::Empty }; -struct NoteHashLeafPreimage { +pub struct NoteHashLeafPreimage { value : Field, } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/nullifier.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/nullifier.nr index 13b2105c640..93bf2cfec28 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/nullifier.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/nullifier.nr @@ -5,7 +5,7 @@ use crate::{ utils::{arrays::array_concat, reader::Reader} }; -struct Nullifier { +pub struct Nullifier { value: Field, counter: u32, note_hash: Field, @@ -70,7 +70,7 @@ impl Nullifier { } } -struct ScopedNullifier { +pub struct ScopedNullifier { nullifier: Nullifier, contract_address: AztecAddress, } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/nullifier_leaf_preimage.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/nullifier_leaf_preimage.nr index e3e40bd7bf6..4321af0c13f 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/nullifier_leaf_preimage.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/nullifier_leaf_preimage.nr @@ -5,7 +5,7 @@ use crate::{ merkle_tree::leaf_preimage::{LeafPreimage, IndexedTreeLeafPreimage}, traits::{Empty, Hash} }; -struct NullifierLeafPreimage { +pub struct NullifierLeafPreimage { nullifier : Field, next_nullifier :Field, next_index : u32, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_call_request.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_call_request.nr index d0b64e0890b..d682d3be4ff 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_call_request.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_call_request.nr @@ -4,7 +4,7 @@ use crate::{ utils::reader::Reader }; -struct PrivateCallRequest { +pub struct PrivateCallRequest { contract_address: AztecAddress, call_context: CallContext, args_hash: Field, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_call_stack_item.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_call_stack_item.nr index 5cd0a86d6aa..e6dd0ca7dca 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_call_stack_item.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_call_stack_item.nr @@ -4,7 +4,7 @@ use crate::{ traits::{Deserialize, Serialize, Empty}, utils::reader::Reader }; -struct PrivateCallStackItem { +pub struct PrivateCallStackItem { // This is the _actual_ contract address relating to where this function's code resides in the // contract tree. Regardless of whether this is a call or delegatecall, this // `contract_address` _does not change_. Amongst other things, it's used as a lookup for diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_circuit_public_inputs.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_circuit_public_inputs.nr index a954f5dbd1f..0c9121a206b 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_circuit_public_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_circuit_public_inputs.nr @@ -16,7 +16,7 @@ use crate::{ utils::reader::Reader, transaction::tx_context::TxContext, utils::arrays::validate_array }; -struct PrivateCircuitPublicInputsArrayLengths { +pub struct PrivateCircuitPublicInputsArrayLengths { note_hash_read_requests: u32, nullifier_read_requests: u32, key_validation_requests_and_generators: u32, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_kernel/private_call_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_kernel/private_call_data.nr index 512d114dbc6..b60eed12cad 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_kernel/private_call_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_kernel/private_call_data.nr @@ -4,7 +4,7 @@ use crate::{ merkle_tree::membership::MembershipWitness, recursion::{verification_key::VerificationKey} }; -struct PrivateCallData { +pub struct PrivateCallData { call_stack_item: PrivateCallStackItem, vk: VerificationKey, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_kernel_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_kernel_data.nr index 623ef5f1cad..2da1b406533 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_kernel_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_kernel_data.nr @@ -4,7 +4,7 @@ use crate::{ utils::arrays::find_index_hint }; -struct PrivateKernelData { +pub struct PrivateKernelData { public_inputs: PrivateKernelCircuitPublicInputs, vk: VerificationKey, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_call_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_call_data.nr index e807e732124..16a1099a399 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_call_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_call_data.nr @@ -1,10 +1,10 @@ use crate::abis::public_call_stack_item::PublicCallStackItem; // Mocked here as the only remaining non-recursive proof -struct Proof {} +pub struct Proof {} // TODO(#7124): To be deprecated. -struct PublicCallData { +pub struct PublicCallData { call_stack_item: PublicCallStackItem, proof: Proof, bytecode_hash: Field, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_call_request.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_call_request.nr index 2c1b2772d8a..7a1eaf96265 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_call_request.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_call_request.nr @@ -4,7 +4,7 @@ use crate::{ utils::reader::Reader }; -struct PublicCallRequest { +pub struct PublicCallRequest { contract_address: AztecAddress, call_context: CallContext, args_hash: Field, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_call_stack_item.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_call_stack_item.nr index e8d8a409fb9..5a8d9301233 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_call_stack_item.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_call_stack_item.nr @@ -2,7 +2,7 @@ use crate::abis::{function_data::FunctionData, public_circuit_public_inputs::Pub use crate::address::AztecAddress; // TODO(#7124): To be deprecated. -struct PublicCallStackItem { +pub struct PublicCallStackItem { contract_address: AztecAddress, public_inputs: PublicCircuitPublicInputs, function_data: FunctionData, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_call_stack_item_compressed.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_call_stack_item_compressed.nr index b2eb5280142..42efa7eb2fb 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_call_stack_item_compressed.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_call_stack_item_compressed.nr @@ -7,18 +7,18 @@ use crate::utils::reader::Reader; /** * A compressed version of the PublicCallStackItem struct used to compute the "hash" * of a PublicCallStackItem. - * + * * Historically, we have been zeroing most values in the PublicCallStackItem struct * to compute the hash involved when adding a PublicCallStackItem to the PublicCallStack. - * + * * This struct is used to store the values that we did not zero out, and allow us to hash * only these, thereby skipping a lot of computation and saving us a lot of constraints - * - * Essentially this struct exists such that we don't have a `hash` function in the + * + * Essentially this struct exists such that we don't have a `hash` function in the * PublicCallStackItem struct that practically throws away some values of the struct * without clearly indicating that it does so. */ -struct PublicCallStackItemCompressed { +pub struct PublicCallStackItemCompressed { contract_address: AztecAddress, call_context: CallContext, args_hash: Field, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_circuit_public_inputs.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_circuit_public_inputs.nr index 44486a3499c..294406aeb10 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_circuit_public_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_circuit_public_inputs.nr @@ -19,7 +19,7 @@ use crate::{ }; // Public inputs to public app circuit. -struct PublicCircuitPublicInputs { +pub struct PublicCircuitPublicInputs { call_context: CallContext, args_hash: Field, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_data_read.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_data_read.nr index f5a3ce9d067..7ba5ce28f44 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_data_read.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_data_read.nr @@ -5,7 +5,7 @@ use crate::{ traits::{Empty, Serialize, Deserialize} }; -struct PublicDataRead { +pub struct PublicDataRead { leaf_slot: Field, value: Field, counter: u32, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_data_update_request.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_data_update_request.nr index 2516e214fa3..3222c469775 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_data_update_request.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_data_update_request.nr @@ -9,7 +9,7 @@ use crate::{ }; // TODO: Rename to PublicDataWrite -struct PublicDataUpdateRequest { +pub struct PublicDataUpdateRequest { leaf_slot : Field, new_value : Field, counter: u32 diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_data_write.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_data_write.nr index c7b9b7ce047..134e00f7b30 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_data_write.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_data_write.nr @@ -6,7 +6,7 @@ use crate::{ traits::Empty }; -struct OverridablePublicDataWrite { +pub struct OverridablePublicDataWrite { write: PublicDataUpdateRequest, override_counter: u32, } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_inner_call_request.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_inner_call_request.nr index 22db348e213..ab77f5aca60 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_inner_call_request.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_inner_call_request.nr @@ -5,7 +5,7 @@ use crate::{ }; // TODO(#7124): To be deprecated. -struct PublicInnerCallRequest { +pub struct PublicInnerCallRequest { item: PublicCallStackItemCompressed, counter: u32, } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_kernel_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_kernel_data.nr index 62053755e1a..050a092d29e 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_kernel_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_kernel_data.nr @@ -5,7 +5,7 @@ use crate::{ utils::arrays::find_index_hint }; -struct PublicKernelData { +pub struct PublicKernelData { public_inputs: PublicKernelCircuitPublicInputs, proof: NestedRecursiveProof, vk: VerificationKey, @@ -35,4 +35,3 @@ impl PublicKernelData { ); } } - diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_kernel_inner_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_kernel_inner_data.nr index 011e46e87aa..7986b55cbc1 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_kernel_inner_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_kernel_inner_data.nr @@ -3,7 +3,7 @@ use crate::{ recursion::{proof::NestedRecursiveProof, verification_key::VerificationKey, traits::Verifiable} }; -struct PublicKernelInnerData { +pub struct PublicKernelInnerData { public_inputs: VMCircuitPublicInputs, proof: NestedRecursiveProof, vk: VerificationKey, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/read_request.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/read_request.nr index b68d480c5a1..6497dba6419 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/read_request.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/read_request.nr @@ -4,7 +4,7 @@ use crate::{ utils::{arrays::array_concat, reader::Reader} }; -struct ReadRequest { +pub struct ReadRequest { value: Field, counter: u32, } @@ -45,7 +45,7 @@ impl ReadRequest { } } -struct ScopedReadRequest { +pub struct ScopedReadRequest { read_request: ReadRequest, contract_address: AztecAddress, } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/side_effect.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/side_effect.nr index ac98426ae34..df8eea9d545 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/side_effect.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/side_effect.nr @@ -1,33 +1,33 @@ use crate::{address::AztecAddress}; -trait Ordered { +pub trait Ordered { fn counter(self) -> u32; } -trait RangeOrdered { +pub trait RangeOrdered { fn counter_start(self) -> u32; fn counter_end(self) -> u32; } -trait OrderedValue where T: Eq { +pub trait OrderedValue where T: Eq { fn value(self) -> T; fn counter(self) -> u32; } -trait Scoped where T: Eq { +pub trait Scoped where T: Eq { fn contract_address(self) -> AztecAddress; fn inner(self) -> T; } -trait Readable { +pub trait Readable { fn assert_match_read_request(self, read_request: T); } -trait Overridable { +pub trait Overridable { // The counter of the next side effect that's overriding the current side effect. fn override_counter(self) -> u32; } -trait Inner { +pub trait Inner { fn inner(self) -> T; } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/tree_leaf_read_request.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/tree_leaf_read_request.nr index 4a8a386fe55..fe03444b4ca 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/tree_leaf_read_request.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/tree_leaf_read_request.nr @@ -1,6 +1,6 @@ use crate::{traits::{Empty, Serialize, Deserialize}, constants::TREE_LEAF_READ_REQUEST_LENGTH}; -struct TreeLeafReadRequest { +pub struct TreeLeafReadRequest { value: Field, leaf_index: Field, } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/key_validation_request.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/key_validation_request.nr index ec0a59ab834..ef1a6196598 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/key_validation_request.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/key_validation_request.nr @@ -1,7 +1,7 @@ use crate::{traits::{Empty, Serialize, Deserialize}, point::Point}; pub use crate::constants::KEY_VALIDATION_REQUEST_LENGTH; -struct KeyValidationRequest { +pub struct KeyValidationRequest { pk_m: Point, sk_app: Field, // not a grumpkin scalar because it's output of poseidon2 } @@ -34,4 +34,3 @@ impl Deserialize for KeyValidationRequest { Self { pk_m: Point { x: fields[0], y: fields[1], is_infinite: fields[2] as bool }, sk_app: fields[3] } } } - diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/key_validation_request_and_generator.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/key_validation_request_and_generator.nr index c35e1289696..184fa47535e 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/key_validation_request_and_generator.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/key_validation_request_and_generator.nr @@ -8,7 +8,7 @@ use crate::{ utils::{arrays::array_concat, reader::Reader} }; -struct KeyValidationRequestAndGenerator { +pub struct KeyValidationRequestAndGenerator { request: KeyValidationRequest, sk_app_generator: Field, } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/private_validation_requests.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/private_validation_requests.nr index 763bc2f685e..4b8ceeef053 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/private_validation_requests.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/private_validation_requests.nr @@ -13,7 +13,7 @@ use crate::{ traits::{Serialize, Deserialize, Empty}, utils::reader::Reader }; -struct PrivateValidationRequests { +pub struct PrivateValidationRequests { for_rollup: RollupValidationRequests, note_hash_read_requests: [ScopedReadRequest; MAX_NOTE_HASH_READ_REQUESTS_PER_TX], nullifier_read_requests: [ScopedReadRequest; MAX_NULLIFIER_READ_REQUESTS_PER_TX], diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/private_validation_requests_builder.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/private_validation_requests_builder.nr index 3cee3e151e0..109eb77956c 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/private_validation_requests_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/private_validation_requests_builder.nr @@ -14,7 +14,7 @@ use crate::{ traits::Empty }; -struct PrivateValidationRequestsBuilder { +pub struct PrivateValidationRequestsBuilder { max_block_number: MaxBlockNumber, note_hash_read_requests: BoundedVec, nullifier_read_requests: BoundedVec, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/public_validation_requests.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/public_validation_requests.nr index 31c8f10c317..8eba0da9316 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/public_validation_requests.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/public_validation_requests.nr @@ -13,7 +13,7 @@ use crate::{ traits::{Serialize, Deserialize, Empty}, utils::{arrays::array_length, reader::Reader} }; -struct PublicValidationRequests { +pub struct PublicValidationRequests { for_rollup: RollupValidationRequests, note_hash_read_requests: [TreeLeafReadRequest; MAX_NOTE_HASH_READ_REQUESTS_PER_TX], nullifier_read_requests: [ScopedReadRequest; MAX_NULLIFIER_READ_REQUESTS_PER_TX], @@ -112,7 +112,7 @@ impl Eq for PublicValidationRequests { } } -struct PublicValidationRequestArrayLengths { +pub struct PublicValidationRequestArrayLengths { note_hash_read_requests: u32, nullifier_read_requests: u32, nullifier_non_existent_read_requests: u32, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/public_validation_requests_builder.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/public_validation_requests_builder.nr index 4cf894617f3..3b541ca6aa0 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/public_validation_requests_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/public_validation_requests_builder.nr @@ -15,7 +15,7 @@ use crate::{ traits::Empty, utils::arrays::array_to_bounded_vec }; -struct PublicValidationRequestsBuilder { +pub struct PublicValidationRequestsBuilder { max_block_number: MaxBlockNumber, note_hash_read_requests: BoundedVec, nullifier_read_requests: BoundedVec, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/rollup_validation_requests.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/rollup_validation_requests.nr index 9cfac17a676..59921e2103c 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/rollup_validation_requests.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/rollup_validation_requests.nr @@ -3,9 +3,9 @@ use crate::{ constants::ROLLUP_VALIDATION_REQUESTS_LENGTH, utils::reader::Reader }; -// These are validation requests that cannot be fulfilled in the current context (private or public), and must be +// These are validation requests that cannot be fulfilled in the current context (private or public), and must be // instead forwarded to the rollup for it to take care of them. -struct RollupValidationRequests { +pub struct RollupValidationRequests { max_block_number: MaxBlockNumber, } @@ -43,4 +43,3 @@ fn serialization_of_empty() { let deserialized = RollupValidationRequests::deserialize(serialized); assert(item.eq(deserialized)); } - diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/scoped_key_validation_request_and_generator.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/scoped_key_validation_request_and_generator.nr index ecceea2812f..d42bf260460 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/scoped_key_validation_request_and_generator.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/scoped_key_validation_request_and_generator.nr @@ -7,7 +7,7 @@ use crate::{ } }; -struct ScopedKeyValidationRequestAndGenerator { +pub struct ScopedKeyValidationRequestAndGenerator { request: KeyValidationRequestAndGenerator, contract_address: AztecAddress, } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/address/eth_address.nr b/noir-projects/noir-protocol-circuits/crates/types/src/address/eth_address.nr index cc3a7e292f7..79e90bd2c00 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/address/eth_address.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/address/eth_address.nr @@ -1,6 +1,6 @@ use crate::{constants::ETH_ADDRESS_LENGTH, traits::{Empty, ToField, Serialize, Deserialize}, utils}; -struct EthAddress{ +pub struct EthAddress{ inner : Field } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/address/partial_address.nr b/noir-projects/noir-protocol-circuits/crates/types/src/address/partial_address.nr index 0f073a4dcba..de1ca920cea 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/address/partial_address.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/address/partial_address.nr @@ -7,7 +7,7 @@ use crate::{ global PARTIAL_ADDRESS_LENGTH: u32 = 1; // Partial address -struct PartialAddress { +pub struct PartialAddress { inner : Field } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/address/public_keys_hash.nr b/noir-projects/noir-protocol-circuits/crates/types/src/address/public_keys_hash.nr index 29aa5aa9a5a..9e05807428a 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/address/public_keys_hash.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/address/public_keys_hash.nr @@ -1,7 +1,7 @@ use crate::traits::{ToField, Serialize, Deserialize}; // Public keys hash. Used in the computation of an address. -struct PublicKeysHash { +pub struct PublicKeysHash { inner: Field } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/address/salted_initialization_hash.nr b/noir-projects/noir-protocol-circuits/crates/types/src/address/salted_initialization_hash.nr index 07fc4dc215b..27c4cf7a65f 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/address/salted_initialization_hash.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/address/salted_initialization_hash.nr @@ -4,7 +4,7 @@ use crate::{ }; // Salted initialization hash. Used in the computation of a partial address. -struct SaltedInitializationHash { +pub struct SaltedInitializationHash { inner: Field } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/content_commitment.nr b/noir-projects/noir-protocol-circuits/crates/types/src/content_commitment.nr index 03b54424d73..71b160aac52 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/content_commitment.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/content_commitment.nr @@ -1,6 +1,6 @@ use crate::{constants::CONTENT_COMMITMENT_LENGTH, traits::{Deserialize, Empty, Serialize}}; -struct ContentCommitment { +pub struct ContentCommitment { num_txs: Field, txs_effects_hash: Field, in_hash: Field, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/contract_class_id.nr b/noir-projects/noir-protocol-circuits/crates/types/src/contract_class_id.nr index 0060031f1a3..fbe77eb62f9 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/contract_class_id.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/contract_class_id.nr @@ -1,7 +1,7 @@ use crate::constants::GENERATOR_INDEX__CONTRACT_LEAF; use crate::traits::{ToField, FromField, Serialize, Deserialize}; -struct ContractClassId { +pub struct ContractClassId { inner: Field } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/contract_instance.nr b/noir-projects/noir-protocol-circuits/crates/types/src/contract_instance.nr index be2f0f48833..c10fa38c944 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/contract_instance.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/contract_instance.nr @@ -4,7 +4,7 @@ use crate::{ traits::{Deserialize, Hash, Serialize} }; -struct ContractInstance { +pub struct ContractInstance { salt : Field, deployer: AztecAddress, contract_class_id : ContractClassId, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/contrakt/storage_read.nr b/noir-projects/noir-protocol-circuits/crates/types/src/contrakt/storage_read.nr index e7dfed3542e..b69bc4915e3 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/contrakt/storage_read.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/contrakt/storage_read.nr @@ -1,6 +1,6 @@ use crate::{constants::CONTRACT_STORAGE_READ_LENGTH, traits::{Deserialize, Empty, Serialize}}; -struct StorageRead { +pub struct StorageRead { storage_slot: Field, current_value: Field, counter: u32, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/contrakt/storage_update_request.nr b/noir-projects/noir-protocol-circuits/crates/types/src/contrakt/storage_update_request.nr index e082b3c3990..46efa3d7c5c 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/contrakt/storage_update_request.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/contrakt/storage_update_request.nr @@ -1,6 +1,6 @@ use crate::{constants::CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH, traits::{Deserialize, Empty, Serialize}}; -struct StorageUpdateRequest { +pub struct StorageUpdateRequest { storage_slot : Field, new_value : Field, counter: u32 diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/data/public_data_hint.nr b/noir-projects/noir-protocol-circuits/crates/types/src/data/public_data_hint.nr index 23252c3a22c..7625534119a 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/data/public_data_hint.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/data/public_data_hint.nr @@ -4,7 +4,7 @@ use crate::{ constants::PUBLIC_DATA_TREE_HEIGHT }; -struct PublicDataHint { +pub struct PublicDataHint { leaf_slot: Field, value: Field, override_counter: u32, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/data/public_data_leaf_hint.nr b/noir-projects/noir-protocol-circuits/crates/types/src/data/public_data_leaf_hint.nr index ba6640318e2..f7a544abb4a 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/data/public_data_leaf_hint.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/data/public_data_leaf_hint.nr @@ -3,7 +3,7 @@ use crate::{ merkle_tree::MembershipWitness, constants::PUBLIC_DATA_TREE_HEIGHT }; -struct PublicDataLeafHint { +pub struct PublicDataLeafHint { preimage: PublicDataTreeLeafPreimage, membership_witness: MembershipWitness, } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/data/public_data_tree_leaf.nr b/noir-projects/noir-protocol-circuits/crates/types/src/data/public_data_tree_leaf.nr index 22741788061..5a0cdb28f58 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/data/public_data_tree_leaf.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/data/public_data_tree_leaf.nr @@ -1,6 +1,6 @@ use crate::{abis::{public_data_read::PublicDataRead, side_effect::{Overridable, Readable}}, traits::Empty}; -struct PublicDataTreeLeaf { +pub struct PublicDataTreeLeaf { slot: Field, value: Field, } @@ -23,7 +23,7 @@ impl PublicDataTreeLeaf { } } -struct OverridablePublicDataTreeLeaf { +pub struct OverridablePublicDataTreeLeaf { leaf: PublicDataTreeLeaf, override_counter: u32, } @@ -50,4 +50,3 @@ impl Overridable for OverridablePublicDataTreeLeaf { self.override_counter } } - diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/data/public_data_tree_leaf_preimage.nr b/noir-projects/noir-protocol-circuits/crates/types/src/data/public_data_tree_leaf_preimage.nr index 89fc59187c0..df33169354c 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/data/public_data_tree_leaf_preimage.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/data/public_data_tree_leaf_preimage.nr @@ -1,6 +1,6 @@ use crate::{merkle_tree::leaf_preimage::IndexedTreeLeafPreimage, traits::{Empty, Hash}}; -struct PublicDataTreeLeafPreimage { +pub struct PublicDataTreeLeafPreimage { slot : Field, value: Field, next_slot :Field, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/header.nr b/noir-projects/noir-protocol-circuits/crates/types/src/header.nr index 0421cf76181..c92dfdbc16d 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/header.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/header.nr @@ -13,7 +13,7 @@ use crate::{ }; // docs:start:header -struct Header { +pub struct Header { last_archive: AppendOnlyTreeSnapshot, content_commitment: ContentCommitment, state: StateReference, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/leaf_preimage.nr b/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/leaf_preimage.nr index 899481e57e4..f33dd072d96 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/leaf_preimage.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/leaf_preimage.nr @@ -1,9 +1,9 @@ -trait LeafPreimage { +pub trait LeafPreimage { fn get_key(self) -> Field; fn as_leaf(self) -> Field; } -trait IndexedTreeLeafPreimage { +pub trait IndexedTreeLeafPreimage { fn get_key(self) -> Field; fn get_next_key(self) -> Field; fn as_leaf(self) -> Field; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/membership.nr b/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/membership.nr index 72e77f13ffa..4dea95699f1 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/membership.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/membership.nr @@ -6,7 +6,7 @@ use crate::{ traits::Empty }; -struct MembershipWitness { +pub struct MembershipWitness { leaf_index: Field, sibling_path: [Field; N] } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/merkle_tree.nr b/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/merkle_tree.nr index 90f346cfa62..352ba795485 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/merkle_tree.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/merkle_tree.nr @@ -1,6 +1,6 @@ use crate::{traits::Empty, hash::merkle_hash}; -struct MerkleTree { +pub struct MerkleTree { leaves: [Field; N], nodes: [Field; N], } @@ -71,4 +71,3 @@ impl MerkleTree { pub fn sibling_index(index: u32) -> u32 { if index % 2 == 0 { index + 1 } else { index - 1 } } - diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/variable_merkle_tree.nr b/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/variable_merkle_tree.nr index dc0ca51c9d2..b4ffadabeb6 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/variable_merkle_tree.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/variable_merkle_tree.nr @@ -1,7 +1,7 @@ use crate::{hash::accumulate_sha256}; // N = maximum leaves // For now we only care about the root -struct VariableMerkleTree { +pub struct VariableMerkleTree { // leaves: [Field; N], root: Field, } @@ -207,4 +207,3 @@ mod tests { assert_eq(tree.root, full_tree.get_root()); } } - diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/messaging/l2_to_l1_message.nr b/noir-projects/noir-protocol-circuits/crates/types/src/messaging/l2_to_l1_message.nr index 2ba5999897c..e083d269d50 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/messaging/l2_to_l1_message.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/messaging/l2_to_l1_message.nr @@ -6,7 +6,7 @@ use crate::{ }; // Note: Not to be confused with L2ToL1Msg in Solidity -struct L2ToL1Message { +pub struct L2ToL1Message { recipient: EthAddress, content: Field, counter: u32, @@ -50,7 +50,7 @@ impl L2ToL1Message { } } -struct ScopedL2ToL1Message { +pub struct ScopedL2ToL1Message { message: L2ToL1Message, contract_address: AztecAddress, } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/meta/mod.nr b/noir-projects/noir-protocol-circuits/crates/types/src/meta/mod.nr index 231bd8d320a..6ecc896a137 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/meta/mod.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/meta/mod.nr @@ -172,19 +172,19 @@ pub(crate) comptime fn derive_deserialize(s: StructDefinition) -> Quoted { } #[derive(Serialize, Deserialize, Eq)] -struct Smol { +pub struct Smol { a: Field, b: Field, } #[derive(Serialize, Deserialize, Eq)] -struct HasArray { +pub struct HasArray { a: [Field; 2], b: bool } #[derive(Serialize, Deserialize, Eq)] -struct Fancier { +pub struct Fancier { a: Smol, b: [Field; 2], c: [u8; 3], diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/partial_state_reference.nr b/noir-projects/noir-protocol-circuits/crates/types/src/partial_state_reference.nr index c1a9dd30433..0390c3d8dc3 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/partial_state_reference.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/partial_state_reference.nr @@ -3,7 +3,7 @@ use crate::{ traits::{Deserialize, Empty, Serialize} }; -struct PartialStateReference { +pub struct PartialStateReference { note_hash_tree: AppendOnlyTreeSnapshot, nullifier_tree: AppendOnlyTreeSnapshot, public_data_tree: AppendOnlyTreeSnapshot, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/recursion/proof.nr b/noir-projects/noir-protocol-circuits/crates/types/src/recursion/proof.nr index 4d3d97280a3..6dc97c15c9e 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/recursion/proof.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/recursion/proof.nr @@ -3,7 +3,7 @@ use crate::{ constants::{RECURSIVE_PROOF_LENGTH, NESTED_RECURSIVE_PROOF_LENGTH} }; -struct RecursiveProof { +pub struct RecursiveProof { fields: [Field; RECURSIVE_PROOF_LENGTH], } @@ -25,7 +25,7 @@ impl Empty for RecursiveProof { } } -struct NestedRecursiveProof { +pub struct NestedRecursiveProof { fields: [Field; NESTED_RECURSIVE_PROOF_LENGTH], } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/recursion/traits.nr b/noir-projects/noir-protocol-circuits/crates/types/src/recursion/traits.nr index 49fca6738a1..7d0565e7c5c 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/recursion/traits.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/recursion/traits.nr @@ -1,3 +1,3 @@ -trait Verifiable { +pub trait Verifiable { fn verify(self); } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/recursion/verification_key.nr b/noir-projects/noir-protocol-circuits/crates/types/src/recursion/verification_key.nr index 2ebd2de3cde..e2b21da3bb3 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/recursion/verification_key.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/recursion/verification_key.nr @@ -2,7 +2,7 @@ use crate::{traits::{Serialize, Deserialize, Empty}, constants::VERIFICATION_KEY global SERIALIZED_VERIFICATION_KEY_LENGTH: u32 = VERIFICATION_KEY_LENGTH_IN_FIELDS + 1; -struct VerificationKey { +pub struct VerificationKey { key: [Field; VERIFICATION_KEY_LENGTH_IN_FIELDS], hash: Field, } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/state_reference.nr b/noir-projects/noir-protocol-circuits/crates/types/src/state_reference.nr index 1f0ca7a64e5..b8f7322e98f 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/state_reference.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/state_reference.nr @@ -5,7 +5,7 @@ use crate::{ utils::arr_copy_slice }; -struct StateReference { +pub struct StateReference { l1_to_l2_message_tree: AppendOnlyTreeSnapshot, partial: PartialStateReference, } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixture_builder.nr b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixture_builder.nr index f59d76d5ed9..1bd4a1c6e1b 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixture_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixture_builder.nr @@ -74,7 +74,7 @@ fn vec_reverse(vec: BoundedVec) -> BoundedVec { reversed } -struct FixtureBuilder { +pub struct FixtureBuilder { contract_address: AztecAddress, storage_contract_address: AztecAddress, msg_sender: AztecAddress, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/contract_functions.nr b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/contract_functions.nr index f0022e81473..972bbc6ac0f 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/contract_functions.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/contract_functions.nr @@ -2,7 +2,7 @@ use crate::abis::{function_data::FunctionData, function_selector::FunctionSelect use crate::merkle_tree::membership::MembershipWitness; use crate::constants::FUNCTION_TREE_HEIGHT; -struct ContractFunction { +pub struct ContractFunction { data: FunctionData, vk_hash: Field, acir_hash: Field, @@ -47,4 +47,3 @@ global default_public_function = ContractFunction { ], }, }; - diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/contracts.nr b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/contracts.nr index f711fdec1db..319ffb287e1 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/contracts.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/contracts.nr @@ -3,7 +3,7 @@ use crate::{ contract_class_id::ContractClassId }; -struct ContractData { +pub struct ContractData { address: AztecAddress, artifact_hash: Field, contract_address_salt: Field, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/tests/merkle_tree_utils.nr b/noir-projects/noir-protocol-circuits/crates/types/src/tests/merkle_tree_utils.nr index 0d759258d51..421e21f6ff1 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/tests/merkle_tree_utils.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/tests/merkle_tree_utils.nr @@ -65,7 +65,7 @@ fn test_merkle_tree_update_leaf_three_layers() { assert_eq(tree.get_root(), calculate_empty_tree_root(3)); } -struct NonEmptyMerkleTree { +pub struct NonEmptyMerkleTree { subtree: MerkleTree, zero_hashes: [Field; TREE_HEIGHT], left_supertree_branch: [Field; SUPERTREE_HEIGHT], diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/tests/types.nr b/noir-projects/noir-protocol-circuits/crates/types/src/tests/types.nr index d432ecb0cff..87afcbc0f8f 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/tests/types.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/tests/types.nr @@ -1,6 +1,6 @@ use crate::{abis::side_effect::Ordered, traits::Empty}; -struct TestValue { +pub(crate) struct TestValue { value: Field, counter: u32, } @@ -23,7 +23,7 @@ impl Ordered for TestValue { } } -struct TestTwoValues { +pub(crate) struct TestTwoValues { value_1: Field, value_2: Field, counter: u32, @@ -49,7 +49,7 @@ impl Ordered for TestTwoValues { } } -struct TestCombinedValue { +pub(crate) struct TestCombinedValue { value: Field, } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/traits.nr b/noir-projects/noir-protocol-circuits/crates/types/src/traits.nr index e2190c49967..8b287d4177a 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/traits.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/traits.nr @@ -107,7 +107,7 @@ impl ToField for str { } } -trait FromField { +pub trait FromField { fn from_field(value: Field) -> Self; } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/transaction/tx_context.nr b/noir-projects/noir-protocol-circuits/crates/types/src/transaction/tx_context.nr index f450a1a0eb3..0393c23652d 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/transaction/tx_context.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/transaction/tx_context.nr @@ -4,7 +4,7 @@ use crate::{ }; // docs:start:tx-context -struct TxContext { +pub struct TxContext { chain_id : Field, version : Field, gas_settings: GasSettings, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/transaction/tx_request.nr b/noir-projects/noir-protocol-circuits/crates/types/src/transaction/tx_request.nr index 5bc79a41c83..8bc221c8d3c 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/transaction/tx_request.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/transaction/tx_request.nr @@ -5,7 +5,7 @@ use crate::{ utils::reader::Reader }; -struct TxRequest { +pub struct TxRequest { origin: AztecAddress, args_hash: Field, tx_context: TxContext, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_combined_sorted_transformed_value_array/get_combined_order_hints.nr b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_combined_sorted_transformed_value_array/get_combined_order_hints.nr index 09ae1627c83..7f593937cf6 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_combined_sorted_transformed_value_array/get_combined_order_hints.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_combined_sorted_transformed_value_array/get_combined_order_hints.nr @@ -3,7 +3,7 @@ use crate::{ utils::arrays::{array_length, sort_by_counter::compare_by_counter_empty_padded_asc, get_sorted_tuple::get_sorted_tuple} }; -struct CombinedOrderHint { +pub(crate) struct CombinedOrderHint { counter: u32, original_index: u32, } @@ -254,4 +254,3 @@ mod tests { asc_to_equal(array_lt, array_gte, expected_hints); } } - diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_exposed_sorted_transformed_value_array/get_order_hints.nr b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_exposed_sorted_transformed_value_array/get_order_hints.nr index f5e6ba6200b..55ff2c86848 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_exposed_sorted_transformed_value_array/get_order_hints.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_exposed_sorted_transformed_value_array/get_order_hints.nr @@ -6,7 +6,7 @@ use crate::{ } }; -struct OrderHint { +pub struct OrderHint { counter: u32, sorted_index: u32, } @@ -147,4 +147,3 @@ mod tests { builder.desc_to_equal(expected_hints); } } - diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_split_sorted_transformed_value_arrays/get_split_order_hints.nr b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_split_sorted_transformed_value_arrays/get_split_order_hints.nr index 285835edf14..1b51607e7c9 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_split_sorted_transformed_value_arrays/get_split_order_hints.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_split_sorted_transformed_value_arrays/get_split_order_hints.nr @@ -6,7 +6,7 @@ use crate::{ } }; -struct SplitOrderHints { +pub struct SplitOrderHints { sorted_counters_lt: [u32; N], sorted_counters_gte: [u32; N], sorted_indexes: [u32; N], @@ -281,4 +281,3 @@ mod tests { builder.desc_to_equal(expected_hints); } } - diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/get_sorted_result.nr b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/get_sorted_result.nr index 7356f9c5ce3..3c51059a76b 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/get_sorted_result.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/get_sorted_result.nr @@ -1,6 +1,6 @@ use crate::{utils::arrays::{get_sorted_tuple::{get_sorted_tuple, SortedTuple}}}; -struct SortedResult { +pub struct SortedResult { sorted_array: [T; N], sorted_index_hints: [u32; N], original_index_hints: [u32; N], diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/get_sorted_tuple.nr b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/get_sorted_tuple.nr index 204d90c1fc9..bc57dfcd30a 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/get_sorted_tuple.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/get_sorted_tuple.nr @@ -1,6 +1,6 @@ use crate::utils::arrays::sort_by::sort_by; -struct SortedTuple { +pub struct SortedTuple { elem: T, original_index: u32, } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/utils/reader.nr b/noir-projects/noir-protocol-circuits/crates/types/src/utils/reader.nr index f537f0c9bce..3d8ace278ef 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/utils/reader.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/utils/reader.nr @@ -1,4 +1,4 @@ -struct Reader { +pub struct Reader { data: [Field; N], offset: u32, } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/utils/uint256.nr b/noir-projects/noir-protocol-circuits/crates/types/src/utils/uint256.nr index 54ac75ed94a..b54b7cc3b88 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/utils/uint256.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/utils/uint256.nr @@ -5,7 +5,7 @@ // // This is needed because in the cpp code, we have accumulate_sha256 // which returns 2 field elements, one for the high and low limb. -struct U256 { +pub struct U256 { // This is in big-endian order, typically because // sha256 is usually in big endian order. // Note: this means that inner[0] has the most significant 64 bits. @@ -56,7 +56,7 @@ impl U256 { // We cannot represent u128 in the type system // so we cannot return a u128 type. - // + // // This as conversion assumes that Field can store 128 bits of information // or else the conversion is lossy. // @@ -101,13 +101,13 @@ fn smoke_u256_from_bytes32_one_zero_zero_zero() { #[test] fn smoke_u256_from_bytes32_test() { /* - input: [ 0xAA, 0xBB, 0xCC, 0xDD, - 0xEE, 0xFF, 0x00, 0x11, - 0x22, 0x33, 0x44, 0x55, - 0x66, 0x77, 0x88, 0x99, - 0x11, 0x22, 0x33, 0x44, - 0x55, 0x66, 0x77, 0x88, - 0x99, 0xAA, 0xBB, 0xCC, + input: [ 0xAA, 0xBB, 0xCC, 0xDD, + 0xEE, 0xFF, 0x00, 0x11, + 0x22, 0x33, 0x44, 0x55, + 0x66, 0x77, 0x88, 0x99, + 0x11, 0x22, 0x33, 0x44, + 0x55, 0x66, 0x77, 0x88, + 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x00 ] output: inner[0]: 0xAABBCCDDEEFF0011