Skip to content

Add enabled_bits to ProofConfig#453

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

Add enabled_bits to ProofConfig#453
ilyalesokhin-starkware wants to merge 1 commit intomainfrom
ilya/enable_bits

Conversation

@ilyalesokhin-starkware
Copy link
Copy Markdown
Contributor

Store per-component enable bits directly in ProofConfig instead of deriving them from component disabled state. This supports dynamic component sets in the Cairo1 verifier. Disabled components are now filtered out before being passed to the verifier, and pad_disabled re-expands values for channel mixing to maintain Fiat-Shamir compatibility.

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 14, 2026

PR Summary

High Risk
High risk because it changes proof transcript mixing and component selection logic in the STARK/circuit verifier; any mismatch in enabled_bits handling or padding can invalidate proofs or enable malformed-proof acceptance.

Overview
Adds explicit per-component enabled_bits to ProofConfig and threads it through all config builders. Callers now pass enable flags into ProofConfig::from_statement/from_components, and Cairo privacy config builds both the filtered component map and the full enable-bit vector.

Stops representing disabled components as EmptyComponent and instead filters them out. Verification/circuit construction now builds component maps from enabled_bits, and Cairo proof preparation drops disabled components’ log-sizes/claimed-sums before proof_from_stark_proof.

Preserves Fiat–Shamir transcript compatibility via padding. The verifier pads component log sizes and claimed sums back to the full component layout for channel mixing, updates logup-sum validation accordingly, and adjusts example/prover tests and the simple_* fixtures to reflect filtered claims plus padded transcript inputs.

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

@reviewable-StarkWare
Copy link
Copy Markdown
Collaborator

This change is Reviewable

Comment thread crates/cairo_air/src/statement.rs
Comment thread crates/circuits/src/context.rs Outdated
@ilyalesokhin-starkware ilyalesokhin-starkware marked this pull request as draft April 14, 2026 13:41
@ilyalesokhin-starkware ilyalesokhin-starkware changed the base branch from main to graphite-base/453 April 15, 2026 07:55
@ilyalesokhin-starkware ilyalesokhin-starkware changed the base branch from graphite-base/453 to ilya/named April 15, 2026 07:55
Copy link
Copy Markdown
Contributor Author

ilyalesokhin-starkware commented Apr 15, 2026

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

Comment thread crates/cairo_air/src/statement.rs
Copy link
Copy Markdown
Contributor Author

@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 16 files reviewed, 2 unresolved discussions (waiting on az-starkware, Gali-StarkWare, and leo-starkware).

Comment thread crates/circuits/src/context.rs Outdated
Copy link
Copy Markdown
Contributor Author

@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 resolved 1 discussion.
Reviewable status: 0 of 19 files reviewed, all discussions resolved (waiting on az-starkware, Gali-StarkWare, and leo-starkware).

Comment thread crates/circuit_prover/src/prover_test.rs
Copy link
Copy Markdown
Contributor

@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 partially reviewed 3 files.
Reviewable status: 3 of 19 files reviewed, 1 unresolved discussion (waiting on az-starkware, ilyalesokhin-starkware, and leo-starkware).

Copy link
Copy Markdown
Contributor

@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 reviewed all commit messages.
Reviewable status: 3 of 19 files reviewed, 1 unresolved discussion (waiting on az-starkware, ilyalesokhin-starkware, and leo-starkware).

Copy link
Copy Markdown
Contributor

@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 reviewed 1 file and made 2 comments.
Reviewable status: 4 of 19 files reviewed, 3 unresolved discussions (waiting on az-starkware, ilyalesokhin-starkware, and leo-starkware).


crates/cairo_air/src/privacy.rs line 23 at r3 (raw file):

    let preprocessed_trace_variant = PreProcessedTraceVariant::CanonicalSmall;
    let privacy_set = privacy_components();
    let all = all_components::<NoValue>();

Suggestion:

let all_components = all_components::<NoValue>();

crates/cairo_air/src/privacy.rs line 26 at r3 (raw file):

    let enabled_bits: Vec<bool> = all.keys().map(|name| privacy_set.contains(name)).collect();
    let components: IndexMap<&'static str, Box<dyn CircuitEval<NoValue>>> =
        all.into_iter().filter(|(name, _)| privacy_set.contains(name)).collect();

Repeated code, maybe create them in one go? Similar to before with unzip?

Code quote:

    let enabled_bits: Vec<bool> = all.keys().map(|name| privacy_set.contains(name)).collect();
    let components: IndexMap<&'static str, Box<dyn CircuitEval<NoValue>>> =
        all.into_iter().filter(|(name, _)| privacy_set.contains(name)).collect();

