You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR fixes a soundness bug in DeferralCircuitCountAir where is_valid was not constrained on the first row, allowing a malicious prover to set is_valid = 0 on all rows even when num_deferral_circuits > 0, effectively bypassing the count constraint.
Review
The fix is correct and well-structured. The change splits the is_valid constraints into two cases:
num_deferral_circuits > 0: Adds when_first_row().assert_one(local.is_valid) to anchor the start of the valid region, then retains the existing boolean and monotone-decreasing constraints.
num_deferral_circuits == 0: Forces is_valid to be zero everywhere with assert_zero(local.is_valid).
Why the old code was broken: Without the first-row constraint, the existing constraints (is_valid ∈ {0,1} and is_valid - next.is_valid ∈ {0,1}) only ensured that is_valid was a non-increasing boolean sequence. A prover could satisfy all constraints by setting is_valid = 0 on every row — the "last row is valid implies row_idx + 1 == n" check (line 79-81) would simply not trigger, and the when_ne transition check (line 76-77) would also pass trivially.
Correctness argument for the fix: With the new first-row assertion:
When n > 0: is_valid starts at 1 and can only transition from 1→0 once (monotone decreasing boolean). The when_ne constraint forces the transition to happen exactly at row_idx = n - 1, giving exactly n valid rows.
When n == 0: All rows are forced to have is_valid = 0.
No issues found. The fix is minimal, targeted, and correct.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves INT-6786.