Skip to content

fix(avm)!: add std multi-row computation constraint#21718

Open
IlyasRidhuan wants to merge 2 commits intomerge-train/avmfrom
03-18-fix_avm_add_std_multi-row_computation_constraint
Open

fix(avm)!: add std multi-row computation constraint#21718
IlyasRidhuan wants to merge 2 commits intomerge-train/avmfrom
03-18-fix_avm_add_std_multi-row_computation_constraint

Conversation

@IlyasRidhuan
Copy link
Contributor

@IlyasRidhuan IlyasRidhuan commented Mar 18, 2026

Adds the standard multi-row constraint to prevent valid computation from being maliciously terminated midway.

Note there there is no vulnerability that this was fixing. [WRITE_TO_SLICE] is a permutation requiring round == 24 so a malicious prover could not invalidly terminate the keccak computation. This is just to standardise multi-row constraints.

Copy link
Contributor Author

IlyasRidhuan commented Mar 18, 2026

@IlyasRidhuan IlyasRidhuan force-pushed the ir/03-13-fix_avm_keccak_pre-audit branch from 0a38e7c to b54fe00 Compare March 18, 2026 09:13
@IlyasRidhuan IlyasRidhuan force-pushed the 03-18-fix_avm_add_std_multi-row_computation_constraint branch from 716857c to e199983 Compare March 18, 2026 09:13
@IlyasRidhuan IlyasRidhuan marked this pull request as ready for review March 18, 2026 11:27
Copy link
Contributor

@jeanmon jeanmon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please apply the standard recipe.

@IlyasRidhuan IlyasRidhuan force-pushed the ir/03-13-fix_avm_keccak_pre-audit branch from b54fe00 to db4424a Compare March 19, 2026 01:14
@IlyasRidhuan IlyasRidhuan force-pushed the 03-18-fix_avm_add_std_multi-row_computation_constraint branch 2 times, most recently from 736c793 to 85004f6 Compare March 19, 2026 03:38
pol commit round_inv;
#[KECCAK_SEL_ROUND_NON_ZERO]
round * ((1 - sel) * (1 - round_inv) + round_inv) - sel = 0;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this ended up being redundant as derivable form the new multi-row constraints (specifically SEL_ON_START_OR_END)

  • For sel = 1 => round !=0

    • #[START_AFTER_LATCH] ensures every computation block begins with start=1
    • start * (round - 1) = 0 forces round = 1 on the first row
    • #[KECCAK_ROUND_INCREMENT] increments round by 1 each subsequent row within the block
  • For round != 0 => sel = 1

    • sel_slice_write == 1 ==> round == 24 (by #[WRITE_TO_SLICE] perm)
    • sel_slice_write = sel_no_error * end, the new #[SEL_ON_START_OR_END] guarantees end = 1 => sel = 1 as well

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. Good simplification.

@IlyasRidhuan IlyasRidhuan requested a review from jeanmon March 19, 2026 03:49
Base automatically changed from ir/03-13-fix_avm_keccak_pre-audit to merge-train/avm March 19, 2026 04:28
@IlyasRidhuan IlyasRidhuan force-pushed the 03-18-fix_avm_add_std_multi-row_computation_constraint branch from 85004f6 to 7e0654f Compare March 19, 2026 04:30
// write: #[WRITE_TO_SLICE] is a permutation requiring round == 24 on a row with sel == 1.
// ==== MULTI-ROW COMPUTATION SELECTORS ====
// See recipe: https://github.com/AztecProtocol/aztec-packages/blob/next/barretenberg/cpp/pil/vm2/docs/recipes.md#contiguous-multi-rows-computation-trace

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move the declarations for start and end here with their boolean conditions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants