Skip to content

Commit 4fd338f

Browse files
author
Kunming Jiang
committed
Add all commitments
1 parent ed6f719 commit 4fd338f

File tree

5 files changed

+183
-66
lines changed

5 files changed

+183
-66
lines changed

circ_blocks/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

circ_blocks/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ once_cell = "1"
6161
regex = "1"
6262
ff_ext = { path = "../../ceno/ff_ext" }
6363
goldilocks = { git = "https://github.com/scroll-tech/ceno-Goldilocks" }
64+
mpcs = { path = "../../ceno/mpcs" }
6465

6566
[dev-dependencies]
6667
quickcheck = "1"

circ_blocks/examples/zxc.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ use libspartan::{
3838
};
3939
use serde::{Deserialize, Serialize};
4040
use std::time::*;
41+
use mpcs::{WhirDefault, PolynomialCommitmentScheme};
4142

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

1292-
fn run_spartan_proof<E: ExtensionField + Send + Sync>(
1293+
fn run_spartan_proof<E: ExtensionField + Send + Sync, Pcs: PolynomialCommitmentScheme<E>>(
12931294
ctk: CompileTimeKnowledge,
12941295
rtk: RunTimeKnowledge<E>,
12951296
) {
@@ -1380,11 +1381,11 @@ fn run_spartan_proof<E: ExtensionField + Send + Sync>(
13801381
// block_comm_map records the sparse_polys committed in each commitment
13811382
// Note that A, B, C are committed separately, so sparse_poly[3*i+2] corresponds to poly C of instance i
13821383
let (block_comm_map, block_comm_list, block_decomm_list) =
1383-
SNARK::multi_encode(&block_inst_for_commit);
1384+
SNARK::<E, Pcs>::multi_encode(&block_inst_for_commit);
13841385
println!("Finished Block");
1385-
let (pairwise_check_comm, pairwise_check_decomm) = SNARK::encode(&pairwise_check_inst);
1386+
let (pairwise_check_comm, pairwise_check_decomm) = SNARK::<E, Pcs>::encode(&pairwise_check_inst);
13861387
println!("Finished Pairwise");
1387-
let (perm_root_comm, perm_root_decomm) = SNARK::encode(&perm_root_inst);
1388+
let (perm_root_comm, perm_root_decomm) = SNARK::<E, Pcs>::encode(&perm_root_inst);
13881389
println!("Finished Perm");
13891390

13901391
// --
@@ -1401,7 +1402,7 @@ fn run_spartan_proof<E: ExtensionField + Send + Sync>(
14011402
println!("Running the proof...");
14021403
// produce a proof of satisfiability
14031404
let mut prover_transcript = Transcript::new(b"snark_example");
1404-
let proof = SNARK::prove(
1405+
let proof: SNARK<E, Pcs> = SNARK::prove(
14051406
ctk.input_block_num,
14061407
ctk.output_block_num,
14071408
&ctk.input_liveness,
@@ -1446,7 +1447,7 @@ fn run_spartan_proof<E: ExtensionField + Send + Sync>(
14461447
&perm_root_comm,
14471448
&perm_root_decomm,
14481449
&mut prover_transcript,
1449-
);
1450+
);
14501451

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

14971498
fn main() {
1499+
type E = GoldilocksExt2;
1500+
type Pcs = WhirDefault<E>;
14981501
env_logger::Builder::from_default_env()
14991502
.format_level(false)
15001503
.format_timestamp(None)
@@ -1604,7 +1607,7 @@ fn main() {
16041607
// --
16051608
// Generate Witnesses
16061609
// --
1607-
let rtk = get_run_time_knowledge::<false, GoldilocksExt2>(
1610+
let rtk = get_run_time_knowledge::<false, E>(
16081611
path.clone(),
16091612
&options,
16101613
entry_regs,
@@ -1633,7 +1636,7 @@ fn main() {
16331636
rtk.serialize_to_file(benchmark_name.to_string(), MAX_FILE_SIZE)
16341637
.unwrap();
16351638
if INLINE_SPARTAN_PROOF {
1636-
run_spartan_proof(ctk, rtk);
1639+
run_spartan_proof::<E, Pcs>(ctk, rtk);
16371640
}
16381641

16391642
println!("Compiler time: {}ms", compiler_time.as_millis());

spartan_parallel/examples/interface.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use goldilocks::GoldilocksExt2;
99
use libspartan::{instance::Instance, InputsAssignment, MemsAssignment, VarsAssignment, SNARK, transcript::Transcript};
1010
use serde::{Deserialize, Serialize};
1111
use std::time::*;
12+
use mpcs::WhirDefault;
1213

1314
const TOTAL_NUM_VARS_BOUND: usize = 10000000;
1415

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

102103
fn main() {
104+
type E = GoldilocksExt2;
105+
type Pcs = WhirDefault<E>;
106+
103107
let benchmark_name = &env::args().collect::<Vec<String>>()[1];
104108
// let ctk = CompileTimeKnowledge::read_from_file(benchmark_name.to_string()).unwrap();
105109
let ctk = CompileTimeKnowledge::deserialize_from_file(benchmark_name.to_string());
@@ -197,11 +201,11 @@ fn main() {
197201
// block_comm_map records the sparse_polys committed in each commitment
198202
// Note that A, B, C are committed separately, so sparse_poly[3*i+2] corresponds to poly C of instance i
199203
let (block_comm_map, block_comm_list, block_decomm_list) =
200-
SNARK::multi_encode(&block_inst_for_commit);
204+
SNARK::<E, Pcs>::multi_encode(&block_inst_for_commit);
201205
println!("Finished Block");
202-
let (pairwise_check_comm, pairwise_check_decomm) = SNARK::encode(&pairwise_check_inst);
206+
let (pairwise_check_comm, pairwise_check_decomm) = SNARK::<E, Pcs>::encode(&pairwise_check_inst);
203207
println!("Finished Pairwise");
204-
let (perm_root_comm, perm_root_decomm) = SNARK::encode(&perm_root_inst);
208+
let (perm_root_comm, perm_root_decomm) = SNARK::<E, Pcs>::encode(&perm_root_inst);
205209
println!("Finished Perm");
206210

207211
// --
@@ -218,7 +222,7 @@ fn main() {
218222
println!("Running the proof...");
219223
// produce a proof of satisfiability
220224
let mut prover_transcript = Transcript::new(b"snark_example");
221-
let proof = SNARK::prove(
225+
let proof: SNARK<E, Pcs> = SNARK::prove(
222226
ctk.input_block_num,
223227
ctk.output_block_num,
224228
&ctk.input_liveness,

0 commit comments

Comments
 (0)