From 899fd4e3215847e20bde38eadc7b6591b7be2c3f Mon Sep 17 00:00:00 2001 From: kunxian xia Date: Fri, 8 Aug 2025 12:20:59 +0800 Subject: [PATCH 1/4] wip --- .cargo/config.toml | 10 ++++++++++ src/e2e/mod.rs | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..27415bf --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,10 @@ +[patch."https://github.com/scroll-tech/ceno.git"] +ceno_mle = { path = "../ceno/multilinear_extensions", package = "multilinear_extensions" } +ceno_sumcheck = { path = "../ceno/sumcheck", package = "sumcheck" } +ceno_transcript = { path = "../ceno/transcript", package = "transcript" } +ceno_witness = { path = "../ceno/witness", package = "witness" } +ceno_zkvm = { path = "../ceno/ceno_zkvm" } +ceno_emul = { path = "../ceno/ceno_emul" } +gkr_iop = { path = "../ceno/gkr_iop" } +mpcs = { path = "../ceno/mpcs" } +ff_ext = { path = "../ceno/ff_ext" } diff --git a/src/e2e/mod.rs b/src/e2e/mod.rs index b4d15ee..6996b28 100644 --- a/src/e2e/mod.rs +++ b/src/e2e/mod.rs @@ -7,6 +7,7 @@ use crate::zkvm_verifier::binding::{ }; use crate::zkvm_verifier::verifier::{verify_zkvm_proof, verify_gkr_circuit}; use ceno_mle::util::ceil_log2; +use ceno_transcript::BasicTranscript; use ff_ext::BabyBearExt4; use gkr_iop::gkr::{ GKRCircuit, @@ -307,8 +308,10 @@ pub fn inner_test_thread() { .expect("Failed to deserialize vk file"); let verifier = ZKVMVerifier::new(vk); - let zkvm_proof_input = parse_zkvm_proof_import(zkvm_proof, &verifier); + let zkvm_proof_input = parse_zkvm_proof_import(zkvm_proof.clone(), &verifier); + let transcript = BasicTranscript::new(b"riscv"); + verifier.verify_proof(zkvm_proof, transcript).expect("ZKVM proof verification failed"); // OpenVM DSL let mut builder = AsmBuilder::::default(); From 2b0f1e4f8767513b2c0c2edcac500644daadc463 Mon Sep 17 00:00:00 2001 From: kunxian xia Date: Fri, 8 Aug 2025 17:02:36 +0800 Subject: [PATCH 2/4] report root cause --- src/e2e/mod.rs | 2 +- src/zkvm_verifier/verifier.rs | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/e2e/mod.rs b/src/e2e/mod.rs index 6996b28..f5d2e7f 100644 --- a/src/e2e/mod.rs +++ b/src/e2e/mod.rs @@ -328,7 +328,7 @@ pub fn inner_test_thread() { witness_stream.extend(zkvm_proof_input.write()); // Compile program - let options = CompilerOptions::default().with_cycle_tracker(); + let options = CompilerOptions::default(); let mut compiler = AsmCompiler::new(options.word_size); compiler.build(builder.operations); let asm_code = compiler.code(); diff --git a/src/zkvm_verifier/verifier.rs b/src/zkvm_verifier/verifier.rs index c51d9c3..b5b8232 100644 --- a/src/zkvm_verifier/verifier.rs +++ b/src/zkvm_verifier/verifier.rs @@ -286,6 +286,9 @@ pub fn verify_zkvm_proof>( &mut poly_evaluator, ) }; + // root cause: for keccak, the input_opening_point has length=12 + // but outside the loop, it becomes 7 + builder.print_v(input_opening_point.len().get_var()); builder.cycle_tracker_end("Verify chip proof"); let witin_round: RoundOpeningVariable = builder.eval(RoundOpeningVariable { @@ -362,7 +365,6 @@ pub fn verify_zkvm_proof>( ); } - /* _debug batch_verify( builder, zkvm_proof_input.max_num_var, @@ -370,7 +372,6 @@ pub fn verify_zkvm_proof>( zkvm_proof_input.pcs_proof, &mut challenger, ); - */ let empty_arr: Array> = builder.dyn_array(0); let initial_global_state = eval_ceno_expr_with_instance( @@ -673,12 +674,13 @@ pub fn verify_gkr_circuit( // Update claim layer.in_eval_expr.iter().enumerate().for_each(|(idx, pos)| { let val = builder.get(&main_evals, idx); - builder.set(&claims, *pos, PointAndEvalVariable { + let point_eval = builder.eval(PointAndEvalVariable { point: PointVariable { fs: in_point.clone() }, - eval: val, + eval: val }); + builder.set_value(&claims, *pos, point_eval); }); } From 6df4adafa1a1c50652da99630e489627a6c21234 Mon Sep 17 00:00:00 2001 From: kunxian xia Date: Fri, 8 Aug 2025 17:05:22 +0800 Subject: [PATCH 3/4] point out bugs --- src/zkvm_verifier/verifier.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/zkvm_verifier/verifier.rs b/src/zkvm_verifier/verifier.rs index b5b8232..1cba44f 100644 --- a/src/zkvm_verifier/verifier.rs +++ b/src/zkvm_verifier/verifier.rs @@ -970,9 +970,11 @@ pub fn evaluate_gkr_expression( // _debug // assert!(parts.iter().all(|part| part.point == parts[0].point)); + // FIXME: this is WRONG. we should use builder.dyn_array(); let mut new_point: Vec> = vec![]; builder.range(0, parts[0].point.fs.len()).for_each(|idx_vec, builder| { let e = builder.get(&parts[0].point.fs, idx_vec[0]); + // FIXME: this is WRONG. new_point.push(e); }); for (index_in_point, c) in indices { From 85ed32c3be2fb4078b2fe266eaaa8a47357f4a0f Mon Sep 17 00:00:00 2001 From: kunxian xia Date: Tue, 26 Aug 2025 01:30:00 +0800 Subject: [PATCH 4/4] add missing changes --- src/zkvm_verifier/verifier.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/zkvm_verifier/verifier.rs b/src/zkvm_verifier/verifier.rs index 1eb8ab8..009ac04 100644 --- a/src/zkvm_verifier/verifier.rs +++ b/src/zkvm_verifier/verifier.rs @@ -18,6 +18,7 @@ use crate::transcript::transcript_observe_label; use crate::zkvm_verifier::binding::{ GKRProofVariable, LayerProofVariable, SumcheckLayerProofVariable, }; +use crate::basefold_verifier::verifier::batch_verify; use crate::{ arithmetics::{ build_eq_x_r_vec_sequential, ceil_log2, concat, dot_product as ext_dot_product, @@ -381,6 +382,7 @@ pub fn verify_zkvm_proof>( batch_verify( builder, zkvm_proof_input.max_num_var, + zkvm_proof_input.max_width, rounds, zkvm_proof_input.pcs_proof, &mut challenger,