diff --git a/aztec/src/macros/notes/mod.nr b/aztec/src/macros/notes/mod.nr index 90c9ca7..39cf5d0 100644 --- a/aztec/src/macros/notes/mod.nr +++ b/aztec/src/macros/notes/mod.nr @@ -412,7 +412,7 @@ comptime fn generate_fixed_generators() -> (Quoted, Quoted) { /// std::hash::from_field_unsafe(npk_m_hash as Field), /// std::hash::from_field_unsafe(randomness as Field) /// ] -/// args_list: [amount: U128, npk_m_hash: Field, randomness: Field] +/// args_list: [amount: u128, npk_m_hash: Field, randomness: Field] /// aux_vars: [] comptime fn generate_multi_scalar_mul( indexed_fields: [(Quoted, Type, u32)], @@ -695,7 +695,7 @@ comptime fn get_setup_log_plaintext_body( /// } /// /// impl TokenNoteFinalizationPayload { -/// fn new(mut self, context: &mut aztec::prelude::PublicContext, slot: Field, amount: U128) -> TokenNoteFinalizationPayload { +/// fn new(mut self, context: &mut aztec::prelude::PublicContext, slot: Field, amount: u128) -> TokenNoteFinalizationPayload { /// self.context = context; /// self.hiding_point_slot = slot; /// self.setup_log_slot = slot + aztec::protocol_types::point::POINT_LENGTH as Field; @@ -978,7 +978,6 @@ comptime fn register_note( /// Separates note struct members into fixed and nullable ones. It also stores the index of where each struct member /// starts in the serialized note. Note that each struct member can occupy multiple fields (as in Field type). -/// An example of a struct member occupying multiple fields is `amount` in `TokenNote` that uses `U128` type. comptime fn index_note_fields( s: StructDefinition, nullable_fields: [Quoted], diff --git a/aztec/src/state_vars/public_immutable.nr b/aztec/src/state_vars/public_immutable.nr index bb27e13..7e1e77a 100644 --- a/aztec/src/state_vars/public_immutable.nr +++ b/aztec/src/state_vars/public_immutable.nr @@ -27,7 +27,7 @@ use dep::protocol_types::{constants::INITIALIZATION_SLOT_SEPARATOR, traits::Pack /// #[derive(Eq, Packable)] /// pub struct Config \{ /// pub address_1: AztecAddress, -/// pub value_1: U128, +/// pub value_1: u128, /// pub value_2: u64, /// ... /// } diff --git a/uint-note/src/uint_note.nr b/uint-note/src/uint_note.nr index 3e0517a..23c4e68 100644 --- a/uint-note/src/uint_note.nr +++ b/uint-note/src/uint_note.nr @@ -10,14 +10,14 @@ use dep::aztec::{ #[derive(Eq, Serialize)] pub struct UintNote { // The amount of tokens in the note - value: U128, + value: u128, owner: AztecAddress, // Randomness of the note to protect against note hash preimage attacks randomness: Field, } // docs:end:UintNote impl UintNote { - pub fn new(value: U128, owner: AztecAddress) -> Self { + pub fn new(value: u128, owner: AztecAddress) -> Self { // Safety: We use the randomness to preserve the privacy of the note recipient by preventing brute-forcing, // so a malicious sender could use non-random values to make the note less private. But they already know // the full note pre-image anyway, and so the recipient already trusts them to not disclose this @@ -26,7 +26,7 @@ impl UintNote { Self { value, owner, randomness } } - pub fn get_value(self) -> U128 { + pub fn get_value(self) -> u128 { self.value } } diff --git a/value-note/src/filter.nr b/value-note/src/filter.nr index 11cf250..5390712 100644 --- a/value-note/src/filter.nr +++ b/value-note/src/filter.nr @@ -1,6 +1,10 @@ use crate::value_note::ValueNote; -use dep::aztec::note::retrieved_note::RetrievedNote; -use dep::aztec::protocol_types::constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL; +use aztec::{ + note::retrieved_note::RetrievedNote, + protocol_types::{ + constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, utils::field::full_field_less_than, + }, +}; pub fn filter_notes_min_sum( notes: [Option>; MAX_NOTE_HASH_READ_REQUESTS_PER_CALL], @@ -8,12 +12,12 @@ pub fn filter_notes_min_sum( ) -> [Option>; MAX_NOTE_HASH_READ_REQUESTS_PER_CALL] { let mut selected = [Option::none(); MAX_NOTE_HASH_READ_REQUESTS_PER_CALL]; - let mut sum = U128::from_integer(0); + let mut sum = 0; for i in 0..notes.len() { - if notes[i].is_some() & (sum < U128::from_integer(min_sum)) { + if notes[i].is_some() & full_field_less_than(sum, min_sum) { let retrieved_note = notes[i].unwrap_unchecked(); selected[i] = Option::some(retrieved_note); - sum += U128::from_integer(retrieved_note.note.value); + sum += retrieved_note.note.value; } }