Skip to content

Commit

Permalink
chore: Add todo for using generator indices in note commitment and nu…
Browse files Browse the repository at this point in the history
…llifier computation. (#1762)
  • Loading branch information
suyash67 authored Aug 24, 2023
1 parent 13ab91d commit 2db6728
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ impl EcdsaPublicKeyNote {
fn compute_nullifier(self) -> Field {
let unique_siloed_note_hash = compute_unique_siloed_note_hash(EcdsaPublicKeyNoteInterface, self);
let secret = get_secret_key(self.owner);
// TODO(#1205) Should use a non-zero generator index.
dep::std::hash::pedersen([
unique_siloed_note_hash,
secret,
Expand Down Expand Up @@ -90,6 +91,7 @@ fn serialise(note: EcdsaPublicKeyNote) -> [Field; ECDSA_PUBLIC_KEY_NOTE_LEN] {
}

fn compute_note_hash(note: EcdsaPublicKeyNote) -> Field {
// TODO(#1205) Should use a non-zero generator index.
dep::std::hash::pedersen(note.serialise())[0]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ impl AddressNote {
fn compute_nullifier(self) -> Field {
let siloed_note_hash = compute_siloed_note_hash(AddressNoteMethods, self);
let secret = get_secret_key(self.owner);
// TODO(#1205) Should use a non-zero generator index.
dep::std::hash::pedersen([
siloed_note_hash,
secret,
Expand All @@ -53,6 +54,7 @@ fn serialise(note: AddressNote) -> [Field; ADDRESS_NOTE_LEN]{
}

fn compute_note_hash(note: AddressNote) -> Field {
// TODO(#1205) Should use a non-zero generator index.
dep::std::hash::pedersen(note.serialise())[0]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ impl TransparentNote {
}

fn compute_note_hash(self) -> Field {
// TODO(#1205) Should use a non-zero generator index.
dep::std::hash::pedersen([
self.amount,
self.secret_hash,
Expand All @@ -70,6 +71,7 @@ impl TransparentNote {
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/1386): should use
// `compute_note_hash_for_read_or_nullify` once public functions inject nonce!
let siloed_note_hash = compute_siloed_note_hash(TransparentNoteMethods, self);
// TODO(#1205) Should use a non-zero generator index.
pedersen([self.secret, siloed_note_hash])[0]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ impl AddressNote {
fn compute_nullifier(self) -> Field {
let unique_siloed_note_hash = compute_unique_siloed_note_hash(AddressNoteMethods, self);
let secret = get_secret_key(self.address);
// TODO(#1205) Should use a non-zero generator index.
dep::std::hash::pedersen([
unique_siloed_note_hash,
secret,
Expand All @@ -51,6 +52,7 @@ fn serialise(note: AddressNote) -> [Field; ADDRESS_NOTE_LEN] {
}

fn compute_note_hash(note: AddressNote) -> Field {
// TODO(#1205) Should use a non-zero generator index.
dep::std::hash::pedersen(note.serialise())[0]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ impl ClaimNote {
}

fn compute_note_hash(self) -> Field {
// TODO(#1205) Should use a non-zero generator index.
dep::std::hash::pedersen([
self.value,
self.secret_hash,
Expand All @@ -43,6 +44,7 @@ impl ClaimNote {

fn compute_nullifier(self) -> Field {
let note_hash_for_nullify = compute_note_hash_for_read_or_nullify(ClaimNoteMethods, self);
// TODO(#1205) Should use a non-zero generator index.
dep::std::hash::pedersen([
note_hash_for_nullify,
self.secret_hash, // Include the secret_hash again so that the public won't know the note has been claimed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ impl PublicKeyNote {
fn compute_nullifier(self) -> Field {
let unique_siloed_note_hash = compute_unique_siloed_note_hash(PublicKeyNoteMethods, self);
let secret = get_secret_key(self.owner);
// TODO(#1205) Should use a non-zero generator index.
dep::std::hash::pedersen([
unique_siloed_note_hash,
secret,
Expand All @@ -58,6 +59,7 @@ fn serialise(note: PublicKeyNote) -> [Field; PUBLIC_KEY_NOTE_LEN] {
}

fn compute_note_hash(note: PublicKeyNote) -> Field {
// TODO(#1205) Should use a non-zero generator index.
dep::std::hash::pedersen(note.serialise())[0]
}

Expand Down
2 changes: 1 addition & 1 deletion yarn-project/noir-libs/noir-aztec/src/note/lifecycle.nr
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fn destroy_note<Note, N>(
// commitment) in which case `nullified_commitment` is not used since the kernel
// just siloes and forwards the nullier to its output.
if (header.nonce == 0) {
// TODO(suyash): Can we reuse the note commitment computed in `compute_nullifier`?
// TODO(1718): Can we reuse the note commitment computed in `compute_nullifier`?
nullified_commitment = compute_inner_note_hash(note_interface, note);
}
assert(notify_nullified_note(storage_slot, nullifier, preimage, nullified_commitment) == 0);
Expand Down
2 changes: 2 additions & 0 deletions yarn-project/noir-libs/value-note/src/value_note.nr
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ impl ValueNote {
}

fn compute_note_hash(self) -> Field {
// TODO(#1205) Should use a non-zero generator index.
dep::std::hash::pedersen([
self.value,
self.owner,
Expand All @@ -55,6 +56,7 @@ impl ValueNote {
fn compute_nullifier(self) -> Field {
let note_hash_for_nullify = compute_note_hash_for_read_or_nullify(ValueNoteMethods, self);
let secret = get_secret_key(self.owner);
// TODO(#1205) Should use a non-zero generator index.
dep::std::hash::pedersen([
note_hash_for_nullify,
secret,
Expand Down

0 comments on commit 2db6728

Please sign in to comment.