plonky2/src/vars.rs

30 lines
815 B
Rust
Raw Normal View History

2021-05-19 15:57:28 -07:00
use std::convert::TryInto;
use std::ops::Range;
use crate::field::extension_field::{Extendable, FieldExtension};
2021-02-09 21:25:21 -08:00
use crate::field::field::Field;
use crate::target::Target;
2021-02-09 21:25:21 -08:00
#[derive(Copy, Clone)]
pub struct EvaluationVars<'a, F: Field> {
2021-02-09 21:25:21 -08:00
pub(crate) local_constants: &'a [F],
2021-03-18 12:44:45 -07:00
pub(crate) local_wires: &'a [F],
2021-02-09 21:25:21 -08:00
}
2021-05-19 15:57:28 -07:00
impl<'a, F: Field> EvaluationVars<'a, F> {
pub fn get_local_ext<const D: usize>(&self, wire_range: Range<usize>) -> F::Extension
where
F: Extendable<D>,
{
debug_assert_eq!(wire_range.len(), D);
let arr = self.local_wires[wire_range].try_into().unwrap();
F::Extension::from_basefield_array(arr)
}
}
2021-04-02 19:15:39 -07:00
#[derive(Copy, Clone)]
pub struct EvaluationTargets<'a> {
pub(crate) local_constants: &'a [Target],
pub(crate) local_wires: &'a [Target],
2021-02-09 21:25:21 -08:00
}