Skip to content

Commit

Permalink
1090 - noir code should never push a zero nullified_commitment
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanmon committed Sep 27, 2023
1 parent f036a9a commit 4ee0bfa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions yarn-project/aztec-nr/aztec/src/auth.nr
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
use crate::context::{PrivateContext, PublicContext};
use crate::oracle::compute_selector::compute_selector;
use crate::constants_gen::EMPTY_NULLIFIED_COMMITMENT;

global IS_VALID_SELECTOR = 0xe86ab4ff;
global IS_VALID_PUBLIC_SELECTOR = 0xf3661153;

fn assert_valid_message_for(context: &mut PrivateContext, whom: Field, message_hash: Field) {
let result = context.call_private_function(whom, IS_VALID_SELECTOR, [message_hash])[0];
context.push_new_nullifier(message_hash, 0);
context.push_new_nullifier(message_hash, EMPTY_NULLIFIED_COMMITMENT);
assert(result == IS_VALID_SELECTOR, "Message not authorized by account");
}

fn assert_valid_public_message_for(context: &mut PublicContext, whom: Field, message_hash: Field) {
let result = context.call_public_function(whom, IS_VALID_PUBLIC_SELECTOR, [message_hash])[0];
context.push_new_nullifier(message_hash, 0);
context.push_new_nullifier(message_hash, EMPTY_NULLIFIED_COMMITMENT);
assert(result == IS_VALID_SELECTOR, "Message not authorized by account");
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ contract Test {
let note = DummyNote::new(amount, secretHash);

// Public oracle call to emit new commitment.
context.push_new_nullifier(note.get_commitment(), 0);
context.push_new_nullifier(note.get_commitment(), EMPTY_NULLIFIED_COMMITMENT);
}

// Forcefully emits a nullifier (for testing purposes)
Expand Down

0 comments on commit 4ee0bfa

Please sign in to comment.