From 1bc0c9839094a64664c6d2d539c63134951e1af5 Mon Sep 17 00:00:00 2001 From: benesjan Date: Mon, 5 Aug 2024 15:02:28 +0000 Subject: [PATCH 1/2] feat: nuking unnecessary siloing --- noir-projects/aztec-nr/aztec/src/note/utils.nr | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/noir-projects/aztec-nr/aztec/src/note/utils.nr b/noir-projects/aztec-nr/aztec/src/note/utils.nr index 8bce7674865..040ec7e9c65 100644 --- a/noir-projects/aztec-nr/aztec/src/note/utils.nr +++ b/noir-projects/aztec-nr/aztec/src/note/utils.nr @@ -64,16 +64,7 @@ pub fn compute_note_hash_for_consumption(note: Not // tree) created in a previous TX. So we need the siloed_note_hash which has already been hashed with // nonce and then contract address. This hash will match the existing leaf in the note hash // tree, so the kernel can just perform a membership check directly on this hash/leaf. - let unique_note_hash = compute_unique_note_hash(header.nonce, note_hash); - compute_siloed_note_hash(header.contract_address, unique_note_hash) - // IMPORTANT NOTE ON REDUNDANT SILOING BY CONTRACT ADDRESS: The note hash computed above is - // "siloed" by contract address. When a note hash is computed solely for the purpose of - // nullification, it is not strictly necessary to silo the note hash before computing - // its nullifier. In other words, it is NOT NECESSARY for protocol security that a nullifier - // be computed from a siloed note hash. After all, persistable note hashes and nullifiers are - // siloed by the kernel circuit. That being said, the siloed note hash computed above CAN be - // used for nullifier computation, and this achieves the (arguably unnecessary) property that - // nullifiers are computed from a note hash's fully-computed note hash tree leaf. + compute_unique_note_hash(header.nonce, note_hash) } } From 5e31907aa4aca573149a37b48889e512f41a5f45 Mon Sep 17 00:00:00 2001 From: benesjan Date: Mon, 5 Aug 2024 15:31:17 +0000 Subject: [PATCH 2/2] test fix --- .../simulator/src/client/simulator.test.ts | 14 +++++--------- yarn-project/simulator/src/client/simulator.ts | 4 ++-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/yarn-project/simulator/src/client/simulator.test.ts b/yarn-project/simulator/src/client/simulator.test.ts index 601cb2aa6e6..c7291e4bfdc 100644 --- a/yarn-project/simulator/src/client/simulator.test.ts +++ b/yarn-project/simulator/src/client/simulator.test.ts @@ -1,6 +1,6 @@ import { type AztecNode, CompleteAddress, Note } from '@aztec/circuit-types'; import { GeneratorIndex, KeyValidationRequest, computeAppNullifierSecretKey, deriveKeys } from '@aztec/circuits.js'; -import { computeUniqueNoteHash, siloNoteHash } from '@aztec/circuits.js/hash'; +import { computeUniqueNoteHash } from '@aztec/circuits.js/hash'; import { type FunctionArtifact, getFunctionArtifact } from '@aztec/foundation/abi'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto'; @@ -63,9 +63,8 @@ describe('Simulator', () => { const note = createNote(); const noteHash = computeNoteHash(storageSlot, note.items); const uniqueNoteHash = computeUniqueNoteHash(nonce, noteHash); - const siloedNoteHash = siloNoteHash(contractAddress, uniqueNoteHash); const innerNullifier = poseidon2HashWithSeparator( - [siloedNoteHash, appNullifierSecretKey], + [uniqueNoteHash, appNullifierSecretKey], GeneratorIndex.NOTE_NULLIFIER, ); @@ -78,12 +77,9 @@ describe('Simulator', () => { note, ); - expect(result).toEqual({ - noteHash, - uniqueNoteHash, - siloedNoteHash, - innerNullifier, - }); + expect(result.noteHash).toEqual(noteHash); + expect(result.uniqueNoteHash).toEqual(uniqueNoteHash); + expect(result.innerNullifier).toEqual(innerNullifier); }); it('throw if the contract does not implement "compute_note_hash_and_optionally_a_nullifier"', async () => { diff --git a/yarn-project/simulator/src/client/simulator.ts b/yarn-project/simulator/src/client/simulator.ts index 2f2fc033a61..91117802b07 100644 --- a/yarn-project/simulator/src/client/simulator.ts +++ b/yarn-project/simulator/src/client/simulator.ts @@ -130,14 +130,14 @@ export class AcirSimulator { } /** - * Computes the inner nullifier of a note. + * Computes note hashes and an inner nullifier. * @param contractAddress - The address of the contract. * @param nonce - The nonce of the note hash. * @param storageSlot - The storage slot. * @param noteTypeId - The note type identifier. * @param computeNullifier - A flag indicating whether to compute the nullifier or just return 0. * @param note - The note. - * @returns The nullifier. + * @returns Note hashes and inner nullifier (nullifier before contract address siloing). */ public async computeNoteHashAndOptionallyANullifier( contractAddress: AztecAddress,