arnaucube
arnaucube/sonobePublic Self-hosted repository
sonobe/folding-schemes/src/arith/mod.rs
folding-schemes/src/arith/mod.rsRaw
 1use ark_ff::PrimeField;
 2
 3use crate::Error;
 4
 5pub mod ccs;
 6pub mod r1cs;
 7
 8pub trait Arith<F: PrimeField> {
 9    /// Evaluate the given Arith structure at `z`, a vector of assignments, and
10    /// return the evaluation.
11    fn eval_relation(&self, z: &[F]) -> Result<Vec<F>, Error>;
12
13    /// Checks that the given Arith structure is satisfied by a z vector, i.e.,
14    /// if the evaluation is a zero vector
15    ///
16    /// Used only for testing.
17    fn check_relation(&self, z: &[F]) -> Result<(), Error> {
18        if self.eval_relation(z)?.iter().all(|f| f.is_zero()) {
19            Ok(())
20        } else {
21            Err(Error::NotSatisfied)
22        }
23    }
24
25    /// Returns the bytes that represent the parameters, that is, the matrices sizes, the amount of
26    /// public inputs, etc, without the matrices/polynomials values.
27    fn params_to_le_bytes(&self) -> Vec<u8>;
28}