This commit is contained in:
wborgeaud 2021-07-15 10:24:11 +02:00
parent 2e12ee8e82
commit 7d41785ac6
5 changed files with 10 additions and 1 deletions

View File

@ -46,9 +46,11 @@ pub struct CircuitBuilder<F: Extendable<D>, const D: usize> {
copy_constraints: Vec<CopyConstraint>,
/// A context string used to give context to copy constraints.
context: String,
pub marked_targets: Vec<MarkedTargets<D>>,
/// A vector of marked targets. The values assigned to these targets will be displayed by the prover.
marked_targets: Vec<MarkedTargets<D>>,
/// Generators used to generate the witness.
generators: Vec<Box<dyn WitnessGenerator<F>>>,

View File

@ -130,6 +130,7 @@ pub(crate) struct ProverOnlyCircuitData<F: Extendable<D>, const D: usize> {
pub copy_constraints: Vec<CopyConstraint>,
/// The concrete placement of each gate in the circuit.
pub gate_instances: Vec<GateInstance<F, D>>,
/// A vector of marked targets. The values assigned to these targets will be displayed by the prover.
pub marked_targets: Vec<MarkedTargets<D>>,
}

View File

@ -1,5 +1,6 @@
use crate::target::Target;
/// A named copy constraint.
pub struct CopyConstraint {
pub pair: (Target, Target),
pub name: String,

View File

@ -41,6 +41,7 @@ pub(crate) fn prove<F: Extendable<D>, const D: usize>(
"to generate witness"
);
// Display the marked targets for debugging purposes.
for m in &prover_data.marked_targets {
m.display(&partial_witness);
}

View File

@ -7,6 +7,7 @@ use crate::proof::HashTarget;
use crate::target::Target;
use crate::witness::{PartialWitness, Witness};
/// Enum representing all types of targets, so that they can be marked.
#[derive(Clone)]
pub enum Markable<const D: usize> {
Target(Target),
@ -37,6 +38,7 @@ impl<M: Into<Markable<D>>, const D: usize> From<Vec<M>> for Markable<D> {
}
impl<const D: usize> Markable<D> {
/// Display a `Markable` by querying a partial witness.
fn print_markable<F: Extendable<D>>(&self, pw: &PartialWitness<F>) {
match self {
Markable::Target(t) => println!("{}", pw.get_target(*t)),
@ -47,6 +49,7 @@ impl<const D: usize> Markable<D> {
}
}
/// A named collection of targets.
#[derive(Clone)]
pub struct MarkedTargets<const D: usize> {
pub targets: Markable<D>,
@ -54,6 +57,7 @@ pub struct MarkedTargets<const D: usize> {
}
impl<const D: usize> MarkedTargets<D> {
/// Display the collection of targets along with its name by querying a partial witness.
pub fn display<F: Extendable<D>>(&self, pw: &PartialWitness<F>) {
println!("Values for {}:", self.name);
self.targets.print_markable(pw);