Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Optimize prove_note_validity #4418 #4426

Merged
merged 1 commit into from
Feb 5, 2024
Merged
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
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
Loading