Skip to content

Increase SMALL_VALUE_BITS to 29 and rename builtin-specific bound.#431

Open
ilyalesokhin-starkware wants to merge 1 commit intomainfrom
ilya/29_bit
Open

Increase SMALL_VALUE_BITS to 29 and rename builtin-specific bound.#431
ilyalesokhin-starkware wants to merge 1 commit intomainfrom
ilya/29_bit

Conversation

@ilyalesokhin-starkware
Copy link
Copy Markdown
Contributor

@ilyalesokhin-starkware ilyalesokhin-starkware commented Mar 26, 2026

SMALL_VALUE_BITS increases from 27 to 29 for general small values. The builtin n_uses range check keeps the tighter 27-bit bound under the new name BUILTIN_USAGE_BITS, since builtin_start + n_uses * instance_size must not overflow M31_P.


Note

Medium Risk
Touches constraint bit-decomposition and range-check bounds used in proof verification; incorrect bounds could allow invalid public data or break compatibility with existing traces.

Overview
Updates Cairo AIR statement constraints to treat general “small” public values as 29-bit instead of 27-bit, including updating the value-to-limb splitter to output 4×9-bit limbs and using it for public memory and safe-call initialization logup terms.

Keeps builtin n_uses range checks at a tighter 27-bit bound under the new BUILTIN_USAGE_BITS constant, and adjusts the associated overflow assertion and extraction calls to match the new split between 29-bit addresses/values and 27-bit builtin usage counts.

Reviewed by Cursor Bugbot for commit d20a814. Bugbot is set up for automated code reviews on this repo. Configure here.

@reviewable-StarkWare
Copy link
Copy Markdown
Collaborator

This change is Reviewable

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Comment thread crates/cairo_air/src/statement.rs
SMALL_VALUE_BITS increases from 27 to 29 for general small values.
The builtin n_uses range check keeps the tighter 27-bit bound under
the new name BUILTIN_USAGE_BITS, since builtin_start + n_uses *
instance_size must not overflow M31_P.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@cursor
Copy link
Copy Markdown

cursor bot commented Apr 16, 2026

PR Summary

Medium Risk
Touches AIR constraint bit-bounds and limb encoding used in public memory logup and builtin usage checks; incorrect bounds could cause verification failures or unintended acceptance/rejection of proofs.

Overview
Updates Cairo AIR statement constraints to treat “small” public values as 29-bit instead of 27-bit.

This renames and refactors the limb-splitting helper to split_29bit_value_to_9bit_limbs (now producing 4×9-bit limbs) and threads it through segment-range and safe-call public memory logup terms.

Builtin usage range checks are decoupled from the new 29-bit bound via a new BUILTIN_USAGE_BITS = 27, updating the extract_bits calls and overflow assertion/documentation to ensure start + n_uses * instance_size stays below M31_P.

Reviewed by Cursor Bugbot for commit bf0b3a8. Bugbot is set up for automated code reviews on this repo. Configure here.

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