Skip to content

Ohadn/program segment as ppt#1672

Open
ohad-nir-starkware wants to merge 1 commit intofeature/program_pptfrom
ohadn/program_segment-as-ppt
Open

Ohadn/program segment as ppt#1672
ohad-nir-starkware wants to merge 1 commit intofeature/program_pptfrom
ohadn/program_segment-as-ppt

Conversation

@ohad-nir-starkware
Copy link
Copy Markdown
Collaborator

@ohad-nir-starkware ohad-nir-starkware commented Feb 28, 2026

This change is Reviewable


Note

Medium Risk
Touches prover/verifier commitment inputs and preprocessed-trace sizing/ids, so any mismatch in program_in_ppt handling can break proof generation/verification. Uses a global program table which adds concurrency/statefulness risk if misused across proofs.

Overview
Adds optional inclusion of the Cairo program segment into the preprocessed trace by introducing new program preprocessed columns and wiring a program_in_ppt flag through ProverParameters and both proof structs.

When program_in_ppt is enabled, the prover/verifier build a PreProcessedTrace::new_with_program(...) (using a global program table) so the preprocessed commitment/log sizes/column ids match the extra columns; helper APIs for generating preprocessed commitment roots now accept optional program data. Minor follow-ups update serialization destructuring and test input data accordingly.

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

@ohad-nir-starkware ohad-nir-starkware self-assigned this Feb 28, 2026
@ohad-nir-starkware ohad-nir-starkware force-pushed the ohadn/program_segment-as-ppt branch from 97a1b5d to 8cecb56 Compare March 1, 2026 09:15
@ohad-nir-starkware ohad-nir-starkware changed the base branch from main to ohadn/compute-program_segment-in-adapter March 1, 2026 09:47
@ohad-nir-starkware ohad-nir-starkware force-pushed the ohadn/program_segment-as-ppt branch from 8cecb56 to a61a711 Compare March 1, 2026 09:51
@ohad-nir-starkware ohad-nir-starkware force-pushed the ohadn/compute-program_segment-in-adapter branch from 4657471 to d33522e Compare March 1, 2026 13:29
@ohad-nir-starkware ohad-nir-starkware force-pushed the ohadn/program_segment-as-ppt branch 5 times, most recently from 36b9029 to 6ff12c7 Compare March 1, 2026 16:31
@ohad-nir-starkware ohad-nir-starkware force-pushed the ohadn/compute-program_segment-in-adapter branch from d33522e to 64911c9 Compare March 2, 2026 16:40
@ohad-nir-starkware ohad-nir-starkware force-pushed the ohadn/program_segment-as-ppt branch from 6ff12c7 to 6854950 Compare March 2, 2026 16:41
@ohad-nir-starkware ohad-nir-starkware force-pushed the ohadn/compute-program_segment-in-adapter branch from 64911c9 to 68a8dd2 Compare March 4, 2026 08:28
@ohad-nir-starkware ohad-nir-starkware force-pushed the ohadn/program_segment-as-ppt branch 3 times, most recently from 87bc46a to 8db774a Compare March 4, 2026 12:41
@ohad-nir-starkware ohad-nir-starkware force-pushed the ohadn/compute-program_segment-in-adapter branch from 68a8dd2 to d155537 Compare March 8, 2026 13:49
@ohad-nir-starkware ohad-nir-starkware force-pushed the ohadn/program_segment-as-ppt branch from 8db774a to 2e38c67 Compare March 8, 2026 13:57
Copy link
Copy Markdown
Contributor

@anatgstarkware anatgstarkware left a comment

Choose a reason for hiding this comment

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

@anatgstarkware made 1 comment.
Reviewable status: 0 of 16 files reviewed, 1 unresolved discussion (waiting on ohad-nir-starkware).


stwo_cairo_prover/crates/cairo-air/src/air.rs line 68 at r2 (raw file):

    pub channel_salt: u32,
    pub preprocessed_trace_variant: PreProcessedTraceVariant,
    pub program: Vec<(u32, [u32; 8])>,

Why did you add it to the proof?
It's already in the claim
but I think we can remove it from there now

Code quote:

pub program: Vec<(u32, [u32; 8])>,

@ohad-nir-starkware ohad-nir-starkware force-pushed the ohadn/program_segment-as-ppt branch 2 times, most recently from 59f6ffd to bf3ef29 Compare March 8, 2026 14:45
Copy link
Copy Markdown
Collaborator Author

