Skip to content

feat: integrate bytecode and program image reductions#19

Open
RadNi wants to merge 9 commits into
amir/bytecode-stack/03-program-foundationfrom
amir/bytecode-stack/04-bytecode-program-reduction
Open

feat: integrate bytecode and program image reductions#19
RadNi wants to merge 9 commits into
amir/bytecode-stack/03-program-foundationfrom
amir/bytecode-stack/04-bytecode-program-reduction

Conversation

@RadNi
Copy link
Copy Markdown

@RadNi RadNi commented May 21, 2026

Generated stack PR from amir/bytecode-commitment-merged.

Depends on spec PR: a16z#1565

Stack position: 04
Base branch: amir/bytecode-stack/03-program-foundation

Owned paths:

jolt-core/src/zkvm/claim_reductions/precommitted.rs
jolt-core/src/zkvm/claim_reductions/mod.rs
jolt-core/src/zkvm/bytecode/read_raf_checking.rs
jolt-core/src/zkvm/bytecode/mod.rs
jolt-core/src/zkvm/ram/mod.rs
jolt-core/src/zkvm/ram/val_check.rs
jolt-core/src/zkvm/claim_reductions/hamming_weight.rs
jolt-core/src/poly/opening_proof.rs
jolt-core/src/poly/commitment/dory/wrappers.rs
jolt-core/src/poly/rlc_polynomial.rs
jolt-core/src/utils/errors.rs
jolt-core/src/zkvm/config.rs
jolt-core/src/zkvm/mod.rs
jolt-core/src/zkvm/program.rs
jolt-core/src/zkvm/prover.rs
jolt-core/src/zkvm/transpilable_verifier.rs
jolt-core/src/zkvm/verifier.rs
jolt-core/src/zkvm/witness.rs
jolt-core/src/guest/prover.rs
jolt-core/src/guest/verifier.rs
jolt-core/benches/e2e_profiling.rs
jolt-sdk/macros/src/lib.rs
jolt-sdk/src/host_utils.rs
src/build_wasm.rs
transpiler/src/main.rs

This PR is expected to be updated manually when amir/bytecode-commitment-merged is resliced.

@github-actions
Copy link
Copy Markdown

Warning

This PR has more than 500 changed lines and does not include a spec.

Large features and architectural changes benefit from a spec-driven workflow.
See CONTRIBUTING.md for details on how to create a spec.

If this PR is a bug fix, refactor, or doesn't warrant a spec, feel free to ignore this message.

@github-actions github-actions Bot added the no-spec PR has no spec file label May 21, 2026
@RadNi RadNi force-pushed the amir/bytecode-stack/03-program-foundation branch from e4cdbb5 to 744ada7 Compare May 21, 2026 01:44
@RadNi RadNi force-pushed the amir/bytecode-stack/04-bytecode-program-reduction branch from 01ce43e to 8d14d29 Compare May 21, 2026 01:44
@RadNi RadNi force-pushed the amir/bytecode-stack/03-program-foundation branch from 744ada7 to d8d5384 Compare May 21, 2026 01:51
@RadNi RadNi force-pushed the amir/bytecode-stack/04-bytecode-program-reduction branch from 8d14d29 to b2cab0e Compare May 21, 2026 01:51
@RadNi RadNi changed the title Integrate bytecode program reductions [04/05] Integrate bytecode program reductions May 21, 2026
@RadNi RadNi force-pushed the amir/bytecode-stack/03-program-foundation branch from d8d5384 to 0b06125 Compare May 21, 2026 01:56
@RadNi RadNi force-pushed the amir/bytecode-stack/04-bytecode-program-reduction branch from b2cab0e to 5d0aa55 Compare May 21, 2026 01:56
@RadNi RadNi force-pushed the amir/bytecode-stack/03-program-foundation branch from 0b06125 to f33facb Compare May 21, 2026 15:37
@RadNi RadNi force-pushed the amir/bytecode-stack/04-bytecode-program-reduction branch from 5d0aa55 to 4741cdb Compare May 21, 2026 15:37
@RadNi RadNi changed the title [04/05] Integrate bytecode program reductions [04/05] Integrate bytecode and program image polynomials reductions May 21, 2026
@RadNi RadNi force-pushed the amir/bytecode-stack/03-program-foundation branch from f33facb to 77801f2 Compare May 21, 2026 18:02
@RadNi RadNi force-pushed the amir/bytecode-stack/04-bytecode-program-reduction branch from 4741cdb to 6150eee Compare May 21, 2026 18:02
@RadNi RadNi marked this pull request as ready for review May 21, 2026 18:10
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 2 potential issues.

