mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-03 22:33:06 +00:00
Comments etc
This commit is contained in:
parent
9b158103d2
commit
524005579d
@ -1,12 +1,12 @@
|
||||
use crate::circuit_builder::CircuitBuilder;
|
||||
use crate::field::field::Field;
|
||||
use crate::gates::gate::GateRef;
|
||||
use crate::generator::WitnessGenerator;
|
||||
use crate::proof::{Hash, Proof};
|
||||
use crate::proof::{Hash, Proof, HashTarget};
|
||||
use crate::prover::prove;
|
||||
use crate::target::Target;
|
||||
use crate::verifier::verify;
|
||||
use crate::witness::PartialWitness;
|
||||
use crate::circuit_builder::CircuitBuilder;
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct CircuitConfig {
|
||||
@ -53,7 +53,13 @@ impl<F: Field> CircuitData<F> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Circuit data required by the prover.
|
||||
/// Circuit data required by the prover. This may be thought of as a proving key, although it
|
||||
/// includes code for witness generation.
|
||||
///
|
||||
/// The goal here is to make proof generation as fast as we can, rather than making this prover
|
||||
/// structure as succinct as we can. Thus we include various precomputed data which isn't strictly
|
||||
/// required, like LDEs of preprocessed polynomials. If more succinctness was desired, we could
|
||||
/// construct a more minimal prover structure and convert back and forth.
|
||||
pub struct ProverCircuitData<F: Field> {
|
||||
pub(crate) prover_only: ProverOnlyCircuitData<F>,
|
||||
pub(crate) common: CommonCircuitData<F>,
|
||||
@ -139,3 +145,15 @@ impl<F: Field> CommonCircuitData<F> {
|
||||
self.config.num_checks * 2 + self.num_gate_constraints
|
||||
}
|
||||
}
|
||||
|
||||
/// The `Target` version of `VerifierCircuitData`, for use inside recursive circuits. Note that this
|
||||
/// is intentionally missing certain fields, such as `CircuitConfig`, because we support only a
|
||||
/// limited form of dynamic inner circuits. We can't practically make things like the wire count
|
||||
/// dynamic, at least not without setting a maximum wire count and paying for the worst case.
|
||||
pub(crate) struct VerifierCircuitTarget {
|
||||
/// A commitment to each constant polynomial.
|
||||
pub(crate) constants_root: HashTarget,
|
||||
|
||||
/// A commitment to each permutation polynomial.
|
||||
pub(crate) sigmas_root: HashTarget,
|
||||
}
|
||||
|
||||
@ -4,6 +4,11 @@ use crate::target::Target;
|
||||
use crate::vars::{EvaluationTargets, EvaluationVars};
|
||||
use crate::gates::gate::GateRef;
|
||||
|
||||
/// Evaluates all gate constraints.
|
||||
///
|
||||
/// `num_gate_constraints` is the largest number of constraints imposed by any gate. It is not
|
||||
/// strictly necessary, but it helps performance by ensuring that we allocate a vector with exactly
|
||||
/// the capacity that we need.
|
||||
pub fn evaluate_gate_constraints<F: Field>(
|
||||
gates: &[GateRef<F>],
|
||||
num_gate_constraints: usize,
|
||||
|
||||
@ -1,10 +1,20 @@
|
||||
use crate::circuit_builder::CircuitBuilder;
|
||||
use crate::circuit_data::{CircuitConfig, VerifierCircuitTarget};
|
||||
use crate::field::field::Field;
|
||||
use crate::gates::gate::GateRef;
|
||||
use crate::proof::ProofTarget;
|
||||
|
||||
const MIN_WIRES: usize = 120; // TODO: Double check.
|
||||
const MIN_ROUTED_WIRES: usize = 8; // TODO: Double check.
|
||||
|
||||
pub fn add_recursive_verifier<F: Field>(builder: &mut CircuitBuilder<F>) {
|
||||
/// Recursively verifies an inner proof.
|
||||
pub fn add_recursive_verifier<F: Field>(
|
||||
builder: &mut CircuitBuilder<F>,
|
||||
inner_config: CircuitConfig,
|
||||
inner_circuit: VerifierCircuitTarget,
|
||||
inner_gates: Vec<GateRef<F>>,
|
||||
inner_proof: ProofTarget,
|
||||
) {
|
||||
assert!(builder.config.num_wires >= MIN_WIRES);
|
||||
assert!(builder.config.num_wires >= MIN_ROUTED_WIRES);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user