Skip to content

Commit

Permalink
fix: issue if commitment hints when the same commitment appears twice…
Browse files Browse the repository at this point in the history
… within the same tx (#4702)
  • Loading branch information
jeanmon authored Feb 21, 2024
1 parent 19d2bbe commit 9c3c880
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion yarn-project/pxe/src/kernel_prover/kernel_prover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,13 @@ export class KernelProver {
commitments: Tuple<SideEffect, typeof MAX_NEW_COMMITMENTS_PER_TX>,
): Tuple<Fr, typeof MAX_NEW_NULLIFIERS_PER_TX> {
const hints = makeTuple(MAX_NEW_NULLIFIERS_PER_TX, Fr.zero);
const alreadyUsed = new Set<number>();
for (let i = 0; i < MAX_NEW_NULLIFIERS_PER_TX; i++) {
if (!nullifiedCommitments[i].isZero()) {
const equalToCommitment = (cmt: SideEffect) => cmt.value.equals(nullifiedCommitments[i]);
const equalToCommitment = (cmt: SideEffect, index: number) =>
cmt.value.equals(nullifiedCommitments[i]) && !alreadyUsed.has(index);
const result = commitments.findIndex(equalToCommitment);
alreadyUsed.add(result);
if (result == -1) {
throw new Error(
`The nullified commitment at index ${i} with value ${nullifiedCommitments[
Expand Down

0 comments on commit 9c3c880

Please sign in to comment.