From 3003cb3e31bb2acc60abba26a5aa605e12f57aa4 Mon Sep 17 00:00:00 2001 From: sirasistant Date: Mon, 9 Dec 2024 13:12:35 +0000 Subject: [PATCH] fix avm emitted nullifiers --- .../simulator/src/public/transitional_adapters.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/yarn-project/simulator/src/public/transitional_adapters.ts b/yarn-project/simulator/src/public/transitional_adapters.ts index 5d540085d51..5bb11a5c7bb 100644 --- a/yarn-project/simulator/src/public/transitional_adapters.ts +++ b/yarn-project/simulator/src/public/transitional_adapters.ts @@ -118,7 +118,8 @@ export function generateAvmCircuitPublicInputs( revertibleAccumulatedDataFromPrivate, ); - const firstNullifier = nonRevertibleAccumulatedDataFromPrivate.nullifiers[0]; + const txHash = avmCircuitPublicInputs.previousNonRevertibleAccumulatedData.nullifiers[0]; + for ( let revertibleIndex = 0; revertibleIndex < avmCircuitPublicInputs.previousRevertibleAccumulatedData.noteHashes.length; @@ -130,7 +131,8 @@ export function generateAvmCircuitPublicInputs( } const indexInTx = revertibleIndex + avmCircuitPublicInputs.previousNonRevertibleAccumulatedDataArrayLengths.noteHashes; - const nonce = computeNoteHashNonce(firstNullifier, indexInTx); + + const nonce = computeNoteHashNonce(txHash, indexInTx); const uniqueNoteHash = computeUniqueNoteHash(nonce, noteHash); avmCircuitPublicInputs.previousRevertibleAccumulatedData.noteHashes[revertibleIndex] = uniqueNoteHash; } @@ -147,8 +149,6 @@ export function generateAvmCircuitPublicInputs( MAX_NOTE_HASHES_PER_TX, ); - const txHash = avmCircuitPublicInputs.previousNonRevertibleAccumulatedData.nullifiers[0]; - const scopedNoteHashesFromPublic = trace.getSideEffects().noteHashes; for (let i = 0; i < scopedNoteHashesFromPublic.length; i++) { const scopedNoteHash = scopedNoteHashesFromPublic[i]; @@ -156,9 +156,10 @@ export function generateAvmCircuitPublicInputs( if (!noteHash.isZero()) { const noteHashIndexInTx = i + countAccumulatedItems(noteHashesFromPrivate); const nonce = computeNoteHashNonce(txHash, noteHashIndexInTx); - const uniqueNoteHash = computeUniqueNoteHash(nonce, noteHash); - const siloedNoteHash = siloNoteHash(scopedNoteHash.contractAddress, uniqueNoteHash); - avmCircuitPublicInputs.accumulatedData.noteHashes[noteHashIndexInTx] = siloedNoteHash; + const siloedNoteHash = siloNoteHash(scopedNoteHash.contractAddress, noteHash); + const uniqueNoteHash = computeUniqueNoteHash(nonce, siloedNoteHash); + + avmCircuitPublicInputs.accumulatedData.noteHashes[noteHashIndexInTx] = uniqueNoteHash; } }