diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/log_hash.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/log_hash.nr index 54068a15e3fc..79d208a60831 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/log_hash.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/log_hash.nr @@ -22,9 +22,6 @@ impl OrderedValue for LogHash { fn value(self) -> Field { self.value } - fn counter(self) -> u32 { - self.counter - } } impl Eq for LogHash { @@ -83,9 +80,6 @@ impl OrderedValue for ScopedLogHash { fn value(self) -> Field { self.log_hash.value } - fn counter(self) -> u32 { - self.log_hash.counter - } } impl Eq for ScopedLogHash { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/note_hash.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/note_hash.nr index 0b842cc16251..eb88ed9024db 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/note_hash.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/note_hash.nr @@ -71,9 +71,6 @@ impl OrderedValue for ScopedNoteHash { fn value(self) -> Field { self.note_hash.value } - fn counter(self) -> u32 { - self.note_hash.counter - } } impl Eq for ScopedNoteHash { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/nullifier.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/nullifier.nr index eab73ba87a22..d376f34bebb4 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/nullifier.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/nullifier.nr @@ -23,9 +23,6 @@ impl OrderedValue for Nullifier { fn value(self) -> Field { self.value } - fn counter(self) -> u32 { - self.counter - } } impl Eq for Nullifier { @@ -102,9 +99,6 @@ impl OrderedValue for ScopedNullifier { fn value(self) -> Field { self.nullifier.value } - fn counter(self) -> u32 { - self.nullifier.counter - } } impl Eq for ScopedNullifier { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/nullifier_leaf_preimage.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/nullifier_leaf_preimage.nr index cdc559f353d0..a57a5e2f077d 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/nullifier_leaf_preimage.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/nullifier_leaf_preimage.nr @@ -40,10 +40,6 @@ impl LeafPreimage for NullifierLeafPreimage { } impl IndexedTreeLeafPreimage for NullifierLeafPreimage { - fn get_key(self) -> Field { - self.nullifier - } - fn get_next_key(self) -> Field { self.next_nullifier } @@ -52,10 +48,6 @@ impl IndexedTreeLeafPreimage for NullifierLeafPreimage { (self.next_nullifier == 0) & (self.next_index == 0) } - fn as_leaf(self) -> Field { - self.hash() - } - fn update_pointers(self, next_key: Field, next_index: u32) -> Self { Self { nullifier: self.nullifier, next_nullifier: next_key, next_index } } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/side_effect/mod.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/side_effect/mod.nr index d0025825da95..dff003c43fa6 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/side_effect/mod.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/side_effect/mod.nr @@ -14,12 +14,11 @@ pub trait RangeOrdered { fn counter_end(self) -> u32; } -pub trait OrderedValue +pub trait OrderedValue: Ordered where T: Eq, { fn value(self) -> T; - fn counter(self) -> u32; } pub trait Scoped diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/data/public_data_tree_leaf_preimage.nr b/noir-projects/noir-protocol-circuits/crates/types/src/data/public_data_tree_leaf_preimage.nr index 558c4169f01e..06b4112600d1 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/data/public_data_tree_leaf_preimage.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/data/public_data_tree_leaf_preimage.nr @@ -1,6 +1,6 @@ use crate::{ data::public_data_tree_leaf::PublicDataTreeLeaf, - merkle_tree::leaf_preimage::IndexedTreeLeafPreimage, + merkle_tree::leaf_preimage::{IndexedTreeLeafPreimage, LeafPreimage}, traits::{Empty, Hash}, }; @@ -41,11 +41,17 @@ impl Hash for PublicDataTreeLeafPreimage { } } -impl IndexedTreeLeafPreimage for PublicDataTreeLeafPreimage { +impl LeafPreimage for PublicDataTreeLeafPreimage { fn get_key(self) -> Field { self.slot } + fn as_leaf(self) -> Field { + self.hash() + } +} + +impl IndexedTreeLeafPreimage for PublicDataTreeLeafPreimage { fn get_next_key(self) -> Field { self.next_slot } @@ -54,10 +60,6 @@ impl IndexedTreeLeafPreimage for PublicDataTreeLeafPreimage (self.next_slot == 0) & (self.next_index == 0) } - fn as_leaf(self) -> Field { - self.hash() - } - fn update_pointers(self, next_slot: Field, next_index: u32) -> Self { Self { slot: self.slot, value: self.value, next_slot, next_index } } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/indexed_tree/check_valid_low_leaf.nr b/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/indexed_tree/check_valid_low_leaf.nr index 8fbe3334ee4a..0bf69d0ad127 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/indexed_tree/check_valid_low_leaf.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/indexed_tree/check_valid_low_leaf.nr @@ -19,6 +19,7 @@ mod tests { indexed_tree::check_valid_low_leaf::assert_check_valid_low_leaf, leaf_preimage::IndexedTreeLeafPreimage, }; + use crate::merkle_tree::leaf_preimage::LeafPreimage; use crate::traits::Empty; struct TestLeafPreimage { @@ -38,11 +39,18 @@ mod tests { } } - impl IndexedTreeLeafPreimage for TestLeafPreimage { + impl LeafPreimage for TestLeafPreimage { fn get_key(self) -> Field { self.value } + fn as_leaf(self) -> Field { + self.value + } + } + + impl IndexedTreeLeafPreimage for TestLeafPreimage { + fn get_next_key(self) -> Field { self.next_value } @@ -51,10 +59,6 @@ mod tests { (self.next_value == 0) } - fn as_leaf(self) -> Field { - self.value - } - fn update_pointers(self, next_value: Field, _next_index: u32) -> Self { Self { value: self.value, next_value } } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/leaf_preimage.nr b/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/leaf_preimage.nr index c1192a03a0d0..9b5fcee268af 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/leaf_preimage.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/leaf_preimage.nr @@ -5,13 +5,9 @@ pub trait LeafPreimage { fn as_leaf(self) -> Field; } -pub trait IndexedTreeLeafPreimage: Eq + Empty { - fn get_key(self) -> Field; - +pub trait IndexedTreeLeafPreimage: Eq + Empty + LeafPreimage { fn get_next_key(self) -> Field; - fn as_leaf(self) -> Field; - fn points_to_infinity(self) -> bool; fn update_pointers(self, next_key: Field, next_index: u32) -> Self; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/membership.nr b/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/membership.nr index 61bc479d2fcb..ac3ac7c26fca 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/membership.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/membership.nr @@ -124,10 +124,6 @@ mod tests { } impl IndexedTreeLeafPreimage for TestLeafPreimage { - fn get_key(self) -> Field { - self.value - } - fn get_next_key(self) -> Field { self.next_value } @@ -136,10 +132,6 @@ mod tests { (self.next_value == 0) } - fn as_leaf(self) -> Field { - pedersen_hash([self.value]) - } - fn update_pointers(self, next_value: Field, _next_index: u32) -> Self { Self { value: self.value, next_value } }