pad the ppt program columns to allow lengths that arent powers of 2#1712
Conversation
0586653 to
c777a9a
Compare
c777a9a to
b346ed5
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.
|
|
||
| builtin_segments.verify_program = Some(MemorySegmentAddresses { | ||
| begin_addr: initial_pc as usize, | ||
| stop_ptr: initial_pc as usize + program_length, |
There was a problem hiding this comment.
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.


Note
Medium Risk
Updates
verify_programAIR/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_BOUNDand adding an extra program column that acts as an in-bounds indicator.verify_programis updated to use this indicator via a newMemVerifyCondsubroutine, 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