mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-08 00:33:06 +00:00
Remove remove_prefix
This commit is contained in:
parent
dbaa31d818
commit
744996ef1c
@ -448,7 +448,7 @@ mod tests {
|
||||
};
|
||||
|
||||
let vars = EvaluationVars {
|
||||
local_constants: vec![],
|
||||
local_constants: &[],
|
||||
local_wires: &get_wires(addends, carries),
|
||||
public_inputs_hash: &HashOut::rand(),
|
||||
};
|
||||
|
||||
@ -445,7 +445,7 @@ mod tests {
|
||||
};
|
||||
|
||||
let vars = EvaluationVars {
|
||||
local_constants: vec![],
|
||||
local_constants: &[],
|
||||
local_wires: &get_wires(multiplicands_0, multiplicands_1, addends),
|
||||
public_inputs_hash: &HashOut::rand(),
|
||||
};
|
||||
|
||||
@ -602,7 +602,7 @@ mod tests {
|
||||
_phantom: PhantomData,
|
||||
};
|
||||
let less_than_vars = EvaluationVars {
|
||||
local_constants: vec![],
|
||||
local_constants: &[],
|
||||
local_wires: &get_wires(first_input, second_input),
|
||||
public_inputs_hash: &HashOut::rand(),
|
||||
};
|
||||
@ -620,7 +620,7 @@ mod tests {
|
||||
_phantom: PhantomData,
|
||||
};
|
||||
let equal_vars = EvaluationVars {
|
||||
local_constants: vec![],
|
||||
local_constants: &[],
|
||||
local_wires: &get_wires(first_input, first_input),
|
||||
public_inputs_hash: &HashOut::rand(),
|
||||
};
|
||||
|
||||
@ -682,7 +682,7 @@ mod tests {
|
||||
_phantom: PhantomData,
|
||||
};
|
||||
let less_than_vars = EvaluationVars {
|
||||
local_constants: vec![],
|
||||
local_constants: &[],
|
||||
local_wires: &get_wires(first_input, second_input),
|
||||
public_inputs_hash: &HashOut::rand(),
|
||||
};
|
||||
@ -700,7 +700,7 @@ mod tests {
|
||||
_phantom: PhantomData,
|
||||
};
|
||||
let equal_vars = EvaluationVars {
|
||||
local_constants: vec![],
|
||||
local_constants: &[],
|
||||
local_wires: &get_wires(first_input, first_input),
|
||||
public_inputs_hash: &HashOut::rand(),
|
||||
};
|
||||
|
||||
@ -394,7 +394,7 @@ mod tests {
|
||||
};
|
||||
|
||||
let vars = EvaluationVars {
|
||||
local_constants: vec![],
|
||||
local_constants: &[],
|
||||
local_wires: &get_wires(base, power as u64),
|
||||
public_inputs_hash: &HashOut::rand(),
|
||||
};
|
||||
|
||||
@ -38,7 +38,7 @@ pub trait Gate<F: RichField + Extendable<D>, const D: usize>: 'static + Send + S
|
||||
) {
|
||||
// Note that this method uses `yield_constr` instead of returning its constraints.
|
||||
// `yield_constr` abstracts out the underlying memory layout.
|
||||
let local_constants = vars_base
|
||||
let local_constants = &vars_base
|
||||
.local_constants
|
||||
.iter()
|
||||
.map(|c| F::Extension::from_basefield(*c))
|
||||
@ -91,7 +91,6 @@ pub trait Gate<F: RichField + Extendable<D>, const D: usize>: 'static + Send + S
|
||||
combination_num,
|
||||
vars.local_constants[selector_index],
|
||||
);
|
||||
vars.remove_prefix(selector_index);
|
||||
self.eval_unfiltered(vars)
|
||||
.into_iter()
|
||||
.map(|c| filter * c)
|
||||
@ -116,7 +115,6 @@ pub trait Gate<F: RichField + Extendable<D>, const D: usize>: 'static + Send + S
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
vars_batch.remove_prefix(selector_index);
|
||||
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);
|
||||
@ -139,7 +137,6 @@ pub trait Gate<F: RichField + Extendable<D>, const D: usize>: 'static + Send + S
|
||||
combination_num,
|
||||
vars.local_constants[selector_index],
|
||||
);
|
||||
vars.remove_prefix(selector_index);
|
||||
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,7 @@ 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 {
|
||||
local_constants: local_constants.to_vec(),
|
||||
local_constants,
|
||||
local_wires,
|
||||
public_inputs_hash,
|
||||
})
|
||||
@ -113,7 +113,7 @@ where
|
||||
let vars_base_batch =
|
||||
EvaluationVarsBaseBatch::new(1, &constants_base, &wires_base, &public_inputs_hash);
|
||||
let vars = EvaluationVars {
|
||||
local_constants: constants,
|
||||
local_constants: &constants,
|
||||
local_wires: &wires,
|
||||
public_inputs_hash: &public_inputs_hash,
|
||||
};
|
||||
@ -145,7 +145,7 @@ where
|
||||
pw.set_hash_target(public_inputs_hash_t, public_inputs_hash);
|
||||
|
||||
let vars = EvaluationVars {
|
||||
local_constants: constants,
|
||||
local_constants: &constants,
|
||||
local_wires: &wires,
|
||||
public_inputs_hash: &public_inputs_hash,
|
||||
};
|
||||
|
||||
@ -352,7 +352,7 @@ mod tests {
|
||||
let eval_point = FF::rand();
|
||||
let gate = HighDegreeInterpolationGate::<F, D>::new(1);
|
||||
let vars = EvaluationVars {
|
||||
local_constants: vec![],
|
||||
local_constants: &[],
|
||||
local_wires: &get_wires(&gate, shift, coeffs, eval_point),
|
||||
public_inputs_hash: &HashOut::rand(),
|
||||
};
|
||||
|
||||
@ -453,7 +453,7 @@ mod tests {
|
||||
let eval_point = FF::rand();
|
||||
let gate = LowDegreeInterpolationGate::<F, D>::new(subgroup_bits);
|
||||
let vars = EvaluationVars {
|
||||
local_constants: vec![],
|
||||
local_constants: &[],
|
||||
local_wires: &get_wires(&gate, shift, coeffs, eval_point),
|
||||
public_inputs_hash: &HashOut::rand(),
|
||||
};
|
||||
|
||||
@ -413,7 +413,7 @@ mod tests {
|
||||
.map(|(l, &i)| l[i])
|
||||
.collect();
|
||||
let good_vars = EvaluationVars {
|
||||
local_constants: vec![],
|
||||
local_constants: &[],
|
||||
local_wires: &get_wires(
|
||||
bits,
|
||||
lists.clone(),
|
||||
@ -424,7 +424,7 @@ mod tests {
|
||||
};
|
||||
let bad_claimed_elements = F::rand_vec(4);
|
||||
let bad_vars = EvaluationVars {
|
||||
local_constants: vec![],
|
||||
local_constants: &[],
|
||||
local_wires: &get_wires(bits, lists, access_indices, bad_claimed_elements),
|
||||
public_inputs_hash: &HashOut::rand(),
|
||||
};
|
||||
|
||||
@ -292,7 +292,7 @@ mod tests {
|
||||
};
|
||||
|
||||
let vars = EvaluationVars {
|
||||
local_constants: vec![],
|
||||
local_constants: &[],
|
||||
local_wires: &get_wires(input_limbs),
|
||||
public_inputs_hash: &HashOut::rand(),
|
||||
};
|
||||
|
||||
@ -437,7 +437,7 @@ mod tests {
|
||||
};
|
||||
|
||||
let vars = EvaluationVars {
|
||||
local_constants: vec![],
|
||||
local_constants: &[],
|
||||
local_wires: &get_wires(inputs_x, inputs_y, borrows),
|
||||
public_inputs_hash: &HashOut::rand(),
|
||||
};
|
||||
|
||||
@ -446,7 +446,7 @@ mod tests {
|
||||
};
|
||||
|
||||
let vars = EvaluationVars {
|
||||
local_constants: vec![],
|
||||
local_constants: &[],
|
||||
local_wires: &get_wires(first_inputs, second_inputs, switch_bools),
|
||||
public_inputs_hash: &HashOut::rand(),
|
||||
};
|
||||
|
||||
@ -9,9 +9,9 @@ use crate::hash::hash_types::{HashOut, HashOutTarget, RichField};
|
||||
use crate::iop::ext_target::{ExtensionAlgebraTarget, ExtensionTarget};
|
||||
use crate::util::strided_view::PackedStridedView;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct EvaluationVars<'a, F: RichField + Extendable<D>, const D: usize> {
|
||||
pub local_constants: Vec<F::Extension>,
|
||||
pub local_constants: &'a [F::Extension],
|
||||
pub local_wires: &'a [F::Extension],
|
||||
pub public_inputs_hash: &'a HashOut<F>,
|
||||
}
|
||||
@ -19,10 +19,10 @@ pub struct EvaluationVars<'a, F: RichField + Extendable<D>, const D: usize> {
|
||||
/// A batch of evaluation vars, in the base field.
|
||||
/// Wires and constants are stored in an evaluation point-major order (that is, wire 0 for all
|
||||
/// evaluation points, then wire 1 for all points, and so on).
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct EvaluationVarsBaseBatch<'a, F: Field> {
|
||||
batch_size: usize,
|
||||
pub local_constants: Vec<F>,
|
||||
pub local_constants: &'a [F],
|
||||
pub local_wires: &'a [F],
|
||||
pub public_inputs_hash: &'a HashOut<F>,
|
||||
}
|
||||
@ -54,10 +54,6 @@ 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, selector_index: usize) {
|
||||
self.local_constants.remove(selector_index);
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, F: Field> EvaluationVarsBaseBatch<'a, F> {
|
||||
@ -71,18 +67,12 @@ impl<'a, F: Field> EvaluationVarsBaseBatch<'a, F> {
|
||||
assert_eq!(local_wires.len() % batch_size, 0);
|
||||
Self {
|
||||
batch_size,
|
||||
local_constants: local_constants.to_vec(),
|
||||
local_constants,
|
||||
local_wires,
|
||||
public_inputs_hash,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn remove_prefix(&mut self, selector_index: usize) {
|
||||
let mut v = self.local_constants[..self.len() * selector_index].to_vec();
|
||||
v.extend(&self.local_constants[self.len() * (selector_index + 1)..]);
|
||||
self.local_constants = v;
|
||||
}
|
||||
|
||||
pub fn len(&self) -> usize {
|
||||
self.batch_size
|
||||
}
|
||||
@ -91,7 +81,7 @@ impl<'a, F: Field> EvaluationVarsBaseBatch<'a, F> {
|
||||
// We cannot implement `Index` as `EvaluationVarsBase` is a struct, not a reference.
|
||||
assert!(index < self.len());
|
||||
let local_constants =
|
||||
PackedStridedView::new(self.local_constants.clone(), self.len(), index);
|
||||
PackedStridedView::new(self.local_constants.to_vec(), self.len(), index);
|
||||
let local_wires = PackedStridedView::new(self.local_wires.to_vec(), self.len(), index);
|
||||
EvaluationVarsBase {
|
||||
local_constants,
|
||||
@ -217,13 +207,7 @@ impl<'a, P: PackedField> ExactSizeIterator for EvaluationVarsBaseBatchIterPacked
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, const D: usize> EvaluationTargets<'a, D> {
|
||||
pub fn remove_prefix(&mut self, selector_index: usize) {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct EvaluationTargets<'a, const D: usize> {
|
||||
pub local_constants: &'a [ExtensionTarget<D>],
|
||||
pub local_wires: &'a [ExtensionTarget<D>],
|
||||
|
||||
@ -49,7 +49,7 @@ pub(crate) fn verify_with_challenges<
|
||||
where
|
||||
[(); C::Hasher::HASH_SIZE]:,
|
||||
{
|
||||
let local_constants = proof.openings.constants.clone();
|
||||
let local_constants = &proof.openings.constants;
|
||||
let local_wires = &proof.openings.wires;
|
||||
let vars = EvaluationVars {
|
||||
local_constants,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user