Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions noir-projects/aztec-nr/aztec/src/history/nullifier.nr
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ use crate::oracle::get_nullifier_membership_witness::{
get_low_nullifier_membership_witness, get_nullifier_membership_witness,
};

use crate::protocol::{
abis::block_header::BlockHeader,
merkle_tree::root::root_from_sibling_path,
traits::Hash,
utils::field::{full_field_greater_than, full_field_less_than},
};
use crate::protocol::{abis::block_header::BlockHeader, merkle_tree::root::root_from_sibling_path, traits::Hash};

mod test;

Expand Down Expand Up @@ -105,16 +100,15 @@ pub fn assert_nullifier_did_not_exist_by(block_header: BlockHeader, siloed_nulli

// 4) Prove that the low leaf is indeed smaller than the nullifier
assert(
full_field_less_than(low_nullifier_leaf.nullifier, siloed_nullifier),
low_nullifier_leaf.nullifier.lt(siloed_nullifier),
"Proving nullifier non-inclusion failed: low_nullifier.value < nullifier.value check failed",
);

// 5) Prove that the low leaf is pointing "over" the nullifier, which means that the nullifier is not included in
// the nullifier tree, since if it were it'd need to be between the low leaf and the next leaf. Note the special
// case in which the low leaf is the largest of all entries, in which case there's no 'next' entry.
assert(
full_field_greater_than(low_nullifier_leaf.next_nullifier, siloed_nullifier)
| (low_nullifier_leaf.next_index == 0),
siloed_nullifier.lt(low_nullifier_leaf.next_nullifier) | (low_nullifier_leaf.next_index == 0),
"Proving nullifier non-inclusion failed: low_nullifier.next_value > nullifier.value check failed",
);
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// docs:start:custom_filter_imports
use aztec::{
note::HintedNote,
protocol::{constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, utils::field::full_field_less_than},
};
use aztec::{note::HintedNote, protocol::constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL};
// docs:end:custom_filter_imports
use field_note::FieldNote;

Expand All @@ -15,7 +12,7 @@ pub fn filter_notes_min_sum(

let mut sum = 0;
for i in 0..notes.len() {
if notes[i].is_some() & full_field_less_than(sum, min_sum) {
if notes[i].is_some() & sum.lt(min_sum) {
let hinted_note = notes[i].unwrap_unchecked();
selected[i] = Option::some(hinted_note);
sum += hinted_note.note.value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,6 @@ pub fn field_from_bytes_32_trunc(bytes32: [u8; 32]) -> Field {
low + high * v
}

// 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)
}

pub fn min(f1: Field, f2: Field) -> Field {
if f1.lt(f2) {
f1
Expand Down Expand Up @@ -299,17 +290,6 @@ unconstrained fn min_test() {
assert_eq(min(0, 1), 0);
}

#[test]
unconstrained fn full_field_comparison_test() {
assert(full_field_less_than(5, 10));
assert(!full_field_less_than(10, 5));
assert(!full_field_less_than(5, 5));

assert(full_field_greater_than(10, 5));
assert(!full_field_greater_than(5, 10));
assert(!full_field_greater_than(5, 5));
}

#[test]
unconstrained fn sqrt_has_two_roots_test() {
// Every square has two roots: r and -r (i.e., p - r)
Expand Down
Loading