Skip to content

pad the ppt program columns to allow lengths that arent powers of 2#1712

Open
ohad-nir-starkware wants to merge 1 commit intoohadn/remove_program_segment_from_prooffrom
ohadn/padded-verify_program-simpler
Open

pad the ppt program columns to allow lengths that arent powers of 2#1712
ohad-nir-starkware wants to merge 1 commit intoohadn/remove_program_segment_from_prooffrom
ohadn/padded-verify_program-simpler

Conversation

@ohad-nir-starkware
Copy link
Collaborator

@ohad-nir-starkware ohad-nir-starkware commented Mar 24, 2026

Note

Medium Risk
Updates verify_program AIR/witness generation and program preprocessed columns, which affects proof constraints and trace layout; mistakes could break proof generation/verification or cause out-of-bounds reads.

Overview
Supports program lengths that aren’t powers of two by padding the program preprocessed table to a fixed PROGRAM_LOG_LEN_BOUND and adding an extra program column that acts as an in-bounds indicator.

verify_program is updated to use this indicator via a new MemVerifyCond subroutine, expanding its trace width and making the memory lookup/consistency checks apply only when the current program row is within the real program length. Prover-side witness generation and fast deduction are updated accordingly, and the old padded Cairo test program is removed in favor of the standard opcode-components test.

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


This change is Reviewable

@ohad-nir-starkware ohad-nir-starkware self-assigned this Mar 24, 2026
@ohad-nir-starkware ohad-nir-starkware force-pushed the ohadn/padded-verify_program-simpler branch from 0586653 to c777a9a Compare March 24, 2026 20:46
@ohad-nir-starkware ohad-nir-starkware force-pushed the ohadn/padded-verify_program-simpler branch from c777a9a to b346ed5 Compare March 24, 2026 21:29
Copy link

@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.


builtin_segments.verify_program = Some(MemorySegmentAddresses {
begin_addr: initial_pc as usize,
stop_ptr: initial_pc as usize + program_length,
Copy link

Choose a reason for hiding this comment

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

Missing validation that program fits within bound

Medium Severity

The old code dynamically sized the preprocessed column via data.len().next_power_of_two(), accommodating any program length. The new code hardcodes the column length to 1 << PROGRAM_LOG_LEN_BOUND (4096) but never validates that the actual program length (initial_ap - 2 - initial_pc) fits within this bound. If a program exceeds 4096 entries, ProgramColumn::new silently truncates the data while get_program_len() returns the full length, causing deduce_output to set cond=1 for indices beyond the preprocessed column — a mismatch that could lead to proof failures or incomplete program verification.

Additional Locations (1)
Fix in Cursor Fix in Web

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.

1 participant