Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Use real trusted setup instead of a random generator #272

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions examples/blake2f.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use chiquito::{
CircuitContext, StepTypeSetupContext, StepTypeWGHandler,
},
plonkish::{
backend::halo2::{halo2_verify, DummyRng, PlonkishHalo2},
backend::halo2::{halo2_verify, PlonkishHalo2},
compiler::{
cell_manager::{MaxWidthCellManager, SingleRowCellManager},
config,
Expand All @@ -19,7 +19,6 @@ use chiquito::{
sbpir::query::Queriable,
};
use halo2_proofs::halo2curves::{bn256::Fr, group::ff::PrimeField};
use rand_chacha::rand_core::block::BlockRng;
use std::{fmt::Write, hash::Hash};

pub const IV_LEN: usize = 8;
Expand Down Expand Up @@ -1479,9 +1478,8 @@ fn main() {

let witness = super_circuit.get_mapping().generate(values);

let rng = BlockRng::new(DummyRng {});

let halo2_prover = super_circuit.create_halo2_prover(rng);
let params_path = "examples/ptau/hermez-raw-11";
let halo2_prover = super_circuit.create_halo2_prover(params_path);
println!("k={}", halo2_prover.get_k());

let (proof, instance) = halo2_prover.generate_proof(witness);
Expand Down
11 changes: 5 additions & 6 deletions examples/factorial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use chiquito::{
frontend::dsl::{circuit, trace::DSLTraceGenerator}, /* main function for constructing an AST
* circuit */
plonkish::{
backend::halo2::{halo2_verify, DummyRng, PlonkishHalo2},
backend::halo2::{halo2_verify, PlonkishHalo2},
compiler::{
cell_manager::SingleRowCellManager, // input for constructing the compiler
compile, // input for constructing the compiler
Expand All @@ -23,7 +23,6 @@ use chiquito::{
poly::ToField,
};
use halo2_proofs::halo2curves::bn256::Fr;
use rand_chacha::rand_core::block::BlockRng;

const MAX_FACTORIAL: usize = 10;

Expand Down Expand Up @@ -136,9 +135,9 @@ fn generate<F: Field + From<u64> + Hash>() -> PlonkishCompilationResult<F, DSLTr
// standard main function for a Halo2 circuit
fn main() {
let mut plonkish = generate::<Fr>();
let rng = BlockRng::new(DummyRng {});
let params_path = "examples/ptau/hermez-raw-11";

let halo2_prover = plonkish.create_halo2_prover(rng);
let halo2_prover = plonkish.create_halo2_prover(params_path);
println!("k={}", halo2_prover.get_k());

let (proof, instance) =
Expand All @@ -158,9 +157,9 @@ fn main() {
}

let mut plonkish = generate::<Fr>();
let rng = BlockRng::new(DummyRng {});
let params_path = "examples/ptau/hermez-raw-11";

let halo2_prover = plonkish.create_halo2_prover(rng);
let halo2_prover = plonkish.create_halo2_prover(params_path);
println!("k={}", halo2_prover.get_k());

let (proof, instance) =
Expand Down
7 changes: 3 additions & 4 deletions examples/fibo_with_padding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use chiquito::{
frontend::dsl::{circuit, trace::DSLTraceGenerator}, /* main function for constructing an AST
* circuit */
plonkish::{
backend::halo2::{halo2_verify, DummyRng, PlonkishHalo2},
backend::halo2::{halo2_verify, PlonkishHalo2},
compiler::{
cell_manager::SingleRowCellManager, // input for constructing the compiler
compile, // input for constructing the compiler
Expand All @@ -23,7 +23,6 @@ use chiquito::{
poly::ToField,
};
use halo2_proofs::halo2curves::bn256::Fr;
use rand_chacha::rand_core::block::BlockRng;

// This example file extends the rust example file 'fibonacci.rs',
// describing usage of multiple steptypes, padding, and exposing signals.
Expand Down Expand Up @@ -206,9 +205,9 @@ fn fibo_circuit<F: Field + From<u64> + Hash>(
// standard main function for a Halo2 circuit
fn main() {
let mut plonkish = fibo_circuit::<Fr>();
let rng = BlockRng::new(DummyRng {});
let params_path = "examples/ptau/hermez-raw-11";

let halo2_prover = plonkish.create_halo2_prover(rng);
let halo2_prover = plonkish.create_halo2_prover(params_path);
println!("k={}", halo2_prover.get_k());

let (proof, instance) =
Expand Down
7 changes: 3 additions & 4 deletions examples/fibonacci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use chiquito::{
* circuit */
plonkish::{
backend::{
halo2::{halo2_verify, DummyRng, PlonkishHalo2},
halo2::{halo2_verify, PlonkishHalo2},
hyperplonk::ChiquitoHyperPlonkCircuit,
},
compiler::{
Expand All @@ -27,7 +27,6 @@ use chiquito::{
sbpir::SBPIR,
};
use halo2_proofs::halo2curves::bn256::Fr;
use rand_chacha::rand_core::block::BlockRng;

// the main circuit function: returns the compiled IR of a Chiquito circuit
// Generic types F, (), (u64, 64) stand for:
Expand Down Expand Up @@ -134,9 +133,9 @@ fn fibo_circuit<F: Field + From<u64> + Hash>() -> FiboReturn<F> {
fn main() {
let (mut chiquito, _) = fibo_circuit::<Fr>();

let rng = BlockRng::new(DummyRng {});
let params_path = "examples/ptau/hermez-raw-11";

let halo2_prover = chiquito.create_halo2_prover(rng);
let halo2_prover = chiquito.create_halo2_prover(params_path);
println!("k={}", halo2_prover.get_k());

let (proof, instance) =
Expand Down
7 changes: 3 additions & 4 deletions examples/keccak.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use chiquito::{
lb::LookupTable, super_circuit, trace::DSLTraceGenerator, CircuitContext, StepTypeWGHandler,
},
plonkish::{
backend::halo2::{halo2_verify, DummyRng, PlonkishHalo2},
backend::halo2::{halo2_verify, PlonkishHalo2},
compiler::{
cell_manager::{MaxWidthCellManager, SingleRowCellManager},
config,
Expand All @@ -14,7 +14,6 @@ use chiquito::{
poly::ToExpr,
sbpir::query::Queriable,
};
use rand_chacha::rand_core::block::BlockRng;
use std::{hash::Hash, ops::Neg};

use halo2_proofs::halo2curves::{bn256::Fr, group::ff::PrimeField};
Expand Down Expand Up @@ -2254,11 +2253,11 @@ fn main() {

let mut super_circuit = keccak_super_circuit::<Fr>(circuit_param.bytes.len());

let rng = BlockRng::new(DummyRng {});
let params_path = "examples/ptau/hermez-raw-11";

let witness = super_circuit.get_mapping().generate(circuit_param);

let halo2_prover = super_circuit.create_halo2_prover(rng);
let halo2_prover = super_circuit.create_halo2_prover(params_path);
println!("k={}", halo2_prover.get_k());

let (proof, instance) = halo2_prover.generate_proof(witness);
Expand Down
7 changes: 3 additions & 4 deletions examples/mimc7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use halo2_proofs::halo2curves::{bn256::Fr, group::ff::PrimeField};
use chiquito::{
frontend::dsl::{lb::LookupTable, super_circuit, trace::DSLTraceGenerator, CircuitContext},
plonkish::{
backend::halo2::{halo2_verify, DummyRng, PlonkishHalo2},
backend::halo2::{halo2_verify, PlonkishHalo2},
compiler::{
cell_manager::SingleRowCellManager, config, step_selector::SimpleStepSelectorBuilder,
},
Expand All @@ -15,7 +15,6 @@ use chiquito::{
};

use mimc7_constants::ROUND_CONSTANTS;
use rand_chacha::rand_core::block::BlockRng;

// MiMC7 always has 91 rounds
pub const ROUNDS: usize = 91;
Expand Down Expand Up @@ -201,11 +200,11 @@ fn main() {

let mut super_circuit = mimc7_super_circuit::<Fr>();

let rng = BlockRng::new(DummyRng {});
let params_path = "examples/ptau/hermez-raw-11";

let witness = super_circuit.get_mapping().generate((x_in_value, k_value));

let halo2_prover = super_circuit.create_halo2_prover(rng);
let halo2_prover = super_circuit.create_halo2_prover(params_path);
println!("k={}", halo2_prover.get_k());

let (proof, instance) = halo2_prover.generate_proof(witness);
Expand Down
7 changes: 3 additions & 4 deletions examples/poseidon.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use chiquito::{
frontend::dsl::{lb::LookupTable, super_circuit, trace::DSLTraceGenerator, CircuitContext},
plonkish::{
backend::halo2::{halo2_verify, DummyRng, PlonkishHalo2},
backend::halo2::{halo2_verify, PlonkishHalo2},
compiler::{
cell_manager::{MaxWidthCellManager, SingleRowCellManager},
config,
Expand All @@ -11,7 +11,6 @@ use chiquito::{
},
sbpir::query::Queriable,
};
use rand_chacha::rand_core::block::BlockRng;

use std::hash::Hash;

Expand Down Expand Up @@ -704,9 +703,9 @@ fn main() {
let mut super_circuit = poseidon_super_circuit(lens);
let witness = super_circuit.get_mapping().generate(values);

let rng = BlockRng::new(DummyRng {});
let params_path = "examples/ptau/hermez-raw-11";

let halo2_prover = super_circuit.create_halo2_prover(rng);
let halo2_prover = super_circuit.create_halo2_prover(params_path);
println!("k={}", halo2_prover.get_k());

let (proof, instance) = halo2_prover.generate_proof(witness);
Expand Down
Binary file added examples/ptau/hermez-raw-11
Binary file not shown.
13 changes: 5 additions & 8 deletions src/frontend/python/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ use pyo3::{
prelude::*,
types::{PyDict, PyList, PyLong, PyString},
};
use rand_chacha::rand_core::block::BlockRng;

use crate::{
frontend::dsl::{StepTypeHandler, SuperCircuitContext},
pil::backend::powdr_pil::chiquito2Pil,
plonkish::{
backend::halo2::{chiquito2Halo2, halo2_verify, ChiquitoHalo2, DummyRng, PlonkishHalo2},
backend::halo2::{chiquito2Halo2, halo2_verify, ChiquitoHalo2, PlonkishHalo2},
compiler::{
cell_manager::SingleRowCellManager, compile, config,
step_selector::SimpleStepSelectorBuilder, PlonkishCompilationResult,
Expand Down Expand Up @@ -146,9 +145,8 @@ pub fn chiquito_super_circuit_halo2_mock_prover(

let super_assignments = mapping_ctx.get_super_assignments();

let rng = BlockRng::new(DummyRng {});

let halo2_prover = super_circuit.create_halo2_prover(rng);
let params_path = "examples/ptau/hermez-raw-11";
let halo2_prover = super_circuit.create_halo2_prover(params_path);

let (proof, instance) = halo2_prover.generate_proof(super_assignments);

Expand Down Expand Up @@ -182,14 +180,13 @@ pub fn chiquito_halo2_mock_prover(witness_json: &str, rust_id: UUID) {
serde_json::from_str(witness_json).expect("Json deserialization to TraceWitness failed.");
let (_, compiled, assignment_generator) = rust_id_to_halo2(rust_id);

let rng = BlockRng::new(DummyRng {});

let mut plonkish = PlonkishCompilationResult {
circuit: compiled.plonkish_ir,
assignment_generator,
};

let halo2_prover = plonkish.create_halo2_prover(rng);
let params_path = "examples/ptau/hermez-raw-11";
let halo2_prover = plonkish.create_halo2_prover(params_path);

let (proof, instance) = halo2_prover.generate_proof(
plonkish
Expand Down
12 changes: 3 additions & 9 deletions src/interpreter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,14 +323,13 @@ fn get_block_stmts(stmt: &Statement<BigInt, Identifier>) -> Vec<Statement<BigInt
mod test {
use crate::plonkish::backend::halo2::PlonkishHalo2;
use halo2_proofs::halo2curves::bn256::Fr;
use rand_chacha::rand_core::block::BlockRng;
use std::collections::HashMap;

use crate::{
compiler::{compile, Config},
parser::ast::debug_sym_factory::DebugSymRefFactory,
plonkish::{
backend::halo2::{halo2_verify, DummyRng},
backend::halo2::halo2_verify,
compiler::{
cell_manager::SingleRowCellManager, config,
step_selector::SimpleStepSelectorBuilder,
Expand Down Expand Up @@ -449,11 +448,8 @@ mod test {
SimpleStepSelectorBuilder {},
));

let rng = BlockRng::new(DummyRng {});

let halo2_prover = plonkish.create_halo2_prover(rng);
let halo2_prover = plonkish.create_test_prover();
assert!(halo2_prover.get_k() == 5);

let (proof, instance) = halo2_prover.generate_proof(
plonkish
.assignment_generator
Expand Down Expand Up @@ -530,9 +526,7 @@ mod test {
SimpleStepSelectorBuilder {},
));

let rng = BlockRng::new(DummyRng {});

let halo2_prover = plonkish.create_halo2_prover(rng);
let halo2_prover = plonkish.create_test_prover();
println!("k={}", halo2_prover.get_k());

let (proof, instance) = halo2_prover.generate_proof(
Expand Down
Loading
Loading