Copy link
Copy Markdown
Contributor

@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 reviewed 1 file and made 1 comment.
Reviewable status: 5 of 19 files reviewed, 4 unresolved discussions (waiting on az-starkware, ilyalesokhin-starkware, and leo-starkware).


crates/cairo_air/src/statement.rs line 232 at r3 (raw file):

                // The component is not supported by the circuit - actual_uses must be 0.
                eq(context, actual_uses, context.zero());
                continue;

Why the added continue?

Code quote:

continue;

@ilyalesokhin-starkware
Copy link
Copy Markdown
Contributor Author

crates/cairo_air/src/statement.rs line 232 at r3 (raw file):

Previously, Gali-StarkWare wrote…

Why the added continue?

No need to check:
actual_uses <= component_size
when actual_uses == 0.

Copy link
Copy Markdown
Contributor Author

@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 2 comments.
Reviewable status: 4 of 19 files reviewed, 3 unresolved discussions (waiting on az-starkware, Gali-StarkWare, and leo-starkware).


crates/cairo_air/src/privacy.rs line 26 at r3 (raw file):

Previously, Gali-StarkWare wrote…

Repeated code, maybe create them in one go? Similar to before with unzip?

Done.


crates/cairo_air/src/privacy.rs line 23 at r3 (raw file):

    let preprocessed_trace_variant = PreProcessedTraceVariant::CanonicalSmall;
    let privacy_set = privacy_components();
    let all = all_components::<NoValue>();

Done.

Copy link
Copy Markdown
Contributor

@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 reviewed 2 files and all commit messages, and resolved 3 discussions.
Reviewable status: 6 of 19 files reviewed, all discussions resolved (waiting on az-starkware and leo-starkware).

Copy link
Copy Markdown
Contributor

@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 reviewed 5 files and made 2 comments.
Reviewable status: 11 of 19 files reviewed, 2 unresolved discussions (waiting on az-starkware, ilyalesokhin-starkware, and leo-starkware).


crates/cairo_air/src/test.rs line 61 at r4 (raw file):

    let components: indexmap::IndexMap<&'static str, Box<dyn CircuitEval<QM31>>> =
        zip_eq(all_components::<QM31>().into_iter(), &component_enable_bits)
            .filter_map(|((component_name, component), &enable_bit)| {

What does it filter here?

Code quote:

filter_map

crates/stark_verifier_examples/src/simple_air.rs line 250 at r4 (raw file):

    // Mix the component log sizes into the channel.
    // Component_3 is disabled, so it has trace size 0.
    prover_channel.mix_felts(&pack_component_log_sizes(&COMPONENT_LOG_SIZES));

Revert and use packed_component_log_sizes later

Code quote:

 prover_channel.mix_felts(&pack_component_log_sizes(&COMPONENT_LOG_SIZES));

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.

There are 2 total unresolved issues (including 1 from previous review).

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.

Reviewed by Cursor Bugbot for commit 4b3e641. Configure here.

Comment thread crates/cairo_air/src/mod.rs Outdated
@ilyalesokhin-starkware
Copy link
Copy Markdown
Contributor Author

crates/cairo_air/src/test.rs line 61 at r4 (raw file):

Previously, Gali-StarkWare wrote…

What does it filter here?

I'm removing disable components.

Comment thread crates/cairo_air/src/mod.rs Outdated
@ilyalesokhin-starkware
Copy link
Copy Markdown
Contributor Author

crates/stark_verifier_examples/src/simple_air.rs line 250 at r4 (raw file):

Previously, Gali-StarkWare wrote…

Revert and use packed_component_log_sizes later

Done,
Note that I want to remove the zero padding, so there is no point in making the padding code cleared.

@ilyalesokhin-starkware ilyalesokhin-starkware changed the base branch from ilya/named to graphite-base/453 April 15, 2026 11:24
@graphite-app graphite-app bot changed the base branch from graphite-base/453 to main April 15, 2026 11:24
Store per-component enable bits directly in ProofConfig instead of
deriving them from component disabled state. This supports dynamic
component sets in the Cairo1 verifier. Disabled components are now
filtered out before being passed to the verifier, and pad_disabled
re-expands values for channel mixing to maintain Fiat-Shamir
compatibility.
Copy link
Copy Markdown
Contributor Author

@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 resolved 1 discussion.
Reviewable status: 9 of 19 files reviewed, 1 unresolved discussion (waiting on az-starkware, Gali-StarkWare, and leo-starkware).

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