From 2a0c73692b61e8afe485221b74bdd46ad08d4f75 Mon Sep 17 00:00:00 2001 From: benesjan Date: Tue, 23 Apr 2024 09:25:00 +0000 Subject: [PATCH] cleanup --- .../noir-contracts/contracts/test_contract/src/main.nr | 4 ++-- .../simulator/src/client/private_execution.test.ts | 7 ++----- yarn-project/simulator/src/client/simulator.test.ts | 9 +++++++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr index 39e33c1cda10..16b48e3c5e1c 100644 --- a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr @@ -16,7 +16,7 @@ contract Test { use dep::aztec::{ context::{Context, inputs::private_context_inputs::PrivateContextInputs}, - hash::{pedersen_hash, poseidon2_hash, ArgsHasher}, + hash::{compute_secret_hash, pedersen_hash, ArgsHasher}, note::{ lifecycle::{create_note, destroy_note}, note_getter::{get_notes, view_notes}, note_getter_options::NoteStatus @@ -350,7 +350,7 @@ contract Test { // Adapted from TokenContract#redeem_shield but without an initcheck so it can be run in simulator/src/client/private_execution.test.ts fn consume_note_from_secret(secret: Field) { let notes_set = storage.example_set; - let secret_hash = poseidon2_hash([secret, 92543]); // global GENERATOR_INDEX__TRANSPARENT_NOTE = 92543; + let secret_hash = compute_secret_hash(secret); let mut options = NoteGetterOptions::new(); options = options.select(FieldNote::properties().value, secret_hash, Option::none()).set_limit(1); let notes = notes_set.get_notes(options); diff --git a/yarn-project/simulator/src/client/private_execution.test.ts b/yarn-project/simulator/src/client/private_execution.test.ts index 10cdff0172fa..ecff905aea08 100644 --- a/yarn-project/simulator/src/client/private_execution.test.ts +++ b/yarn-project/simulator/src/client/private_execution.test.ts @@ -21,7 +21,7 @@ import { nonEmptySideEffects, sideEffectArrayToValueArray, } from '@aztec/circuits.js'; -import { computeCommitmentNonce, computeVarArgsHash } from '@aztec/circuits.js/hash'; +import { computeCommitmentNonce, computeSecretHash, computeVarArgsHash } from '@aztec/circuits.js/hash'; import { makeHeader } from '@aztec/circuits.js/testing'; import { type FunctionArtifact, @@ -62,9 +62,6 @@ import { AcirSimulator } from './simulator.js'; jest.setTimeout(60_000); -// Copied over from `transparent_note.nr` - not placed in constants.nr as it's not a protocol constant -const GENERATOR_INDEX__TRANSPARENT_NOTE = 92543; - describe('Private Execution test suite', () => { let oracle: MockProxy; let node: MockProxy; @@ -730,7 +727,7 @@ describe('Private Execution test suite', () => { it('Should be able to consume a dummy public to private message', async () => { const artifact = getFunctionArtifact(TestContractArtifact, 'consume_note_from_secret'); const secret = new Fr(1n); - const secretHash = poseidon2Hash([secret, GENERATOR_INDEX__TRANSPARENT_NOTE]); + const secretHash = computeSecretHash(secret); const note = new Note([secretHash]); const storageSlot = new Fr(5); oracle.getNotes.mockResolvedValue([ diff --git a/yarn-project/simulator/src/client/simulator.test.ts b/yarn-project/simulator/src/client/simulator.test.ts index e4af77f494bd..62bb0c13b074 100644 --- a/yarn-project/simulator/src/client/simulator.test.ts +++ b/yarn-project/simulator/src/client/simulator.test.ts @@ -1,13 +1,18 @@ import { type AztecNode, CompleteAddress, Note } from '@aztec/circuit-types'; import { GeneratorIndex, computeAppNullifierSecretKey, deriveKeys } from '@aztec/circuits.js'; -import { computeInnerNoteHash, computeNoteContentHash, computeUniqueNoteHash, siloNoteHash } from '@aztec/circuits.js/hash'; +import { + computeInnerNoteHash, + computeNoteContentHash, + computeUniqueNoteHash, + siloNoteHash, +} from '@aztec/circuits.js/hash'; import { ABIParameterVisibility, type FunctionArtifactWithDebugMetadata, getFunctionArtifact, } from '@aztec/foundation/abi'; import { AztecAddress } from '@aztec/foundation/aztec-address'; -import { pedersenHash, poseidon2Hash } from '@aztec/foundation/crypto'; +import { poseidon2Hash } from '@aztec/foundation/crypto'; import { Fr } from '@aztec/foundation/fields'; import { TokenContractArtifact } from '@aztec/noir-contracts.js/Token';