Fix All in Cursor

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 6150eee. Configure here.

),
padded_len,
},
);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Program image words not padded for precommitted polynomial

Medium Severity

When constructing PrecommittedPolynomial::ProgramImage for Stage 8, the words field is set to the raw bytecode_words from RAM preprocessing (unpadded), but padded_len is set to the padded power-of-two length. The vmp_precommitted_contribution function iterates over words and uses padded_len for matrix dimensions (log_2, balanced sigma/nu), creating a mismatch — the words vector is shorter than padded_len, so indexing row_idx = coeff_idx / precommitted_cols may skip contributions that would exist in a properly padded polynomial, and the matrix shape doesn't match the committed polynomial.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6150eee. Configure here.


let booleanity_cycle_params =
BooleanityCyclePhaseParams::new(booleanity.into_params(), &self.opening_accumulator);
drop(instances);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ZK sumcheck proof removed from Stage 6a prover

High Severity

The prove_stage6a method previously had a #[cfg(feature = "zk")] block that used BatchedSumcheck::prove_zk with a local BlindFoldAccumulator, because Stage 6a input claims depend on hidden prior-stage outputs in ZK mode. The new code unconditionally uses prove_batched_sumcheck (the non-ZK path), which means Stage 6a no longer produces a ZK sumcheck proof when the zk feature is enabled. This breaks zero-knowledge soundness. The blindfold stage count assertion also changed from 7 to 8, which seems inconsistent with removing a ZK stage.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6150eee. Configure here.

@RadNi RadNi changed the title [04/05] Integrate bytecode and program image polynomials reductions feat: integrate bytecode and program image reductions May 21, 2026
Comment thread jolt-core/src/zkvm/verifier.rs Outdated
Comment on lines +1212 to +1220
let entry_bytecode_index = self
.preprocessing
.shared
.program_meta
.entry_address
.saturating_sub(self.preprocessing.shared.program_meta.min_bytecode_address)
as usize
/ BYTES_PER_INSTRUCTION
+ 1;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This duplicates the logic from BytecodePreprocessing::entry_bytecode_index(). We can move entry_bytecode_index onto ProgramMetadata instead so it can be used by both prover and verifier

