Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Apr 22, 2024
1 parent dec8c46 commit 6081783
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 6 additions & 3 deletions yarn-project/simulator/src/client/private_execution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
CompleteAddress,
FunctionData,
GasSettings,
GeneratorIndex,
type GrumpkinPrivateKey,
Header,
L1_TO_L2_MSG_TREE_HEIGHT,
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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);
});
Expand Down Expand Up @@ -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);
});
Expand Down
7 changes: 3 additions & 4 deletions yarn-project/simulator/src/client/simulator.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
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,
type FunctionArtifactWithDebugMetadata,
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';

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 6081783

Please sign in to comment.