Skip to content

Commit

Permalink
refactor: Optimize prove_note_validity #4418 (#4426)
Browse files Browse the repository at this point in the history
Resolves #4418
  • Loading branch information
sklppy88 authored Feb 5, 2024
1 parent 4f248b5 commit 4de2540
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion yarn-project/aztec-nr/aztec/src/history/note_inclusion.nr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
oracle::get_membership_witness::get_note_hash_membership_witness,
};

fn _note_inclusion<Note, N>(note: Note, header: Header) where Note: NoteInterface<N> {
pub fn _note_inclusion<Note, N>(note: Note, header: Header) where Note: NoteInterface<N> {
// 1) Compute note_hash
let note_hash = compute_note_hash_for_consumption(note);

Expand Down
17 changes: 12 additions & 5 deletions yarn-project/aztec-nr/aztec/src/history/note_validity.nr
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ use crate::{
context::PrivateContext,
history::{
note_inclusion::prove_note_inclusion,
note_inclusion::prove_note_inclusion_at,
note_inclusion::_note_inclusion,
nullifier_non_inclusion::prove_note_not_nullified,
nullifier_non_inclusion::prove_note_not_nullified_at,
nullifier_non_inclusion::_nullifier_non_inclusion,
},
note::{
utils::compute_siloed_nullifier,
note_interface::NoteInterface,
},
note::note_interface::NoteInterface,
};

pub fn prove_note_validity<Note, N>(note: Note, context: &mut PrivateContext) where Note: NoteInterface<N> {
Expand All @@ -20,6 +23,10 @@ pub fn prove_note_validity_at<Note, N>(
block_number: u32,
context: &mut PrivateContext
) where Note: NoteInterface<N> {
prove_note_inclusion_at(note, block_number, *context);
prove_note_not_nullified_at(note, block_number, context);
// We are calling the internal functions here because we want to avoid calling get_header_at twice
let header = context.get_header_at(block_number);
_note_inclusion(note, header);

let nullifier = compute_siloed_nullifier(note, context);
_nullifier_non_inclusion(nullifier, header);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::{
},
};

fn _nullifier_non_inclusion(nullifier: Field, header: Header) {
pub fn _nullifier_non_inclusion(nullifier: Field, header: Header) {
// 1) Get the membership witness of a low nullifier of the nullifier
let witness = get_low_nullifier_membership_witness(header.global_variables.block_number as u32, nullifier);

Expand Down

0 comments on commit 4de2540

Please sign in to comment.