mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-02 13:53:07 +00:00
Tweaks
This commit is contained in:
parent
f42120482a
commit
44eeb505eb
@ -75,6 +75,7 @@ impl<F: Field> CircuitBuilder<F> {
|
||||
pub fn assert_equal(&mut self, x: Target, y: Target) {
|
||||
assert!(x.is_routable(self.config));
|
||||
assert!(y.is_routable(self.config));
|
||||
// TODO: Add to copy_constraints.
|
||||
}
|
||||
|
||||
pub fn add_generator<G: WitnessGenerator<F>>(&mut self, generator: G) {
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
use crate::constraint_polynomial::{EvaluationTargets, EvaluationVars};
|
||||
use crate::field::field::Field;
|
||||
use crate::gates::gate::GateRef;
|
||||
use crate::generator::WitnessGenerator;
|
||||
use crate::proof::{Hash, Proof2};
|
||||
use crate::proof::{Hash, Proof};
|
||||
use crate::prover::prove;
|
||||
use crate::target::Target;
|
||||
use crate::verifier::verify;
|
||||
use crate::witness::PartialWitness;
|
||||
use crate::gates::gate::{GateRef};
|
||||
use crate::constraint_polynomial::{EvaluationVars, EvaluationTargets};
|
||||
use crate::target::Target;
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct CircuitConfig {
|
||||
@ -44,7 +44,7 @@ pub struct CircuitData<F: Field> {
|
||||
}
|
||||
|
||||
impl<F: Field> CircuitData<F> {
|
||||
pub fn prove(&self, inputs: PartialWitness<F>) -> Proof2<F> {
|
||||
pub fn prove(&self, inputs: PartialWitness<F>) -> Proof<F> {
|
||||
prove(&self.prover_only, &self.common, inputs)
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ pub struct ProverCircuitData<F: Field> {
|
||||
}
|
||||
|
||||
impl<F: Field> ProverCircuitData<F> {
|
||||
pub fn prove(&self, inputs: PartialWitness<F>) -> Proof2<F> {
|
||||
pub fn prove(&self, inputs: PartialWitness<F>) -> Proof<F> {
|
||||
prove(&self.prover_only, &self.common, inputs)
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ pub struct HashTarget {
|
||||
elements: Vec<Target>,
|
||||
}
|
||||
|
||||
pub struct Proof2<F: Field> {
|
||||
pub struct Proof<F: Field> {
|
||||
/// Merkle root of LDEs of wire values.
|
||||
pub wires_root: Hash<F>,
|
||||
/// Merkle root of LDEs of Z, in the context of Plonk's permutation argument.
|
||||
@ -35,7 +35,7 @@ pub struct Proof2<F: Field> {
|
||||
// TODO: FRI Merkle proofs.
|
||||
}
|
||||
|
||||
pub struct ProofTarget2 {
|
||||
pub struct ProofTarget {
|
||||
/// Merkle root of LDEs of wire values.
|
||||
pub wires_root: HashTarget,
|
||||
/// Merkle root of LDEs of Z, in the context of Plonk's permutation argument.
|
||||
|
||||
@ -11,7 +11,7 @@ use crate::field::field::Field;
|
||||
use crate::generator::generate_partial_witness;
|
||||
use crate::hash::{compress, hash_n_to_hash, hash_n_to_m, hash_or_noop, merkle_root_bit_rev_order};
|
||||
use crate::plonk_common::reduce_with_powers;
|
||||
use crate::proof::{Hash, Proof2};
|
||||
use crate::proof::{Hash, Proof};
|
||||
use crate::util::{log2_ceil, reverse_index_bits, transpose};
|
||||
use crate::wire::Wire;
|
||||
use crate::witness::PartialWitness;
|
||||
@ -20,7 +20,7 @@ pub(crate) fn prove<F: Field>(
|
||||
prover_data: &ProverOnlyCircuitData<F>,
|
||||
common_data: &CommonCircuitData<F>,
|
||||
inputs: PartialWitness<F>,
|
||||
) -> Proof2<F> {
|
||||
) -> Proof<F> {
|
||||
let mut witness = inputs;
|
||||
let start_witness = Instant::now();
|
||||
info!("Running {} generators", prover_data.generators.len());
|
||||
@ -31,16 +31,21 @@ pub(crate) fn prove<F: Field>(
|
||||
let num_wires = config.num_wires;
|
||||
|
||||
let start_wire_ldes = Instant::now();
|
||||
// TODO: Simplify using lde_multiple.
|
||||
// TODO: Parallelize.
|
||||
let degree = common_data.degree();
|
||||
let wire_ldes = (0..num_wires)
|
||||
.map(|i| compute_wire_lde(i, &witness, common_data.degree(), config.rate_bits))
|
||||
.into_par_iter()
|
||||
.map(|i| compute_wire_lde(i, &witness, degree, config.rate_bits))
|
||||
.collect::<Vec<_>>();
|
||||
info!("Computing wire LDEs took {}s", start_wire_ldes.elapsed().as_secs_f32());
|
||||
|
||||
let start_wires_root = Instant::now();
|
||||
// TODO: Could try parallelizing the transpose, or not doing it explicitly, instead having
|
||||
// merkle_root_bit_rev_order do it implicitly.
|
||||
let start_wire_transpose = Instant::now();
|
||||
let wire_ldes_t = transpose(&wire_ldes);
|
||||
info!("Transposing wire LDEs took {}s", start_wire_transpose.elapsed().as_secs_f32());
|
||||
|
||||
// TODO: Could avoid cloning if it's significant?
|
||||
let start_wires_root = Instant::now();
|
||||
let wires_root = merkle_root_bit_rev_order(wire_ldes_t.clone());
|
||||
info!("Merklizing wire LDEs took {}s", start_wires_root.elapsed().as_secs_f32());
|
||||
|
||||
@ -64,7 +69,7 @@ pub(crate) fn prove<F: Field>(
|
||||
|
||||
let openings = todo!();
|
||||
|
||||
Proof2 {
|
||||
Proof {
|
||||
wires_root,
|
||||
plonk_z_root,
|
||||
plonk_t_root,
|
||||
|
||||
@ -2,7 +2,7 @@ use crate::circuit_builder::CircuitBuilder;
|
||||
use crate::field::field::Field;
|
||||
|
||||
const MIN_WIRES: usize = 120; // TODO: Double check.
|
||||
const MIN_ROUTED_WIRES: usize = 12; // TODO: Double check.
|
||||
const MIN_ROUTED_WIRES: usize = 8; // TODO: Double check.
|
||||
|
||||
pub fn add_recursive_verifier<F: Field>(builder: &mut CircuitBuilder<F>) {
|
||||
assert!(builder.config.num_wires >= MIN_WIRES);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user