@ohad-nir-starkware ohad-nir-starkware left a comment

Choose a reason for hiding this comment

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

@ohad-nir-starkware made 1 comment.
Reviewable status: 0 of 16 files reviewed, 1 unresolved discussion (waiting on anatgstarkware and ohad-nir-starkware).


stwo_cairo_prover/crates/cairo-air/src/air.rs line 68 at r2 (raw file):

Previously, anatgstarkware (anatg) wrote…

Why did you add it to the proof?
It's already in the claim
but I think we can remove it from there now

Done.

@ohad-nir-starkware ohad-nir-starkware force-pushed the ohadn/compute-program_segment-in-adapter branch from d155537 to 15b36bc Compare March 10, 2026 15:11
@ohad-nir-starkware ohad-nir-starkware force-pushed the ohadn/program_segment-as-ppt branch from bf3ef29 to 49bb42d Compare March 10, 2026 15:17
@ohad-nir-starkware ohad-nir-starkware changed the base branch from ohadn/compute-program_segment-in-adapter to feature/program_ppt March 10, 2026 15:47
@ohad-nir-starkware ohad-nir-starkware force-pushed the ohadn/program_segment-as-ppt branch from 49bb42d to 66b6578 Compare March 10, 2026 16:04
Copy link
Copy Markdown
Contributor

@anatgstarkware anatgstarkware left a comment

Choose a reason for hiding this comment

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

@anatgstarkware partially reviewed 7 files and made 2 comments.
Reviewable status: 2 of 16 files reviewed, 2 unresolved discussions (waiting on ohad-nir-starkware).


stwo_cairo_prover/crates/cairo-air/src/air.rs line 68 at r2 (raw file):

Previously, ohad-nir-starkware (Ohad Nir) wrote…

Done.

I think the program shouldn't be in the proof at all (currently it's in the public data), and the verifier should know a specific ppt with a specific program


stwo_cairo_prover/crates/common/src/preprocessed_columns/program.rs line 12 at r6 (raw file):

