Skip to content

Commit

Permalink
fix avm emitted nullifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
sirasistant committed Dec 9, 2024
1 parent a98b002 commit 3003cb3
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions yarn-project/simulator/src/public/transitional_adapters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand All @@ -147,18 +149,17 @@ 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];
const noteHash = scopedNoteHash.value;
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;
}
}

Expand Down

0 comments on commit 3003cb3

Please sign in to comment.