Skip to content

Commit

Permalink
chore: update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
eigmax committed Aug 4, 2024
1 parent a021490 commit 289f3f2
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 170 deletions.
163 changes: 1 addition & 162 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion algebraic-gpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ rand = "0.8.5"
env_logger = "0.10"

[features]
default = ["bellperson/default", "wasmer/default"]
default = ["bellperson/default", "wasmer/singlepass"]
cuda = ["bellperson/cuda", "wasmer/singlepass"]
opencl = ["bellperson/opencl", "wasmer/singlepass"]
2 changes: 1 addition & 1 deletion algebraic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ env_logger = "0.10"


[features]
default = ["franklin-crypto/multicore", "wasmer/default"]
default = ["franklin-crypto/multicore", "wasmer/singlepass"]
2 changes: 1 addition & 1 deletion recursion/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ powdr-parser-util = { git = "https://github.com/0xEigenLabs/powdr", branch = "e
env_logger = "0.10"

[features]
default = ["wasmer/default", "starky/default"]
default = ["wasmer/singlepass", "starky/default"]
avx512 = ["fields/avx512", "starky/avx512", "powdr/starky-avx512"]
3 changes: 3 additions & 0 deletions recursion/src/compressor12/compressor12_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ pub fn setup(
) -> Result<()> {
// 0. readR1cs
let r1cs_reader = File::open(r1cs_file)?;
log::debug!("setup load r1cs");
let (r1cs, _) = load_r1cs_from_bin::<_, GL>(r1cs_reader);
let opts = Options {
force_bits: force_n_bits,
};

log::debug!("plonk setup");
// 1. plonk setup: generate plonk circuit, the pil file.
let res = PlonkSetup::new(&r1cs, &opts);

log::debug!("save");
// 2. And write it into pil_file.
let mut file =
File::create(pil_file).map_err(|_| anyhow!("Create file error, {}", pil_file))?;
Expand Down
15 changes: 15 additions & 0 deletions recursion/src/compressor12/plonk_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,20 @@ pub struct PlonkSetup {
impl PlonkSetup {
pub fn new(r1cs: &R1CS<GL>, opts: &Options) -> Self {
// 1. plonk_setup_render phase
log::debug!("setup");
let plonk_setup_info = PlonkSetupRenderInfo::plonk_setup_render(r1cs, opts);
// 2. render .pil file by template.
// // And save as a file.
log::debug!("render, plonk_setup_info");
let pil_str = compressor12_pil::render(plonk_setup_info.n_bits, plonk_setup_info.n_publics);
// let mut file = File::create(out_pil.clone()).unwrap();
// write!(file, "{}", pil_str).unwrap();

log::debug!("compile pil");
// 3. compile pil to pil_json
let pil_json = compile_pil_from_str(&pil_str);

log::debug!("plonk setup compressor");
//4. plonk_setup_fix_compressor phase
let (const_pols, s_map) = plonk_setup_compressor(r1cs, &pil_json, &plonk_setup_info);

Expand Down Expand Up @@ -178,17 +182,26 @@ pub struct PlonkSetupRenderInfo {
impl PlonkSetupRenderInfo {
pub fn plonk_setup_render(r1cs: &R1CS<GL>, opts: &Options) -> Self {
// 1. r1cs to plonk
log::debug!("r1cs2plonk");
let (plonk_constrains, plonk_additions) = r1cs2plonk(r1cs);

log::debug!("get plonk info");
// 2. get normal plonk info
let plonk_info = NormalPlonkInfo::new(&plonk_constrains);
// 3. get custom gate info

log::debug!("get custom gate");
let custom_gates_info = CustomGateInfo::from_r1cs(r1cs);

// 4. calculate columns,rows,constraints info.
let n_publics = r1cs.num_inputs + r1cs.num_outputs - 1;
let n_public_rows = (n_publics - 1) / 12 + 1;

log::debug!(
"{n_publics} {n_public_rows} {} {:?}",
plonk_info.N,
custom_gates_info
);
let n_used = n_public_rows
+ plonk_info.N
+ (custom_gates_info.n_c_mul_add
Expand Down Expand Up @@ -218,12 +231,14 @@ pub fn plonk_setup_compressor(
plonk_setup_info: &PlonkSetupRenderInfo,
) -> (PolsArray, Vec<Vec<u64>>) {
// 1. construct init ConstantPolsArray
log::debug!("pil: new constant");
let mut const_pols = PolsArray::new(pil, PolKind::Constant);

let n_used = plonk_setup_info.n_used;
let n_publics = plonk_setup_info.n_publics;
let n_public_rows = (n_publics - 1) / 12 + 1;

log::debug!("n_used {n_used}, n_publics {n_publics}, rows: {n_public_rows}");
// 2. init sMap and construct it.
let mut s_map: Vec<Vec<u64>> = vec![vec![0u64; n_used]; 12];

Expand Down
9 changes: 4 additions & 5 deletions zkvm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn generate_witness_and_prove<F: FieldElement>(
) -> Result<Pipeline<F>, Vec<String>> {
let start = Instant::now();
log::debug!("Generating witness...");
pipeline.compute_witness().unwrap();
pipeline.compute_witness()?;
let duration = start.elapsed();
log::debug!("Generating witness took: {:?}", duration);

Expand All @@ -38,7 +38,7 @@ fn generate_witness_and_prove<F: FieldElement>(
BackendType::EStarkStarkyComposite,
Some("stark_gl".to_string()),
);
pipeline.compute_proof().unwrap();
pipeline.compute_proof()?;
let duration = start.elapsed();
log::debug!("Proving took: {:?}", duration);
Ok(pipeline)
Expand All @@ -49,7 +49,7 @@ fn generate_witness_and_prove_raw<F: FieldElement>(
) -> Result<(), Vec<String>> {
let start = Instant::now();
log::debug!("Generating witness...");
pipeline.compute_witness().unwrap();
pipeline.compute_witness()?;
let duration = start.elapsed();
log::debug!("Generating witness took: {:?}", duration);

Expand All @@ -60,7 +60,7 @@ fn generate_witness_and_prove_raw<F: FieldElement>(
BackendType::EStarkStarkyComposite,
Some("stark_gl".to_string()),
);
pipeline.compute_proof().unwrap();
pipeline.compute_proof()?;
let duration = start.elapsed();
log::debug!("Proving took: {:?}", duration);
Ok(())
Expand All @@ -87,7 +87,6 @@ fn generate_verifier<F: FieldElement>(
let proof_data = pipeline.proof().unwrap();
let cf: CompositeProof = bincode::deserialize(proof_data)?;

// FIXME, we should use the sub machine pil
let full_pil = pipeline.optimized_pil().unwrap();
let pils = split::split_pil((*full_pil).clone());

Expand Down

0 comments on commit 289f3f2

Please sign in to comment.