Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Apr 22, 2024
1 parent 4e13a59 commit dbc3ceb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
4 changes: 2 additions & 2 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, hash::poseidon2_hash, constants::GENERATOR_INDEX__NULLIFIER},
protocol_types::{address::AztecAddress, traits::Empty, 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},
context::PrivateContext
context::PrivateContext, hash::poseidon2_hash
};

global ADDRESS_NOTE_LEN: Field = 3;
Expand Down
19 changes: 11 additions & 8 deletions noir-projects/aztec-nr/value-note/src/value_note.nr
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
use dep::aztec::{
protocol_types::{address::AztecAddress, traits::{Deserialize, Serialize}},
protocol_types::{
address::AztecAddress, traits::{Deserialize, Serialize},
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},
log::emit_encrypted_log, hash::pedersen_hash, context::PrivateContext
log::emit_encrypted_log, hash::poseidon2_hash, context::PrivateContext
};

global VALUE_NOTE_LEN: Field = 3; // 3 plus a header.
Expand All @@ -22,23 +25,23 @@ impl NoteInterface<VALUE_NOTE_LEN> for ValueNote {
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,
])
}

// docs:end:nullifier

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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use dep::aztec::prelude::{AztecAddress, PrivateContext, NoteHeader, emit_encrypted_log, NoteInterface};
use dep::aztec::{
note::utils::compute_note_hash_for_consumption, hash::pedersen_hash,
constants::GENERATOR_INDEX__NULLIFIER, note::utils::compute_note_hash_for_consumption,
hash::poseidon2_hash,
oracle::{nullifier_key::get_app_nullifier_secret_key, get_public_key::get_public_key}
};

Expand All @@ -17,23 +18,23 @@ struct SubscriptionNote {

impl NoteInterface<SUBSCRIPTION_NOTE_LEN> for SubscriptionNote {
fn compute_nullifier(self, context: &mut PrivateContext) -> Field {
let unique_siloed_note_hash = compute_note_hash_for_consumption(self);
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([
unique_siloed_note_hash,
poseidon2_hash([
note_hash_for_nullify,
secret,
],0)
GENERATOR_INDEX__NULLIFIER as Field,
])
}

fn compute_nullifier_without_context(self) -> Field {
let unique_siloed_note_hash = compute_note_hash_for_consumption(self);
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([
unique_siloed_note_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 dbc3ceb

Please sign in to comment.