mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-07 00:03:10 +00:00
Rollback to previous semantics
This commit is contained in:
parent
c22bc6261e
commit
3bc27c65ef
@ -236,7 +236,7 @@ impl<F: Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn sigma_vecs(&self, k_is: &[F]) -> (Vec<PolynomialValues<F>>, TargetPartitions) {
|
||||
fn sigma_vecs(&self, k_is: &[F]) -> Vec<PolynomialValues<F>> {
|
||||
let degree = self.gate_instances.len();
|
||||
let degree_log = log2_strict(degree);
|
||||
let mut target_partitions = TargetPartitions::new();
|
||||
@ -257,10 +257,7 @@ impl<F: Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
|
||||
let wire_partitions = target_partitions.to_wire_partitions();
|
||||
|
||||
(
|
||||
wire_partitions.get_sigma_polys(degree_log, k_is),
|
||||
target_partitions,
|
||||
)
|
||||
wire_partitions.get_sigma_polys(degree_log, k_is)
|
||||
}
|
||||
|
||||
/// Builds a "full circuit", with both prover and verifier data.
|
||||
@ -282,7 +279,7 @@ impl<F: Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
);
|
||||
|
||||
let k_is = get_unique_coset_shifts(degree, self.config.num_routed_wires);
|
||||
let (sigma_vecs, targets_partition) = self.sigma_vecs(&k_is);
|
||||
let sigma_vecs = self.sigma_vecs(&k_is);
|
||||
let sigmas_commitment = ListPolynomialCommitment::new(
|
||||
sigma_vecs.into_iter().map(|v| v.ifft()).collect(),
|
||||
self.config.fri_config.rate_bits,
|
||||
@ -301,7 +298,6 @@ impl<F: Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
generators,
|
||||
constants_commitment,
|
||||
sigmas_commitment,
|
||||
targets_partition,
|
||||
};
|
||||
|
||||
// The HashSet of gates will have a non-deterministic order. When converting to a Vec, we
|
||||
|
||||
@ -5,7 +5,6 @@ use crate::field::field::Field;
|
||||
use crate::fri::FriConfig;
|
||||
use crate::gates::gate::GateRef;
|
||||
use crate::generator::WitnessGenerator;
|
||||
use crate::permutation_argument::TargetPartitions;
|
||||
use crate::polynomial::commitment::ListPolynomialCommitment;
|
||||
use crate::proof::{Hash, HashTarget, Proof};
|
||||
use crate::prover::prove;
|
||||
@ -105,8 +104,6 @@ pub(crate) struct ProverOnlyCircuitData<F: Field> {
|
||||
pub constants_commitment: ListPolynomialCommitment<F>,
|
||||
/// Commitments to the sigma polynomial.
|
||||
pub sigmas_commitment: ListPolynomialCommitment<F>,
|
||||
/// Partition of the targets into copy-constrained sets.
|
||||
pub targets_partition: TargetPartitions,
|
||||
}
|
||||
|
||||
/// Circuit data required by the verifier, but not the prover.
|
||||
|
||||
@ -370,13 +370,7 @@ mod tests {
|
||||
}
|
||||
|
||||
let generators = gate.0.generators(0, &[]);
|
||||
let mut tp = TargetPartitions::new();
|
||||
for g in 0..10 {
|
||||
for i in 0..config.num_routed_wires {
|
||||
tp.add_partition(Target::wire(g, i));
|
||||
}
|
||||
}
|
||||
generate_partial_witness(&mut witness, &generators, &tp);
|
||||
generate_partial_witness(&mut witness, &generators);
|
||||
|
||||
let expected_outputs: [F; W] =
|
||||
gmimc_permute_naive(permutation_inputs.try_into().unwrap(), constants);
|
||||
|
||||
@ -11,7 +11,6 @@ use crate::witness::PartialWitness;
|
||||
pub(crate) fn generate_partial_witness<F: Field>(
|
||||
witness: &mut PartialWitness<F>,
|
||||
generators: &[Box<dyn WitnessGenerator<F>>],
|
||||
target_partition: &TargetPartitions,
|
||||
) {
|
||||
// Index generator indices by their watched targets.
|
||||
let mut generator_indices_by_watches = HashMap::new();
|
||||
@ -20,12 +19,10 @@ pub(crate) fn generate_partial_witness<F: Field>(
|
||||
generator_indices_by_watches
|
||||
.entry(watch)
|
||||
.or_insert_with(Vec::new)
|
||||
.push(i)
|
||||
.push(i);
|
||||
}
|
||||
}
|
||||
|
||||
target_partition.generate_copies(witness, &witness.all_populated_targets());
|
||||
|
||||
// Build a list of "pending" generators which are queued to be run. Initially, all generators
|
||||
// are queued.
|
||||
let mut pending_generator_indices: HashSet<_> = (0..generators.len()).collect();
|
||||
@ -38,14 +35,11 @@ pub(crate) fn generate_partial_witness<F: Field>(
|
||||
let mut next_pending_generator_indices = HashSet::new();
|
||||
|
||||
for &generator_idx in &pending_generator_indices {
|
||||
let (mut result, finished) = generators[generator_idx].run(&witness);
|
||||
let (result, finished) = generators[generator_idx].run(&witness);
|
||||
if finished {
|
||||
expired_generator_indices.insert(generator_idx);
|
||||
}
|
||||
|
||||
let new_targets = result.all_populated_targets();
|
||||
target_partition.generate_copies(&mut result, &new_targets);
|
||||
|
||||
// Enqueue unfinished generators that were watching one of the newly populated targets.
|
||||
for watch in result.target_values.keys() {
|
||||
if let Some(watching_generator_indices) = generator_indices_by_watches.get(watch) {
|
||||
|
||||
@ -6,7 +6,6 @@ use crate::field::field::Field;
|
||||
use crate::polynomial::polynomial::PolynomialValues;
|
||||
use crate::target::Target;
|
||||
use crate::wire::Wire;
|
||||
use crate::witness::PartialWitness;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TargetPartitions {
|
||||
@ -83,26 +82,6 @@ impl TargetPartitions {
|
||||
indices,
|
||||
}
|
||||
}
|
||||
/// For the given set of targets, find any copy constraints involving those targets and populate
|
||||
/// the witness with copies as needed.
|
||||
pub fn generate_copies<F: Field>(&self, witness: &mut PartialWitness<F>, targets: &[Target]) {
|
||||
let mut result = PartialWitness::new();
|
||||
|
||||
for &target in targets {
|
||||
let value = witness.get_target(target);
|
||||
let partition = self.get_partition(target);
|
||||
|
||||
for &sibling in partition {
|
||||
if witness.contains(sibling) {
|
||||
// This sibling's value was already set; make sure it has the same value.
|
||||
assert_eq!(witness.get_target(sibling), value);
|
||||
} else {
|
||||
result.set_target(sibling, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
witness.extend(result);
|
||||
}
|
||||
}
|
||||
|
||||
pub struct WirePartitions {
|
||||
|
||||
@ -352,11 +352,7 @@ mod tests {
|
||||
}
|
||||
let circuit = builder.build();
|
||||
let mut witness = PartialWitness::new();
|
||||
generate_partial_witness(
|
||||
&mut witness,
|
||||
&circuit.prover_only.generators,
|
||||
&circuit.prover_only.targets_partition,
|
||||
);
|
||||
generate_partial_witness(&mut witness, &circuit.prover_only.generators);
|
||||
let recursive_output_values_per_round: Vec<Vec<F>> = recursive_outputs_per_round
|
||||
.iter()
|
||||
.map(|outputs| witness.get_targets(outputs))
|
||||
|
||||
@ -34,11 +34,7 @@ pub(crate) fn prove<F: Extendable<D>, const D: usize>(
|
||||
let mut witness = inputs;
|
||||
info!("Running {} generators", prover_data.generators.len());
|
||||
timed!(
|
||||
generate_partial_witness(
|
||||
&mut witness,
|
||||
&prover_data.generators,
|
||||
&prover_data.targets_partition
|
||||
),
|
||||
generate_partial_witness(&mut witness, &prover_data.generators,),
|
||||
"to generate witness"
|
||||
);
|
||||
|
||||
|
||||
@ -59,10 +59,6 @@ impl<F: Field> PartialWitness<F> {
|
||||
targets.iter().all(|&t| self.contains(t))
|
||||
}
|
||||
|
||||
pub fn all_populated_targets(&self) -> Vec<Target> {
|
||||
self.target_values.keys().cloned().collect()
|
||||
}
|
||||
|
||||
pub fn set_target(&mut self, target: Target, value: F) {
|
||||
let opt_old_value = self.target_values.insert(target, value);
|
||||
if let Some(old_value) = opt_old_value {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user