diff --git a/address-note/src/address_note.nr b/address-note/src/address_note.nr index 62786dd4..a1207e21 100644 --- a/address-note/src/address_note.nr +++ b/address-note/src/address_note.nr @@ -1,13 +1,16 @@ use dep::aztec::{ + context::PrivateContext, + keys::getters::get_nsk_app, + macros::notes::note, + note::{ + note_header::NoteHeader, note_interface::NullifiableNote, + utils::compute_note_hash_for_nullify, + }, + oracle::random::random, protocol_types::{ address::AztecAddress, constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash_with_separator, }, - note::{ - note_header::NoteHeader, note_interface::NullifiableNote, - utils::compute_note_hash_for_nullify, - }, oracle::random::random, keys::getters::get_nsk_app, context::PrivateContext, - macros::notes::note, }; // docs:start:address_note_def diff --git a/authwit/src/account.nr b/authwit/src/account.nr index 55f0e791..93c8ce72 100644 --- a/authwit/src/account.nr +++ b/authwit/src/account.nr @@ -1,11 +1,11 @@ use dep::aztec::{ context::PrivateContext, - protocol_types::constants::{GENERATOR_INDEX__COMBINED_PAYLOAD, GENERATOR_INDEX__TX_NULLIFIER}, hash::poseidon2_hash_with_separator, + protocol_types::constants::{GENERATOR_INDEX__COMBINED_PAYLOAD, GENERATOR_INDEX__TX_NULLIFIER}, }; +use crate::auth::{compute_authwit_message_hash, IS_VALID_SELECTOR}; use crate::entrypoint::{app::AppPayload, fee::FeePayload}; -use crate::auth::{IS_VALID_SELECTOR, compute_authwit_message_hash}; pub struct AccountActions { context: Context, diff --git a/authwit/src/auth.nr b/authwit/src/auth.nr index 88b8f3ea..a3f15076 100644 --- a/authwit/src/auth.nr +++ b/authwit/src/auth.nr @@ -1,11 +1,13 @@ +use dep::aztec::{context::{gas::GasOpts, PrivateContext, PublicContext}, hash::hash_args_array}; use dep::aztec::protocol_types::{ - abis::function_selector::FunctionSelector, address::AztecAddress, + abis::function_selector::FunctionSelector, + address::AztecAddress, constants::{ - GENERATOR_INDEX__AUTHWIT_INNER, GENERATOR_INDEX__AUTHWIT_OUTER, - GENERATOR_INDEX__AUTHWIT_NULLIFIER, CANONICAL_AUTH_REGISTRY_ADDRESS, - }, hash::poseidon2_hash_with_separator, + CANONICAL_AUTH_REGISTRY_ADDRESS, GENERATOR_INDEX__AUTHWIT_INNER, + GENERATOR_INDEX__AUTHWIT_NULLIFIER, GENERATOR_INDEX__AUTHWIT_OUTER, + }, + hash::poseidon2_hash_with_separator, }; -use dep::aztec::{context::{PrivateContext, PublicContext, gas::GasOpts}, hash::hash_args_array}; /** * Authenticaion witness helper library diff --git a/authwit/src/cheatcodes.nr b/authwit/src/cheatcodes.nr index a61c1f24..7b2192fe 100644 --- a/authwit/src/cheatcodes.nr +++ b/authwit/src/cheatcodes.nr @@ -1,11 +1,12 @@ use dep::aztec::{ - protocol_types::address::AztecAddress, - context::{public_context::PublicContext, call_interfaces::CallInterface}, - test::helpers::cheatcodes, oracle::execution::{get_block_number, get_contract_address}, + context::{call_interfaces::CallInterface, public_context::PublicContext}, hash::hash_args, + oracle::execution::{get_block_number, get_contract_address}, + protocol_types::address::AztecAddress, + test::helpers::cheatcodes, }; -use crate::auth::{compute_inner_authwit_hash, compute_authwit_message_hash, set_authorized}; +use crate::auth::{compute_authwit_message_hash, compute_inner_authwit_hash, set_authorized}; pub fn add_private_authwit_from_call_interface( on_behalf_of: AztecAddress, diff --git a/authwit/src/entrypoint/app.nr b/authwit/src/entrypoint/app.nr index 1aac89e5..3b1c1be2 100644 --- a/authwit/src/entrypoint/app.nr +++ b/authwit/src/entrypoint/app.nr @@ -1,6 +1,7 @@ use dep::aztec::prelude::PrivateContext; use dep::aztec::protocol_types::{ - constants::GENERATOR_INDEX__SIGNATURE_PAYLOAD, hash::poseidon2_hash_with_separator, + constants::GENERATOR_INDEX__SIGNATURE_PAYLOAD, + hash::poseidon2_hash_with_separator, traits::{Hash, Serialize}, }; diff --git a/authwit/src/entrypoint/fee.nr b/authwit/src/entrypoint/fee.nr index 7033b8e9..2adddbff 100644 --- a/authwit/src/entrypoint/fee.nr +++ b/authwit/src/entrypoint/fee.nr @@ -1,9 +1,10 @@ +use crate::entrypoint::function_call::FunctionCall; use dep::aztec::prelude::PrivateContext; use dep::aztec::protocol_types::{ - constants::GENERATOR_INDEX__FEE_PAYLOAD, hash::poseidon2_hash_with_separator, + constants::GENERATOR_INDEX__FEE_PAYLOAD, + hash::poseidon2_hash_with_separator, traits::{Hash, Serialize}, }; -use crate::entrypoint::function_call::FunctionCall; // 2 * 5 (FUNCTION_CALL_SIZE) + 2 global FEE_PAYLOAD_SIZE: u32 = 12; diff --git a/aztec/src/context/call_interfaces.nr b/aztec/src/context/call_interfaces.nr index c888c7b4..b4e55f61 100644 --- a/aztec/src/context/call_interfaces.nr +++ b/aztec/src/context/call_interfaces.nr @@ -3,12 +3,12 @@ use dep::protocol_types::{ }; use crate::context::{ - private_context::PrivateContext, public_context::PublicContext, gas::GasOpts, - inputs::PrivateContextInputs, + gas::GasOpts, inputs::PrivateContextInputs, private_context::PrivateContext, + public_context::PublicContext, }; -use crate::oracle::arguments::pack_arguments; use crate::hash::hash_args; +use crate::oracle::arguments::pack_arguments; pub trait CallInterface { fn get_args(self) -> [Field] { diff --git a/aztec/src/context/inputs/private_context_inputs.nr b/aztec/src/context/inputs/private_context_inputs.nr index d41648e4..926450aa 100644 --- a/aztec/src/context/inputs/private_context_inputs.nr +++ b/aztec/src/context/inputs/private_context_inputs.nr @@ -1,6 +1,6 @@ use dep::protocol_types::{ - transaction::tx_context::TxContext, abis::call_context::CallContext, header::Header, - traits::Empty, + abis::call_context::CallContext, header::Header, traits::Empty, + transaction::tx_context::TxContext, }; // PrivateContextInputs are expected to be provided to each private function diff --git a/aztec/src/context/mod.nr b/aztec/src/context/mod.nr index f4cf63fd..62347deb 100644 --- a/aztec/src/context/mod.nr +++ b/aztec/src/context/mod.nr @@ -10,12 +10,12 @@ mod call_interfaces; mod gas; pub use call_interfaces::{ - PrivateCallInterface, PrivateStaticCallInterface, PublicCallInterface, - PublicStaticCallInterface, PrivateVoidCallInterface, PrivateStaticVoidCallInterface, - PublicVoidCallInterface, PublicStaticVoidCallInterface, + PrivateCallInterface, PrivateStaticCallInterface, PrivateStaticVoidCallInterface, + PrivateVoidCallInterface, PublicCallInterface, PublicStaticCallInterface, + PublicStaticVoidCallInterface, PublicVoidCallInterface, }; -pub use private_context::PrivateContext; pub use packed_returns::PackedReturns; -pub use public_context::PublicContext; +pub use private_context::PrivateContext; pub use public_context::FunctionReturns; +pub use public_context::PublicContext; pub use unconstrained_context::UnconstrainedContext; diff --git a/aztec/src/context/private_context.nr b/aztec/src/context/private_context.nr index 049a828a..1465b61e 100644 --- a/aztec/src/context/private_context.nr +++ b/aztec/src/context/private_context.nr @@ -1,34 +1,47 @@ use crate::{ context::{inputs::PrivateContextInputs, packed_returns::PackedReturns}, - messaging::process_l1_to_l2_message, hash::{hash_args_array, ArgsHasher}, - keys::constants::{NULLIFIER_INDEX, OUTGOING_INDEX, NUM_KEY_TYPES, sk_generators}, + hash::{ArgsHasher, hash_args_array}, + keys::constants::{NULLIFIER_INDEX, NUM_KEY_TYPES, OUTGOING_INDEX, sk_generators}, + messaging::process_l1_to_l2_message, oracle::{ - key_validation_request::get_key_validation_request, arguments, returns::pack_returns, - call_private_function::call_private_function_internal, header::get_header_at, - logs::{emit_encrypted_note_log, emit_encrypted_event_log}, + arguments, + call_private_function::call_private_function_internal, enqueue_public_function_call::{ enqueue_public_function_call_internal, notify_set_min_revertible_side_effect_counter, set_public_teardown_function_call_internal, }, + header::get_header_at, + key_validation_request::get_key_validation_request, + logs::{emit_encrypted_event_log, emit_encrypted_note_log}, + returns::pack_returns, }, }; use dep::protocol_types::{ abis::{ - call_context::CallContext, function_selector::FunctionSelector, + call_context::CallContext, + function_selector::FunctionSelector, + log_hash::{EncryptedLogHash, LogHash, NoteLogHash}, max_block_number::MaxBlockNumber, - validation_requests::{KeyValidationRequest, KeyValidationRequestAndGenerator}, + note_hash::NoteHash, + nullifier::Nullifier, private_call_request::PrivateCallRequest, private_circuit_public_inputs::PrivateCircuitPublicInputs, - public_call_request::PublicCallRequest, read_request::ReadRequest, note_hash::NoteHash, - nullifier::Nullifier, log_hash::{LogHash, NoteLogHash, EncryptedLogHash}, - }, address::{AztecAddress, EthAddress}, + public_call_request::PublicCallRequest, + read_request::ReadRequest, + validation_requests::{KeyValidationRequest, KeyValidationRequestAndGenerator}, + }, + address::{AztecAddress, EthAddress}, constants::{ - MAX_NOTE_HASHES_PER_CALL, MAX_L2_TO_L1_MSGS_PER_CALL, MAX_NULLIFIERS_PER_CALL, + MAX_ENCRYPTED_LOGS_PER_CALL, MAX_KEY_VALIDATION_REQUESTS_PER_CALL, + MAX_L2_TO_L1_MSGS_PER_CALL, MAX_NOTE_ENCRYPTED_LOGS_PER_CALL, + MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, MAX_NOTE_HASHES_PER_CALL, + MAX_NULLIFIER_READ_REQUESTS_PER_CALL, MAX_NULLIFIERS_PER_CALL, MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, - MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, MAX_NULLIFIER_READ_REQUESTS_PER_CALL, - MAX_KEY_VALIDATION_REQUESTS_PER_CALL, MAX_ENCRYPTED_LOGS_PER_CALL, - MAX_UNENCRYPTED_LOGS_PER_CALL, MAX_NOTE_ENCRYPTED_LOGS_PER_CALL, PUBLIC_DISPATCH_SELECTOR, - }, header::Header, messaging::l2_to_l1_message::L2ToL1Message, traits::Empty, + MAX_UNENCRYPTED_LOGS_PER_CALL, PUBLIC_DISPATCH_SELECTOR, + }, + header::Header, + messaging::l2_to_l1_message::L2ToL1Message, + traits::Empty, }; // When finished, one can call .finish() to convert back to the abi diff --git a/aztec/src/context/public_context.nr b/aztec/src/context/public_context.nr index 8c09a49c..e63fde7e 100644 --- a/aztec/src/context/public_context.nr +++ b/aztec/src/context/public_context.nr @@ -1,9 +1,9 @@ -use crate::hash::{compute_secret_hash, compute_message_hash, compute_message_nullifier}; +use crate::context::gas::GasOpts; +use crate::hash::{compute_message_hash, compute_message_nullifier, compute_secret_hash}; +use dep::protocol_types::abis::function_selector::FunctionSelector; use dep::protocol_types::address::{AztecAddress, EthAddress}; use dep::protocol_types::constants::{MAX_FIELD_VALUE, PUBLIC_DISPATCH_SELECTOR}; -use dep::protocol_types::traits::{Serialize, Deserialize, Empty}; -use dep::protocol_types::abis::function_selector::FunctionSelector; -use crate::context::gas::GasOpts; +use dep::protocol_types::traits::{Deserialize, Empty, Serialize}; pub struct PublicContext { args_hash: Option, diff --git a/aztec/src/context/unconstrained_context.nr b/aztec/src/context/unconstrained_context.nr index fad4adff..26b85311 100644 --- a/aztec/src/context/unconstrained_context.nr +++ b/aztec/src/context/unconstrained_context.nr @@ -1,8 +1,8 @@ -use dep::protocol_types::{address::AztecAddress, traits::Deserialize}; use crate::oracle::{ - execution::{get_chain_id, get_version, get_contract_address, get_block_number}, + execution::{get_block_number, get_chain_id, get_contract_address, get_version}, storage::storage_read, }; +use dep::protocol_types::{address::AztecAddress, traits::Deserialize}; pub struct UnconstrainedContext { block_number: u32, diff --git a/aztec/src/deploy.nr b/aztec/src/deploy.nr index 2920d1c9..ec564f7b 100644 --- a/aztec/src/deploy.nr +++ b/aztec/src/deploy.nr @@ -1,7 +1,7 @@ use crate::{context::PrivateContext, oracle::get_contract_instance::get_contract_instance}; use dep::protocol_types::{ - address::AztecAddress, abis::function_selector::FunctionSelector, + abis::function_selector::FunctionSelector, address::AztecAddress, constants::DEPLOYER_CONTRACT_ADDRESS, }; diff --git a/aztec/src/encrypted_logs/encrypted_event_emission.nr b/aztec/src/encrypted_logs/encrypted_event_emission.nr index 960313d9..5cccd747 100644 --- a/aztec/src/encrypted_logs/encrypted_event_emission.nr +++ b/aztec/src/encrypted_logs/encrypted_event_emission.nr @@ -1,10 +1,11 @@ use crate::{ - context::PrivateContext, event::event_interface::EventInterface, - encrypted_logs::payload::compute_encrypted_log, keys::getters::get_ovsk_app, - oracle::random::random, + context::PrivateContext, encrypted_logs::payload::compute_encrypted_log, + event::event_interface::EventInterface, keys::getters::get_ovsk_app, oracle::random::random, }; use dep::protocol_types::{ - address::AztecAddress, public_keys::{OvpkM, IvpkM}, hash::sha256_to_field, + address::AztecAddress, + hash::sha256_to_field, + public_keys::{IvpkM, OvpkM}, }; fn compute_raw_event_log( diff --git a/aztec/src/encrypted_logs/encrypted_note_emission.nr b/aztec/src/encrypted_logs/encrypted_note_emission.nr index 698da4ee..5239418d 100644 --- a/aztec/src/encrypted_logs/encrypted_note_emission.nr +++ b/aztec/src/encrypted_logs/encrypted_note_emission.nr @@ -1,10 +1,14 @@ use crate::{ - context::PrivateContext, note::{note_emission::NoteEmission, note_interface::NoteInterface}, - keys::getters::get_ovsk_app, encrypted_logs::payload::compute_encrypted_log, + context::PrivateContext, + encrypted_logs::payload::compute_encrypted_log, + keys::getters::get_ovsk_app, + note::{note_emission::NoteEmission, note_interface::NoteInterface}, }; use dep::protocol_types::{ - address::AztecAddress, public_keys::{PublicKeys, OvpkM, IvpkM}, hash::sha256_to_field, abis::note_hash::NoteHash, + address::AztecAddress, + hash::sha256_to_field, + public_keys::{IvpkM, OvpkM, PublicKeys}, }; fn compute_raw_note_log( diff --git a/aztec/src/encrypted_logs/header.nr b/aztec/src/encrypted_logs/header.nr index 1872fbb2..54850470 100644 --- a/aztec/src/encrypted_logs/header.nr +++ b/aztec/src/encrypted_logs/header.nr @@ -1,5 +1,8 @@ use dep::protocol_types::{ - address::AztecAddress, public_keys::{PublicKeys, IvpkM, ToPoint}, scalar::Scalar, point::Point, + address::AztecAddress, + point::Point, + public_keys::{IvpkM, PublicKeys, ToPoint}, + scalar::Scalar, }; use crate::keys::point_to_symmetric_key::point_to_symmetric_key; diff --git a/aztec/src/encrypted_logs/payload.nr b/aztec/src/encrypted_logs/payload.nr index 60dad282..8e8a419f 100644 --- a/aztec/src/encrypted_logs/payload.nr +++ b/aztec/src/encrypted_logs/payload.nr @@ -1,16 +1,20 @@ use dep::protocol_types::{ - address::AztecAddress, scalar::Scalar, point::Point, public_keys::{OvpkM, IvpkM}, - constants::GENERATOR_INDEX__SYMMETRIC_KEY, hash::poseidon2_hash_with_separator, + address::AztecAddress, + constants::GENERATOR_INDEX__SYMMETRIC_KEY, + hash::poseidon2_hash_with_separator, + point::Point, + public_keys::{IvpkM, OvpkM}, + scalar::Scalar, }; use std::{ aes128::aes128_encrypt, embedded_curve_ops::fixed_base_scalar_mul as derive_public_key, - hash::from_field_unsafe as fr_to_fq_unsafe, field::bn254::decompose, + field::bn254::decompose, hash::from_field_unsafe as fr_to_fq_unsafe, }; use crate::{ - oracle::random::random, utils::point::point_to_bytes, encrypted_logs::header::EncryptedLogHeader, - keys::point_to_symmetric_key::point_to_symmetric_key, + keys::point_to_symmetric_key::point_to_symmetric_key, oracle::random::random, + utils::point::point_to_bytes, }; pub fn compute_encrypted_log( @@ -152,10 +156,13 @@ mod test { use crate::encrypted_logs::payload::{ compute_encrypted_log, compute_incoming_body_ciphertext, compute_outgoing_body_ciphertext, }; - use std::embedded_curve_ops::fixed_base_scalar_mul as derive_public_key; use dep::protocol_types::{ - address::AztecAddress, public_keys::{OvpkM, IvpkM}, point::Point, scalar::Scalar, + address::AztecAddress, + point::Point, + public_keys::{IvpkM, OvpkM}, + scalar::Scalar, }; + use std::embedded_curve_ops::fixed_base_scalar_mul as derive_public_key; use std::test::OracleMock; #[test] diff --git a/aztec/src/generators.nr b/aztec/src/generators.nr index 7671d8f2..5c787b60 100644 --- a/aztec/src/generators.nr +++ b/aztec/src/generators.nr @@ -34,7 +34,7 @@ global G_slot = Point { }; mod test { - use crate::generators::{Ga1, Ga2, Ga3, Ga4, Ga5, G_slot}; + use crate::generators::{G_slot, Ga1, Ga2, Ga3, Ga4, Ga5}; use dep::protocol_types::point::Point; use std::hash::derive_generators; diff --git a/aztec/src/hash.nr b/aztec/src/hash.nr index c58c78db..4e5b9111 100644 --- a/aztec/src/hash.nr +++ b/aztec/src/hash.nr @@ -1,12 +1,14 @@ +use crate::utils::to_bytes::{arr_to_be_bytes_arr, str_to_be_bytes_arr}; use dep::protocol_types::{ address::{AztecAddress, EthAddress}, constants::{ - GENERATOR_INDEX__SECRET_HASH, GENERATOR_INDEX__MESSAGE_NULLIFIER, - GENERATOR_INDEX__FUNCTION_ARGS, - }, point::Point, traits::Hash, - hash::{sha256_to_field, poseidon2_hash_with_separator, poseidon2_hash_with_separator_slice}, + GENERATOR_INDEX__FUNCTION_ARGS, GENERATOR_INDEX__MESSAGE_NULLIFIER, + GENERATOR_INDEX__SECRET_HASH, + }, + hash::{poseidon2_hash_with_separator, poseidon2_hash_with_separator_slice, sha256_to_field}, + point::Point, + traits::Hash, }; -use crate::utils::to_bytes::{arr_to_be_bytes_arr, str_to_be_bytes_arr}; pub use dep::protocol_types::hash::{compute_siloed_nullifier, pedersen_hash}; diff --git a/aztec/src/history/contract_inclusion.nr b/aztec/src/history/contract_inclusion.nr index 456c1dac..342be3c0 100644 --- a/aztec/src/history/contract_inclusion.nr +++ b/aztec/src/history/contract_inclusion.nr @@ -1,6 +1,6 @@ use dep::protocol_types::{ - header::Header, address::AztecAddress, hash::compute_siloed_nullifier, - constants::DEPLOYER_CONTRACT_ADDRESS, + address::AztecAddress, constants::DEPLOYER_CONTRACT_ADDRESS, hash::compute_siloed_nullifier, + header::Header, }; trait ProveContractDeployment { diff --git a/aztec/src/history/note_inclusion.nr b/aztec/src/history/note_inclusion.nr index a7f18eb4..0876b824 100644 --- a/aztec/src/history/note_inclusion.nr +++ b/aztec/src/history/note_inclusion.nr @@ -1,8 +1,8 @@ -use dep::protocol_types::merkle_tree::root::root_from_sibling_path; use dep::protocol_types::header::Header; +use dep::protocol_types::merkle_tree::root::root_from_sibling_path; use crate::{ - note::{utils::compute_note_hash_for_nullify, note_interface::{NoteInterface, NullifiableNote}}, + note::{note_interface::{NoteInterface, NullifiableNote}, utils::compute_note_hash_for_nullify}, oracle::get_membership_witness::get_note_hash_membership_witness, }; diff --git a/aztec/src/history/nullifier_inclusion.nr b/aztec/src/history/nullifier_inclusion.nr index 3651acab..bd0f508d 100644 --- a/aztec/src/history/nullifier_inclusion.nr +++ b/aztec/src/history/nullifier_inclusion.nr @@ -1,10 +1,10 @@ -use dep::protocol_types::merkle_tree::root::root_from_sibling_path; use dep::protocol_types::header::Header; +use dep::protocol_types::merkle_tree::root::root_from_sibling_path; use crate::{ context::PrivateContext, + note::{note_interface::{NoteInterface, NullifiableNote}, utils::compute_siloed_nullifier}, oracle::get_nullifier_membership_witness::get_nullifier_membership_witness, - note::{utils::compute_siloed_nullifier, note_interface::{NoteInterface, NullifiableNote}}, }; trait ProveNullifierInclusion { diff --git a/aztec/src/history/nullifier_non_inclusion.nr b/aztec/src/history/nullifier_non_inclusion.nr index e8cf5d7b..95a43086 100644 --- a/aztec/src/history/nullifier_non_inclusion.nr +++ b/aztec/src/history/nullifier_non_inclusion.nr @@ -1,12 +1,13 @@ -use dep::protocol_types::merkle_tree::root::root_from_sibling_path; -use dep::protocol_types::{ - header::Header, utils::field::{full_field_less_than, full_field_greater_than}, -}; use crate::{ context::PrivateContext, - note::{utils::compute_siloed_nullifier, note_interface::{NoteInterface, NullifiableNote}}, + note::{note_interface::{NoteInterface, NullifiableNote}, utils::compute_siloed_nullifier}, oracle::get_nullifier_membership_witness::get_low_nullifier_membership_witness, }; +use dep::protocol_types::{ + header::Header, + utils::field::{full_field_greater_than, full_field_less_than}, +}; +use dep::protocol_types::merkle_tree::root::root_from_sibling_path; trait ProveNullifierNonInclusion { fn prove_nullifier_non_inclusion(header: Header, nullifier: Field); diff --git a/aztec/src/history/public_storage.nr b/aztec/src/history/public_storage.nr index 78aeeb63..d26397d1 100644 --- a/aztec/src/history/public_storage.nr +++ b/aztec/src/history/public_storage.nr @@ -1,6 +1,6 @@ use dep::protocol_types::{ - constants::GENERATOR_INDEX__PUBLIC_LEAF_INDEX, hash::poseidon2_hash_with_separator, - address::AztecAddress, header::Header, utils::field::full_field_less_than, + address::AztecAddress, constants::GENERATOR_INDEX__PUBLIC_LEAF_INDEX, + hash::poseidon2_hash_with_separator, header::Header, utils::field::full_field_less_than, }; use dep::protocol_types::merkle_tree::root::root_from_sibling_path; diff --git a/aztec/src/initializer.nr b/aztec/src/initializer.nr index ec966af7..71509340 100644 --- a/aztec/src/initializer.nr +++ b/aztec/src/initializer.nr @@ -1,11 +1,11 @@ use dep::protocol_types::{ - address::AztecAddress, hash::poseidon2_hash_with_separator, - constants::GENERATOR_INDEX__CONSTRUCTOR, abis::function_selector::FunctionSelector, + abis::function_selector::FunctionSelector, address::AztecAddress, + constants::GENERATOR_INDEX__CONSTRUCTOR, hash::poseidon2_hash_with_separator, }; use crate::{ - context::{PrivateContext, PublicContext}, oracle::get_contract_instance::get_contract_instance, - oracle::get_contract_instance::get_contract_instance_avm, + context::{PrivateContext, PublicContext}, + oracle::get_contract_instance::{get_contract_instance, get_contract_instance_avm}, }; pub fn mark_as_initialized_public(context: &mut PublicContext) { diff --git a/aztec/src/keys/constants.nr b/aztec/src/keys/constants.nr index 2d465369..ad2c7cc7 100644 --- a/aztec/src/keys/constants.nr +++ b/aztec/src/keys/constants.nr @@ -1,5 +1,5 @@ use dep::protocol_types::constants::{ - GENERATOR_INDEX__NSK_M, GENERATOR_INDEX__IVSK_M, GENERATOR_INDEX__OVSK_M, + GENERATOR_INDEX__IVSK_M, GENERATOR_INDEX__NSK_M, GENERATOR_INDEX__OVSK_M, GENERATOR_INDEX__TSK_M, }; diff --git a/aztec/src/keys/getters/mod.nr b/aztec/src/keys/getters/mod.nr index 52502eed..da3b7cd6 100644 --- a/aztec/src/keys/getters/mod.nr +++ b/aztec/src/keys/getters/mod.nr @@ -1,10 +1,11 @@ -use dep::protocol_types::{address::AztecAddress, public_keys::PublicKeys}; use crate::{ + keys::constants::{NULLIFIER_INDEX, OUTGOING_INDEX}, oracle::{ - keys::get_public_keys_and_partial_address, key_validation_request::get_key_validation_request, - }, keys::constants::{NULLIFIER_INDEX, OUTGOING_INDEX}, + keys::get_public_keys_and_partial_address, + }, }; +use dep::protocol_types::{address::AztecAddress, public_keys::PublicKeys}; mod test; diff --git a/aztec/src/keys/point_to_symmetric_key.nr b/aztec/src/keys/point_to_symmetric_key.nr index 7c55cbe5..f1ad2b43 100644 --- a/aztec/src/keys/point_to_symmetric_key.nr +++ b/aztec/src/keys/point_to_symmetric_key.nr @@ -1,8 +1,8 @@ +use crate::utils::point::point_to_bytes; use dep::protocol_types::{ - constants::GENERATOR_INDEX__SYMMETRIC_KEY, scalar::Scalar, point::Point, utils::arr_copy_slice, + constants::GENERATOR_INDEX__SYMMETRIC_KEY, point::Point, scalar::Scalar, utils::arr_copy_slice, }; -use crate::utils::point::point_to_bytes; -use std::{hash::sha256, embedded_curve_ops::multi_scalar_mul}; +use std::{embedded_curve_ops::multi_scalar_mul, hash::sha256}; // TODO(#5726): This function is called deriveAESSecret in TS. I don't like point_to_symmetric_key name much since // point is not the only input of the function. Unify naming with TS once we have a better name. diff --git a/aztec/src/macros/events/mod.nr b/aztec/src/macros/events/mod.nr index be9e588c..bf7f433e 100644 --- a/aztec/src/macros/events/mod.nr +++ b/aztec/src/macros/events/mod.nr @@ -1,5 +1,5 @@ -use protocol_types::meta::flatten_to_fields; use super::utils::compute_event_selector; +use protocol_types::meta::flatten_to_fields; comptime fn generate_event_interface(s: StructDefinition) -> Quoted { let name = s.name(); diff --git a/aztec/src/macros/functions/interfaces.nr b/aztec/src/macros/functions/interfaces.nr index d2800f8f..720ca217 100644 --- a/aztec/src/macros/functions/interfaces.nr +++ b/aztec/src/macros/functions/interfaces.nr @@ -1,10 +1,11 @@ +use crate::macros::utils::{ + add_to_field_slice, compute_fn_selector, get_fn_visibility, is_fn_private, is_fn_public, + is_fn_view, +}; use std::{ - meta::{unquote, type_of}, collections::umap::UHashMap, + collections::umap::UHashMap, hash::{BuildHasherDefault, poseidon2::Poseidon2Hasher}, -}; -use crate::macros::utils::{ - get_fn_visibility, is_fn_view, is_fn_private, add_to_field_slice, compute_fn_selector, - is_fn_public, + meta::{type_of, unquote}, }; comptime mut global STUBS: UHashMap> = diff --git a/aztec/src/macros/functions/mod.nr b/aztec/src/macros/functions/mod.nr index b60212dc..bc74d225 100644 --- a/aztec/src/macros/functions/mod.nr +++ b/aztec/src/macros/functions/mod.nr @@ -1,11 +1,11 @@ mod interfaces; -use std::meta::type_of; use super::utils::{ - modify_fn_body, is_fn_private, get_fn_visibility, is_fn_view, is_fn_initializer, is_fn_internal, - fn_has_noinitcheck, add_to_hasher, module_has_storage, module_has_initializer, + add_to_hasher, fn_has_noinitcheck, get_fn_visibility, is_fn_initializer, is_fn_internal, + is_fn_private, is_fn_view, modify_fn_body, module_has_initializer, module_has_storage, }; use protocol_types::meta::flatten_to_fields; +use std::meta::type_of; use interfaces::{create_fn_abi_export, register_stub, stub_fn}; diff --git a/aztec/src/macros/mod.nr b/aztec/src/macros/mod.nr index cc9b860f..95a30da6 100644 --- a/aztec/src/macros/mod.nr +++ b/aztec/src/macros/mod.nr @@ -6,12 +6,12 @@ mod storage; mod events; use functions::interfaces::STUBS; +use notes::{generate_note_export, NOTES}; use storage::STORAGE_LAYOUT_NAME; -use notes::{NOTES, generate_note_export}; +use dispatch::generate_public_dispatch; use functions::transform_unconstrained; use utils::module_has_storage; -use dispatch::generate_public_dispatch; /// Marks a contract as an Aztec contract, generating the interfaces for its functions and notes, as well as injecting /// the `compute_note_hash_and_optionally_a_nullifier` function PXE requires in order to validate notes. diff --git a/aztec/src/macros/notes/mod.nr b/aztec/src/macros/notes/mod.nr index edbf60dc..511cf4ec 100644 --- a/aztec/src/macros/notes/mod.nr +++ b/aztec/src/macros/notes/mod.nr @@ -1,9 +1,10 @@ +use crate::note::{note_getter_options::PropertySelector, note_header::NoteHeader}; +use protocol_types::meta::{flatten_to_fields, pack_from_fields}; use std::{ - meta::{type_of, unquote, typ::fresh_type_variable}, collections::umap::UHashMap, + collections::umap::UHashMap, hash::{BuildHasherDefault, poseidon2::Poseidon2Hasher}, + meta::{typ::fresh_type_variable, type_of, unquote}, }; -use protocol_types::meta::{flatten_to_fields, pack_from_fields}; -use crate::note::{note_header::NoteHeader, note_getter_options::PropertySelector}; comptime global NOTE_HEADER_TYPE = type_of(NoteHeader::empty()); diff --git a/aztec/src/macros/storage/mod.nr b/aztec/src/macros/storage/mod.nr index c9535db0..5d1e27c7 100644 --- a/aztec/src/macros/storage/mod.nr +++ b/aztec/src/macros/storage/mod.nr @@ -1,5 +1,6 @@ use std::{ - collections::umap::UHashMap, hash::{BuildHasherDefault, poseidon2::Poseidon2Hasher}, + collections::umap::UHashMap, + hash::{BuildHasherDefault, poseidon2::Poseidon2Hasher}, meta::unquote, }; diff --git a/aztec/src/messaging.nr b/aztec/src/messaging.nr index ffeddf4d..6679fe06 100644 --- a/aztec/src/messaging.nr +++ b/aztec/src/messaging.nr @@ -1,10 +1,11 @@ use crate::{ - hash::{compute_secret_hash, compute_message_hash, compute_message_nullifier}, + hash::{compute_message_hash, compute_message_nullifier, compute_secret_hash}, oracle::get_l1_to_l2_membership_witness::get_l1_to_l2_membership_witness, }; use dep::protocol_types::{ - address::{AztecAddress, EthAddress}, merkle_tree::root::root_from_sibling_path, + address::{AztecAddress, EthAddress}, + merkle_tree::root::root_from_sibling_path, }; pub fn process_l1_to_l2_message( diff --git a/aztec/src/note/lifecycle.nr b/aztec/src/note/lifecycle.nr index a348ef3f..d07e61e8 100644 --- a/aztec/src/note/lifecycle.nr +++ b/aztec/src/note/lifecycle.nr @@ -1,8 +1,9 @@ use crate::context::{PrivateContext, PublicContext}; use crate::note::{ - note_header::NoteHeader, note_interface::{NoteInterface, NullifiableNote}, - utils::{compute_note_hash_for_read_request, compute_note_hash_for_nullify_internal}, note_emission::NoteEmission, + note_header::NoteHeader, + note_interface::{NoteInterface, NullifiableNote}, + utils::{compute_note_hash_for_nullify_internal, compute_note_hash_for_read_request}, }; use crate::oracle::notes::{notify_created_note, notify_nullified_note}; diff --git a/aztec/src/note/note_getter/mod.nr b/aztec/src/note/note_getter/mod.nr index fb463154..52e8a14b 100644 --- a/aztec/src/note/note_getter/mod.nr +++ b/aztec/src/note/note_getter/mod.nr @@ -1,15 +1,16 @@ -use dep::protocol_types::constants::{ - MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, GET_NOTES_ORACLE_RETURN_LENGTH, -}; use crate::context::PrivateContext; use crate::note::{ constants::{GET_NOTE_ORACLE_RETURN_LENGTH, VIEW_NOTE_ORACLE_RETURN_LENGTH}, - note_getter_options::{NoteGetterOptions, Select, Sort, SortOrder, NoteStatus, PropertySelector}, - note_interface::{NoteInterface, NullifiableNote}, note_viewer_options::NoteViewerOptions, + note_getter_options::{NoteGetterOptions, NoteStatus, PropertySelector, Select, Sort, SortOrder}, + note_interface::{NoteInterface, NullifiableNote}, + note_viewer_options::NoteViewerOptions, utils::compute_note_hash_for_read_request, }; use crate::oracle; use crate::utils::comparison::compare; +use dep::protocol_types::constants::{ + GET_NOTES_ORACLE_RETURN_LENGTH, MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, +}; pub use crate::note::constants::MAX_NOTES_PER_PAGE; diff --git a/aztec/src/note/note_getter/test.nr b/aztec/src/note/note_getter/test.nr index b9267de3..48728210 100644 --- a/aztec/src/note/note_getter/test.nr +++ b/aztec/src/note/note_getter/test.nr @@ -1,10 +1,11 @@ -use dep::protocol_types::constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL; use crate::{ note::{ - note_getter_options::{NoteGetterOptions, SortOrder, PropertySelector}, note_getter::constrain_get_notes_internal, - }, oracle::execution::get_contract_address, + note_getter_options::{NoteGetterOptions, PropertySelector, SortOrder}, + }, + oracle::execution::get_contract_address, }; +use dep::protocol_types::constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL; use crate::test::{helpers::test_environment::TestEnvironment, mocks::mock_note::MockNote}; use crate::utils::comparison::Comparator; diff --git a/aztec/src/note/note_getter_options.nr b/aztec/src/note/note_getter_options.nr index 452818b9..c4a5eb0f 100644 --- a/aztec/src/note/note_getter_options.nr +++ b/aztec/src/note/note_getter_options.nr @@ -1,6 +1,6 @@ -use std::option::Option; -use dep::protocol_types::{constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, traits::ToField}; use crate::note::note_interface::NoteInterface; +use dep::protocol_types::{constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, traits::ToField}; +use std::option::Option; pub struct PropertySelector { index: u8, // index of the field in the serialized note array diff --git a/aztec/src/note/note_viewer_options.nr b/aztec/src/note/note_viewer_options.nr index 321e3d6c..e4d64104 100644 --- a/aztec/src/note/note_viewer_options.nr +++ b/aztec/src/note/note_viewer_options.nr @@ -1,8 +1,8 @@ -use std::option::Option; -use crate::note::note_getter_options::{PropertySelector, Select, Sort, NoteStatus}; -use dep::protocol_types::traits::ToField; -use crate::note::note_interface::NoteInterface; use crate::note::constants::MAX_NOTES_PER_PAGE; +use crate::note::note_getter_options::{NoteStatus, PropertySelector, Select, Sort}; +use crate::note::note_interface::NoteInterface; +use dep::protocol_types::traits::ToField; +use std::option::Option; // docs:start:NoteViewerOptions pub struct NoteViewerOptions { diff --git a/aztec/src/note/utils.nr b/aztec/src/note/utils.nr index 0dab8de2..6f3031f0 100644 --- a/aztec/src/note/utils.nr +++ b/aztec/src/note/utils.nr @@ -1,13 +1,15 @@ use crate::{ context::PrivateContext, - note::{note_header::NoteHeader, note_interface::{NullifiableNote, NoteInterface}}, + note::{note_header::NoteHeader, note_interface::{NoteInterface, NullifiableNote}}, }; use dep::protocol_types::{ hash::{ - compute_unique_note_hash, compute_siloed_note_hash as compute_siloed_note_hash, + compute_siloed_note_hash as compute_siloed_note_hash, compute_siloed_nullifier as compute_siloed_nullifier_from_preimage, - }, utils::arr_copy_slice, + compute_unique_note_hash, + }, + utils::arr_copy_slice, }; pub fn compute_siloed_nullifier( diff --git a/aztec/src/oracle/get_contract_instance.nr b/aztec/src/oracle/get_contract_instance.nr index 7e8416c5..7958bfd8 100644 --- a/aztec/src/oracle/get_contract_instance.nr +++ b/aztec/src/oracle/get_contract_instance.nr @@ -1,5 +1,5 @@ use dep::protocol_types::{ - address::AztecAddress, contract_instance::ContractInstance, constants::CONTRACT_INSTANCE_LENGTH, + address::AztecAddress, constants::CONTRACT_INSTANCE_LENGTH, contract_instance::ContractInstance, utils::reader::Reader, }; diff --git a/aztec/src/oracle/get_membership_witness.nr b/aztec/src/oracle/get_membership_witness.nr index 3987fab9..fed4c3b6 100644 --- a/aztec/src/oracle/get_membership_witness.nr +++ b/aztec/src/oracle/get_membership_witness.nr @@ -1,5 +1,6 @@ use dep::protocol_types::{ - constants::{ARCHIVE_HEIGHT, NOTE_HASH_TREE_HEIGHT}, utils::arr_copy_slice, + constants::{ARCHIVE_HEIGHT, NOTE_HASH_TREE_HEIGHT}, + utils::arr_copy_slice, }; global NOTE_HASH_TREE_ID = 1; diff --git a/aztec/src/oracle/get_nullifier_membership_witness.nr b/aztec/src/oracle/get_nullifier_membership_witness.nr index 3bf863eb..bfdf6a6d 100644 --- a/aztec/src/oracle/get_nullifier_membership_witness.nr +++ b/aztec/src/oracle/get_nullifier_membership_witness.nr @@ -1,6 +1,7 @@ use dep::protocol_types::{ - abis::nullifier_leaf_preimage::{NullifierLeafPreimage, NULLIFIER_LEAF_PREIMAGE_LENGTH}, - constants::NULLIFIER_TREE_HEIGHT, utils::arr_copy_slice, + abis::nullifier_leaf_preimage::{NULLIFIER_LEAF_PREIMAGE_LENGTH, NullifierLeafPreimage}, + constants::NULLIFIER_TREE_HEIGHT, + utils::arr_copy_slice, }; // INDEX_LENGTH + NULLIFIER_LEAF_PREIMAGE_LENGTH + NULLIFIER_TREE_HEIGHT diff --git a/aztec/src/oracle/header.nr b/aztec/src/oracle/header.nr index b093494e..9ce477aa 100644 --- a/aztec/src/oracle/header.nr +++ b/aztec/src/oracle/header.nr @@ -1,5 +1,5 @@ -use dep::protocol_types::merkle_tree::root::root_from_sibling_path; use dep::protocol_types::{constants::HEADER_LENGTH, header::Header}; +use dep::protocol_types::merkle_tree::root::root_from_sibling_path; use crate::{ context::PrivateContext, oracle::get_membership_witness::get_archive_membership_witness, diff --git a/aztec/src/oracle/key_validation_request.nr b/aztec/src/oracle/key_validation_request.nr index 6a779675..30fa8f6d 100644 --- a/aztec/src/oracle/key_validation_request.nr +++ b/aztec/src/oracle/key_validation_request.nr @@ -1,5 +1,5 @@ use dep::protocol_types::abis::validation_requests::{ - KeyValidationRequest, key_validation_request::KEY_VALIDATION_REQUEST_LENGTH, + key_validation_request::KEY_VALIDATION_REQUEST_LENGTH, KeyValidationRequest, }; #[oracle(getKeyValidationRequest)] diff --git a/aztec/src/oracle/keys.nr b/aztec/src/oracle/keys.nr index 7c6bb4a3..f29c0e8b 100644 --- a/aztec/src/oracle/keys.nr +++ b/aztec/src/oracle/keys.nr @@ -1,6 +1,7 @@ use dep::protocol_types::{ - address::{AztecAddress, PartialAddress}, public_keys::{PublicKeys, NpkM, IvpkM, OvpkM, TpkM}, + address::{AztecAddress, PartialAddress}, point::Point, + public_keys::{IvpkM, NpkM, OvpkM, PublicKeys, TpkM}, }; #[oracle(getPublicKeysAndPartialAddress)] diff --git a/aztec/src/oracle/storage.nr b/aztec/src/oracle/storage.nr index 5a7e6018..c766c739 100644 --- a/aztec/src/oracle/storage.nr +++ b/aztec/src/oracle/storage.nr @@ -36,8 +36,8 @@ mod tests { use crate::oracle::storage::{raw_storage_read, storage_read}; use dep::protocol_types::address::AztecAddress; - use std::test::OracleMock; use crate::test::mocks::mock_struct::MockStruct; + use std::test::OracleMock; global address = AztecAddress::from_field(29); global slot = 7; diff --git a/aztec/src/prelude.nr b/aztec/src/prelude.nr index bfa103d6..04dee82b 100644 --- a/aztec/src/prelude.nr +++ b/aztec/src/prelude.nr @@ -1,18 +1,23 @@ // docs:start:prelude -pub use dep::protocol_types::{ - address::{AztecAddress, EthAddress}, abis::function_selector::FunctionSelector, point::Point, - traits::{Serialize, Deserialize}, -}; pub use crate::{ + context::{FunctionReturns, PackedReturns, PrivateContext, PublicContext}, + note::{ + note_getter_options::NoteGetterOptions, + note_header::NoteHeader, + note_interface::{NoteInterface, NullifiableNote}, + note_viewer_options::NoteViewerOptions, + utils::compute_note_hash_and_optionally_a_nullifier as utils_compute_note_hash_and_optionally_a_nullifier, + }, state_vars::{ map::Map, private_immutable::PrivateImmutable, private_mutable::PrivateMutable, - public_immutable::PublicImmutable, public_mutable::PublicMutable, private_set::PrivateSet, + private_set::PrivateSet, public_immutable::PublicImmutable, public_mutable::PublicMutable, shared_immutable::SharedImmutable, shared_mutable::SharedMutable, storage::Storable, - }, context::{PrivateContext, PackedReturns, FunctionReturns, PublicContext}, - note::{ - note_header::NoteHeader, note_interface::{NoteInterface, NullifiableNote}, - note_getter_options::NoteGetterOptions, note_viewer_options::NoteViewerOptions, - utils::compute_note_hash_and_optionally_a_nullifier as utils_compute_note_hash_and_optionally_a_nullifier, }, }; +pub use dep::protocol_types::{ + abis::function_selector::FunctionSelector, + address::{AztecAddress, EthAddress}, + point::Point, + traits::{Deserialize, Serialize}, +}; // docs:end:prelude diff --git a/aztec/src/state_vars/map.nr b/aztec/src/state_vars/map.nr index ddb88ac8..f695a78a 100644 --- a/aztec/src/state_vars/map.nr +++ b/aztec/src/state_vars/map.nr @@ -1,5 +1,5 @@ -use dep::protocol_types::{storage::map::derive_storage_slot_in_map, traits::ToField}; use crate::state_vars::storage::Storage; +use dep::protocol_types::{storage::map::derive_storage_slot_in_map, traits::ToField}; // docs:start:map pub struct Map { diff --git a/aztec/src/state_vars/mod.nr b/aztec/src/state_vars/mod.nr index 127f3509..72d00c2a 100644 --- a/aztec/src/state_vars/mod.nr +++ b/aztec/src/state_vars/mod.nr @@ -11,9 +11,9 @@ mod storage; pub use crate::state_vars::map::Map; pub use crate::state_vars::private_immutable::PrivateImmutable; pub use crate::state_vars::private_mutable::PrivateMutable; +pub use crate::state_vars::private_set::PrivateSet; pub use crate::state_vars::public_immutable::PublicImmutable; pub use crate::state_vars::public_mutable::PublicMutable; -pub use crate::state_vars::private_set::PrivateSet; pub use crate::state_vars::shared_immutable::SharedImmutable; pub use crate::state_vars::shared_mutable::SharedMutable; pub use crate::state_vars::storage::Storage; diff --git a/aztec/src/state_vars/private_immutable.nr b/aztec/src/state_vars/private_immutable.nr index 4f6ff618..81bb6e42 100644 --- a/aztec/src/state_vars/private_immutable.nr +++ b/aztec/src/state_vars/private_immutable.nr @@ -4,9 +4,11 @@ use dep::protocol_types::{ use crate::context::{PrivateContext, UnconstrainedContext}; use crate::note::{ - lifecycle::create_note, note_getter::{get_note, view_notes}, - note_interface::{NoteInterface, NullifiableNote}, note_viewer_options::NoteViewerOptions, + lifecycle::create_note, note_emission::NoteEmission, + note_getter::{get_note, view_notes}, + note_interface::{NoteInterface, NullifiableNote}, + note_viewer_options::NoteViewerOptions, }; use crate::oracle::notes::check_nullifier_exists; use crate::state_vars::storage::Storage; diff --git a/aztec/src/state_vars/private_mutable.nr b/aztec/src/state_vars/private_mutable.nr index 29cc9c6b..7b144d13 100644 --- a/aztec/src/state_vars/private_mutable.nr +++ b/aztec/src/state_vars/private_mutable.nr @@ -4,9 +4,11 @@ use dep::protocol_types::{ use crate::context::{PrivateContext, UnconstrainedContext}; use crate::note::{ - lifecycle::{create_note, destroy_note_unsafe}, note_getter::{get_note, view_notes}, - note_interface::{NoteInterface, NullifiableNote}, note_viewer_options::NoteViewerOptions, + lifecycle::{create_note, destroy_note_unsafe}, note_emission::NoteEmission, + note_getter::{get_note, view_notes}, + note_interface::{NoteInterface, NullifiableNote}, + note_viewer_options::NoteViewerOptions, }; use crate::oracle::notes::check_nullifier_exists; use crate::state_vars::storage::Storage; diff --git a/aztec/src/state_vars/private_mutable/test.nr b/aztec/src/state_vars/private_mutable/test.nr index 4d72ba7a..6f9ca70c 100644 --- a/aztec/src/state_vars/private_mutable/test.nr +++ b/aztec/src/state_vars/private_mutable/test.nr @@ -1,8 +1,8 @@ use crate::{ - context::PrivateContext, state_vars::private_mutable::PrivateMutable, - oracle::execution::get_contract_address, + context::PrivateContext, oracle::execution::get_contract_address, + state_vars::private_mutable::PrivateMutable, }; -use crate::test::{mocks::mock_note::MockNote, helpers::test_environment::TestEnvironment}; +use crate::test::{helpers::test_environment::TestEnvironment, mocks::mock_note::MockNote}; use std::test::OracleMock; global storage_slot = 17; diff --git a/aztec/src/state_vars/private_set.nr b/aztec/src/state_vars/private_set.nr index da2d4926..b63638fc 100644 --- a/aztec/src/state_vars/private_set.nr +++ b/aztec/src/state_vars/private_set.nr @@ -1,15 +1,18 @@ -use dep::protocol_types::{ - constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, abis::read_request::ReadRequest, -}; use crate::context::{PrivateContext, PublicContext, UnconstrainedContext}; use crate::note::{ constants::MAX_NOTES_PER_PAGE, lifecycle::{create_note, create_note_hash_from_public, destroy_note_unsafe}, - note_getter::{get_notes, view_notes}, note_getter_options::NoteGetterOptions, - note_interface::{NoteInterface, NullifiableNote}, note_viewer_options::NoteViewerOptions, - utils::compute_note_hash_for_read_request, note_emission::NoteEmission, + note_emission::NoteEmission, + note_getter::{get_notes, view_notes}, + note_getter_options::NoteGetterOptions, + note_interface::{NoteInterface, NullifiableNote}, + note_viewer_options::NoteViewerOptions, + utils::compute_note_hash_for_read_request, }; use crate::state_vars::storage::Storage; +use dep::protocol_types::{ + abis::read_request::ReadRequest, constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, +}; // docs:start:struct pub struct PrivateSet { diff --git a/aztec/src/state_vars/public_immutable.nr b/aztec/src/state_vars/public_immutable.nr index 4fac882d..1e9afe1d 100644 --- a/aztec/src/state_vars/public_immutable.nr +++ b/aztec/src/state_vars/public_immutable.nr @@ -1,6 +1,7 @@ use crate::{context::{PublicContext, UnconstrainedContext}, state_vars::storage::Storage}; use dep::protocol_types::{ - constants::INITIALIZATION_SLOT_SEPARATOR, traits::{Deserialize, Serialize}, + constants::INITIALIZATION_SLOT_SEPARATOR, + traits::{Deserialize, Serialize}, }; // Just like SharedImmutable but without the ability to read from private functions. diff --git a/aztec/src/state_vars/public_mutable.nr b/aztec/src/state_vars/public_mutable.nr index a1472db1..d2b965d3 100644 --- a/aztec/src/state_vars/public_mutable.nr +++ b/aztec/src/state_vars/public_mutable.nr @@ -1,6 +1,6 @@ use crate::context::{PublicContext, UnconstrainedContext}; -use dep::protocol_types::traits::{Deserialize, Serialize}; use crate::state_vars::storage::Storage; +use dep::protocol_types::traits::{Deserialize, Serialize}; // docs:start:public_mutable_struct pub struct PublicMutable { diff --git a/aztec/src/state_vars/shared_immutable.nr b/aztec/src/state_vars/shared_immutable.nr index 8c6f3ecb..00add0af 100644 --- a/aztec/src/state_vars/shared_immutable.nr +++ b/aztec/src/state_vars/shared_immutable.nr @@ -1,8 +1,10 @@ use crate::{ - context::{PrivateContext, PublicContext, UnconstrainedContext}, state_vars::storage::Storage, + context::{PrivateContext, PublicContext, UnconstrainedContext}, + state_vars::storage::Storage, }; use dep::protocol_types::{ - constants::INITIALIZATION_SLOT_SEPARATOR, traits::{Deserialize, Serialize}, + constants::INITIALIZATION_SLOT_SEPARATOR, + traits::{Deserialize, Serialize}, }; // Just like PublicImmutable but with the ability to read from private functions. diff --git a/aztec/src/state_vars/shared_mutable/scheduled_delay_change.nr b/aztec/src/state_vars/shared_mutable/scheduled_delay_change.nr index 05ce69f5..9522af5a 100644 --- a/aztec/src/state_vars/shared_mutable/scheduled_delay_change.nr +++ b/aztec/src/state_vars/shared_mutable/scheduled_delay_change.nr @@ -1,4 +1,4 @@ -use dep::protocol_types::traits::{Serialize, Deserialize}; +use dep::protocol_types::traits::{Deserialize, Serialize}; use std::cmp::min; mod test; diff --git a/aztec/src/state_vars/shared_mutable/scheduled_value_change.nr b/aztec/src/state_vars/shared_mutable/scheduled_value_change.nr index fb2288b3..0bf97e77 100644 --- a/aztec/src/state_vars/shared_mutable/scheduled_value_change.nr +++ b/aztec/src/state_vars/shared_mutable/scheduled_value_change.nr @@ -1,4 +1,4 @@ -use dep::protocol_types::traits::{Serialize, Deserialize, FromField, ToField}; +use dep::protocol_types::traits::{Deserialize, FromField, Serialize, ToField}; use std::cmp::min; mod test; diff --git a/aztec/src/state_vars/shared_mutable/shared_mutable.nr b/aztec/src/state_vars/shared_mutable/shared_mutable.nr index b07f08e5..0a499c40 100644 --- a/aztec/src/state_vars/shared_mutable/shared_mutable.nr +++ b/aztec/src/state_vars/shared_mutable/shared_mutable.nr @@ -1,16 +1,18 @@ use dep::protocol_types::{ - hash::{poseidon2_hash, poseidon2_hash_with_separator}, address::AztecAddress, - traits::{FromField, ToField}, utils::arrays::array_concat, + address::AztecAddress, + hash::{poseidon2_hash, poseidon2_hash_with_separator}, + traits::{FromField, ToField}, + utils::arrays::array_concat, }; use crate::context::{PrivateContext, PublicContext, UnconstrainedContext}; +use crate::oracle::storage::storage_read; use crate::state_vars::{ - storage::Storage, shared_mutable::{ - scheduled_value_change::ScheduledValueChange, scheduled_delay_change::ScheduledDelayChange, + scheduled_delay_change::ScheduledDelayChange, scheduled_value_change::ScheduledValueChange, }, + storage::Storage, }; -use crate::oracle::storage::storage_read; use dep::std::mem::zeroed; mod test; diff --git a/aztec/src/state_vars/shared_mutable/test.nr b/aztec/src/state_vars/shared_mutable/test.nr index e3850f28..cdf5414e 100644 --- a/aztec/src/state_vars/shared_mutable/test.nr +++ b/aztec/src/state_vars/shared_mutable/test.nr @@ -1,12 +1,13 @@ use crate::{ - context::{PublicContext, PrivateContext, UnconstrainedContext}, + context::{PrivateContext, PublicContext, UnconstrainedContext}, state_vars::shared_mutable::{ - shared_mutable::SharedMutable, scheduled_value_change::ScheduledValueChange, - scheduled_delay_change::ScheduledDelayChange, - }, test::helpers::test_environment::TestEnvironment, + scheduled_delay_change::ScheduledDelayChange, scheduled_value_change::ScheduledValueChange, + shared_mutable::SharedMutable, + }, + test::helpers::test_environment::TestEnvironment, }; -use dep::std::{test::OracleMock, mem::zeroed}; +use dep::std::{mem::zeroed, test::OracleMock}; global new_value = 17; diff --git a/aztec/src/test/helpers/cheatcodes.nr b/aztec/src/test/helpers/cheatcodes.nr index 2e7a44ad..d3f63c78 100644 --- a/aztec/src/test/helpers/cheatcodes.nr +++ b/aztec/src/test/helpers/cheatcodes.nr @@ -1,9 +1,10 @@ +use crate::context::inputs::PrivateContextInputs; +use crate::test::helpers::utils::TestAccount; use dep::protocol_types::{ - abis::function_selector::FunctionSelector, address::AztecAddress, public_keys::PublicKeys, + abis::function_selector::FunctionSelector, address::AztecAddress, constants::CONTRACT_INSTANCE_LENGTH, contract_instance::ContractInstance, + public_keys::PublicKeys, }; -use crate::context::inputs::PrivateContextInputs; -use crate::test::helpers::utils::TestAccount; pub unconstrained fn reset() { oracle_reset(); diff --git a/aztec/src/test/helpers/test_environment.nr b/aztec/src/test/helpers/test_environment.nr index 8755aefb..4c87fb9e 100644 --- a/aztec/src/test/helpers/test_environment.nr +++ b/aztec/src/test/helpers/test_environment.nr @@ -1,15 +1,16 @@ use dep::protocol_types::{abis::function_selector::FunctionSelector, address::AztecAddress}; +use crate::context::{call_interfaces::CallInterface, packed_returns::PackedReturns}; use crate::context::inputs::PrivateContextInputs; -use crate::context::{packed_returns::PackedReturns, call_interfaces::CallInterface}; use crate::context::{PrivateContext, PublicContext, UnconstrainedContext}; -use crate::test::helpers::{cheatcodes, utils::Deployer}; use crate::hash::hash_args; +use crate::test::helpers::{cheatcodes, utils::Deployer}; use crate::note::{note_header::NoteHeader, note_interface::{NoteInterface, NullifiableNote}}; use crate::oracle::{ - execution::{get_block_number, get_contract_address}, notes::notify_created_note, + execution::{get_block_number, get_contract_address}, + notes::notify_created_note, }; use protocol_types::constants::PUBLIC_DISPATCH_SELECTOR; diff --git a/aztec/src/test/helpers/utils.nr b/aztec/src/test/helpers/utils.nr index 4b2e5373..e8c9734a 100644 --- a/aztec/src/test/helpers/utils.nr +++ b/aztec/src/test/helpers/utils.nr @@ -1,21 +1,23 @@ use dep::protocol_types::{ - traits::{Deserialize, Serialize}, address::AztecAddress, - public_keys::{PublicKeys, PUBLIC_KEYS_LENGTH}, abis::function_selector::FunctionSelector, + abis::function_selector::FunctionSelector, + address::AztecAddress, contract_instance::ContractInstance, + public_keys::{PUBLIC_KEYS_LENGTH, PublicKeys}, + traits::{Deserialize, Serialize}, }; +use crate::context::call_interfaces::{CallInterface, PublicCallInterface}; use crate::context::{ - PrivateContext, PublicContext, UnconstrainedContext, inputs::PrivateContextInputs, + inputs::PrivateContextInputs, PrivateContext, PublicContext, UnconstrainedContext, }; -use crate::context::call_interfaces::{PublicCallInterface, CallInterface}; use crate::test::helpers::cheatcodes; -use crate::oracle::execution::{get_block_number, get_contract_address}; -use protocol_types::constants::PUBLIC_DISPATCH_SELECTOR; -use crate::context::gas::GasOpts; use crate::context::call_interfaces::PublicVoidCallInterface; +use crate::context::gas::GasOpts; use crate::hash::hash_args; use crate::oracle::arguments::pack_arguments; +use crate::oracle::execution::{get_block_number, get_contract_address}; +use protocol_types::constants::PUBLIC_DISPATCH_SELECTOR; pub struct Deployer { path: str, diff --git a/aztec/src/test/mocks/mock_note.nr b/aztec/src/test/mocks/mock_note.nr index 49917101..29920468 100644 --- a/aztec/src/test/mocks/mock_note.nr +++ b/aztec/src/test/mocks/mock_note.nr @@ -1,17 +1,18 @@ use crate::{ - context::PrivateContext, generators::Ga1 as G_val, + context::PrivateContext, + generators::Ga1 as G_val, note::{ note_header::NoteHeader, note_interface::NoteInterface, utils::compute_note_hash_for_nullify, }, }; +use crate::note::note_interface::NullifiableNote; use dep::protocol_types::{ address::AztecAddress, constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash_with_separator, }; use dep::std::{embedded_curve_ops::multi_scalar_mul, hash::from_field_unsafe}; -use crate::note::note_interface::NullifiableNote; global MOCK_NOTE_LENGTH: u32 = 1; diff --git a/aztec/src/test/mocks/mock_struct.nr b/aztec/src/test/mocks/mock_struct.nr index 339312e1..87015947 100644 --- a/aztec/src/test/mocks/mock_struct.nr +++ b/aztec/src/test/mocks/mock_struct.nr @@ -1,4 +1,4 @@ -use dep::protocol_types::traits::{Serialize, Deserialize}; +use dep::protocol_types::traits::{Deserialize, Serialize}; pub(crate) struct MockStruct { a: Field, diff --git a/aztec/src/utils/comparison.nr b/aztec/src/utils/comparison.nr index d3ec8c4f..2da17acc 100644 --- a/aztec/src/utils/comparison.nr +++ b/aztec/src/utils/comparison.nr @@ -32,8 +32,8 @@ pub fn compare(lhs: Field, operation: u8, rhs: Field) -> bool { } mod test { - use super::compare; use super::Comparator; + use super::compare; #[test] unconstrained fn test_compare() { diff --git a/aztec/src/utils/mod.nr b/aztec/src/utils/mod.nr index ae469c45..91236021 100644 --- a/aztec/src/utils/mod.nr +++ b/aztec/src/utils/mod.nr @@ -5,5 +5,5 @@ mod point; mod test; mod to_bytes; -pub use crate::utils::collapse_array::collapse_array; pub use crate::utils::bytes::{bytes_to_fields, fields_to_bytes}; +pub use crate::utils::collapse_array::collapse_array; diff --git a/aztec/src/utils/point.nr b/aztec/src/utils/point.nr index ecfb802d..d02c302f 100644 --- a/aztec/src/utils/point.nr +++ b/aztec/src/utils/point.nr @@ -32,8 +32,8 @@ pub fn point_to_bytes(pk: Point) -> [u8; 32] { } mod test { - use dep::protocol_types::point::Point; use crate::utils::point::point_to_bytes; + use dep::protocol_types::point::Point; #[test] unconstrained fn test_point_to_bytes_positive_sign() { diff --git a/compressed-string/src/compressed_string.nr b/compressed-string/src/compressed_string.nr index 6c209bf9..deab09c4 100644 --- a/compressed-string/src/compressed_string.nr +++ b/compressed-string/src/compressed_string.nr @@ -1,4 +1,4 @@ -use dep::aztec::protocol_types::{utils::field::field_from_bytes, traits::{Serialize, Deserialize}}; +use dep::aztec::protocol_types::{traits::{Deserialize, Serialize}, utils::field::field_from_bytes}; // The general Compressed String. // Compresses M bytes into N fields. diff --git a/compressed-string/src/field_compressed_string.nr b/compressed-string/src/field_compressed_string.nr index 54675974..41b391c2 100644 --- a/compressed-string/src/field_compressed_string.nr +++ b/compressed-string/src/field_compressed_string.nr @@ -1,4 +1,4 @@ -use dep::aztec::protocol_types::{utils::field::field_from_bytes, traits::{Serialize, Deserialize}}; +use dep::aztec::protocol_types::{traits::{Deserialize, Serialize}, utils::field::field_from_bytes}; // A Fixedsize Compressed String. // Essentially a special version of Compressed String for practical use. diff --git a/easy-private-state/src/easy_private_uint.nr b/easy-private-state/src/easy_private_uint.nr index ec014ecd..6b70c6ac 100644 --- a/easy-private-state/src/easy_private_uint.nr +++ b/easy-private-state/src/easy_private_uint.nr @@ -1,8 +1,7 @@ use dep::aztec::{ - context::PrivateContext, protocol_types::address::AztecAddress, - note::note_getter_options::NoteGetterOptions, state_vars::PrivateSet, - encrypted_logs::encrypted_note_emission::encode_and_encrypt_note, - keys::getters::get_public_keys, + context::PrivateContext, encrypted_logs::encrypted_note_emission::encode_and_encrypt_note, + keys::getters::get_public_keys, note::note_getter_options::NoteGetterOptions, + protocol_types::address::AztecAddress, state_vars::PrivateSet, }; use dep::value_note::{filter::filter_notes_min_sum, value_note::ValueNote}; diff --git a/uint-note/src/uint_note.nr b/uint-note/src/uint_note.nr index 4552c980..44ab33c7 100644 --- a/uint-note/src/uint_note.nr +++ b/uint-note/src/uint_note.nr @@ -1,8 +1,11 @@ use dep::aztec::{ + keys::getters::get_nsk_app, + macros::notes::note, + note::utils::compute_note_hash_for_nullify, prelude::{NullifiableNote, PrivateContext}, protocol_types::{ constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash_with_separator, - }, note::utils::compute_note_hash_for_nullify, keys::getters::get_nsk_app, macros::notes::note, + }, }; #[note] diff --git a/value-note/src/balance_utils.nr b/value-note/src/balance_utils.nr index 35254d99..f03b9993 100644 --- a/value-note/src/balance_utils.nr +++ b/value-note/src/balance_utils.nr @@ -1,8 +1,8 @@ +use crate::value_note::ValueNote; use dep::aztec::{ - context::UnconstrainedContext, state_vars::PrivateSet, - note::note_viewer_options::NoteViewerOptions, + context::UnconstrainedContext, note::note_viewer_options::NoteViewerOptions, + state_vars::PrivateSet, }; -use crate::value_note::ValueNote; pub unconstrained fn get_balance(set: PrivateSet) -> Field { get_balance_with_offset(set, 0) diff --git a/value-note/src/filter.nr b/value-note/src/filter.nr index fb24074a..29e2ccd4 100644 --- a/value-note/src/filter.nr +++ b/value-note/src/filter.nr @@ -1,5 +1,5 @@ -use dep::aztec::protocol_types::constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL; use crate::value_note::ValueNote; +use dep::aztec::protocol_types::constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL; pub fn filter_notes_min_sum( notes: [Option; MAX_NOTE_HASH_READ_REQUESTS_PER_CALL], diff --git a/value-note/src/utils.nr b/value-note/src/utils.nr index e5cedaf9..adc37d26 100644 --- a/value-note/src/utils.nr +++ b/value-note/src/utils.nr @@ -1,8 +1,8 @@ -use dep::aztec::prelude::{AztecAddress, PrivateContext, PrivateSet, NoteGetterOptions}; -use dep::aztec::note::note_getter_options::SortOrder; +use crate::{filter::filter_notes_min_sum, value_note::{VALUE_NOTE_LEN, ValueNote}}; use dep::aztec::encrypted_logs::encrypted_note_emission::encode_and_encrypt_note; use dep::aztec::keys::getters::get_public_keys; -use crate::{filter::filter_notes_min_sum, value_note::{ValueNote, VALUE_NOTE_LEN}}; +use dep::aztec::note::note_getter_options::SortOrder; +use dep::aztec::prelude::{AztecAddress, NoteGetterOptions, PrivateContext, PrivateSet}; // Sort the note values (0th field) in descending order. // Pick the fewest notes whose sum is equal to or greater than `amount`. diff --git a/value-note/src/value_note.nr b/value-note/src/value_note.nr index 69d6cd68..c243dbea 100644 --- a/value-note/src/value_note.nr +++ b/value-note/src/value_note.nr @@ -1,12 +1,16 @@ use dep::aztec::{ - protocol_types::{ - traits::Serialize, constants::GENERATOR_INDEX__NOTE_NULLIFIER, - hash::poseidon2_hash_with_separator, - }, macros::notes::note, + context::PrivateContext, + keys::getters::get_nsk_app, + macros::notes::note, note::{ note_header::NoteHeader, note_interface::NullifiableNote, utils::compute_note_hash_for_nullify, - }, oracle::random::random, keys::getters::get_nsk_app, context::PrivateContext, + }, + oracle::random::random, + protocol_types::{ + constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash_with_separator, + traits::Serialize, + }, }; global VALUE_NOTE_LEN: u32 = 3; // 3 plus a header.