mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-03 14:23:07 +00:00
Rollback
This commit is contained in:
parent
185d8faef6
commit
7cf3220439
@ -415,7 +415,6 @@ mod tests {
|
||||
_phantom: PhantomData,
|
||||
};
|
||||
let vars = EvaluationVars {
|
||||
selector_index: usize::MAX,
|
||||
local_constants: &[],
|
||||
local_wires: &get_wires(orig_vec, insertion_index, element_to_insert),
|
||||
public_inputs_hash: &HashOut::rand(),
|
||||
|
||||
@ -613,20 +613,16 @@ mod tests {
|
||||
type FF = <C as GenericConfig<D>>::FE;
|
||||
|
||||
let config = CircuitConfig::standard_recursion_zk_config();
|
||||
let config = CircuitConfig::standard_recursion_config();
|
||||
|
||||
let mut pw = PartialWitness::new();
|
||||
let pw = PartialWitness::new();
|
||||
let mut builder = CircuitBuilder::<F, D>::new(config);
|
||||
|
||||
let x = FF::rand();
|
||||
let y = FF::rand();
|
||||
let z = x / y;
|
||||
let xt = builder.add_virtual_extension_target();
|
||||
pw.set_extension_target(xt, x);
|
||||
let yt = builder.add_virtual_extension_target();
|
||||
pw.set_extension_target(yt, y);
|
||||
let zt = builder.add_virtual_extension_target();
|
||||
pw.set_extension_target(zt, z);
|
||||
let xt = builder.constant_extension(x);
|
||||
let yt = builder.constant_extension(y);
|
||||
let zt = builder.constant_extension(z);
|
||||
let comp_zt = builder.div_extension(xt, yt);
|
||||
builder.connect_extension(zt, comp_zt);
|
||||
|
||||
@ -639,7 +635,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_mul_algebra() -> Result<()> {
|
||||
const D: usize = 2;
|
||||
type C = PoseidonGoldilocksConfig;
|
||||
type C = KeccakGoldilocksConfig;
|
||||
type F = <C as GenericConfig<D>>::F;
|
||||
type FF = <C as GenericConfig<D>>::FE;
|
||||
|
||||
@ -654,15 +650,14 @@ mod tests {
|
||||
ExtensionAlgebraTarget(builder.add_virtual_extension_targets(D).try_into().unwrap());
|
||||
let zt =
|
||||
ExtensionAlgebraTarget(builder.add_virtual_extension_targets(D).try_into().unwrap());
|
||||
// let comp_zt = builder.mul_ext_algebra(xt, yt);
|
||||
let comp_zt = builder.add_ext_algebra(xt, yt);
|
||||
let comp_zt = builder.mul_ext_algebra(xt, yt);
|
||||
for i in 0..D {
|
||||
builder.connect_extension(zt.0[i], comp_zt.0[i]);
|
||||
}
|
||||
|
||||
let x = ExtensionAlgebra::<FF, D>(FF::rand_arr());
|
||||
let y = ExtensionAlgebra::<FF, D>(FF::rand_arr());
|
||||
let z = x + y;
|
||||
let z = x * y;
|
||||
for i in 0..D {
|
||||
pw.set_extension_target(xt.0[i], x.0[i]);
|
||||
pw.set_extension_target(yt.0[i], y.0[i]);
|
||||
@ -674,34 +669,4 @@ mod tests {
|
||||
|
||||
verify(proof, &data.verifier_only, &data.common)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_yo() -> Result<()> {
|
||||
const D: usize = 2;
|
||||
type C = PoseidonGoldilocksConfig;
|
||||
type F = <C as GenericConfig<D>>::F;
|
||||
type FF = <C as GenericConfig<D>>::FE;
|
||||
|
||||
let config = CircuitConfig::standard_recursion_config();
|
||||
|
||||
let mut pw = PartialWitness::new();
|
||||
let mut builder = CircuitBuilder::<F, D>::new(config);
|
||||
|
||||
let xt = builder.add_virtual_extension_target();
|
||||
let yt = builder.add_virtual_extension_target();
|
||||
let zt = builder.add_virtual_extension_target();
|
||||
let comp_zt = builder.mul_extension(xt, yt);
|
||||
builder.connect_extension(zt, comp_zt);
|
||||
|
||||
let x = FF::rand();
|
||||
let y = FF::rand();
|
||||
let z = x * y;
|
||||
pw.set_extension_target(xt, x);
|
||||
pw.set_extension_target(yt, y);
|
||||
|
||||
let data = builder.build::<C>();
|
||||
let proof = data.prove(pw)?;
|
||||
|
||||
verify(proof, &data.verifier_only, &data.common)
|
||||
}
|
||||
}
|
||||
|
||||
@ -448,7 +448,6 @@ mod tests {
|
||||
};
|
||||
|
||||
let vars = EvaluationVars {
|
||||
selector_index: usize::MAX,
|
||||
local_constants: &[],
|
||||
local_wires: &get_wires(addends, carries),
|
||||
public_inputs_hash: &HashOut::rand(),
|
||||
|
||||
@ -57,8 +57,8 @@ impl<F: RichField + Extendable<D>, const D: usize> Gate<F, D> for ArithmeticGate
|
||||
}
|
||||
|
||||
fn eval_unfiltered(&self, vars: EvaluationVars<F, D>) -> Vec<F::Extension> {
|
||||
let const_0 = vars.get_constant(0);
|
||||
let const_1 = vars.get_constant(1);
|
||||
let const_0 = vars.local_constants[0];
|
||||
let const_1 = vars.local_constants[1];
|
||||
|
||||
let mut constraints = Vec::new();
|
||||
for i in 0..self.num_ops {
|
||||
@ -91,8 +91,8 @@ impl<F: RichField + Extendable<D>, const D: usize> Gate<F, D> for ArithmeticGate
|
||||
builder: &mut CircuitBuilder<F, D>,
|
||||
vars: EvaluationTargets<D>,
|
||||
) -> Vec<ExtensionTarget<D>> {
|
||||
let const_0 = vars.get_constant(0);
|
||||
let const_1 = vars.get_constant(1);
|
||||
let const_0 = vars.local_constants[0];
|
||||
let const_1 = vars.local_constants[1];
|
||||
|
||||
let mut constraints = Vec::new();
|
||||
for i in 0..self.num_ops {
|
||||
@ -157,8 +157,8 @@ impl<F: RichField + Extendable<D>, const D: usize> PackedEvaluableBase<F, D> for
|
||||
vars: EvaluationVarsBasePacked<P>,
|
||||
mut yield_constr: StridedConstraintConsumer<P>,
|
||||
) {
|
||||
let const_0 = vars.get_constant(0);
|
||||
let const_1 = vars.get_constant(1);
|
||||
let const_0 = vars.local_constants[0];
|
||||
let const_1 = vars.local_constants[1];
|
||||
|
||||
for i in 0..self.num_ops {
|
||||
let multiplicand_0 = vars.local_wires[Self::wire_ith_multiplicand_0(i)];
|
||||
|
||||
@ -55,8 +55,8 @@ impl<F: RichField + Extendable<D>, const D: usize> Gate<F, D> for ArithmeticExte
|
||||
}
|
||||
|
||||
fn eval_unfiltered(&self, vars: EvaluationVars<F, D>) -> Vec<F::Extension> {
|
||||
let const_0 = vars.get_constant(0);
|
||||
let const_1 = vars.get_constant(1);
|
||||
let const_0 = vars.local_constants[0];
|
||||
let const_1 = vars.local_constants[1];
|
||||
|
||||
let mut constraints = Vec::new();
|
||||
for i in 0..self.num_ops {
|
||||
@ -78,8 +78,8 @@ impl<F: RichField + Extendable<D>, const D: usize> Gate<F, D> for ArithmeticExte
|
||||
vars: EvaluationVarsBase<F>,
|
||||
mut yield_constr: StridedConstraintConsumer<F>,
|
||||
) {
|
||||
let const_0 = vars.get_constant(0);
|
||||
let const_1 = vars.get_constant(1);
|
||||
let const_0 = vars.local_constants[0];
|
||||
let const_1 = vars.local_constants[1];
|
||||
|
||||
for i in 0..self.num_ops {
|
||||
let multiplicand_0 = vars.get_local_ext(Self::wires_ith_multiplicand_0(i));
|
||||
@ -98,8 +98,8 @@ impl<F: RichField + Extendable<D>, const D: usize> Gate<F, D> for ArithmeticExte
|
||||
builder: &mut CircuitBuilder<F, D>,
|
||||
vars: EvaluationTargets<D>,
|
||||
) -> Vec<ExtensionTarget<D>> {
|
||||
let const_0 = vars.get_constant(0);
|
||||
let const_1 = vars.get_constant(1);
|
||||
let const_0 = vars.local_constants[0];
|
||||
let const_1 = vars.local_constants[1];
|
||||
|
||||
let mut constraints = Vec::new();
|
||||
for i in 0..self.num_ops {
|
||||
|
||||
@ -445,7 +445,6 @@ mod tests {
|
||||
};
|
||||
|
||||
let vars = EvaluationVars {
|
||||
selector_index: usize::MAX,
|
||||
local_constants: &[],
|
||||
local_wires: &get_wires(multiplicands_0, multiplicands_1, addends),
|
||||
public_inputs_hash: &HashOut::rand(),
|
||||
|
||||
@ -602,7 +602,6 @@ mod tests {
|
||||
_phantom: PhantomData,
|
||||
};
|
||||
let less_than_vars = EvaluationVars {
|
||||
selector_index: usize::MAX,
|
||||
local_constants: &[],
|
||||
local_wires: &get_wires(first_input, second_input),
|
||||
public_inputs_hash: &HashOut::rand(),
|
||||
@ -621,7 +620,6 @@ mod tests {
|
||||
_phantom: PhantomData,
|
||||
};
|
||||
let equal_vars = EvaluationVars {
|
||||
selector_index: usize::MAX,
|
||||
local_constants: &[],
|
||||
local_wires: &get_wires(first_input, first_input),
|
||||
public_inputs_hash: &HashOut::rand(),
|
||||
|
||||
@ -682,7 +682,6 @@ mod tests {
|
||||
_phantom: PhantomData,
|
||||
};
|
||||
let less_than_vars = EvaluationVars {
|
||||
selector_index: usize::MAX,
|
||||
local_constants: &[],
|
||||
local_wires: &get_wires(first_input, second_input),
|
||||
public_inputs_hash: &HashOut::rand(),
|
||||
@ -701,7 +700,6 @@ mod tests {
|
||||
_phantom: PhantomData,
|
||||
};
|
||||
let equal_vars = EvaluationVars {
|
||||
selector_index: usize::MAX,
|
||||
local_constants: &[],
|
||||
local_wires: &get_wires(first_input, first_input),
|
||||
public_inputs_hash: &HashOut::rand(),
|
||||
|
||||
@ -42,7 +42,9 @@ impl<F: RichField + Extendable<D>, const D: usize> Gate<F, D> for ConstantGate {
|
||||
|
||||
fn eval_unfiltered(&self, vars: EvaluationVars<F, D>) -> Vec<F::Extension> {
|
||||
(0..self.num_consts)
|
||||
.map(|i| vars.get_constant(self.const_input(i)) - vars.local_wires[self.wire_output(i)])
|
||||
.map(|i| {
|
||||
vars.local_constants[self.const_input(i)] - vars.local_wires[self.wire_output(i)]
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
@ -66,7 +68,7 @@ impl<F: RichField + Extendable<D>, const D: usize> Gate<F, D> for ConstantGate {
|
||||
(0..self.num_consts)
|
||||
.map(|i| {
|
||||
builder.sub_extension(
|
||||
vars.get_constant(self.const_input(i)),
|
||||
vars.local_constants[self.const_input(i)],
|
||||
vars.local_wires[self.wire_output(i)],
|
||||
)
|
||||
})
|
||||
|
||||
@ -394,7 +394,6 @@ mod tests {
|
||||
};
|
||||
|
||||
let vars = EvaluationVars {
|
||||
selector_index: usize::MAX,
|
||||
local_constants: &[],
|
||||
local_wires: &get_wires(base, power as u64),
|
||||
public_inputs_hash: &HashOut::rand(),
|
||||
|
||||
@ -50,7 +50,6 @@ pub trait Gate<F: RichField + Extendable<D>, const D: usize>: 'static + Send + S
|
||||
.collect::<Vec<_>>();
|
||||
let public_inputs_hash = &vars_base.public_inputs_hash;
|
||||
let vars = EvaluationVars {
|
||||
selector_index: vars_base.selector_index,
|
||||
local_constants,
|
||||
local_wires,
|
||||
public_inputs_hash,
|
||||
@ -93,7 +92,7 @@ pub trait Gate<F: RichField + Extendable<D>, const D: usize>: 'static + Send + S
|
||||
combination_range,
|
||||
vars.local_constants[selector_index],
|
||||
);
|
||||
vars.selector_index = selector_index;
|
||||
vars.remove_prefix(prefix);
|
||||
self.eval_unfiltered(vars)
|
||||
.into_iter()
|
||||
.map(|c| filter * c)
|
||||
@ -119,7 +118,7 @@ pub trait Gate<F: RichField + Extendable<D>, const D: usize>: 'static + Send + S
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
vars_batch.selector_index = selector_index;
|
||||
vars_batch.remove_prefix(prefix);
|
||||
let mut res_batch = self.eval_unfiltered_base_batch(vars_batch);
|
||||
for res_chunk in res_batch.chunks_exact_mut(filters.len()) {
|
||||
batch_multiply_inplace(res_chunk, &filters);
|
||||
@ -142,7 +141,7 @@ pub trait Gate<F: RichField + Extendable<D>, const D: usize>: 'static + Send + S
|
||||
combination_range,
|
||||
vars.local_constants[selector_index],
|
||||
);
|
||||
vars.selector_index = selector_index;
|
||||
vars.remove_prefix(prefix);
|
||||
let my_constraints = self.eval_unfiltered_recursively(builder, vars);
|
||||
for (acc, c) in combined_gate_constraints.iter_mut().zip(my_constraints) {
|
||||
*acc = builder.mul_add_extension(filter, c, *acc);
|
||||
|
||||
@ -32,7 +32,6 @@ pub fn test_low_degree<F: RichField + Extendable<D>, G: Gate<F, D>, const D: usi
|
||||
.iter()
|
||||
.zip(constant_ldes.iter())
|
||||
.map(|(local_wires, local_constants)| EvaluationVars {
|
||||
selector_index: usize::MAX,
|
||||
local_constants,
|
||||
local_wires,
|
||||
public_inputs_hash,
|
||||
@ -111,15 +110,9 @@ where
|
||||
let public_inputs_hash = HashOut::rand();
|
||||
|
||||
// Batch of 1.
|
||||
let vars_base_batch = EvaluationVarsBaseBatch::new(
|
||||
usize::MAX,
|
||||
1,
|
||||
&constants_base,
|
||||
&wires_base,
|
||||
&public_inputs_hash,
|
||||
);
|
||||
let vars_base_batch =
|
||||
EvaluationVarsBaseBatch::new(1, &constants_base, &wires_base, &public_inputs_hash);
|
||||
let vars = EvaluationVars {
|
||||
selector_index: usize::MAX,
|
||||
local_constants: &constants,
|
||||
local_wires: &wires,
|
||||
public_inputs_hash: &public_inputs_hash,
|
||||
@ -152,7 +145,6 @@ where
|
||||
pw.set_hash_target(public_inputs_hash_t, public_inputs_hash);
|
||||
|
||||
let vars = EvaluationVars {
|
||||
selector_index: usize::MAX,
|
||||
local_constants: &constants,
|
||||
local_wires: &wires,
|
||||
public_inputs_hash: &public_inputs_hash,
|
||||
@ -160,7 +152,6 @@ where
|
||||
let evals = gate.eval_unfiltered(vars);
|
||||
|
||||
let vars_t = EvaluationTargets {
|
||||
selector_index: usize::MAX,
|
||||
local_constants: &constants_t,
|
||||
local_wires: &wires_t,
|
||||
public_inputs_hash: &public_inputs_hash_t,
|
||||
|
||||
@ -352,7 +352,6 @@ mod tests {
|
||||
let eval_point = FF::rand();
|
||||
let gate = HighDegreeInterpolationGate::<F, D>::new(1);
|
||||
let vars = EvaluationVars {
|
||||
selector_index: usize::MAX,
|
||||
local_constants: &[],
|
||||
local_wires: &get_wires(&gate, shift, coeffs, eval_point),
|
||||
public_inputs_hash: &HashOut::rand(),
|
||||
|
||||
@ -453,7 +453,6 @@ mod tests {
|
||||
let eval_point = FF::rand();
|
||||
let gate = LowDegreeInterpolationGate::<F, D>::new(subgroup_bits);
|
||||
let vars = EvaluationVars {
|
||||
selector_index: usize::MAX,
|
||||
local_constants: &[],
|
||||
local_wires: &get_wires(&gate, shift, coeffs, eval_point),
|
||||
public_inputs_hash: &HashOut::rand(),
|
||||
|
||||
@ -52,7 +52,7 @@ impl<F: RichField + Extendable<D>, const D: usize> Gate<F, D> for MulExtensionGa
|
||||
}
|
||||
|
||||
fn eval_unfiltered(&self, vars: EvaluationVars<F, D>) -> Vec<F::Extension> {
|
||||
let const_0 = vars.get_constant(0);
|
||||
let const_0 = vars.local_constants[0];
|
||||
|
||||
let mut constraints = Vec::new();
|
||||
for i in 0..self.num_ops {
|
||||
@ -89,7 +89,7 @@ impl<F: RichField + Extendable<D>, const D: usize> Gate<F, D> for MulExtensionGa
|
||||
builder: &mut CircuitBuilder<F, D>,
|
||||
vars: EvaluationTargets<D>,
|
||||
) -> Vec<ExtensionTarget<D>> {
|
||||
let const_0 = vars.get_constant(0);
|
||||
let const_0 = vars.local_constants[0];
|
||||
|
||||
let mut constraints = Vec::new();
|
||||
for i in 0..self.num_ops {
|
||||
|
||||
@ -413,7 +413,6 @@ mod tests {
|
||||
.map(|(l, &i)| l[i])
|
||||
.collect();
|
||||
let good_vars = EvaluationVars {
|
||||
selector_index: usize::MAX,
|
||||
local_constants: &[],
|
||||
local_wires: &get_wires(
|
||||
bits,
|
||||
@ -425,7 +424,6 @@ mod tests {
|
||||
};
|
||||
let bad_claimed_elements = F::rand_vec(4);
|
||||
let bad_vars = EvaluationVars {
|
||||
selector_index: usize::MAX,
|
||||
local_constants: &[],
|
||||
local_wires: &get_wires(bits, lists, access_indices, bad_claimed_elements),
|
||||
public_inputs_hash: &HashOut::rand(),
|
||||
|
||||
@ -292,7 +292,6 @@ mod tests {
|
||||
};
|
||||
|
||||
let vars = EvaluationVars {
|
||||
selector_index: usize::MAX,
|
||||
local_constants: &[],
|
||||
local_wires: &get_wires(input_limbs),
|
||||
public_inputs_hash: &HashOut::rand(),
|
||||
|
||||
@ -437,7 +437,6 @@ mod tests {
|
||||
};
|
||||
|
||||
let vars = EvaluationVars {
|
||||
selector_index: usize::MAX,
|
||||
local_constants: &[],
|
||||
local_wires: &get_wires(inputs_x, inputs_y, borrows),
|
||||
public_inputs_hash: &HashOut::rand(),
|
||||
|
||||
@ -446,7 +446,6 @@ mod tests {
|
||||
};
|
||||
|
||||
let vars = EvaluationVars {
|
||||
selector_index: usize::MAX,
|
||||
local_constants: &[],
|
||||
local_wires: &get_wires(first_inputs, second_inputs, switch_bools),
|
||||
public_inputs_hash: &HashOut::rand(),
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
pub mod circuit_builder;
|
||||
pub mod circuit_data;
|
||||
pub mod config;
|
||||
mod constest;
|
||||
pub(crate) mod copy_constraint;
|
||||
mod get_challenges;
|
||||
pub(crate) mod permutation_argument;
|
||||
|
||||
@ -427,7 +427,6 @@ fn compute_quotient_polys<
|
||||
}
|
||||
|
||||
let vars_batch = EvaluationVarsBaseBatch::new(
|
||||
usize::MAX,
|
||||
xs_batch.len(),
|
||||
&local_constants_batch,
|
||||
&local_wires_batch,
|
||||
|
||||
@ -56,7 +56,6 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
let local_constants = &proof.openings.constants;
|
||||
let local_wires = &proof.openings.wires;
|
||||
let vars = EvaluationTargets {
|
||||
selector_index: usize::MAX,
|
||||
local_constants,
|
||||
local_wires,
|
||||
public_inputs_hash: &public_inputs_hash,
|
||||
|
||||
@ -40,7 +40,7 @@ pub(crate) fn eval_vanishing_poly<
|
||||
let max_degree = common_data.quotient_degree_factor;
|
||||
let num_prods = common_data.num_partial_products;
|
||||
|
||||
let constraint_terms = evaluate_gate_constraints(common_data, vars.clone());
|
||||
let constraint_terms = evaluate_gate_constraints(common_data, vars);
|
||||
|
||||
// The L_1(x) (Z(x) - 1) vanishing terms.
|
||||
let mut vanishing_z_1_terms = Vec::new();
|
||||
@ -127,8 +127,7 @@ pub(crate) fn eval_vanishing_poly_base_batch<
|
||||
|
||||
let num_gate_constraints = common_data.num_gate_constraints;
|
||||
|
||||
let constraint_terms_batch =
|
||||
evaluate_gate_constraints_base_batch(&common_data, vars_batch.clone());
|
||||
let constraint_terms_batch = evaluate_gate_constraints_base_batch(&common_data, vars_batch);
|
||||
debug_assert!(constraint_terms_batch.len() == n * num_gate_constraints);
|
||||
|
||||
let num_challenges = common_data.config.num_challenges;
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
use std::ops::Range;
|
||||
use std::os::unix::raw::uid_t;
|
||||
|
||||
use plonky2_field::extension_field::algebra::ExtensionAlgebra;
|
||||
use plonky2_field::extension_field::{Extendable, FieldExtension};
|
||||
@ -12,7 +11,6 @@ use crate::util::strided_view::PackedStridedView;
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct EvaluationVars<'a, F: RichField + Extendable<D>, const D: usize> {
|
||||
pub selector_index: usize,
|
||||
pub local_constants: &'a [F::Extension],
|
||||
pub local_wires: &'a [F::Extension],
|
||||
pub public_inputs_hash: &'a HashOut<F>,
|
||||
@ -23,7 +21,6 @@ pub struct EvaluationVars<'a, F: RichField + Extendable<D>, const D: usize> {
|
||||
/// evaluation points, then wire 1 for all points, and so on).
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct EvaluationVarsBaseBatch<'a, F: Field> {
|
||||
pub selector_index: usize,
|
||||
batch_size: usize,
|
||||
pub local_constants: &'a [F],
|
||||
pub local_wires: &'a [F],
|
||||
@ -33,7 +30,6 @@ pub struct EvaluationVarsBaseBatch<'a, F: Field> {
|
||||
/// A view into `EvaluationVarsBaseBatch` for a particular evaluation point. Does not copy the data.
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct EvaluationVarsBase<'a, F: Field> {
|
||||
pub selector_index: usize,
|
||||
pub local_constants: PackedStridedView<'a, F>,
|
||||
pub local_wires: PackedStridedView<'a, F>,
|
||||
pub public_inputs_hash: &'a HashOut<F>,
|
||||
@ -44,22 +40,12 @@ pub struct EvaluationVarsBase<'a, F: Field> {
|
||||
// have packed extension fields.
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct EvaluationVarsBasePacked<'a, P: PackedField> {
|
||||
pub selector_index: usize,
|
||||
pub local_constants: PackedStridedView<'a, P>,
|
||||
pub local_wires: PackedStridedView<'a, P>,
|
||||
pub public_inputs_hash: &'a HashOut<P::Scalar>,
|
||||
}
|
||||
impl<'a, P: PackedField> EvaluationVarsBasePacked<'a, P> {
|
||||
pub fn get_constant(&self, i: usize) -> P {
|
||||
self.local_constants[if i < self.selector_index { i } else { i + 1 }]
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, F: RichField + Extendable<D>, const D: usize> EvaluationVars<'a, F, D> {
|
||||
pub fn get_constant(&self, i: usize) -> F::Extension {
|
||||
self.local_constants[if i < self.selector_index { i } else { i + 1 }]
|
||||
}
|
||||
|
||||
pub fn get_local_ext_algebra(
|
||||
&self,
|
||||
wire_range: Range<usize>,
|
||||
@ -68,11 +54,14 @@ impl<'a, F: RichField + Extendable<D>, const D: usize> EvaluationVars<'a, F, D>
|
||||
let arr = self.local_wires[wire_range].try_into().unwrap();
|
||||
ExtensionAlgebra::from_basefield_array(arr)
|
||||
}
|
||||
|
||||
pub fn remove_prefix(&mut self, prefix: &[bool]) {
|
||||
self.local_constants = &self.local_constants[prefix.len()..];
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, F: Field> EvaluationVarsBaseBatch<'a, F> {
|
||||
pub fn new(
|
||||
selector_index: usize,
|
||||
batch_size: usize,
|
||||
local_constants: &'a [F],
|
||||
local_wires: &'a [F],
|
||||
@ -81,7 +70,6 @@ impl<'a, F: Field> EvaluationVarsBaseBatch<'a, F> {
|
||||
assert_eq!(local_constants.len() % batch_size, 0);
|
||||
assert_eq!(local_wires.len() % batch_size, 0);
|
||||
Self {
|
||||
selector_index,
|
||||
batch_size,
|
||||
local_constants,
|
||||
local_wires,
|
||||
@ -89,6 +77,10 @@ impl<'a, F: Field> EvaluationVarsBaseBatch<'a, F> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn remove_prefix(&mut self, prefix: &[bool]) {
|
||||
self.local_constants = &self.local_constants[prefix.len() * self.len()..];
|
||||
}
|
||||
|
||||
pub fn len(&self) -> usize {
|
||||
self.batch_size
|
||||
}
|
||||
@ -99,7 +91,6 @@ impl<'a, F: Field> EvaluationVarsBaseBatch<'a, F> {
|
||||
let local_constants = PackedStridedView::new(self.local_constants, self.len(), index);
|
||||
let local_wires = PackedStridedView::new(self.local_wires, self.len(), index);
|
||||
EvaluationVarsBase {
|
||||
selector_index: self.selector_index,
|
||||
local_constants,
|
||||
local_wires,
|
||||
public_inputs_hash: self.public_inputs_hash,
|
||||
@ -125,10 +116,6 @@ impl<'a, F: Field> EvaluationVarsBaseBatch<'a, F> {
|
||||
}
|
||||
|
||||
impl<'a, F: Field> EvaluationVarsBase<'a, F> {
|
||||
pub fn get_constant(&self, i: usize) -> F {
|
||||
self.local_constants[if i < self.selector_index { i } else { i + 1 }]
|
||||
}
|
||||
|
||||
pub fn get_local_ext<const D: usize>(&self, wire_range: Range<usize>) -> F::Extension
|
||||
where
|
||||
F: RichField + Extendable<D>,
|
||||
@ -168,7 +155,6 @@ impl<'a, F: Field> Iterator for EvaluationVarsBaseBatchIter<'a, F> {
|
||||
/// Note: if the length of `EvaluationVarsBaseBatch` is not a multiple of `P::WIDTH`, then the
|
||||
/// leftovers at the end are ignored.
|
||||
pub struct EvaluationVarsBaseBatchIterPacked<'a, P: PackedField> {
|
||||
selector_index: usize,
|
||||
/// Index to yield next, in units of `P::Scalar`. E.g. if `P::WIDTH == 4`, then we will yield
|
||||
/// the vars for points `i`, `i + 1`, `i + 2`, and `i + 3`, packed.
|
||||
i: usize,
|
||||
@ -182,7 +168,6 @@ impl<'a, P: PackedField> EvaluationVarsBaseBatchIterPacked<'a, P> {
|
||||
) -> Self {
|
||||
assert!(start <= vars_batch.len());
|
||||
EvaluationVarsBaseBatchIterPacked {
|
||||
selector_index: vars_batch.selector_index,
|
||||
i: start,
|
||||
vars_batch,
|
||||
}
|
||||
@ -201,7 +186,6 @@ impl<'a, P: PackedField> Iterator for EvaluationVarsBaseBatchIterPacked<'a, P> {
|
||||
let local_wires =
|
||||
PackedStridedView::new(self.vars_batch.local_wires, self.vars_batch.len(), self.i);
|
||||
let res = EvaluationVarsBasePacked {
|
||||
selector_index: self.selector_index,
|
||||
local_constants,
|
||||
local_wires,
|
||||
public_inputs_hash: self.vars_batch.public_inputs_hash,
|
||||
@ -224,19 +208,20 @@ impl<'a, P: PackedField> ExactSizeIterator for EvaluationVarsBaseBatchIterPacked
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, const D: usize> EvaluationTargets<'a, D> {
|
||||
pub fn remove_prefix(&mut self, prefix: &[bool]) {
|
||||
self.local_constants = &self.local_constants[prefix.len()..];
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct EvaluationTargets<'a, const D: usize> {
|
||||
pub selector_index: usize,
|
||||
pub local_constants: &'a [ExtensionTarget<D>],
|
||||
pub local_wires: &'a [ExtensionTarget<D>],
|
||||
pub public_inputs_hash: &'a HashOutTarget,
|
||||
}
|
||||
|
||||
impl<'a, const D: usize> EvaluationTargets<'a, D> {
|
||||
pub fn get_constant(&self, i: usize) -> ExtensionTarget<D> {
|
||||
self.local_constants[if i < self.selector_index { i } else { i + 1 }]
|
||||
}
|
||||
|
||||
pub fn get_local_ext_algebra(&self, wire_range: Range<usize>) -> ExtensionAlgebraTarget<D> {
|
||||
debug_assert_eq!(wire_range.len(), D);
|
||||
let arr = self.local_wires[wire_range].try_into().unwrap();
|
||||
|
||||
@ -52,7 +52,6 @@ where
|
||||
let local_constants = &proof.openings.constants;
|
||||
let local_wires = &proof.openings.wires;
|
||||
let vars = EvaluationVars {
|
||||
selector_index: usize::MAX,
|
||||
local_constants,
|
||||
local_wires,
|
||||
public_inputs_hash: &public_inputs_hash,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user