Skip to content

fix: reject all-zeroes mask when limit < Range - #60

Open
asterite wants to merge 2 commits into
mainfrom
ab/all-zeroes-bug
Open

fix: reject all-zeroes mask when limit < Range#60
asterite wants to merge 2 commits into
mainfrom
ab/all-zeroes-bug

Conversation

@asterite

@asterite asterite commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Problem Resolved

Resolves https://github.com/noir-lang/noir-library-claude/issues/10
Resolves #59

Summary of Changes

In boundary_check, if __boundary_check returned an all-zeroes array it didn't produce an assertion failure regardless of the value of limit. The fix is to replace one of the last assertions done with assert_eq(r[Range - 1], (limit < Range) as Field) which means that the last position is 0 is the limit is past the range, or 1 if it's before the range (the previous assertions make sure it's always a chain of zeroes followed by a chain of ones).

I also included tests for boundary_check as it wasn't tested, and tests for the "verify this unconstrained value" part of the function, which is now assert_boundary_mask.

PR Checklist

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

@asterite
asterite requested a review from TomAFrench July 28, 2026 15:58
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.

Under-constrained bug: boundary_check accepts the all-zeros mask for any limit

1 participant