/// Extracts a 9-bit limb from a 256-bit value stored as `[u32; 8]` little-endian limbs.
fn extract_9bit_limb(value: &[u32; 8], limb_index: usize) -> u32 {

I think it's better to create all columns once using get_limbs from prover_typers/cpu.rs and return the correct value in packed_at (i.e. create a ProgramTable struct)

Code quote:

fn extract_9bit_limb(value: &[u32; 8], limb_index: usize) -> u32 {

@ohad-nir-starkware ohad-nir-starkware force-pushed the ohadn/program_segment-as-ppt branch from 66b6578 to fb425eb Compare March 11, 2026 17:32
Copy link
Copy Markdown
Collaborator Author

@ohad-nir-starkware ohad-nir-starkware left a comment

Choose a reason for hiding this comment

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

@ohad-nir-starkware made 2 comments.
Reviewable status: 2 of 16 files reviewed, 2 unresolved discussions (waiting on anatgstarkware and ohad-nir-starkware).


stwo_cairo_prover/crates/cairo-air/src/air.rs line 68 at r2 (raw file):

Previously, anatgstarkware (anatg) wrote…

I think the program shouldn't be in the proof at all (currently it's in the public data), and the verifier should know a specific ppt with a specific program

maybe we should do it in a future PR?


stwo_cairo_prover/crates/common/src/preprocessed_columns/program.rs line 12 at r6 (raw file):

Previously, anatgstarkware (anatg) wrote…

I think it's better to create all columns once using get_limbs from prover_typers/cpu.rs and return the correct value in packed_at (i.e. create a ProgramTable struct)

Done.

@ohad-nir-starkware ohad-nir-starkware force-pushed the ohadn/program_segment-as-ppt branch from fb425eb to 9a84d1f Compare March 11, 2026 17:47
@ohad-nir-starkware ohad-nir-starkware force-pushed the ohadn/program_segment-as-ppt branch 3 times, most recently from f5e8fd3 to 030deba Compare March 11, 2026 19:15
Copy link
Copy Markdown
Collaborator Author

@ohad-nir-starkware ohad-nir-starkware left a comment

Choose a reason for hiding this comment

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

@ohad-nir-starkware made 1 comment.
Reviewable status: 2 of 20 files reviewed, 2 unresolved discussions (waiting on anatgstarkware and ohad-nir-starkware).


stwo_cairo_prover/crates/cairo-air/src/air.rs line 68 at r2 (raw file):

Previously, ohad-nir-starkware (Ohad Nir) wrote…

maybe we should do it in a future PR?

I implemented some "middle of the road" approach, let me know what you think.
It will make more sense once we remove the program from the proof, which I think could be the next step.

@ohad-nir-starkware ohad-nir-starkware force-pushed the ohadn/program_segment-as-ppt branch from 030deba to 15b98ac Compare March 22, 2026 14:52
Copy link
Copy Markdown
Contributor

@anatgstarkware anatgstarkware left a comment

Choose a reason for hiding this comment

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

@anatgstarkware reviewed 9 files and all commit messages, and made 1 comment.
Reviewable status: 9 of 20 files reviewed, 5 unresolved discussions (waiting on ohad-nir-starkware).


stwo_cairo_prover/crates/cairo-air/src/air.rs line 68 at r2 (raw file):

Previously, ohad-nir-starkware (Ohad Nir) wrote…

I implemented some "middle of the road" approach, let me know what you think.
It will make more sense once we remove the program from the proof, which I think could be the next step.

I think we shouldn't add the program_in_ppt bool to the proof

@ohad-nir-starkware ohad-nir-starkware force-pushed the ohadn/program_segment-as-ppt branch from 15b98ac to 4ad63bb Compare March 28, 2026 12:35
Copy link
Copy Markdown
Collaborator Author

@ohad-nir-starkware ohad-nir-starkware left a comment

Choose a reason for hiding this comment

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

@ohad-nir-starkware made 1 comment and resolved 1 discussion.
Reviewable status: 9 of 20 files reviewed, 4 unresolved discussions (waiting on anatgstarkware).


stwo_cairo_prover/crates/cairo-air/src/air.rs line 68 at r2 (raw file):

Previously, anatgstarkware (anatg) wrote…

I think we shouldn't add the program_in_ppt bool to the proof

but preprocessed_trace_variant is in the proof, how else do we pass that information?

@ohad-nir-starkware ohad-nir-starkware force-pushed the ohadn/program_segment-as-ppt branch from 4ad63bb to cd8b1b5 Compare March 28, 2026 15:29
@ohad-nir-starkware ohad-nir-starkware force-pushed the ohadn/program_segment-as-ppt branch 2 times, most recently from c3afbc7 to e908d2d Compare March 28, 2026 16:58
@ohad-nir-starkware ohad-nir-starkware force-pushed the ohadn/program_segment-as-ppt branch from e908d2d to 339127a Compare March 30, 2026 16:57
Copy link
Copy Markdown
Collaborator Author

@ohad-nir-starkware ohad-nir-starkware left a comment

Choose a reason for hiding this comment

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

@ohad-nir-starkware made 1 comment and resolved 1 discussion.
Reviewable status: 6 of 20 files reviewed, 2 unresolved discussions (waiting on anatgstarkware).

@ohad-nir-starkware ohad-nir-starkware force-pushed the ohadn/program_segment-as-ppt branch from 339127a to 87fe062 Compare March 30, 2026 17:36
Copy link
Copy Markdown
Collaborator Author

@ohad-nir-starkware ohad-nir-starkware left a comment

Choose a reason for hiding this comment

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

@ohad-nir-starkware made 1 comment and resolved 1 discussion.
Reviewable status: 6 of 20 files reviewed, 2 unresolved discussions (waiting on anatgstarkware).

@ohad-nir-starkware ohad-nir-starkware force-pushed the ohadn/program_segment-as-ppt branch from 87fe062 to 2406cde Compare March 31, 2026 13:40
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.

// Pad to the fixed program table size so ProgramColumn has the correct log_size.
values.resize(1 << MAX_PROGRAM_LOG_LEN, [M31(0); FELT252_N_WORDS]);
*PROGRAM_TABLE.write().unwrap() = values;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Global mutable state creates race condition between callers

Medium Severity

PROGRAM_TABLE is a global LazyLock<RwLock<...>> that's written by set_program_table and then read by ProgramColumn::new inside new_with_program. These two steps are not atomic as a unit — if two threads concurrently call new_with_program with different program data, one thread's set_program_table can overwrite the other's data before the other thread's ProgramColumn::new reads it, silently producing columns with the wrong program. Passing the program data directly into ProgramColumn::new (or holding the lock across both operations) would eliminate this hidden coupling.

Additional Locations (1)
Fix in Cursor Fix in Web

Copy link
Copy Markdown
Collaborator Author

ohad-nir-starkware commented Apr 9, 2026

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