Skip to content

Commit

Permalink
Add all commitments
Browse files Browse the repository at this point in the history
  • Loading branch information
Kunming Jiang committed Jan 30, 2025
1 parent ed6f719 commit 4fd338f
Show file tree
Hide file tree
Showing 5 changed files with 183 additions and 66 deletions.
1 change: 1 addition & 0 deletions circ_blocks/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions circ_blocks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ once_cell = "1"
regex = "1"
ff_ext = { path = "../../ceno/ff_ext" }
goldilocks = { git = "https://github.com/scroll-tech/ceno-Goldilocks" }
mpcs = { path = "../../ceno/mpcs" }

[dev-dependencies]
quickcheck = "1"
Expand Down
19 changes: 11 additions & 8 deletions circ_blocks/examples/zxc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ use libspartan::{
};
use serde::{Deserialize, Serialize};
use std::time::*;
use mpcs::{WhirDefault, PolynomialCommitmentScheme};

// How many reserved variables (EXCLUDING V) are in front of the actual input / output?
// %BN, %RET, %TS, %AS, %SP, %BP
Expand Down Expand Up @@ -1289,7 +1290,7 @@ fn get_run_time_knowledge<const VERBOSE: bool, E: ExtensionField + Send + Sync>(
}
}

fn run_spartan_proof<E: ExtensionField + Send + Sync>(
fn run_spartan_proof<E: ExtensionField + Send + Sync, Pcs: PolynomialCommitmentScheme<E>>(
ctk: CompileTimeKnowledge,
rtk: RunTimeKnowledge<E>,
) {
Expand Down Expand Up @@ -1380,11 +1381,11 @@ fn run_spartan_proof<E: ExtensionField + Send + Sync>(
// block_comm_map records the sparse_polys committed in each commitment
// Note that A, B, C are committed separately, so sparse_poly[3*i+2] corresponds to poly C of instance i
let (block_comm_map, block_comm_list, block_decomm_list) =
SNARK::multi_encode(&block_inst_for_commit);
SNARK::<E, Pcs>::multi_encode(&block_inst_for_commit);
println!("Finished Block");
let (pairwise_check_comm, pairwise_check_decomm) = SNARK::encode(&pairwise_check_inst);
let (pairwise_check_comm, pairwise_check_decomm) = SNARK::<E, Pcs>::encode(&pairwise_check_inst);
println!("Finished Pairwise");
let (perm_root_comm, perm_root_decomm) = SNARK::encode(&perm_root_inst);
let (perm_root_comm, perm_root_decomm) = SNARK::<E, Pcs>::encode(&perm_root_inst);
println!("Finished Perm");

// --
Expand All @@ -1401,7 +1402,7 @@ fn run_spartan_proof<E: ExtensionField + Send + Sync>(
println!("Running the proof...");
// produce a proof of satisfiability
let mut prover_transcript = Transcript::new(b"snark_example");
let proof = SNARK::prove(
let proof: SNARK<E, Pcs> = SNARK::prove(
ctk.input_block_num,
ctk.output_block_num,
&ctk.input_liveness,
Expand Down Expand Up @@ -1446,7 +1447,7 @@ fn run_spartan_proof<E: ExtensionField + Send + Sync>(
&perm_root_comm,
&perm_root_decomm,
&mut prover_transcript,
);
);

println!("Verifying the proof...");
// verify the proof of satisfiability
Expand Down Expand Up @@ -1495,6 +1496,8 @@ fn run_spartan_proof<E: ExtensionField + Send + Sync>(
}

fn main() {
type E = GoldilocksExt2;
type Pcs = WhirDefault<E>;
env_logger::Builder::from_default_env()
.format_level(false)
.format_timestamp(None)
Expand Down Expand Up @@ -1604,7 +1607,7 @@ fn main() {
// --
// Generate Witnesses
// --
let rtk = get_run_time_knowledge::<false, GoldilocksExt2>(
let rtk = get_run_time_knowledge::<false, E>(
path.clone(),
&options,
entry_regs,
Expand Down Expand Up @@ -1633,7 +1636,7 @@ fn main() {
rtk.serialize_to_file(benchmark_name.to_string(), MAX_FILE_SIZE)
.unwrap();
if INLINE_SPARTAN_PROOF {
run_spartan_proof(ctk, rtk);
run_spartan_proof::<E, Pcs>(ctk, rtk);
}

println!("Compiler time: {}ms", compiler_time.as_millis());
Expand Down
12 changes: 8 additions & 4 deletions spartan_parallel/examples/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use goldilocks::GoldilocksExt2;
use libspartan::{instance::Instance, InputsAssignment, MemsAssignment, VarsAssignment, SNARK, transcript::Transcript};
use serde::{Deserialize, Serialize};
use std::time::*;
use mpcs::WhirDefault;

const TOTAL_NUM_VARS_BOUND: usize = 10000000;

Expand Down Expand Up @@ -100,6 +101,9 @@ impl<E: ExtensionField + for<'de> serde::de::Deserialize<'de>> RunTimeKnowledge<
}

fn main() {
type E = GoldilocksExt2;
type Pcs = WhirDefault<E>;

let benchmark_name = &env::args().collect::<Vec<String>>()[1];
// let ctk = CompileTimeKnowledge::read_from_file(benchmark_name.to_string()).unwrap();
let ctk = CompileTimeKnowledge::deserialize_from_file(benchmark_name.to_string());
Expand Down Expand Up @@ -197,11 +201,11 @@ fn main() {
// block_comm_map records the sparse_polys committed in each commitment
// Note that A, B, C are committed separately, so sparse_poly[3*i+2] corresponds to poly C of instance i
let (block_comm_map, block_comm_list, block_decomm_list) =
SNARK::multi_encode(&block_inst_for_commit);
SNARK::<E, Pcs>::multi_encode(&block_inst_for_commit);
println!("Finished Block");
let (pairwise_check_comm, pairwise_check_decomm) = SNARK::encode(&pairwise_check_inst);
let (pairwise_check_comm, pairwise_check_decomm) = SNARK::<E, Pcs>::encode(&pairwise_check_inst);
println!("Finished Pairwise");
let (perm_root_comm, perm_root_decomm) = SNARK::encode(&perm_root_inst);
let (perm_root_comm, perm_root_decomm) = SNARK::<E, Pcs>::encode(&perm_root_inst);
println!("Finished Perm");

// --
Expand All @@ -218,7 +222,7 @@ fn main() {
println!("Running the proof...");
// produce a proof of satisfiability
let mut prover_transcript = Transcript::new(b"snark_example");
let proof = SNARK::prove(
let proof: SNARK<E, Pcs> = SNARK::prove(
ctk.input_block_num,
ctk.output_block_num,
&ctk.input_liveness,
Expand Down
Loading

0 comments on commit 4fd338f

Please sign in to comment.