Skip to content

Commit

Permalink
refactor: using poseidon2 when computing a nullifier
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Apr 22, 2024
1 parent bb62a0e commit b5ef7e7
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions noir-projects/aztec-nr/address-note/src/address_note.nr
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
use dep::aztec::log::emit_encrypted_log;
// docs:end:encrypted_import
use dep::aztec::{
protocol_types::{address::AztecAddress, traits::Empty},
protocol_types::{address::AztecAddress, traits::Empty, hash::poseidon2_hash, constants::GENERATOR_INDEX__NULLIFIER},
note::{note_header::NoteHeader, note_interface::NoteInterface, utils::compute_note_hash_for_consumption},
oracle::{unsafe_rand::unsafe_rand, nullifier_key::get_app_nullifier_secret_key, get_public_key::get_public_key},
hash::pedersen_hash, context::PrivateContext
context::PrivateContext
};

global ADDRESS_NOTE_LEN: Field = 3;
Expand All @@ -24,21 +24,21 @@ impl NoteInterface<ADDRESS_NOTE_LEN> for AddressNote {
fn compute_nullifier(self, context: &mut PrivateContext) -> Field {
let note_hash_for_nullify = compute_note_hash_for_consumption(self);
let secret = context.request_app_nullifier_secret_key(self.owner);
// TODO(#1205) Should use a non-zero generator index.
pedersen_hash([
poseidon2_hash([
note_hash_for_nullify,
secret,
],0)
GENERATOR_INDEX__NULLIFIER as Field,
])
}

fn compute_nullifier_without_context(self) -> Field {
let note_hash_for_nullify = compute_note_hash_for_consumption(self);
let secret = get_app_nullifier_secret_key(self.owner);
// TODO(#1205) Should use a non-zero generator index.
pedersen_hash([
poseidon2_hash([
note_hash_for_nullify,
secret,
],0)
GENERATOR_INDEX__NULLIFIER as Field,
])
}

// Broadcasts the note as an encrypted log on L1.
Expand Down

0 comments on commit b5ef7e7

Please sign in to comment.