Ohadn/program segment as ppt#1672
Ohadn/program segment as ppt#1672ohad-nir-starkware wants to merge 1 commit intofeature/program_pptfrom
Conversation
97a1b5d to
8cecb56
Compare
8cecb56 to
a61a711
Compare
4657471 to
d33522e
Compare
36b9029 to
6ff12c7
Compare
d33522e to
64911c9
Compare
6ff12c7 to
6854950
Compare
64911c9 to
68a8dd2
Compare
87bc46a to
8db774a
Compare
68a8dd2 to
d155537
Compare
8db774a to
2e38c67
Compare
anatgstarkware
left a comment
There was a problem hiding this comment.
@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])>,59f6ffd to
bf3ef29
Compare
ohad-nir-starkware
left a comment
There was a problem hiding this comment.
@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.
d155537 to
15b36bc
Compare
bf3ef29 to
49bb42d
Compare
49bb42d to
66b6578
Compare
anatgstarkware
left a comment
There was a problem hiding this comment.
@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 {66b6578 to
fb425eb
Compare
ohad-nir-starkware
left a comment
There was a problem hiding this comment.
@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_limbsfrom prover_typers/cpu.rs and return the correct value inpacked_at(i.e. create aProgramTablestruct)
Done.
fb425eb to
9a84d1f
Compare
f5e8fd3 to
030deba
Compare
ohad-nir-starkware
left a comment
There was a problem hiding this comment.
@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.
030deba to
15b98ac
Compare
stwo_cairo_prover/crates/common/src/preprocessed_columns/preprocessed_trace.rs
Show resolved
Hide resolved
stwo_cairo_prover/crates/common/src/preprocessed_columns/preprocessed_trace.rs
Outdated
Show resolved
Hide resolved
stwo_cairo_prover/crates/common/src/preprocessed_columns/program.rs
Outdated
Show resolved
Hide resolved
anatgstarkware
left a comment
There was a problem hiding this comment.
@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
15b98ac to
4ad63bb
Compare
ohad-nir-starkware
left a comment
There was a problem hiding this comment.
@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_pptbool to the proof
but preprocessed_trace_variant is in the proof, how else do we pass that information?
4ad63bb to
cd8b1b5
Compare
0548048 to
e9d4667
Compare
c3afbc7 to
e908d2d
Compare
stwo_cairo_prover/crates/common/src/preprocessed_columns/preprocessed_trace.rs
Outdated
Show resolved
Hide resolved
e908d2d to
339127a
Compare
stwo_cairo_prover/crates/prover/src/witness/preprocessed_trace.rs
Outdated
Show resolved
Hide resolved
ohad-nir-starkware
left a comment
There was a problem hiding this comment.
@ohad-nir-starkware made 1 comment and resolved 1 discussion.
Reviewable status: 6 of 20 files reviewed, 2 unresolved discussions (waiting on anatgstarkware).
stwo_cairo_prover/crates/prover/src/witness/preprocessed_trace.rs
Outdated
Show resolved
Hide resolved
339127a to
87fe062
Compare
ohad-nir-starkware
left a comment
There was a problem hiding this comment.
@ohad-nir-starkware made 1 comment and resolved 1 discussion.
Reviewable status: 6 of 20 files reviewed, 2 unresolved discussions (waiting on anatgstarkware).
87fe062 to
2406cde
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
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; | ||
| } |
There was a problem hiding this comment.
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)
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |



This change is
Note
Medium Risk
Touches prover/verifier commitment inputs and preprocessed-trace sizing/ids, so any mismatch in
program_in_ppthandling 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
programpreprocessed columns and wiring aprogram_in_pptflag throughProverParametersand both proof structs.When
program_in_pptis enabled, the prover/verifier build aPreProcessedTrace::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.