From f692ae8952d80324e9b05b25874b6ca0e2fb5dd8 Mon Sep 17 00:00:00 2001 From: Suyash Bagad Date: Thu, 24 Aug 2023 17:27:49 +0530 Subject: [PATCH] chore: Add todo for using generator indices in note commitment and nullifier computation. (#1762) --- .../ecdsa_account_contract/src/ecdsa_public_key_note.nr | 2 ++ .../src/contracts/escrow_contract/src/address_note.nr | 2 ++ .../contracts/non_native_token_contract/src/transparent_note.nr | 2 ++ .../src/contracts/pokeable_token_contract/src/address_note.nr | 2 ++ .../contracts/private_token_airdrop_contract/src/claim_note.nr | 2 ++ .../contracts/schnorr_account_contract/src/public_key_note.nr | 2 ++ yarn-project/noir-libs/noir-aztec/src/note/lifecycle.nr | 2 +- yarn-project/noir-libs/value-note/src/value_note.nr | 2 ++ 8 files changed, 15 insertions(+), 1 deletion(-) diff --git a/yarn-project/noir-contracts/src/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr b/yarn-project/noir-contracts/src/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr index 7ecf11df45b4..a53d9a443dea 100644 --- a/yarn-project/noir-contracts/src/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr +++ b/yarn-project/noir-contracts/src/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr @@ -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, @@ -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] } diff --git a/yarn-project/noir-contracts/src/contracts/escrow_contract/src/address_note.nr b/yarn-project/noir-contracts/src/contracts/escrow_contract/src/address_note.nr index a623c5cf9d64..c1615d540128 100644 --- a/yarn-project/noir-contracts/src/contracts/escrow_contract/src/address_note.nr +++ b/yarn-project/noir-contracts/src/contracts/escrow_contract/src/address_note.nr @@ -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, @@ -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] } diff --git a/yarn-project/noir-contracts/src/contracts/non_native_token_contract/src/transparent_note.nr b/yarn-project/noir-contracts/src/contracts/non_native_token_contract/src/transparent_note.nr index 0b5286cd5e6c..5d2feef509c4 100644 --- a/yarn-project/noir-contracts/src/contracts/non_native_token_contract/src/transparent_note.nr +++ b/yarn-project/noir-contracts/src/contracts/non_native_token_contract/src/transparent_note.nr @@ -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, @@ -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] } diff --git a/yarn-project/noir-contracts/src/contracts/pokeable_token_contract/src/address_note.nr b/yarn-project/noir-contracts/src/contracts/pokeable_token_contract/src/address_note.nr index b2da2581c687..37a2270ad327 100644 --- a/yarn-project/noir-contracts/src/contracts/pokeable_token_contract/src/address_note.nr +++ b/yarn-project/noir-contracts/src/contracts/pokeable_token_contract/src/address_note.nr @@ -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, @@ -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] } diff --git a/yarn-project/noir-contracts/src/contracts/private_token_airdrop_contract/src/claim_note.nr b/yarn-project/noir-contracts/src/contracts/private_token_airdrop_contract/src/claim_note.nr index ca936a59a11c..49ed92e15b54 100644 --- a/yarn-project/noir-contracts/src/contracts/private_token_airdrop_contract/src/claim_note.nr +++ b/yarn-project/noir-contracts/src/contracts/private_token_airdrop_contract/src/claim_note.nr @@ -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, @@ -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. diff --git a/yarn-project/noir-contracts/src/contracts/schnorr_account_contract/src/public_key_note.nr b/yarn-project/noir-contracts/src/contracts/schnorr_account_contract/src/public_key_note.nr index 8b16de73d7c6..f42d5e7ded39 100644 --- a/yarn-project/noir-contracts/src/contracts/schnorr_account_contract/src/public_key_note.nr +++ b/yarn-project/noir-contracts/src/contracts/schnorr_account_contract/src/public_key_note.nr @@ -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, @@ -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] } diff --git a/yarn-project/noir-libs/noir-aztec/src/note/lifecycle.nr b/yarn-project/noir-libs/noir-aztec/src/note/lifecycle.nr index f56622e3d2cb..1e5f75f79b89 100644 --- a/yarn-project/noir-libs/noir-aztec/src/note/lifecycle.nr +++ b/yarn-project/noir-libs/noir-aztec/src/note/lifecycle.nr @@ -72,7 +72,7 @@ fn destroy_note( // 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); diff --git a/yarn-project/noir-libs/value-note/src/value_note.nr b/yarn-project/noir-libs/value-note/src/value_note.nr index c721da0aa5f5..79f0213edb1b 100644 --- a/yarn-project/noir-libs/value-note/src/value_note.nr +++ b/yarn-project/noir-libs/value-note/src/value_note.nr @@ -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, @@ -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,