Comment thread jolt-core/src/zkvm/verifier.rs Outdated
bytecode_read_raf_params: BytecodeReadRafSumcheckParams<F>,
booleanity_params: BooleanitySumcheckParams<F>,
) -> Result<StageVerifyResult<F>, ProofVerifyError> {
let bytecode_reduction_seed_params = bytecode_read_raf_params.clone();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this is a potentially heavy clone, when BytecodeClaimReductionParams really only needs the gamma values

Comment thread jolt-core/src/zkvm/prover.rs Outdated
Comment on lines -1271 to -1321
@@ -1293,46 +1343,25 @@
write_instance_flamegraph_svg(&instances, "stage6a_start_flamechart.svg");
tracing::info!("Stage 6a proving");

#[cfg(feature = "zk")]
let (sumcheck_proof, _r_stage6a, _initial_claim) = {
// Stage 6a input claims depend on hidden prior-stage outputs in ZK mode,
// so we prove it with a ZK sumcheck proof. We keep a local blindfold
// accumulator so this split-internal phase does not add a new global
// BlindFold stage.
let mut rng = rand::thread_rng();
let mut local_blindfold =
crate::subprotocols::blindfold::BlindFoldAccumulator::<F, C>::new();
BatchedSumcheck::prove_zk::<F, C, _, _>(
instances.iter_mut().map(|v| &mut **v as _).collect(),
&mut self.opening_accumulator,
&mut local_blindfold,
&mut self.transcript,
&self.pedersen_generators,
&mut rng,
)
};
#[cfg(not(feature = "zk"))]
let (sumcheck_proof, _r_stage6a, _initial_claim) =
self.prove_batched_sumcheck(instances.iter_mut().map(|v| &mut **v as _).collect());

#[cfg(feature = "allocative")]
write_instance_flamegraph_svg(&instances, "stage6a_end_flamechart.svg");

let booleanity_cycle_params =
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this sort of Arc::new(bytecode.clone()) appears a couple of times in this PR; we should avoid cloning the bytecode as much as possible. Can we return an Arc from a preprocessing method?

@RadNi RadNi force-pushed the amir/bytecode-stack/03-program-foundation branch from 77801f2 to d1eb7e0 Compare May 22, 2026 15:57
@RadNi RadNi force-pushed the amir/bytecode-stack/04-bytecode-program-reduction branch from 6150eee to 42d671b Compare May 22, 2026 15:57
@RadNi RadNi force-pushed the amir/bytecode-stack/03-program-foundation branch from d1eb7e0 to 78c82ba Compare May 22, 2026 17:11
@RadNi RadNi force-pushed the amir/bytecode-stack/04-bytecode-program-reduction branch from 42d671b to 5c76a6b Compare May 22, 2026 17:11
@RadNi RadNi force-pushed the amir/bytecode-stack/03-program-foundation branch from 78c82ba to 9d5b82e Compare May 22, 2026 17:30
@RadNi RadNi force-pushed the amir/bytecode-stack/04-bytecode-program-reduction branch from 5c76a6b to 546aa02 Compare May 22, 2026 17:30
@RadNi RadNi force-pushed the amir/bytecode-stack/03-program-foundation branch from 9d5b82e to e587e65 Compare May 22, 2026 17:48
@RadNi RadNi force-pushed the amir/bytecode-stack/04-bytecode-program-reduction branch from 546aa02 to 30d2a9b Compare May 22, 2026 17:48
@RadNi RadNi force-pushed the amir/bytecode-stack/03-program-foundation branch from e587e65 to 36378dd Compare May 22, 2026 19:53
@RadNi RadNi force-pushed the amir/bytecode-stack/04-bytecode-program-reduction branch 2 times, most recently from 48e80c2 to f307a64 Compare May 23, 2026 06:57
@RadNi RadNi force-pushed the amir/bytecode-stack/03-program-foundation branch 2 times, most recently from 850790c to 268b434 Compare May 25, 2026 18:46
@RadNi RadNi force-pushed the amir/bytecode-stack/04-bytecode-program-reduction branch from 3e65aa6 to 4637de5 Compare May 25, 2026 18:46
quangvdao and others added 8 commits May 25, 2026 20:37
Co-authored-by: Amirhossein Khajehpour <khajepour.amirhossein@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Amirhossein Khajehpour <khajepour.amirhossein@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Update bytecode and program-image verifier integration to use the shared precommitted phase transition helper after cycle-phase openings are cached.

Made-with: Cursor

Co-authored-by: Cursor <cursoragent@cursor.com>
Thread committed bytecode metadata consistently through prover and verifier paths so bytecode reduction state stays synchronized.

Made-with: Cursor

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@RadNi RadNi force-pushed the amir/bytecode-stack/03-program-foundation branch from 268b434 to bf067dd Compare May 26, 2026 04:17
@RadNi RadNi force-pushed the amir/bytecode-stack/04-bytecode-program-reduction branch from 4637de5 to 881b8fc Compare May 26, 2026 04:38
Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-spec PR has no spec file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants