Skip to content

Verify All Builtins Acorrding to Whether They are Supported or Not#430

Open
Gali-StarkWare wants to merge 1 commit intomainfrom
gali/assert_builtins
Open

Verify All Builtins Acorrding to Whether They are Supported or Not#430
Gali-StarkWare wants to merge 1 commit intomainfrom
gali/assert_builtins

Conversation

@Gali-StarkWare
Copy link
Copy Markdown
Contributor

@Gali-StarkWare Gali-StarkWare commented Mar 26, 2026

Note

High Risk
High risk because it changes core proof/statement verification constraints for builtin segments, which could cause valid proofs to fail or invalid proofs to pass if the mapping/sizes are wrong. Also updates hard-coded privacy recursion hashes/roots that must match the generated circuit/preprocessed trace.

Overview
Statement verification now validates builtin segments based on support. verify_builtins is refactored to treat each builtin as supported (compute/constraint its n_uses against the enabled component size) or unsupported (enforce start == end, i.e., an empty segment), instead of only checking a fixed subset plus ad-hoc zeroing for others.

Privacy proof constants updated. PRIVACY_RECURSION_CIRCUIT_CONSTS_HASH and PRIVACY_RECURSION_CIRCUIT_PREPROCESSED_ROOT are replaced with new values to match the current privacy recursion circuit artifacts.

Written by Cursor Bugbot for commit 6c1b6b4. This will update automatically on new commits. Configure here.

@reviewable-StarkWare
Copy link
Copy Markdown
Collaborator

This change is Reviewable

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Gali-StarkWare Gali-StarkWare marked this pull request as ready for review March 26, 2026 12:32
@Gali-StarkWare Gali-StarkWare self-assigned this Mar 26, 2026
@ilyalesokhin-starkware
Copy link
Copy Markdown
Contributor

crates/cairo_air/src/statement.rs line 263 at r1 (raw file):

        let zero = context.zero();
        for segment_range in builtin_segment_ranges {
            if !supported_builtins.iter().any(|s| ptr::eq(*s, segment_range)) {

?

Code quote:

ptr::eq(*s, segment_range)

Copy link
Copy Markdown
Contributor Author

@Gali-StarkWare Gali-StarkWare left a comment

Choose a reason for hiding this comment

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

@Gali-StarkWare made 1 comment.
Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on ilyalesokhin-starkware).


crates/cairo_air/src/statement.rs line 263 at r1 (raw file):

Previously, ilyalesokhin-starkware wrote…

?

Checking if they are in the supported list. I'll change it

Copy link
Copy Markdown
Contributor

@ilyalesokhin-starkware ilyalesokhin-starkware left a comment

Choose a reason for hiding this comment

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

@ilyalesokhin-starkware made 1 comment.
Reviewable status: 0 of 1 files reviewed, 2 unresolved discussions (waiting on Gali-StarkWare).


crates/cairo_air/src/statement.rs line 185 at r1 (raw file):

            _range_check96_segment_range,
            _add_mod_segment_range,
            _mul_mod_segment_range,

now you have unused vars, isn't the old flow better?

Code quote:

            _add_mod_segment_range,
            _mul_mod_segment_range,

Copy link
Copy Markdown
Contributor Author

@Gali-StarkWare Gali-StarkWare left a comment

Choose a reason for hiding this comment

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

@Gali-StarkWare made 1 comment.
Reviewable status: 0 of 1 files reviewed, 2 unresolved discussions (waiting on Gali-StarkWare and ilyalesokhin-starkware).


crates/cairo_air/src/statement.rs line 185 at r1 (raw file):

Previously, ilyalesokhin-starkware wrote…

now you have unused vars, isn't the old flow better?

How about now?

@ilyalesokhin-starkware
Copy link
Copy Markdown
Contributor

crates/cairo_air/src/statement.rs line 240 at r2 (raw file):

        let builtin_instance_size_inverses = pack_into_qm31s(
            supported_builtins.iter().map(|(_, _, size)| M31::from(*size as u32).inverse()),

Suggestion:

u32::from(*size)

Copy link
Copy Markdown
Contributor

@ilyalesokhin-starkware ilyalesokhin-starkware left a comment

Choose a reason for hiding this comment

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

@ilyalesokhin-starkware reviewed 1 file, made 1 comment, and resolved 2 discussions.
Reviewable status: 1 of 2 files reviewed, 2 unresolved discussions (waiting on Gali-StarkWare).


crates/cairo_air/src/statement.rs line 217 at r2 (raw file):

                    let diff =
                        eval!(context, (segment_range.end.value) - (segment_range.start.value));
                    eq(context, diff, zero);

might as well fix that.

Suggestion:

                None => {
                    eq(context, segment_range.end.value, segment_range.start.value);

Copy link
Copy Markdown
Contributor Author

@Gali-StarkWare Gali-StarkWare left a comment

Choose a reason for hiding this comment

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

@Gali-StarkWare made 2 comments.
Reviewable status: 0 of 2 files reviewed, 2 unresolved discussions (waiting on Gali-StarkWare and ilyalesokhin-starkware).


crates/cairo_air/src/statement.rs line 217 at r2 (raw file):

Previously, ilyalesokhin-starkware wrote…

might as well fix that.

Done. I'll see if there are any other places this occurs


crates/cairo_air/src/statement.rs line 240 at r2 (raw file):

        let builtin_instance_size_inverses = pack_into_qm31s(
            supported_builtins.iter().map(|(_, _, size)| M31::from(*size as u32).inverse()),

It doesn't compile

@ilyalesokhin-starkware
Copy link
Copy Markdown
Contributor

crates/cairo_air/src/statement.rs line 240 at r2 (raw file):

Previously, Gali-StarkWare wrote…

It doesn't compile

than make it compile without using as

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.

3 participants