From 44aaba565b8b3639eff1fa6e8119416df04dd15d Mon Sep 17 00:00:00 2001 From: benesjan Date: Mon, 22 Apr 2024 12:06:00 +0000 Subject: [PATCH] fix --- .../simulator/src/client/private_execution.test.ts | 9 ++++++--- yarn-project/simulator/src/client/simulator.test.ts | 7 +++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/yarn-project/simulator/src/client/private_execution.test.ts b/yarn-project/simulator/src/client/private_execution.test.ts index 5cbf65ec767..39b113f07fc 100644 --- a/yarn-project/simulator/src/client/private_execution.test.ts +++ b/yarn-project/simulator/src/client/private_execution.test.ts @@ -5,6 +5,7 @@ import { CompleteAddress, FunctionData, GasSettings, + GeneratorIndex, type GrumpkinPrivateKey, Header, L1_TO_L2_MSG_TREE_HEIGHT, @@ -32,7 +33,7 @@ import { import { asyncMap } from '@aztec/foundation/async-map'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { times } from '@aztec/foundation/collection'; -import { pedersenHash, randomInt } from '@aztec/foundation/crypto'; +import { pedersenHash, poseidon2Hash, randomInt } from '@aztec/foundation/crypto'; import { EthAddress } from '@aztec/foundation/eth-address'; import { Fr } from '@aztec/foundation/fields'; import { type DebugLogger, createDebugLogger } from '@aztec/foundation/log'; @@ -893,9 +894,10 @@ describe('Private Execution test suite', () => { expect(result.returnValues).toEqual([new Fr(amountToTransfer)]); const nullifier = result.callStackItem.publicInputs.newNullifiers[0]; - const expectedNullifier = pedersenHash([ + const expectedNullifier = poseidon2Hash([ innerNoteHash, computeAppNullifierSecretKey(ownerMasterNullifierSecretKey, contractAddress), + GeneratorIndex.NULLIFIER, ]); expect(nullifier.value).toEqual(expectedNullifier); }); @@ -963,9 +965,10 @@ describe('Private Execution test suite', () => { expect(execGetThenNullify.returnValues).toEqual([new Fr(amountToTransfer)]); const nullifier = execGetThenNullify.callStackItem.publicInputs.newNullifiers[0]; - const expectedNullifier = pedersenHash([ + const expectedNullifier = poseidon2Hash([ innerNoteHash, computeAppNullifierSecretKey(ownerMasterNullifierSecretKey, contractAddress), + GeneratorIndex.NULLIFIER, ]); expect(nullifier.value).toEqual(expectedNullifier); }); diff --git a/yarn-project/simulator/src/client/simulator.test.ts b/yarn-project/simulator/src/client/simulator.test.ts index c22244d2881..4e18033ec6b 100644 --- a/yarn-project/simulator/src/client/simulator.test.ts +++ b/yarn-project/simulator/src/client/simulator.test.ts @@ -1,5 +1,5 @@ import { type AztecNode, CompleteAddress, Note } from '@aztec/circuit-types'; -import { computeAppNullifierSecretKey, deriveKeys } from '@aztec/circuits.js'; +import { GeneratorIndex, computeAppNullifierSecretKey, deriveKeys } from '@aztec/circuits.js'; import { computeUniqueCommitment, siloNoteHash } from '@aztec/circuits.js/hash'; import { ABIParameterVisibility, @@ -7,7 +7,7 @@ import { getFunctionArtifact, } from '@aztec/foundation/abi'; import { AztecAddress } from '@aztec/foundation/aztec-address'; -import { pedersenHash } from '@aztec/foundation/crypto'; +import { pedersenHash, poseidon2Hash } from '@aztec/foundation/crypto'; import { Fr } from '@aztec/foundation/fields'; import { TokenContractArtifact } from '@aztec/noir-contracts.js/Token'; @@ -67,8 +67,7 @@ describe('Simulator', () => { const innerNoteHash = pedersenHash([storageSlot, tokenNoteHash]); const siloedNoteHash = siloNoteHash(contractAddress, innerNoteHash); const uniqueSiloedNoteHash = computeUniqueCommitment(nonce, siloedNoteHash); - // TODO(#5832): all the pedersen hashes in notes should be replaced with poseidon2 - const innerNullifier = pedersenHash([uniqueSiloedNoteHash, appNullifierSecretKey]); + const innerNullifier = poseidon2Hash([uniqueSiloedNoteHash, appNullifierSecretKey, GeneratorIndex.NULLIFIER]); const result = await simulator.computeNoteHashAndNullifier(contractAddress, nonce, storageSlot, noteTypeId, note);