Conversation
SIERRA_UPDATE_NO_CHANGE_TAG=Changes to non-allowed libfunc.
PR SummaryMedium Risk Overview The Reviewed by Cursor Bugbot for commit 891c35c. Bugbot is set up for automated code reviews on this repo. Configure here. |
TomerStarkware
left a comment
There was a problem hiding this comment.
@TomerStarkware reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on gilbens-starkware).

Summary
Replaces the use of
u128::MAXwithu128_bound()when computing thefixerconstant inbuild_qm31_unpack. This corrects an off-by-one error:u128::MAXis2^128 - 1, but the intended bound is2^128(i.e.,u128_bound()), shifting the fixer value by 1 and producing the correct range-check constant340282366920938463463374607363048734720instead of340282366920938463463374607363048734719.Type of change
Please check one:
Why is this change needed?
The
fixerconstant inbuild_qm31_unpackwas computed usingu128::MAX(2^128 - 1) instead of2^128. The intent is to validate thatsumlies within[0, 2^36)by checking thatsum + fixerfits in au128range check cell, wherefixer = 2^128 - PART_UPPER_BOUND. Usingu128::MAXinstead of2^128shifts the fixer by 1, making the range check boundary incorrect.What was the behavior or documentation before?
The fixer was
u128::MAX - PART_UPPER_BOUND, producing a constant of340282366920938463463374607363048734719.What is the behavior or documentation after?
The fixer is
u128_bound() - PART_UPPER_BOUND, producing the correct constant of340282366920938463463374607363048734720, properly enforcing thatsumis within[0, 2^36).Related issue or discussion (if any)
N/A
Additional context
The e2e test data for the
qm31libfunc is updated to reflect the corrected constant value.