diff --git a/barretenberg/.gitrepo b/barretenberg/.gitrepo index 1f841d2025d..15359699c89 100644 --- a/barretenberg/.gitrepo +++ b/barretenberg/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/AztecProtocol/barretenberg branch = master - commit = a58c46fc8c87db58aa091d9752640f5b5087ade5 - parent = a4d4ee8dc927cf7f8b09013c72a5b4cc4bf86075 + commit = 8afbd6d42c6f63e3e47761fde5cd2d8baebb9f04 + parent = a18288d9b8f3057b9e79362d922da656dacf22a9 method = merge cmdver = 0.4.6 diff --git a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp index a0729568475..60d52d73ba8 100644 --- a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp +++ b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp @@ -38,14 +38,20 @@ class ClientIVCTests : public ::testing::Test { /** * @brief Construct mock circuit with arithmetic gates and goblin ops - * @details Currently default sized to 2^16 to match kernel. (Note: op gates will bump size to next power of - 2) + * @details Currently default sized to 2^16 to match kernel. (Note: dummy op gates added to avoid non-zero + * polynomials will bump size to next power of 2) * */ static Builder create_mock_circuit(ClientIVC& ivc, size_t log2_num_gates = 15) { Builder circuit{ ivc.goblin.op_queue }; MockCircuits::construct_arithmetic_circuit(circuit, log2_num_gates); + + // TODO(https://github.com/AztecProtocol/barretenberg/issues/911): We require goblin ops to be added to the + // function circuit because we cannot support zero commtiments. While the builder handles this at + // finalisation stage via the add_gates_to_ensure_all_polys_are_non_zero function for other UGH + // circuits (where we don't explicitly need to add goblin ops), in ClientIVC merge proving happens prior to + // folding where the absense of goblin ecc ops will result in zero commitments. MockCircuits::construct_goblin_ecc_op_circuit(circuit); return circuit; } diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp index 2cc00db97c7..75db931222c 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp @@ -247,10 +247,6 @@ GoblinUltraCircuitBuilder create_circuit(const AcirFormat& constraint_system, bool has_valid_witness_assignments = !witness.empty(); acir_format::build_constraints(builder, constraint_system, has_valid_witness_assignments); - // TODO(https://github.com/AztecProtocol/barretenberg/issues/817): Add some arbitrary op gates to ensure the - // associated polynomials are non-zero and to give ECCVM and Translator some ECC ops to process. - MockCircuits::construct_goblin_ecc_op_circuit(builder); - return builder; }; diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/goblin_acir_composer.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/goblin_acir_composer.cpp index 5d754a168a7..4ef7c02c345 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/goblin_acir_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/goblin_acir_composer.cpp @@ -17,7 +17,7 @@ void GoblinAcirComposer::create_circuit(acir_format::AcirFormat& constraint_syst acir_format::build_constraints(builder_, constraint_system, true); // TODO(https://github.com/AztecProtocol/barretenberg/issues/817): Add some arbitrary op gates to ensure the - // associated polynomials are non-zero and to give ECCVM and Translator some ECC ops to process. + // to give ECCVM and Translator some ECC ops to process. MockCircuits::construct_goblin_ecc_op_circuit(builder_); } diff --git a/barretenberg/cpp/src/barretenberg/goblin/goblin_recursion.test.cpp b/barretenberg/cpp/src/barretenberg/goblin/goblin_recursion.test.cpp index 49b3f08028f..623c1118b4a 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/goblin_recursion.test.cpp +++ b/barretenberg/cpp/src/barretenberg/goblin/goblin_recursion.test.cpp @@ -45,7 +45,8 @@ TEST_F(GoblinRecursionTests, Vanilla) size_t NUM_CIRCUITS = 2; for (size_t circuit_idx = 0; circuit_idx < NUM_CIRCUITS; ++circuit_idx) { - // Construct and accumulate a mock function circuit + // Construct and accumulate a mock function circuit containing both arbitrary arithmetic gates and goblin + // ecc op gates to make it a meaningful test GoblinUltraCircuitBuilder function_circuit{ goblin.op_queue }; MockCircuits::construct_arithmetic_circuit(function_circuit, /*target_log2_dyadic_size=*/8); MockCircuits::construct_goblin_ecc_op_circuit(function_circuit); diff --git a/barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp b/barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp index 4f4fbdee852..cb87096063e 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp +++ b/barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp @@ -70,9 +70,11 @@ class GoblinMockCircuits { stdlib::generate_ecdsa_verification_test_circuit(builder, NUM_ITERATIONS); // min gates: ~41k stdlib::generate_merkle_membership_test_circuit(builder, NUM_ITERATIONS); // min gates: ~29k - // Note: its not clear whether goblin ops will be supported for function circuits initially but currently - // UGH can only be used if some op gates are included so for now we'll assume each function circuit has - // some. + // TODO(https://github.com/AztecProtocol/barretenberg/issues/911): We require goblin ops to be added to the + // function circuit because we cannot support zero commtiments. While the builder handles this at + // ProverInstance creation stage via the add_gates_to_ensure_all_polys_are_non_zero function for other UGH + // circuits (where we don't explicitly need to add goblin ops), in ClientIVC merge proving happens prior to + // folding where the absense of goblin ecc ops will result in zero commitments. MockCircuits::construct_goblin_ecc_op_circuit(builder); } diff --git a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/goblin_ultra_circuit_builder.cpp b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/goblin_ultra_circuit_builder.cpp index 0267a5be4fa..f6a4c2901a1 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/goblin_ultra_circuit_builder.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/goblin_ultra_circuit_builder.cpp @@ -82,6 +82,10 @@ template void GoblinUltraCircuitBuilder_::add_gates_to_ensure_ // dummy gate to be read into by previous poseidon internal gate via shifts this->create_dummy_gate( this->blocks.poseidon_internal, this->zero_idx, this->zero_idx, this->zero_idx, this->zero_idx); + + // add dummy mul accum op and an equality op + this->queue_ecc_mul_accum(bb::g1::affine_element::one() * FF::random_element(), FF::random_element()); + this->queue_ecc_eq(); } /** diff --git a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mock_circuits.hpp b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mock_circuits.hpp index 8b27ab0afb2..cb523ce7186 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mock_circuits.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mock_circuits.hpp @@ -62,16 +62,15 @@ class MockCircuits { } /** - * @brief Populate a builder with some arbitrary goblinized ECC ops + * @brief Populate a builder with some arbitrary goblinized ECC ops, one of each type * * @param builder */ static void construct_goblin_ecc_op_circuit(GoblinUltraCircuitBuilder& builder) { - // Add a mul accum op and an equality op - auto point = Point::one() * FF::random_element(); - auto scalar = FF::random_element(); - builder.queue_ecc_mul_accum(point, scalar); + // Add a mul accum op, an add accum op and an equality op + builder.queue_ecc_add_accum(Point::one() * FF::random_element()); + builder.queue_ecc_mul_accum(Point::one() * FF::random_element(), FF::random_element()); builder.queue_ecc_eq(); } }; diff --git a/noir-projects/aztec-nr/.gitrepo b/noir-projects/aztec-nr/.gitrepo index 097d70f0924..962ffaf0fed 100644 --- a/noir-projects/aztec-nr/.gitrepo +++ b/noir-projects/aztec-nr/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/AztecProtocol/aztec-nr branch = master - commit = 07332f6ce49d75b3d4186de8edee2610fae3cbaf + commit = 485393ab11218b3f1d785728a92fd3e8e1ea4978 method = merge cmdver = 0.4.6 - parent = f4c6b299253c0bdd3c2a41bd79e1c0d2ed226409 + parent = 52be8932695ae9864e9a78597f716b81c388ca1c diff --git a/noir-projects/aztec-nr/authwit/src/account.nr b/noir-projects/aztec-nr/authwit/src/account.nr index b8a62fb6653..2e33c4a0823 100644 --- a/noir-projects/aztec-nr/authwit/src/account.nr +++ b/noir-projects/aztec-nr/authwit/src/account.nr @@ -1,6 +1,6 @@ use dep::aztec::context::{PrivateContext, PublicContext, Context}; use dep::aztec::state_vars::{Map, PublicMutable}; -use dep::aztec::protocol_types::{address::AztecAddress, abis::function_selector::FunctionSelector, hash::{pedersen_hash}}; +use dep::aztec::protocol_types::{address::AztecAddress, abis::function_selector::FunctionSelector, hash::pedersen_hash}; use crate::entrypoint::{app::AppPayload, fee::FeePayload}; use crate::auth::{IS_VALID_SELECTOR, compute_outer_authwit_hash}; @@ -76,7 +76,12 @@ impl AccountActions { // The `inner_hash` is "siloed" with the `msg_sender` to ensure that only it can // consume the message. // This ensures that contracts cannot consume messages that are not intended for them. - let message_hash = compute_outer_authwit_hash(context.msg_sender(), context.chain_id(), context.version(), inner_hash); + let message_hash = compute_outer_authwit_hash( + context.msg_sender(), + context.chain_id(), + context.version(), + inner_hash + ); let valid_fn = self.is_valid_impl; assert(valid_fn(context, message_hash) == true, "Message not authorized by account"); context.push_new_nullifier(message_hash, 0); @@ -90,7 +95,12 @@ impl AccountActions { // The `inner_hash` is "siloed" with the `msg_sender` to ensure that only it can // consume the message. // This ensures that contracts cannot consume messages that are not intended for them. - let message_hash = compute_outer_authwit_hash(context.msg_sender(), context.chain_id(), context.version(), inner_hash); + let message_hash = compute_outer_authwit_hash( + context.msg_sender(), + context.chain_id(), + context.version(), + inner_hash + ); let is_valid = self.approved_action.at(message_hash).read(); assert(is_valid == true, "Message not authorized by account"); context.push_new_nullifier(message_hash, 0); 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 4d1e8e0e0dd..79523b9affc 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 @@ -1,7 +1,4 @@ -use dep::protocol_types::{ - abis::call_context::CallContext, - header::Header -}; +use dep::protocol_types::{abis::call_context::CallContext, header::Header}; use crate::context::globals::private_global_variables::PrivateGlobalVariables; // PrivateContextInputs are expected to be provided to each private function 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 4abc126bb40..df69e504d34 100644 --- a/noir-projects/aztec-nr/aztec/src/context/public_context.nr +++ b/noir-projects/aztec-nr/aztec/src/context/public_context.nr @@ -15,7 +15,8 @@ use dep::protocol_types::{ MAX_NEW_NOTE_HASHES_PER_CALL, MAX_NEW_L2_TO_L1_MSGS_PER_CALL, MAX_NEW_NULLIFIERS_PER_CALL, MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, MAX_PUBLIC_DATA_READS_PER_CALL, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL, MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, - MAX_NULLIFIER_READ_REQUESTS_PER_CALL, MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL, RETURN_VALUES_LENGTH + MAX_NULLIFIER_READ_REQUESTS_PER_CALL, MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL, + RETURN_VALUES_LENGTH }, contrakt::{storage_read::StorageRead, storage_update_request::StorageUpdateRequest}, hash::hash_args_array, header::Header, messaging::l2_to_l1_message::L2ToL1Message, diff --git a/noir-projects/aztec-nr/aztec/src/deploy.nr b/noir-projects/aztec-nr/aztec/src/deploy.nr index 51d17cb76c9..dc44d1e4cca 100644 --- a/noir-projects/aztec-nr/aztec/src/deploy.nr +++ b/noir-projects/aztec-nr/aztec/src/deploy.nr @@ -8,7 +8,9 @@ pub fn deploy_contract(context: &mut PrivateContext, target: AztecAddress) { let universal_deploy = is_default(instance.deployer); if !universal_deploy { - assert(instance.deployer == context.this_address(), "Deployer address does not match current address"); + assert( + instance.deployer == context.this_address(), "Deployer address does not match current address" + ); } // Adapted from noir-contracts/contracts/contract_instance_deployer_contract/src/interface/ContractInstanceDeployer.nr diff --git a/noir-projects/aztec-nr/aztec/src/history/contract_inclusion.nr b/noir-projects/aztec-nr/aztec/src/history/contract_inclusion.nr index 1a16ea986c7..cb14ef1b06a 100644 --- a/noir-projects/aztec-nr/aztec/src/history/contract_inclusion.nr +++ b/noir-projects/aztec-nr/aztec/src/history/contract_inclusion.nr @@ -1,49 +1,40 @@ use dep::protocol_types::{ - address::{AztecAddress, EthAddress}, - contract_class_id::ContractClassId, - grumpkin_point::GrumpkinPoint, - hash::silo_nullifier, - constants::DEPLOYER_CONTRACT_ADDRESS + address::{AztecAddress, EthAddress}, contract_class_id::ContractClassId, + grumpkin_point::GrumpkinPoint, hash::silo_nullifier, constants::DEPLOYER_CONTRACT_ADDRESS }; use dep::std::merkle::compute_merkle_root; use crate::{ context::PrivateContext, history::{ - nullifier_inclusion::prove_nullifier_inclusion_at, - nullifier_non_inclusion::prove_nullifier_not_included_at, - } + nullifier_inclusion::prove_nullifier_inclusion_at, + nullifier_non_inclusion::prove_nullifier_not_included_at +} }; -pub fn prove_contract_deployment_at( - contract_address: AztecAddress, - block_number: u32, - context: PrivateContext -) { +pub fn prove_contract_deployment_at(contract_address: AztecAddress, block_number: u32, context: PrivateContext) { // Compute deployment nullifier - let nullifier = silo_nullifier(AztecAddress::from_field(DEPLOYER_CONTRACT_ADDRESS), contract_address.to_field()); + let nullifier = silo_nullifier( + AztecAddress::from_field(DEPLOYER_CONTRACT_ADDRESS), + contract_address.to_field() + ); // Prove its inclusion prove_nullifier_inclusion_at(nullifier, block_number, context); } -pub fn prove_contract_non_deployment_at( - contract_address: AztecAddress, - block_number: u32, - context: PrivateContext -) { +pub fn prove_contract_non_deployment_at(contract_address: AztecAddress, block_number: u32, context: PrivateContext) { // Compute deployment nullifier - let nullifier = silo_nullifier(AztecAddress::from_field(DEPLOYER_CONTRACT_ADDRESS), contract_address.to_field()); + let nullifier = silo_nullifier( + AztecAddress::from_field(DEPLOYER_CONTRACT_ADDRESS), + contract_address.to_field() + ); // Prove its non-inclusion prove_nullifier_not_included_at(nullifier, block_number, context); } -pub fn prove_contract_initialization_at( - contract_address: AztecAddress, - block_number: u32, - context: PrivateContext -) { +pub fn prove_contract_initialization_at(contract_address: AztecAddress, block_number: u32, context: PrivateContext) { // Compute initialization nullifier let nullifier = silo_nullifier(contract_address, contract_address.to_field()); @@ -51,11 +42,7 @@ pub fn prove_contract_initialization_at( prove_nullifier_inclusion_at(nullifier, block_number, context); } -pub fn prove_contract_non_initialization_at( - contract_address: AztecAddress, - block_number: u32, - context: PrivateContext -) { +pub fn prove_contract_non_initialization_at(contract_address: AztecAddress, block_number: u32, context: PrivateContext) { // Compute initialization nullifier let nullifier = silo_nullifier(contract_address, contract_address.to_field()); diff --git a/noir-projects/aztec-nr/aztec/src/initializer.nr b/noir-projects/aztec-nr/aztec/src/initializer.nr index 242e0361c27..b851c2491db 100644 --- a/noir-projects/aztec-nr/aztec/src/initializer.nr +++ b/noir-projects/aztec-nr/aztec/src/initializer.nr @@ -1,14 +1,12 @@ use dep::protocol_types::{ - hash::{silo_nullifier, pedersen_hash}, - constants::GENERATOR_INDEX__CONSTRUCTOR, - abis::function_selector::FunctionSelector, - traits::is_default, + hash::{silo_nullifier, pedersen_hash}, constants::GENERATOR_INDEX__CONSTRUCTOR, + abis::function_selector::FunctionSelector, traits::is_default, }; use crate::{ context::{PrivateContext, PublicContext, ContextInterface}, oracle::get_contract_instance::get_contract_instance, - history::nullifier_inclusion::prove_nullifier_inclusion, + history::nullifier_inclusion::prove_nullifier_inclusion }; pub fn mark_as_initialized(context: &mut TContext) where TContext: ContextInterface { @@ -34,7 +32,7 @@ pub fn compute_unsiloed_contract_initialization_nullifier(context: TCo } pub fn assert_initialization_matches_address_preimage(context: TContext) where TContext: ContextInterface { - let address = context.this_address(); + let address = context.this_address(); let instance = get_contract_instance(address); let expected_init = compute_initialization_hash(context.selector(), context.get_args_hash()); assert(instance.initialization_hash == expected_init, "Initialization hash does not match"); @@ -42,5 +40,8 @@ pub fn assert_initialization_matches_address_preimage(context: TContex } pub fn compute_initialization_hash(init_selector: FunctionSelector, init_args_hash: Field) -> Field { - pedersen_hash([init_selector.to_field(), init_args_hash], GENERATOR_INDEX__CONSTRUCTOR) -} \ No newline at end of file + pedersen_hash( + [init_selector.to_field(), init_args_hash], + GENERATOR_INDEX__CONSTRUCTOR + ) +} diff --git a/noir-projects/aztec-nr/aztec/src/messaging.nr b/noir-projects/aztec-nr/aztec/src/messaging.nr index 3f649e9e4bf..77087758f82 100644 --- a/noir-projects/aztec-nr/aztec/src/messaging.nr +++ b/noir-projects/aztec-nr/aztec/src/messaging.nr @@ -16,7 +16,14 @@ pub fn process_l1_to_l2_message( secret: Field ) -> Field { let secret_hash = compute_secret_hash(secret); - let message_hash = compute_message_hash(portal_contract_address, chain_id, storage_contract_address, version, content, secret_hash); + let message_hash = compute_message_hash( + portal_contract_address, + chain_id, + storage_contract_address, + version, + content, + secret_hash + ); let returned_message = get_l1_to_l2_membership_witness(storage_contract_address, message_hash, secret); let leaf_index = returned_message[0]; diff --git a/noir-projects/aztec-nr/aztec/src/oracle/enqueue_public_function_call.nr b/noir-projects/aztec-nr/aztec/src/oracle/enqueue_public_function_call.nr index 61e3bbc4256..28bcb331240 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/enqueue_public_function_call.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/enqueue_public_function_call.nr @@ -1,6 +1,5 @@ use dep::protocol_types::{ - abis::function_selector::FunctionSelector, - address::AztecAddress, + abis::function_selector::FunctionSelector, address::AztecAddress, constants::ENQUEUE_PUBLIC_FUNCTION_CALL_RETURN_LENGTH }; diff --git a/noir-projects/aztec-nr/aztec/src/oracle/get_l1_to_l2_membership_witness.nr b/noir-projects/aztec-nr/aztec/src/oracle/get_l1_to_l2_membership_witness.nr index b22916ea2c6..e1f61401b17 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/get_l1_to_l2_membership_witness.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/get_l1_to_l2_membership_witness.nr @@ -1,12 +1,17 @@ -use dep::protocol_types::{ - address::AztecAddress, - constants::L1_TO_L2_MESSAGE_ORACLE_CALL_LENGTH, -}; +use dep::protocol_types::{address::AztecAddress, constants::L1_TO_L2_MESSAGE_ORACLE_CALL_LENGTH}; // Obtains membership witness (index and sibling path) for a message in the L1 to L2 message tree. #[oracle(getL1ToL2MembershipWitness)] -fn get_l1_to_l2_membership_witness_oracle(_contract_address: AztecAddress, _message_hash: Field, _secret: Field) -> [Field; L1_TO_L2_MESSAGE_ORACLE_CALL_LENGTH] {} +fn get_l1_to_l2_membership_witness_oracle( + _contract_address: AztecAddress, + _message_hash: Field, + _secret: Field +) -> [Field; L1_TO_L2_MESSAGE_ORACLE_CALL_LENGTH] {} -unconstrained pub fn get_l1_to_l2_membership_witness(contract_address: AztecAddress, message_hash: Field, secret: Field) -> [Field; L1_TO_L2_MESSAGE_ORACLE_CALL_LENGTH] { +unconstrained pub fn get_l1_to_l2_membership_witness( + contract_address: AztecAddress, + message_hash: Field, + secret: Field +) -> [Field; L1_TO_L2_MESSAGE_ORACLE_CALL_LENGTH] { get_l1_to_l2_membership_witness_oracle(contract_address, message_hash, secret) } diff --git a/noir-projects/aztec-nr/aztec/src/oracle/logs.nr b/noir-projects/aztec-nr/aztec/src/oracle/logs.nr index 7335cbec6ea..6a95e6897e8 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/logs.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/logs.nr @@ -17,13 +17,13 @@ unconstrained pub fn emit_encrypted_log( encryption_pub_key: GrumpkinPoint, preimage: [Field; N] ) -> Field { - emit_encrypted_log_oracle( - contract_address, - storage_slot, - note_type_id, - encryption_pub_key, - preimage - ) + emit_encrypted_log_oracle( + contract_address, + storage_slot, + note_type_id, + encryption_pub_key, + preimage + ) } #[oracle(emitUnencryptedLog)] diff --git a/noir-projects/aztec-nr/aztec/src/oracle/unsafe_rand.nr b/noir-projects/aztec-nr/aztec/src/oracle/unsafe_rand.nr index f9634308e05..f6bf48bf83f 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/unsafe_rand.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/unsafe_rand.nr @@ -1,7 +1,6 @@ #[oracle(getRandomField)] fn rand_oracle() -> Field {} - // Called `unsafe_rand` because we do not constrain in circuit that we are dealing with an actual random value. // Instead we just trust our PXE. unconstrained pub fn unsafe_rand() -> Field { 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 0deee4556df..a138a8deb9c 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/map.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/map.nr @@ -1,5 +1,5 @@ use crate::context::{PrivateContext, PublicContext, Context}; -use dep::protocol_types::{hash::pedersen_hash, traits::{ToField}}; +use dep::protocol_types::{hash::pedersen_hash, traits::ToField}; use crate::state_vars::storage::Storage; // docs:start:map 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 29772b2d600..7824ae28a58 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 @@ -1,4 +1,4 @@ -use dep::protocol_types::{address::AztecAddress, constants::{GENERATOR_INDEX__INITIALIZATION_NULLIFIER}, hash::pedersen_hash}; +use dep::protocol_types::{address::AztecAddress, constants::GENERATOR_INDEX__INITIALIZATION_NULLIFIER, hash::pedersen_hash}; use crate::context::{PrivateContext, Context}; use crate::note::{ 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 6e06c66d97b..5d0f8b11fec 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 @@ -1,4 +1,4 @@ -use dep::protocol_types::{address::AztecAddress, constants::{GENERATOR_INDEX__INITIALIZATION_NULLIFIER}, hash::pedersen_hash}; +use dep::protocol_types::{address::AztecAddress, constants::GENERATOR_INDEX__INITIALIZATION_NULLIFIER, hash::pedersen_hash}; use crate::context::{PrivateContext, PublicContext, Context}; use crate::note::{ 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 0b24bb08723..442a7d55656 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 @@ -1,4 +1,4 @@ -use crate::context::{Context}; +use crate::context::Context; use crate::oracle::storage::storage_read; use crate::oracle::storage::storage_write; use dep::protocol_types::traits::{Deserialize, Serialize}; diff --git a/noir-projects/noir-contracts/contracts/benchmarking_contract/src/main.nr b/noir-projects/noir-contracts/contracts/benchmarking_contract/src/main.nr index 87d943fef6a..44278fd8d95 100644 --- a/noir-projects/noir-contracts/contracts/benchmarking_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/benchmarking_contract/src/main.nr @@ -10,7 +10,7 @@ contract Benchmarking { }; use dep::value_note::{utils::{increment, decrement}, value_note::ValueNote}; - use dep::aztec::{context::{Context}}; + use dep::aztec::{context::Context}; struct Storage { notes: Map>, 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 9cf549d6c57..5705f9378d1 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 @@ -1,7 +1,7 @@ use dep::aztec::protocol_types::{ contract_class_id::ContractClassId, constants::{MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS, REGISTERER_CONTRACT_CLASS_REGISTERED_MAGIC_VALUE}, - traits::{Serialize} + traits::Serialize }; // #[event] diff --git a/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/events/instance_deployed.nr b/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/events/instance_deployed.nr index 497ff310d2e..caa3cf76d0e 100644 --- a/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/events/instance_deployed.nr +++ b/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/events/instance_deployed.nr @@ -1,7 +1,7 @@ use dep::aztec::protocol_types::{ contract_class_id::ContractClassId, address::{AztecAddress, EthAddress, PublicKeysHash, PartialAddress}, - constants::{DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE}, traits::{Serialize} + constants::DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE, traits::Serialize }; // #[event] diff --git a/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/main.nr b/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/main.nr index 5bc9911e752..c12043d94a9 100644 --- a/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/main.nr @@ -3,8 +3,8 @@ mod events; contract ContractInstanceDeployer { use dep::aztec::protocol_types::{ address::{AztecAddress, EthAddress, PublicKeysHash, PartialAddress}, - contract_class_id::ContractClassId, - constants::{DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE}, traits::{Serialize} + contract_class_id::ContractClassId, constants::DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE, + traits::Serialize }; use dep::aztec::log::{emit_unencrypted_log, emit_unencrypted_log_from_private}; diff --git a/noir-projects/noir-contracts/contracts/gas_token_contract/src/main.nr b/noir-projects/noir-contracts/contracts/gas_token_contract/src/main.nr index 84af6c6af01..ca8f8f7bac5 100644 --- a/noir-projects/noir-contracts/contracts/gas_token_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/gas_token_contract/src/main.nr @@ -2,7 +2,7 @@ mod lib; contract GasToken { use dep::aztec::protocol_types::{abis::function_selector::FunctionSelector, address::{AztecAddress, EthAddress}}; - use dep::aztec::{hash::{compute_secret_hash}, state_vars::{PublicMutable, Map}}; + use dep::aztec::{hash::compute_secret_hash, state_vars::{PublicMutable, Map}}; use crate::lib::{calculate_fee, get_bridge_gas_msg_hash}; diff --git a/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr index 2a2da7ae8ce..d96acfef3fc 100644 --- a/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr @@ -3,9 +3,8 @@ contract StatefulTest { use dep::aztec::prelude::{PrivateContext, NoteHeader, Map, PublicMutable, PrivateSet, AztecAddress, FunctionSelector}; use dep::value_note::{balance_utils, utils::{increment, decrement}, value_note::{VALUE_NOTE_LEN, ValueNote}}; use dep::aztec::{ - deploy::{deploy_contract as aztec_deploy_contract}, context::{PublicContext, Context}, - oracle::get_contract_instance::get_contract_instance, - initializer::assert_is_initialized, + deploy::deploy_contract as aztec_deploy_contract, context::{PublicContext, Context}, + oracle::get_contract_instance::get_contract_instance, initializer::assert_is_initialized }; struct Storage { 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 24311d27087..5dfb7705975 100644 --- a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr @@ -21,7 +21,10 @@ contract Test { note_getter_options::NoteStatus }, deploy::deploy_contract as aztec_deploy_contract, - oracle::{get_public_key::get_public_key as get_public_key_oracle, context::get_portal_address, unsafe_rand::unsafe_rand}, + oracle::{ + get_public_key::get_public_key as get_public_key_oracle, context::get_portal_address, + unsafe_rand::unsafe_rand + }, log::emit_unencrypted_log_from_private }; use dep::token_portal_content_hash_lib::{get_mint_private_content_hash, get_mint_public_content_hash}; diff --git a/noir-projects/noir-contracts/contracts/uniswap_contract/src/main.nr b/noir-projects/noir-contracts/contracts/uniswap_contract/src/main.nr index 751e4c6497b..092169a817b 100644 --- a/noir-projects/noir-contracts/contracts/uniswap_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/uniswap_contract/src/main.nr @@ -169,7 +169,12 @@ contract Uniswap { // if valid, it returns the IS_VALID selector which is expected by token contract #[aztec(public)] fn spend_public_authwit(inner_hash: Field) -> Field { - let message_hash = compute_outer_authwit_hash(context.msg_sender(), context.chain_id(), context.version(), inner_hash); + let message_hash = compute_outer_authwit_hash( + context.msg_sender(), + context.chain_id(), + context.version(), + inner_hash + ); let value = storage.approved_action.at(message_hash).read(); if (value) { context.push_new_nullifier(message_hash, 0); diff --git a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/base.nr b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/base.nr index 962604a949f..1a89c4f17dd 100644 --- a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/base.nr +++ b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/base.nr @@ -1 +1 @@ -mod base_parity_inputs; \ No newline at end of file +mod base_parity_inputs; 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 52a5f4088f1..f6d7fcfb9d4 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,12 +1,7 @@ -use crate::{ - parity_public_inputs::ParityPublicInputs, - utils::sha256_merkle_tree::Sha256MerkleTree, -}; +use crate::{parity_public_inputs::ParityPublicInputs, utils::sha256_merkle_tree::Sha256MerkleTree}; use dep::types::{ - constants::NUM_MSGS_PER_BASE_PARITY, - merkle_tree::MerkleTree, - mocked::AggregationObject, - utils::uint256::U256, + constants::NUM_MSGS_PER_BASE_PARITY, merkle_tree::MerkleTree, mocked::AggregationObject, + utils::uint256::U256 }; struct BaseParityInputs { @@ -15,14 +10,13 @@ struct BaseParityInputs { impl BaseParityInputs { pub fn base_parity_circuit(self) -> ParityPublicInputs { - let sha_tree = Sha256MerkleTree::new(self.msgs); let pedersen_tree = MerkleTree::new(self.msgs); ParityPublicInputs { aggregation_object: AggregationObject {}, sha_root: sha_tree.get_root(), - converted_root: pedersen_tree.get_root(), + converted_root: pedersen_tree.get_root() } } } @@ -31,10 +25,10 @@ impl BaseParityInputs { fn test_sha_root_matches_frontier_tree() { // 31 byte msgs let msgs = [ - 0x151de48ca3efbae39f180fe00b8f472ec9f25be10b4f283a87c6d783935370, - 0x14c2ea9dedf77698d4afe23bc663263eed0bf9aa3a8b17d9b74812f185610f, - 0x1570cc6641699e3ae87fa258d80a6d853f7b8ccb211dc244d017e2ca6530f8, - 0x2806c860af67e9cd50000378411b8c4c4db172ceb2daa862b259b689ccbdc1 + 0x151de48ca3efbae39f180fe00b8f472ec9f25be10b4f283a87c6d783935370, + 0x14c2ea9dedf77698d4afe23bc663263eed0bf9aa3a8b17d9b74812f185610f, + 0x1570cc6641699e3ae87fa258d80a6d853f7b8ccb211dc244d017e2ca6530f8, + 0x2806c860af67e9cd50000378411b8c4c4db172ceb2daa862b259b689ccbdc1 ]; let base_parity_inputs = BaseParityInputs { msgs }; @@ -44,4 +38,4 @@ fn test_sha_root_matches_frontier_tree() { let expected_sha_root = 0xfc986d54a5e0af4f6e0d49399b9806c2b225e6c652fa5a831ecf6c6c29719d; assert(public_inputs.sha_root == expected_sha_root, "sha root does not match"); -} \ No newline at end of file +} diff --git a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/lib.nr b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/lib.nr index c4cdf2ff697..a9e2e5d2cdc 100644 --- a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/lib.nr +++ b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/lib.nr @@ -6,4 +6,4 @@ mod utils; use crate::base::base_parity_inputs::BaseParityInputs; use crate::root::root_parity_input::RootParityInput; use crate::root::root_parity_inputs::RootParityInputs; -use crate::parity_public_inputs::ParityPublicInputs; \ No newline at end of file +use crate::parity_public_inputs::ParityPublicInputs; 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 9f9a5e08666..03240ebe3ab 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,6 +1,4 @@ -use dep::types::{ - mocked::AggregationObject, -}; +use dep::types::{mocked::AggregationObject}; struct ParityPublicInputs { aggregation_object: AggregationObject, diff --git a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root.nr b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root.nr index fad5b442cd4..09b3c1137ca 100644 --- a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root.nr +++ b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root.nr @@ -1,2 +1,2 @@ mod root_parity_input; -mod root_parity_inputs; \ No newline at end of file +mod root_parity_inputs; 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 10d99aa656e..ad7c3d6b990 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 @@ -1,11 +1,7 @@ -use dep::types::{ - merkle_tree::MerkleTree, - mocked::AggregationObject, -}; +use dep::types::{merkle_tree::MerkleTree, mocked::AggregationObject}; use crate::{ - parity_public_inputs::ParityPublicInputs, - root::root_parity_input::RootParityInput, - utils::sha256_merkle_tree::Sha256MerkleTree, + parity_public_inputs::ParityPublicInputs, root::root_parity_input::RootParityInput, + utils::sha256_merkle_tree::Sha256MerkleTree }; global NUM_BASE_PARITY_PER_ROOT_PARITY: u64 = 4; @@ -31,7 +27,7 @@ impl RootParityInputs { ParityPublicInputs { aggregation_object: AggregationObject {}, sha_root: sha_tree.get_root(), - converted_root: pedersen_tree.get_root(), + converted_root: pedersen_tree.get_root() } } } @@ -39,10 +35,7 @@ impl RootParityInputs { mod tests { use crate::{ parity_public_inputs::ParityPublicInputs, - root::{ - root_parity_input::RootParityInput, - root_parity_inputs::RootParityInputs, - } + root::{root_parity_input::RootParityInput, root_parity_inputs::RootParityInputs} }; use dep::types::mocked::{AggregationObject, Proof}; @@ -53,14 +46,26 @@ mod tests { 0xb3a3fc1968999f2c2d798b900bdf0de41311be2a4d20496a7e792a521fc8ab, 0x43f78e0ebc9633ce336a8c086064d898c32fb5d7d6011f5427459c0b8d14e9, 0x024259b6404280addcc9319bc5a32c9a5d56af5c93b2f941fa326064fbe963, - 0x53042d820859d80c474d4694e03778f8dc0ac88fc1c3a97b4369c1096e904a, + 0x53042d820859d80c474d4694e03778f8dc0ac88fc1c3a97b4369c1096e904a ]; let children = [ - RootParityInput { proof: Proof {}, public_inputs: ParityPublicInputs { aggregation_object: AggregationObject {}, sha_root: children_sha_roots[0], converted_root: 0 } }, - RootParityInput { proof: Proof {}, public_inputs: ParityPublicInputs { aggregation_object: AggregationObject {}, sha_root: children_sha_roots[1], converted_root: 0 } }, - RootParityInput { proof: Proof {}, public_inputs: ParityPublicInputs { aggregation_object: AggregationObject {}, sha_root: children_sha_roots[2], converted_root: 0 } }, - RootParityInput { proof: Proof {}, public_inputs: ParityPublicInputs { aggregation_object: AggregationObject {}, sha_root: children_sha_roots[3], converted_root: 0 } }, + RootParityInput { + proof: Proof {}, + public_inputs: ParityPublicInputs { aggregation_object: AggregationObject {}, sha_root: children_sha_roots[0], converted_root: 0 } + }, + RootParityInput { + proof: Proof {}, + public_inputs: ParityPublicInputs { aggregation_object: AggregationObject {}, sha_root: children_sha_roots[1], converted_root: 0 } + }, + RootParityInput { + proof: Proof {}, + public_inputs: ParityPublicInputs { aggregation_object: AggregationObject {}, sha_root: children_sha_roots[2], converted_root: 0 } + }, + RootParityInput { + proof: Proof {}, + public_inputs: ParityPublicInputs { aggregation_object: AggregationObject {}, sha_root: children_sha_roots[3], converted_root: 0 } + } ]; let root_parity_inputs = RootParityInputs { children }; @@ -72,4 +77,4 @@ mod tests { assert(public_inputs.sha_root == expected_sha_root, "sha root does not match"); } -} \ No newline at end of file +} diff --git a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/utils.nr b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/utils.nr index 2d74cfe73d5..a3a41d46166 100644 --- a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/utils.nr +++ b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/utils.nr @@ -1 +1 @@ -mod sha256_merkle_tree; \ No newline at end of file +mod sha256_merkle_tree; 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 0e969cd3fb3..7a96e7c5d10 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 @@ -1,6 +1,4 @@ -use dep::types::{ - hash::accumulate_sha256, -}; +use dep::types::{hash::accumulate_sha256}; // Note: Once we'll truncate sha256 to 1 Field we can nuke this and generalize the standard MerkleTree over different // hash functions. @@ -45,4 +43,4 @@ impl Sha256MerkleTree { fn get_root(self) -> Field { self.nodes[N - 2] } -} \ No newline at end of file +} diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-app-logic-simulated/src/main.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-app-logic-simulated/src/main.nr index 5e45750867f..a41c1710e87 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-app-logic-simulated/src/main.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-app-logic-simulated/src/main.nr @@ -1,5 +1,5 @@ -use dep::public_kernel_lib::{PublicKernelAppLogicCircuitPrivateInputs}; -use dep::types::{PublicKernelCircuitPublicInputs}; +use dep::public_kernel_lib::PublicKernelAppLogicCircuitPrivateInputs; +use dep::types::PublicKernelCircuitPublicInputs; unconstrained fn main(input: PublicKernelAppLogicCircuitPrivateInputs) -> distinct pub PublicKernelCircuitPublicInputs { input.public_kernel_app_logic() diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-app-logic/src/main.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-app-logic/src/main.nr index e67ee442ded..d7c39940cc3 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-app-logic/src/main.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-app-logic/src/main.nr @@ -1,5 +1,5 @@ -use dep::public_kernel_lib::{PublicKernelAppLogicCircuitPrivateInputs}; -use dep::types::{PublicKernelCircuitPublicInputs}; +use dep::public_kernel_lib::PublicKernelAppLogicCircuitPrivateInputs; +use dep::types::PublicKernelCircuitPublicInputs; fn main(input: PublicKernelAppLogicCircuitPrivateInputs) -> distinct pub PublicKernelCircuitPublicInputs { input.public_kernel_app_logic() 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 f0cb914daad..3ae08334f64 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 @@ -17,12 +17,11 @@ use dep::types::{ }, constants::{ NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH, NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, - PUBLIC_DATA_TREE_HEIGHT, NOTE_HASH_SUBTREE_HEIGHT, - MAX_NEW_NOTE_HASHES_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_PUBLIC_DATA_READS_PER_TX, - MAX_NEW_NULLIFIERS_PER_TX, NUM_ENCRYPTED_LOGS_HASHES_PER_TX, MAX_NEW_L2_TO_L1_MSGS_PER_TX, - NUM_UNENCRYPTED_LOGS_HASHES_PER_TX, NULLIFIER_SUBTREE_HEIGHT, NULLIFIER_TREE_HEIGHT, - PUBLIC_DATA_SUBTREE_SIBLING_PATH_LENGTH, PUBLIC_DATA_SUBTREE_HEIGHT, - MAX_REVERTIBLE_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, + PUBLIC_DATA_TREE_HEIGHT, NOTE_HASH_SUBTREE_HEIGHT, MAX_NEW_NOTE_HASHES_PER_TX, + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_PUBLIC_DATA_READS_PER_TX, MAX_NEW_NULLIFIERS_PER_TX, + NUM_ENCRYPTED_LOGS_HASHES_PER_TX, MAX_NEW_L2_TO_L1_MSGS_PER_TX, NUM_UNENCRYPTED_LOGS_HASHES_PER_TX, + NULLIFIER_SUBTREE_HEIGHT, NULLIFIER_TREE_HEIGHT, PUBLIC_DATA_SUBTREE_SIBLING_PATH_LENGTH, + PUBLIC_DATA_SUBTREE_HEIGHT, MAX_REVERTIBLE_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_NON_REVERTIBLE_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_REVERTIBLE_NOTE_HASHES_PER_TX, MAX_NON_REVERTIBLE_NOTE_HASHES_PER_TX, MAX_REVERTIBLE_NULLIFIERS_PER_TX, MAX_NON_REVERTIBLE_NULLIFIERS_PER_TX diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/components.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/components.nr index 5d54cf35149..04f172053ab 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/components.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/components.nr @@ -3,8 +3,8 @@ use crate::abis::previous_rollup_data::PreviousRollupData; use dep::types::{ mocked::AggregationObject, hash::accumulate_sha256, constants::{ - MAX_NEW_NOTE_HASHES_PER_TX, MAX_NEW_NULLIFIERS_PER_TX, - MAX_NEW_L2_TO_L1_MSGS_PER_TX, NUM_UNENCRYPTED_LOGS_HASHES_PER_TX, NUM_ENCRYPTED_LOGS_HASHES_PER_TX, + MAX_NEW_NOTE_HASHES_PER_TX, MAX_NEW_NULLIFIERS_PER_TX, MAX_NEW_L2_TO_L1_MSGS_PER_TX, + NUM_UNENCRYPTED_LOGS_HASHES_PER_TX, NUM_ENCRYPTED_LOGS_HASHES_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX }, utils::uint256::U256, @@ -89,8 +89,8 @@ pub fn compute_out_hash(previous_rollup_data: [PreviousRollupData; 2]) -> Field accumulate_sha256( [ previous_rollup_data[0].base_or_merge_rollup_public_inputs.out_hash, - previous_rollup_data[1].base_or_merge_rollup_public_inputs.out_hash, - ] + previous_rollup_data[1].base_or_merge_rollup_public_inputs.out_hash + ] ) } @@ -119,7 +119,7 @@ pub fn compute_txs_effects_hash(previous_rollup_data: [PreviousRollupData; 2]) - accumulate_sha256( [ previous_rollup_data[0].base_or_merge_rollup_public_inputs.txs_effects_hash, - previous_rollup_data[1].base_or_merge_rollup_public_inputs.txs_effects_hash, + previous_rollup_data[1].base_or_merge_rollup_public_inputs.txs_effects_hash ] ) } 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 c42f8530432..a0fcfee73a8 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 @@ -131,9 +131,7 @@ mod tests { #[test] fn txs_effects_hash() { let mut inputs = default_merge_rollup_inputs(); - let expected_hash = accumulate_sha256( - [1, 2] - ); + let expected_hash = accumulate_sha256([1, 2]); let outputs = inputs.merge_rollup_circuit(); assert_eq(outputs.txs_effects_hash, expected_hash); diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/root.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/root.nr index 3784e95d63b..402760ef95a 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/root.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/root.nr @@ -60,9 +60,7 @@ mod tests { #[test] fn check_block_hashes_empty_blocks() { - let expected_txs_effects_hash = accumulate_sha256( - [1, 2] - ); + let expected_txs_effects_hash = accumulate_sha256([1, 2]); let inputs = default_root_rollup_inputs(); let outputs = inputs.root_rollup_circuit(); 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 4e87655b8f8..52d61a21832 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 @@ -84,10 +84,6 @@ impl RootRollupInputs { 0 ); - RootRollupPublicInputs { - aggregation_object, - archive, - header - } + RootRollupPublicInputs { aggregation_object, archive, header } } } 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 da448ee010f..954e16e3915 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,4 @@ -use dep::types::{ - abis::append_only_tree_snapshot::AppendOnlyTreeSnapshot, - header::Header -}; +use dep::types::{abis::append_only_tree_snapshot::AppendOnlyTreeSnapshot, header::Header}; use dep::types::mocked::AggregationObject; struct RootRollupPublicInputs { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/public_accumulated_revertible_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/public_accumulated_revertible_data.nr index 8e33d220a2f..ee88dfb0cd1 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/public_accumulated_revertible_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/public_accumulated_revertible_data.nr @@ -6,8 +6,7 @@ use crate::{ constants::{ MAX_REVERTIBLE_NOTE_HASHES_PER_TX, MAX_REVERTIBLE_NULLIFIERS_PER_TX, MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, MAX_REVERTIBLE_PUBLIC_CALL_STACK_LENGTH_PER_TX, - MAX_NEW_L2_TO_L1_MSGS_PER_TX, - MAX_REVERTIBLE_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX + MAX_NEW_L2_TO_L1_MSGS_PER_TX, MAX_REVERTIBLE_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX }, traits::is_default, }; 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 4330c0f6601..9b6ec359761 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 @@ -8,9 +8,8 @@ use crate::{ MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, MAX_NULLIFIER_READ_REQUESTS_PER_CALL, MAX_NULLIFIER_KEY_VALIDATION_REQUESTS_PER_CALL, MAX_NEW_NOTE_HASHES_PER_CALL, MAX_NEW_NULLIFIERS_PER_CALL, MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, - MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, MAX_NEW_L2_TO_L1_MSGS_PER_CALL, - RETURN_VALUES_LENGTH, PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH, - GENERATOR_INDEX__PRIVATE_CIRCUIT_PUBLIC_INPUTS + MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, MAX_NEW_L2_TO_L1_MSGS_PER_CALL, RETURN_VALUES_LENGTH, + PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH, GENERATOR_INDEX__PRIVATE_CIRCUIT_PUBLIC_INPUTS }, header::Header, hash::pedersen_hash, messaging::l2_to_l1_message::L2ToL1Message, traits::{Deserialize, Hash, Serialize}, utils::reader::Reader 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 db96e4bb651..7cf3a78eaaf 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,5 +1,5 @@ use crate::{ - address::AztecAddress, constants::{GENERATOR_INDEX__SIDE_EFFECT}, + address::AztecAddress, constants::GENERATOR_INDEX__SIDE_EFFECT, traits::{Hash, Serialize, Deserialize} }; use dep::std::cmp::Eq; 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 e450508bcb5..253af29f254 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, Hash, Serialize}, utils::{arr_copy_slice} + constants::CONTENT_COMMITMENT_LENGTH, traits::{Deserialize, Hash, Serialize}, + utils::arr_copy_slice }; use dep::std::default::Default; 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 44f0d62c765..16196ffe5cb 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,4 +1,4 @@ -use crate::constants::{GENERATOR_INDEX__CONTRACT_LEAF}; +use crate::constants::GENERATOR_INDEX__CONTRACT_LEAF; use crate::traits::{ToField, FromField, Hash, Serialize, Deserialize}; struct ContractClassId { 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 c6290201206..5bb59eaf81a 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/header.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/header.nr @@ -3,12 +3,9 @@ use crate::{ append_only_tree_snapshot::{AppendOnlyTreeSnapshot, APPEND_ONLY_TREE_SNAPSHOT_LENGTH}, global_variables::{GlobalVariables, GLOBAL_VARIABLES_LENGTH} }, - constants::{ - GENERATOR_INDEX__BLOCK_HASH, HEADER_LENGTH, STATE_REFERENCE_LENGTH, - CONTENT_COMMITMENT_LENGTH -}, + constants::{GENERATOR_INDEX__BLOCK_HASH, HEADER_LENGTH, STATE_REFERENCE_LENGTH, CONTENT_COMMITMENT_LENGTH}, hash::pedersen_hash, state_reference::StateReference, traits::{Deserialize, Hash, Serialize}, - utils::{arr_copy_slice}, content_commitment::ContentCommitment + utils::arr_copy_slice, content_commitment::ContentCommitment }; use dep::std::default::Default; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/append_only_tree.nr b/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/append_only_tree.nr index b8ddea2a984..47236c88967 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/append_only_tree.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/append_only_tree.nr @@ -23,7 +23,11 @@ pub fn insert_subtree_to_snapshot_tree( ); // if index of leaf is x, index of its parent is x/2 or x >> 1. We need to find the parent `subtree_depth` levels up. - let new_root = root_from_sibling_path(subtree_root_to_insert, leaf_index_at_depth as Field, sibling_path); + let new_root = root_from_sibling_path( + subtree_root_to_insert, + leaf_index_at_depth as Field, + sibling_path + ); // 2^subtree_depth is the number of leaves added. 2^x = 1 << x let new_next_available_leaf_index = (snapshot.next_available_leaf_index as u64) + (1 << (subtree_depth as u64)); 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 808e92c153a..24cb72b28ef 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 @@ -2,7 +2,7 @@ use crate::{ abis::append_only_tree_snapshot::{AppendOnlyTreeSnapshot, APPEND_ONLY_TREE_SNAPSHOT_LENGTH}, constants::{PARTIAL_STATE_REFERENCE_LENGTH, STATE_REFERENCE_LENGTH}, partial_state_reference::PartialStateReference, traits::{Deserialize, Hash, Serialize}, - utils::{arr_copy_slice} + utils::arr_copy_slice }; struct StateReference { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures.nr b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures.nr index dc1639a2a52..b55f3b8ba8a 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures.nr @@ -5,8 +5,8 @@ mod note_hash_read_requests; use crate::{ abis::{append_only_tree_snapshot::AppendOnlyTreeSnapshot, global_variables::GlobalVariables}, - address::{AztecAddress, EthAddress}, - grumpkin_point::GrumpkinPoint, content_commitment::ContentCommitment, header::Header, + address::{AztecAddress, EthAddress}, grumpkin_point::GrumpkinPoint, + content_commitment::ContentCommitment, header::Header, partial_state_reference::PartialStateReference, state_reference::StateReference, tests::fixtures }; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/note_hash_read_requests.nr b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/note_hash_read_requests.nr index 0123c28e38a..bb574b9165e 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/note_hash_read_requests.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/note_hash_read_requests.nr @@ -1,6 +1,6 @@ use crate::abis::{membership_witness::NoteHashReadRequestMembershipWitness, side_effect::SideEffect}; use crate::tests::fixtures; -use crate::constants::{MAX_NOTE_HASH_READ_REQUESTS_PER_CALL}; +use crate::constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL; pub fn generate_note_hash_read_requests(how_many: u64) -> (BoundedVec, BoundedVec) { generate_note_hash_read_requests_with_config(how_many, false, [0; MAX_NOTE_HASH_READ_REQUESTS_PER_CALL]) diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/tests/kernel_data_builder.nr b/noir-projects/noir-protocol-circuits/crates/types/src/tests/kernel_data_builder.nr index bea2cd791db..ee69f4c09a3 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/tests/kernel_data_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/tests/kernel_data_builder.nr @@ -19,8 +19,7 @@ use crate::{ }; use crate::constants::{ MAX_NEW_NOTE_HASHES_PER_TX, MAX_NON_REVERTIBLE_NULLIFIERS_PER_TX, MAX_NEW_NULLIFIERS_PER_TX, - MAX_PUBLIC_DATA_READS_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, - VK_TREE_HEIGHT + MAX_PUBLIC_DATA_READS_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, VK_TREE_HEIGHT }; use dep::std::unsafe; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/tests/private_call_data_builder.nr b/noir-projects/noir-protocol-circuits/crates/types/src/tests/private_call_data_builder.nr index a7f1433d61e..2eb4d1f2294 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/tests/private_call_data_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/tests/private_call_data_builder.nr @@ -3,7 +3,7 @@ use crate::{ call_request::{CallerContext, CallRequest}, private_call_stack_item::PrivateCallStackItem, function_data::FunctionData, max_block_number::MaxBlockNumber, membership_witness::{FunctionLeafMembershipWitness, NoteHashReadRequestMembershipWitness}, - private_circuit_public_inputs::{PrivateCircuitPublicInputs}, + private_circuit_public_inputs::PrivateCircuitPublicInputs, private_kernel::private_call_data::PrivateCallData }, address::{AztecAddress, EthAddress, SaltedInitializationHash, PublicKeysHash}, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/tests/private_circuit_public_inputs_builder.nr b/noir-projects/noir-protocol-circuits/crates/types/src/tests/private_circuit_public_inputs_builder.nr index c1fb6b1a015..d0ecc0c82c1 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/tests/private_circuit_public_inputs_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/tests/private_circuit_public_inputs_builder.nr @@ -12,8 +12,7 @@ use crate::constants::{ MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, MAX_NULLIFIER_READ_REQUESTS_PER_CALL, MAX_NULLIFIER_KEY_VALIDATION_REQUESTS_PER_CALL, MAX_NEW_NOTE_HASHES_PER_CALL, MAX_NEW_NULLIFIERS_PER_CALL, MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, - MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, MAX_NEW_L2_TO_L1_MSGS_PER_CALL, - RETURN_VALUES_LENGTH + MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, MAX_NEW_L2_TO_L1_MSGS_PER_CALL, RETURN_VALUES_LENGTH }; struct PrivateCircuitPublicInputsBuilder { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/utils/field.nr b/noir-projects/noir-protocol-circuits/crates/types/src/utils/field.nr index abbbc0a5a05..6d366ee838b 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/utils/field.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/utils/field.nr @@ -47,19 +47,23 @@ pub fn full_field_greater_than(lhs: Field, rhs: Field) -> bool { unconstrained fn bytes_field_test() { // Tests correctness of field_from_bytes_32_trunc against existing methods // Bytes representing 0x543e0a6642ffeb8039296861765a53407bba62bd1c97ca43374de950bbe0a7 - let inputs = [84, 62, 10, 102, 66, 255, 235, 128, 57, 41, 104, 97, 118, 90, 83, 64, 123, 186, 98, 189, 28, 151, 202, 67, 55, 77, 233, 80, 187, 224, 167]; + let inputs = [ + 84, 62, 10, 102, 66, 255, 235, 128, 57, 41, 104, 97, 118, 90, 83, 64, 123, 186, 98, 189, 28, 151, 202, 67, 55, 77, 233, 80, 187, 224, 167 + ]; let field = field_from_bytes(inputs, true); let return_bytes = field.to_be_bytes(31); for i in 0..31 { assert_eq(inputs[i], return_bytes[i]); } // 32 bytes - we remove the final byte, and check it matches the field - let inputs2 = [84, 62, 10, 102, 66, 255, 235, 128, 57, 41, 104, 97, 118, 90, 83, 64, 123, 186, 98, 189, 28, 151, 202, 67, 55, 77, 233, 80, 187, 224, 167, 158]; + let inputs2 = [ + 84, 62, 10, 102, 66, 255, 235, 128, 57, 41, 104, 97, 118, 90, 83, 64, 123, 186, 98, 189, 28, 151, 202, 67, 55, 77, 233, 80, 187, 224, 167, 158 + ]; let field2 = field_from_bytes_32_trunc(inputs2); let return_bytes2 = field.to_be_bytes(31); - + for i in 0..31 { assert_eq(return_bytes2[i], return_bytes[i]); } assert_eq(field2, field); -} \ No newline at end of file +} diff --git a/noir/noir-repo/acvm-repo/brillig_vm/src/memory.rs b/noir/noir-repo/acvm-repo/brillig_vm/src/memory.rs index ae442ac2628..d563e13be2e 100644 --- a/noir/noir-repo/acvm-repo/brillig_vm/src/memory.rs +++ b/noir/noir-repo/acvm-repo/brillig_vm/src/memory.rs @@ -33,8 +33,7 @@ impl MemoryValue { pub fn to_usize(&self) -> usize { assert!(self.bit_size == MEMORY_ADDRESSING_BIT_SIZE, "value is not typed as brillig usize"); - usize::try_from(self.value.try_to_u64().expect("value does not fit into u64")) - .expect("value does not fit into usize") + self.value.to_u128() as usize } pub fn expect_bit_size(&self, expected_bit_size: u32) -> Result<(), MemoryTypeError> { @@ -116,7 +115,7 @@ impl TryFrom for u64 { fn try_from(memory_value: MemoryValue) -> Result { memory_value.expect_bit_size(64)?; - Ok(memory_value.value.try_to_u64().expect("value typed as u64 does not fit into u64")) + Ok(memory_value.value.to_u128() as u64) } } @@ -125,9 +124,7 @@ impl TryFrom for u32 { fn try_from(memory_value: MemoryValue) -> Result { memory_value.expect_bit_size(32)?; - let as_u64 = - memory_value.value.try_to_u64().expect("value typed as u32 does not fit into u64"); - Ok(u32::try_from(as_u64).expect("value typed as u32 does not fit into u32")) + Ok(memory_value.value.to_u128() as u32) } } @@ -137,10 +134,7 @@ impl TryFrom for u8 { fn try_from(memory_value: MemoryValue) -> Result { memory_value.expect_bit_size(8)?; - Ok(u8::try_from( - memory_value.value.try_to_u64().expect("value typed as u8 does not fit into u64"), - ) - .expect("value typed as u8 does not fit into u8")) + Ok(memory_value.value.to_u128() as u8) } }