snark_verifier/loader/
halo2.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//! `Loader` implementation for generating verifier in [`halo2_proofs`](crate::halo2_proofs) circuit.

pub(crate) mod loader;
mod shim;

pub use loader::{EcPoint, Halo2Loader, Scalar};
pub use shim::{EccInstructions, IntegerInstructions};
pub use util::Valuetools;

pub use halo2_ecc;

mod util {
    use crate::halo2_proofs::circuit::Value;

    /// Helper methods when dealing with iterator of [`Value`].
    pub trait Valuetools<V>: Iterator<Item = Value<V>> {
        /// Fold zipped values into accumulator, returns `Value::unknown()` if
        /// any is `Value::unknown()`.
        fn fold_zipped<B, F>(self, init: B, mut f: F) -> Value<B>
        where
            Self: Sized,
            F: FnMut(B, V) -> B,
        {
            self.fold(Value::known(init), |acc, value| {
                acc.zip(value).map(|(acc, value)| f(acc, value))
            })
        }
    }

    impl<V, I: Iterator<Item = Value<V>>> Valuetools<V> for I {}
}