diff --git a/noir-projects/aztec-nr/aztec/src/note/utils.nr b/noir-projects/aztec-nr/aztec/src/note/utils.nr index 7d9b200a49b..8bce7674865 100644 --- a/noir-projects/aztec-nr/aztec/src/note/utils.nr +++ b/noir-projects/aztec-nr/aztec/src/note/utils.nr @@ -49,7 +49,7 @@ pub fn compute_note_hash_for_consumption(note: Not if header.nonce == 0 { // Case 1. - // If a note is transient, we just read the note_hash (kernel will hash with nonce and silo by contract address). + // If a note is transient, we just read the note_hash (kernel will hash it with nonce and silo by contract address). note_hash } else { // Case 2: If a note is non-revertible, and is nullified by a revertible nullifier, we cannot squash them in the diff --git a/noir-projects/aztec-nr/aztec/src/oracle/notes.nr b/noir-projects/aztec-nr/aztec/src/oracle/notes.nr index ff832d69268..8732937b7af 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/notes.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/notes.nr @@ -18,13 +18,7 @@ unconstrained pub fn notify_created_note( note_hash: Field, counter: u32 ) -> Field { - notify_created_note_oracle( - storage_slot, - note_type_id, - serialized_note, - note_hash, - counter - ) + notify_created_note_oracle(storage_slot, note_type_id, serialized_note, note_hash, counter) } #[oracle(notifyNullifiedNote)] diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/types/token_note.nr b/noir-projects/noir-contracts/contracts/token_contract/src/types/token_note.nr index dec44b798f3..6a2d4e94fe2 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/types/token_note.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/types/token_note.nr @@ -62,7 +62,7 @@ impl NoteInterface for TokenNote { fn compute_note_hiding_point(self) -> Point { assert(self.header.storage_slot != 0, "Storage slot must be set before computing note hiding point"); - // TODO(benesjan): decompose amount with from_field_unsafe or constrain it fits into limb + // TODO(#7772): decompose amount with from_field_unsafe or constrain it fits into 1 limb let amount_scalar = Scalar { lo: self.amount.to_integer(), hi: 0 diff --git a/noir-projects/noir-contracts/contracts/token_with_refunds_contract/src/main.nr b/noir-projects/noir-contracts/contracts/token_with_refunds_contract/src/main.nr index 63a193a9574..527024d7ea3 100644 --- a/noir-projects/noir-contracts/contracts/token_with_refunds_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_with_refunds_contract/src/main.nr @@ -469,7 +469,8 @@ contract TokenWithRefunds { // to the user in the `complete_refund(...)` function. storage.balances.sub(user, U128::from_integer(funded_amount)).emit(encode_and_encrypt_note_with_keys(&mut context, user_ovpk, user_ivpk, user)); - // 4. Now we "manually" compute the slots (by setting the slots we insert the notes to the balances map under a correct key) + // 4. Now we "manually" compute the slots (by setting the slots we insert the notes to the balances map under + // the correct keys) let fee_payer_balances_slot = derive_storage_slot_in_map(TokenWithRefunds::storage().balances.slot, fee_payer); let user_balances_slot = derive_storage_slot_in_map(TokenWithRefunds::storage().balances.slot, user); @@ -518,14 +519,14 @@ contract TokenWithRefunds { #[aztec(public)] #[aztec(internal)] fn complete_refund( - // TODO: the following makes macros crash --> try getting it work once we migrate to metaprogramming + // TODO(#7771): the following makes macros crash --> try getting it work once we migrate to metaprogramming // mut fee_payer_point: TokenNoteHidingPoint, // mut user_point: TokenNoteHidingPoint, fee_payer_point_immutable: TokenNoteHidingPoint, user_point_immutable: TokenNoteHidingPoint, funded_amount: Field ) { - // TODO: nuke the following 2 lines once we have mutable args + // TODO(#7771): nuke the following 2 lines once we have mutable args let mut fee_payer_point = fee_payer_point_immutable; let mut user_point = user_point_immutable; diff --git a/noir-projects/noir-contracts/contracts/token_with_refunds_contract/src/types/token_note.nr b/noir-projects/noir-contracts/contracts/token_with_refunds_contract/src/types/token_note.nr index e7e9ad2f74c..f7d4666c706 100644 --- a/noir-projects/noir-contracts/contracts/token_with_refunds_contract/src/types/token_note.nr +++ b/noir-projects/noir-contracts/contracts/token_with_refunds_contract/src/types/token_note.nr @@ -48,7 +48,7 @@ impl NoteInterface for TokenNote { fn compute_note_hiding_point(self) -> Point { assert(self.header.storage_slot != 0, "Storage slot must be set before computing note hiding point"); - // TODO(benesjan): decompose amount with from_field_unsafe or constrain it fits into limb + // TODO(#7772): decompose amount with from_field_unsafe or constrain it fits into 1 limb let amount_scalar = Scalar { lo: self.amount.to_integer(), hi: 0 @@ -86,7 +86,7 @@ impl TokenNoteHidingPoint { } fn add_amount(&mut self, amount: U128) { - // TODO(benesjan): decompose amount with from_field_unsafe or constrain it fits into limb + // TODO(#7772): decompose amount with from_field_unsafe or constrain it fits into 1 limb let amount_scalar = Scalar { lo: amount.to_integer(), hi: 0 }; self.inner = multi_scalar_mul([G_amt], [amount_scalar]) + self.inner; } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/hash.nr b/noir-projects/noir-protocol-circuits/crates/types/src/hash.nr index 0dfffa70e13..c0045eb7d29 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/hash.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/hash.nr @@ -59,6 +59,8 @@ pub fn compute_siloed_note_hash(app: AztecAddress, unique_note_hash: Field) -> F ) } +/// Siloing in the context of Aztec refers to the process of hashing a note hash with a contract address (this way +/// the note hash is scoped to a specific contract). This is used to prevent intermingling of notes between contracts. pub fn silo_note_hash(note_hash: ScopedNoteHash, tx_hash: Field, note_index_in_tx: u32) -> Field { if note_hash.contract_address.is_zero() { 0 diff --git a/yarn-project/circuits.js/src/hints/build_note_hash_read_request_hints.test.ts b/yarn-project/circuits.js/src/hints/build_note_hash_read_request_hints.test.ts index 1fad5cfe586..8117be97c14 100644 --- a/yarn-project/circuits.js/src/hints/build_note_hash_read_request_hints.test.ts +++ b/yarn-project/circuits.js/src/hints/build_note_hash_read_request_hints.test.ts @@ -39,7 +39,7 @@ describe('buildNoteHashReadRequestHints', () => { let numSettledReads = 0; let futureNoteHashes: ScopedNoteHash[]; - const noteHash = (index: number) => index + 9999; + const getNoteHashValue = (index: number) => index + 9999; const makeReadRequest = (value: number, counter = 2) => new ReadRequest(new Fr(value), counter).scope(contractAddress); @@ -49,7 +49,7 @@ describe('buildNoteHashReadRequestHints', () => { const readPendingNoteHash = (noteHashIndex: number) => { const readRequestIndex = numReadRequests; const hintIndex = numPendingReads; - noteHashReadRequests[readRequestIndex] = makeReadRequest(noteHash(noteHashIndex)); + noteHashReadRequests[readRequestIndex] = makeReadRequest(getNoteHashValue(noteHashIndex)); expectedHints.readRequestStatuses[readRequestIndex] = ReadRequestStatus.pending(hintIndex); expectedHints.pendingReadHints[hintIndex] = new PendingReadHint(readRequestIndex, noteHashIndex); numReadRequests++; @@ -89,7 +89,7 @@ describe('buildNoteHashReadRequestHints', () => { beforeEach(() => { noteHashReadRequests = makeTuple(MAX_NOTE_HASH_READ_REQUESTS_PER_TX, ScopedReadRequest.empty); - noteHashes = makeTuple(MAX_NOTE_HASHES_PER_TX, i => makeNoteHash(noteHash(i))); + noteHashes = makeTuple(MAX_NOTE_HASHES_PER_TX, i => makeNoteHash(getNoteHashValue(i))); noteHashLeafIndexMap = new Map(); expectedHints = NoteHashReadRequestHintsBuilder.empty( MAX_NOTE_HASH_READ_REQUESTS_PER_TX, @@ -100,7 +100,7 @@ describe('buildNoteHashReadRequestHints', () => { numSettledReads = 0; futureNoteHashes = new Array(MAX_NOTE_HASHES_PER_TX) .fill(null) - .map((_, i) => makeNoteHash(noteHash(i + MAX_NOTE_HASHES_PER_TX))); + .map((_, i) => makeNoteHash(getNoteHashValue(i + MAX_NOTE_HASHES_PER_TX))); }); it('builds empty hints', async () => { diff --git a/yarn-project/pxe/src/database/incoming_note_dao.ts b/yarn-project/pxe/src/database/incoming_note_dao.ts index 7e4ee1eae0a..cba1df864f6 100644 --- a/yarn-project/pxe/src/database/incoming_note_dao.ts +++ b/yarn-project/pxe/src/database/incoming_note_dao.ts @@ -23,7 +23,7 @@ export class IncomingNoteDao implements NoteData { /** The nonce of the note. */ public nonce: Fr, /** - * Note hash of the note. This is customizable by the app circuit. + * A hash of the note. This is customizable by the app circuit. * We can use this value to compute siloedNoteHash and uniqueSiloedNoteHash. */ public noteHash: Fr, diff --git a/yarn-project/simulator/src/acvm/oracle/typed_oracle.ts b/yarn-project/simulator/src/acvm/oracle/typed_oracle.ts index 84a8331a5cb..1b9dae81e8a 100644 --- a/yarn-project/simulator/src/acvm/oracle/typed_oracle.ts +++ b/yarn-project/simulator/src/acvm/oracle/typed_oracle.ts @@ -27,7 +27,7 @@ export interface NoteData { storageSlot: Fr; /** The nonce of the note. */ nonce: Fr; - /** The note hash of the note. */ + /** A hash of the note. */ noteHash: Fr; /** The corresponding nullifier of the note. Undefined for pending notes. */ siloedNullifier?: Fr; diff --git a/yarn-project/simulator/src/client/client_execution_context.ts b/yarn-project/simulator/src/client/client_execution_context.ts index 2eeb18484cc..79b1f913ef4 100644 --- a/yarn-project/simulator/src/client/client_execution_context.ts +++ b/yarn-project/simulator/src/client/client_execution_context.ts @@ -292,7 +292,7 @@ export class ClientExecutionContext extends ViewDataOracle { * @param storageSlot - The storage slot. * @param noteTypeId - The type ID of the note. * @param noteItems - The items to be included in a Note. - * @param noteHash - The hash of the new note. + * @param noteHash - A hash of the new note. * @returns */ public override notifyCreatedNote( diff --git a/yarn-project/simulator/src/client/execution_note_cache.ts b/yarn-project/simulator/src/client/execution_note_cache.ts index 4faf3e77adb..f8e1ec0a670 100644 --- a/yarn-project/simulator/src/client/execution_note_cache.ts +++ b/yarn-project/simulator/src/client/execution_note_cache.ts @@ -83,8 +83,8 @@ export class ExecutionNoteCache { * Add a nullifier to cache. It could be for a db note or a new note created during execution. * @param contractAddress - Contract address of the note. * @param innerNullifier - Inner nullifier of the note. - * @param noteHash - A note hash of the note. If this value equals 0, it means the - * note being nullified is from a previous transaction (and thus not a new note). + * @param noteHash - A hash of the note. If this value equals 0, it means the note being nullified is from a previous + * transaction (and thus not a new note). */ public nullifyNote(contractAddress: AztecAddress, innerNullifier: Fr, noteHash: Fr) { const siloedNullifier = siloNullifier(contractAddress, innerNullifier); diff --git a/yarn-project/simulator/src/client/private_execution.test.ts b/yarn-project/simulator/src/client/private_execution.test.ts index 86de1471b38..d668a2130a3 100644 --- a/yarn-project/simulator/src/client/private_execution.test.ts +++ b/yarn-project/simulator/src/client/private_execution.test.ts @@ -973,7 +973,7 @@ describe('Private Execution test suite', () => { expect(encryptedLog.noteHashCounter).toEqual(result.noteEncryptedLogs[0].noteHashCounter); expect(encryptedLog.value).toEqual(Fr.fromBuffer(result.noteEncryptedLogs[0].log.hash())); - // read request should match note hash for pending notes (there is no nonce, so can't compute "unique" hash) + // read request should match a note hash for pending notes (there is no nonce, so can't compute "unique" hash) const readRequest = getNonEmptyItems(result.callStackItem.publicInputs.noteHashReadRequests)[0]; expect(readRequest.value).toEqual(derivedNoteHash); @@ -1056,7 +1056,7 @@ describe('Private Execution test suite', () => { expect(encryptedLog.noteHashCounter).toEqual(execInsert.noteEncryptedLogs[0].noteHashCounter); expect(encryptedLog.value).toEqual(Fr.fromBuffer(execInsert.noteEncryptedLogs[0].log.hash())); - // read request should match note hash for pending notes (there is no nonce, so can't compute "unique" hash) + // read request should match a note hash for pending notes (there is no nonce, so can't compute "unique" hash) const readRequest = execGetThenNullify.callStackItem.publicInputs.noteHashReadRequests[0]; expect(readRequest.value).toEqual(derivedNoteHash);