diff --git a/yarn-project/aztec-nr/aztec/src/history/nullifier_non_inclusion.nr b/yarn-project/aztec-nr/aztec/src/history/nullifier_non_inclusion.nr index 5568321fbd2..d202ac3a290 100644 --- a/yarn-project/aztec-nr/aztec/src/history/nullifier_non_inclusion.nr +++ b/yarn-project/aztec-nr/aztec/src/history/nullifier_non_inclusion.nr @@ -1,6 +1,11 @@ use dep::std::merkle::compute_merkle_root; -use dep::protocol_types::header::Header; - +use dep::protocol_types::{ + header::Header, + utils::field::{ + full_field_less_than, + full_field_greater_than, + }, +}; use crate::{ context::PrivateContext, note::{ @@ -8,10 +13,6 @@ use crate::{ note_interface::NoteInterface, }, oracle::get_nullifier_membership_witness::get_low_nullifier_membership_witness, - utils::{ - full_field_less_than, - full_field_greater_than, - }, }; pub fn _nullifier_non_inclusion(nullifier: Field, header: Header) { diff --git a/yarn-project/aztec-nr/aztec/src/history/public_value_inclusion.nr b/yarn-project/aztec-nr/aztec/src/history/public_value_inclusion.nr index fbbfe95b9a9..5a5f7f13dc5 100644 --- a/yarn-project/aztec-nr/aztec/src/history/public_value_inclusion.nr +++ b/yarn-project/aztec-nr/aztec/src/history/public_value_inclusion.nr @@ -1,10 +1,11 @@ use dep::protocol_types::{ constants::GENERATOR_INDEX__PUBLIC_LEAF_INDEX, - header::Header, hash::pedersen_hash, address::{ AztecAddress }, + header::Header, + utils::field::full_field_less_than, }; use dep::std::merkle::compute_merkle_root; @@ -13,9 +14,6 @@ use crate::{ oracle::get_public_data_witness::{ get_public_data_witness, }, - utils::{ - full_field_less_than, - }, }; fn _public_value_inclusion( diff --git a/yarn-project/aztec-nr/aztec/src/lib.nr b/yarn-project/aztec-nr/aztec/src/lib.nr index 4b02952d76a..2ca0b281a5a 100644 --- a/yarn-project/aztec-nr/aztec/src/lib.nr +++ b/yarn-project/aztec-nr/aztec/src/lib.nr @@ -9,5 +9,4 @@ mod messaging; mod note; mod oracle; mod state_vars; -mod utils; use dep::protocol_types; diff --git a/yarn-project/aztec-nr/aztec/src/messaging/l1_to_l2_message_getter_data.nr b/yarn-project/aztec-nr/aztec/src/messaging/l1_to_l2_message_getter_data.nr index 34f21c60395..0f7254710c4 100644 --- a/yarn-project/aztec-nr/aztec/src/messaging/l1_to_l2_message_getter_data.nr +++ b/yarn-project/aztec-nr/aztec/src/messaging/l1_to_l2_message_getter_data.nr @@ -1,9 +1,11 @@ use crate::messaging::l1_to_l2_message::L1ToL2Message; -use dep::protocol_types::constants::{ - L1_TO_L2_MSG_TREE_HEIGHT, - L1_TO_L2_MESSAGE_LENGTH, +use dep::protocol_types::{ + constants::{ + L1_TO_L2_MSG_TREE_HEIGHT, + L1_TO_L2_MESSAGE_LENGTH, + }, + utils::arr_copy_slice, }; -use crate::utils::arr_copy_slice; struct L1ToL2MessageGetterData { message: L1ToL2Message, diff --git a/yarn-project/aztec-nr/aztec/src/note/utils.nr b/yarn-project/aztec-nr/aztec/src/note/utils.nr index 5c05cd1b7ca..81f2f2c17ce 100644 --- a/yarn-project/aztec-nr/aztec/src/note/utils.nr +++ b/yarn-project/aztec-nr/aztec/src/note/utils.nr @@ -4,7 +4,6 @@ use crate::{ note_header::NoteHeader, note_interface::NoteInterface, }, - utils::arr_copy_slice, }; use dep::protocol_types::{ @@ -15,6 +14,7 @@ use dep::protocol_types::{ GENERATOR_INDEX__SILOED_COMMITMENT, }, hash::pedersen_hash, + utils::arr_copy_slice, }; fn compute_siloed_hash(contract_address: AztecAddress, inner_note_hash: Field) -> Field { diff --git a/yarn-project/aztec-nr/aztec/src/oracle/get_membership_witness.nr b/yarn-project/aztec-nr/aztec/src/oracle/get_membership_witness.nr index d0ae5e8608b..14d5b9e20ff 100644 --- a/yarn-project/aztec-nr/aztec/src/oracle/get_membership_witness.nr +++ b/yarn-project/aztec-nr/aztec/src/oracle/get_membership_witness.nr @@ -1,9 +1,11 @@ -use dep::protocol_types::constants::{ - ARCHIVE_HEIGHT, - CONTRACT_TREE_HEIGHT, - NOTE_HASH_TREE_HEIGHT, +use dep::protocol_types::{ + constants::{ + ARCHIVE_HEIGHT, + CONTRACT_TREE_HEIGHT, + NOTE_HASH_TREE_HEIGHT, + }, + utils::arr_copy_slice, }; -use crate::utils::arr_copy_slice; global CONTRACT_TREE_ID = 0; global NOTE_HASH_TREE_ID = 2; diff --git a/yarn-project/aztec-nr/aztec/src/oracle/get_nullifier_membership_witness.nr b/yarn-project/aztec-nr/aztec/src/oracle/get_nullifier_membership_witness.nr index 21138a3ecf1..3cf667ce715 100644 --- a/yarn-project/aztec-nr/aztec/src/oracle/get_nullifier_membership_witness.nr +++ b/yarn-project/aztec-nr/aztec/src/oracle/get_nullifier_membership_witness.nr @@ -5,8 +5,8 @@ use dep::protocol_types::{ }, constants::NULLIFIER_TREE_HEIGHT, hash::pedersen_hash, + utils::arr_copy_slice, }; -use crate::utils::arr_copy_slice; // INDEX_LENGTH + NULLIFIER_LEAF_PREIMAGE_LENGTH + NULLIFIER_TREE_HEIGHT global NULLIFIER_MEMBERSHIP_WITNESS: Field = 24; diff --git a/yarn-project/aztec-nr/aztec/src/oracle/get_public_data_witness.nr b/yarn-project/aztec-nr/aztec/src/oracle/get_public_data_witness.nr index f0c4ce2f8e9..1e843f79408 100644 --- a/yarn-project/aztec-nr/aztec/src/oracle/get_public_data_witness.nr +++ b/yarn-project/aztec-nr/aztec/src/oracle/get_public_data_witness.nr @@ -1,35 +1,17 @@ use dep::protocol_types::{ constants::PUBLIC_DATA_TREE_HEIGHT, hash::pedersen_hash, - traits::{Hash, Serialize} + public_data_tree_leaf_preimage::PublicDataTreeLeafPreimage, + traits::{ + Hash, + Serialize, + }, + utils::arr_copy_slice, }; -use crate::utils::arr_copy_slice; global LEAF_PREIMAGE_LENGTH: Field = 4; -// TODO: move this to constants_gen.nr so that it gets computed as INDEX_LENGTH + LEAF_DATA_LENGTH + PUBLIC_DATA_TREE_HEIGHT global PUBLIC_DATA_WITNESS: Field = 45; -// TODO(#3470) replace with /mnt/user-data/jan/aztec-packages/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/abis/public_data_tree_leaf.nr -struct PublicDataTreeLeafPreimage { - slot : Field, - value: Field, - next_index : u32, - next_slot :Field, -} - -impl Serialize for PublicDataTreeLeafPreimage { - fn serialize(self) -> [Field; LEAF_PREIMAGE_LENGTH] { - [self.slot, self.value, self.next_index as Field, self.next_slot] - } -} - -impl Hash for PublicDataTreeLeafPreimage { - fn hash(self) -> Field { - // Performs the same hashing as StandardIndexedTree::encodeLeaf(...) - pedersen_hash(self.serialize(), 0) - } -} - struct PublicDataWitness { index: Field, leaf_preimage: PublicDataTreeLeafPreimage, diff --git a/yarn-project/aztec-nr/aztec/src/oracle/notes.nr b/yarn-project/aztec-nr/aztec/src/oracle/notes.nr index 1c49f54f0c1..f6378c1ecd6 100644 --- a/yarn-project/aztec-nr/aztec/src/oracle/notes.nr +++ b/yarn-project/aztec-nr/aztec/src/oracle/notes.nr @@ -3,10 +3,10 @@ use crate::note::{ note_header::NoteHeader, note_interface::NoteInterface, }; -use crate::utils::arr_copy_slice; use dep::protocol_types::{ address::AztecAddress, + utils::arr_copy_slice, }; #[oracle(notifyCreatedNote)] diff --git a/yarn-project/aztec-nr/aztec/src/utils.nr b/yarn-project/aztec-nr/aztec/src/utils.nr deleted file mode 100644 index 9d66e257b9c..00000000000 --- a/yarn-project/aztec-nr/aztec/src/utils.nr +++ /dev/null @@ -1,18 +0,0 @@ -pub fn arr_copy_slice(src: [T; N], mut dst: [T; M], offset: Field) -> [T; M] { - for i in 0..dst.len() { - dst[i] = src[i + offset]; - } - dst -} - -// TODO(#3470): Copied over from https://github.com/AztecProtocol/aztec-packages/blob/a07c4bd47313be6aa604a63f37857eb0136b41ba/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/base/base_rollup_inputs.nr#L599 -// move to a shared place? - -// TODO to radix returns u8, so we cannot use bigger radixes. It'd be ideal to use a radix of the maximum range-constrained integer noir supports -pub fn full_field_less_than(lhs: Field, rhs: Field) -> bool { - lhs.lt(rhs) -} - -pub fn full_field_greater_than(lhs: Field, rhs: Field) -> bool { - rhs.lt(lhs) -} diff --git a/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/abis.nr b/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/abis.nr index 980149dab8a..fe5d8000c09 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/abis.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/abis.nr @@ -1,4 +1,3 @@ -mod public_data_tree_leaf; mod constant_rollup_data; mod base_or_merge_rollup_public_inputs; mod previous_rollup_data; diff --git a/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/base/base_rollup_inputs.nr b/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/base/base_rollup_inputs.nr index 3181b8cdbd2..73099641c56 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/base/base_rollup_inputs.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/base/base_rollup_inputs.nr @@ -1,41 +1,72 @@ -use crate::abis::public_data_tree_leaf::{PublicDataTreeLeaf, PublicDataTreeLeafPreimage}; -use crate::abis::constant_rollup_data::ConstantRollupData; -use crate::abis::base_or_merge_rollup_public_inputs::{BaseOrMergeRollupPublicInputs, BASE_ROLLUP_TYPE}; -use crate::base::state_diff_hints::StateDiffHints; -use crate::merkle_tree::{calculate_subtree, calculate_empty_tree_root}; -use crate::components; -use dep::types::utils::uint256::U256; -use dep::types::abis::append_only_tree_snapshot::AppendOnlyTreeSnapshot; -use dep::types::abis::public_data_update_request::PublicDataUpdateRequest; -use dep::types::abis::public_data_read::PublicDataRead; -use dep::types::mocked::{AggregationObject, Proof}; -use dep::types::constants::{ - NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH, - NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, - CONTRACT_SUBTREE_SIBLING_PATH_LENGTH, - PUBLIC_DATA_TREE_HEIGHT, - MAX_NEW_CONTRACTS_PER_TX, - NOTE_HASH_SUBTREE_HEIGHT, - CONTRACT_SUBTREE_HEIGHT, - NUM_FIELDS_PER_SHA256, - MAX_NEW_COMMITMENTS_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, +use crate::{ + abis::{ + constant_rollup_data::ConstantRollupData, + base_or_merge_rollup_public_inputs::{ + BaseOrMergeRollupPublicInputs, + BASE_ROLLUP_TYPE, + }, + }, + base::state_diff_hints::StateDiffHints, + components, + merkle_tree::{ + calculate_empty_tree_root, + calculate_subtree, + }, +}; +use dep::types::{ + abis::{ + append_only_tree_snapshot::AppendOnlyTreeSnapshot, + membership_witness::{ + ArchiveRootMembershipWitness, + MembershipWitness, + NullifierMembershipWitness, + PublicDataMembershipWitness, + }, + nullifier_leaf_preimage::NullifierLeafPreimage, + public_data_update_request::PublicDataUpdateRequest, + public_data_read::PublicDataRead, + previous_kernel_data::PreviousKernelData, + side_effect::{ + SideEffect, + SideEffectLinkedToNoteHash, + }, + }, + constants::{ + NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH, + NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, + CONTRACT_SUBTREE_SIBLING_PATH_LENGTH, + PUBLIC_DATA_TREE_HEIGHT, + MAX_NEW_CONTRACTS_PER_TX, + NOTE_HASH_SUBTREE_HEIGHT, + CONTRACT_SUBTREE_HEIGHT, + NUM_FIELDS_PER_SHA256, + MAX_NEW_COMMITMENTS_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, + }, + mocked::{ + AggregationObject, + Proof + }, + partial_state_reference::PartialStateReference, + public_data_tree_leaf::PublicDataTreeLeaf, + public_data_tree_leaf_preimage::PublicDataTreeLeafPreimage, + utils::{ + field::{ + full_field_less_than, + full_field_greater_than, + }, + uint256::U256, + }, }; -use dep::types::abis::previous_kernel_data::PreviousKernelData; -use dep::types::abis::membership_witness::{NullifierMembershipWitness, PublicDataMembershipWitness, MembershipWitness}; -use dep::types::abis::membership_witness::ArchiveRootMembershipWitness; -use dep::types::abis::side_effect::{SideEffect, SideEffectLinkedToNoteHash}; -use dep::types::abis::nullifier_leaf_preimage::NullifierLeafPreimage; -use dep::types::partial_state_reference::PartialStateReference; struct BaseRollupInputs { kernel_data: PreviousKernelData, @@ -520,15 +551,6 @@ fn consistent_call_data_hash_full_fields() { ); } -// TODO to radix returns u8, so we cannot use bigger radixes. It'd be ideal to use a radix of the maximum range-constrained integer noir supports -pub fn full_field_less_than(lhs: Field, rhs: Field) -> bool { - lhs.lt(rhs) -} - -pub fn full_field_greater_than(lhs: Field, rhs: Field) -> bool { - rhs.lt(lhs) -} - #[test] fn test_u256_less_than() { assert(full_field_less_than(1, 1000)); @@ -549,58 +571,77 @@ fn test_u256_greater_than() { mod tests { use crate::{ + abis::{ + constant_rollup_data::ConstantRollupData, + base_or_merge_rollup_public_inputs::BaseOrMergeRollupPublicInputs, + }, base::{ + state_diff_hints::StateDiffHints, base_rollup_inputs::{ CALL_DATA_HASH_FULL_FIELDS, CALL_DATA_HASH_LOG_FIELDS, BaseRollupInputs, - full_field_less_than, }, - state_diff_hints::StateDiffHints, }, - merkle_tree::{calculate_subtree, calculate_empty_tree_root}, - abis::base_or_merge_rollup_public_inputs::BaseOrMergeRollupPublicInputs, - abis::public_data_tree_leaf::{PublicDataTreeLeafPreimage, PublicDataTreeLeaf}, - abis::constant_rollup_data::ConstantRollupData, - tests::merkle_tree_utils::{NonEmptyMerkleTree, compute_zero_hashes}, + merkle_tree::{ + calculate_empty_tree_root, + calculate_subtree, + }, components, - }; - use dep::types::constants::{ - CONTRACT_SUBTREE_SIBLING_PATH_LENGTH, - CONTRACT_TREE_HEIGHT, - CONTRACT_SUBTREE_HEIGHT, - ARCHIVE_HEIGHT, - MAX_PUBLIC_DATA_READS_PER_TX, - MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, - MAX_NEW_COMMITMENTS_PER_TX, - MAX_NEW_NULLIFIERS_PER_TX, - MAX_NEW_CONTRACTS_PER_TX, - NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH, - NOTE_HASH_TREE_HEIGHT, - NOTE_HASH_SUBTREE_HEIGHT, - NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, - NULLIFIER_TREE_HEIGHT, - NULLIFIER_SUBTREE_HEIGHT, - PUBLIC_DATA_TREE_HEIGHT, - PUBLIC_DATA_SUBTREE_HEIGHT, - PUBLIC_DATA_SUBTREE_SIBLING_PATH_LENGTH, - NUM_FIELDS_PER_SHA256, + tests::merkle_tree_utils::{ + NonEmptyMerkleTree, + compute_zero_hashes, + }, }; use dep::types::{ - abis::append_only_tree_snapshot::AppendOnlyTreeSnapshot, - abis::membership_witness::ArchiveRootMembershipWitness, - abis::membership_witness::{NullifierMembershipWitness, PublicDataMembershipWitness}, - abis::new_contract_data::NewContractData, - abis::nullifier_leaf_preimage::NullifierLeafPreimage, - abis::public_data_read::PublicDataRead, - abis::public_data_update_request::PublicDataUpdateRequest, - abis::previous_kernel_data::PreviousKernelData, - abis::side_effect::SideEffect, - tests::previous_kernel_data_builder::PreviousKernelDataBuilder, - address::{AztecAddress, EthAddress}, + abis::{ + append_only_tree_snapshot::AppendOnlyTreeSnapshot, + membership_witness::{ + ArchiveRootMembershipWitness, + NullifierMembershipWitness, + PublicDataMembershipWitness, + }, + new_contract_data::NewContractData, + nullifier_leaf_preimage::NullifierLeafPreimage, + public_data_read::PublicDataRead, + public_data_update_request::PublicDataUpdateRequest, + previous_kernel_data::PreviousKernelData, + side_effect::SideEffect, + }, + address::{ + AztecAddress, + EthAddress, + }, + constants::{ + CONTRACT_SUBTREE_SIBLING_PATH_LENGTH, + CONTRACT_TREE_HEIGHT, + CONTRACT_SUBTREE_HEIGHT, + ARCHIVE_HEIGHT, + MAX_PUBLIC_DATA_READS_PER_TX, + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, + MAX_NEW_COMMITMENTS_PER_TX, + MAX_NEW_NULLIFIERS_PER_TX, + MAX_NEW_CONTRACTS_PER_TX, + NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH, + NOTE_HASH_TREE_HEIGHT, + NOTE_HASH_SUBTREE_HEIGHT, + NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, + NULLIFIER_TREE_HEIGHT, + NULLIFIER_SUBTREE_HEIGHT, + PUBLIC_DATA_TREE_HEIGHT, + PUBLIC_DATA_SUBTREE_HEIGHT, + PUBLIC_DATA_SUBTREE_SIBLING_PATH_LENGTH, + NUM_FIELDS_PER_SHA256, + }, contract_class::ContractClassId, - utils::uint256::U256, partial_state_reference::PartialStateReference, + public_data_tree_leaf::PublicDataTreeLeaf, + public_data_tree_leaf_preimage::PublicDataTreeLeafPreimage, + tests::previous_kernel_data_builder::PreviousKernelDataBuilder, + utils::{ + field::full_field_less_than, + uint256::U256, + } }; use dep::std::option::Option; diff --git a/yarn-project/noir-protocol-circuits/src/crates/types/src/lib.nr b/yarn-project/noir-protocol-circuits/src/crates/types/src/lib.nr index b60e165e4fa..19d13efc03c 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/types/src/lib.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/types/src/lib.nr @@ -24,5 +24,7 @@ mod tests; mod state_reference; mod partial_state_reference; +mod public_data_tree_leaf; +mod public_data_tree_leaf_preimage; use abis::kernel_circuit_public_inputs::{ KernelCircuitPublicInputs, KernelCircuitPublicInputsFinal }; diff --git a/yarn-project/noir-protocol-circuits/src/crates/types/src/public_data_tree_leaf.nr b/yarn-project/noir-protocol-circuits/src/crates/types/src/public_data_tree_leaf.nr new file mode 100644 index 00000000000..57eb1945a3a --- /dev/null +++ b/yarn-project/noir-protocol-circuits/src/crates/types/src/public_data_tree_leaf.nr @@ -0,0 +1,28 @@ +use crate::traits::Empty; +use dep::std::cmp::Eq; + +struct PublicDataTreeLeaf { + slot: Field, + value: Field, +} + +impl Eq for PublicDataTreeLeaf { + fn eq(self, other: Self) -> bool { + (self.slot == other.slot) & (self.value == other.value) + } +} + +impl Empty for PublicDataTreeLeaf { + fn empty() -> Self { + Self { + slot: 0, + value: 0, + } + } +} + +impl PublicDataTreeLeaf { + pub fn is_empty(self) -> bool { + (self.slot == 0) & (self.value == 0) + } +} diff --git a/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/abis/public_data_tree_leaf.nr b/yarn-project/noir-protocol-circuits/src/crates/types/src/public_data_tree_leaf_preimage.nr similarity index 58% rename from yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/abis/public_data_tree_leaf.nr rename to yarn-project/noir-protocol-circuits/src/crates/types/src/public_data_tree_leaf_preimage.nr index 0bd347a6116..dc84f6ee903 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/abis/public_data_tree_leaf.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/types/src/public_data_tree_leaf_preimage.nr @@ -1,5 +1,4 @@ -use dep::std::cmp::Eq; -use dep::types::traits::{Empty, Hash}; +use crate::traits::{Empty, Hash}; struct PublicDataTreeLeafPreimage { slot : Field, @@ -34,29 +33,3 @@ impl PublicDataTreeLeafPreimage { (self.slot == 0) & (self.value == 0) & (self.next_slot == 0) & (self.next_index == 0) } } - -struct PublicDataTreeLeaf { - slot: Field, - value: Field, -} - -impl Eq for PublicDataTreeLeaf { - fn eq(self, other: Self) -> bool { - (self.slot == other.slot) & (self.value == other.value) - } -} - -impl Empty for PublicDataTreeLeaf { - fn empty() -> Self { - Self { - slot: 0, - value: 0, - } - } -} - -impl PublicDataTreeLeaf { - pub fn is_empty(self) -> bool { - (self.slot == 0) & (self.value == 0) - } -} diff --git a/yarn-project/noir-protocol-circuits/src/crates/types/src/utils.nr b/yarn-project/noir-protocol-circuits/src/crates/types/src/utils.nr index b39707c73ae..7b1496afb46 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/types/src/utils.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/types/src/utils.nr @@ -12,7 +12,6 @@ pub fn conditional_assign(predicate: bool, lhs: Field, rhs: Field) -> Field { if predicate { lhs } else { rhs } } -// Copied over from "yarn-project/aztec-nr/aztec/src/utils.nr" pub fn arr_copy_slice(src: [T; N], mut dst: [T; M], offset: Field) -> [T; M] { for i in 0..dst.len() { dst[i] = src[i + offset]; diff --git a/yarn-project/noir-protocol-circuits/src/crates/types/src/utils/field.nr b/yarn-project/noir-protocol-circuits/src/crates/types/src/utils/field.nr index 918543b6665..d5033666f1e 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/types/src/utils/field.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/types/src/utils/field.nr @@ -13,3 +13,12 @@ pub fn field_from_bytes(bytes: [u8; N], big_endian: bool) -> Field { as_field } + +// TODO to radix returns u8, so we cannot use bigger radixes. It'd be ideal to use a radix of the maximum range-constrained integer noir supports +pub fn full_field_less_than(lhs: Field, rhs: Field) -> bool { + lhs.lt(rhs) +} + +pub fn full_field_greater_than(lhs: Field, rhs: Field) -> bool { + rhs.lt(lhs) +}