Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: nuking unnecessary siloing #7774

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions noir-projects/aztec-nr/aztec/src/note/utils.nr
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,7 @@ pub fn compute_note_hash_for_consumption<Note, let N: u32, let M: u32>(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)
}
}

Expand Down
14 changes: 5 additions & 9 deletions yarn-project/simulator/src/client/simulator.test.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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,
);

Expand All @@ -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 () => {
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/simulator/src/client/simulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading