use super::CCS; use crate::utils::gadgets::SparseMatrixVar; use ark_ff::PrimeField; use ark_r1cs_std::{ alloc::{AllocVar, AllocationMode}, fields::fp::FpVar, }; use ark_relations::r1cs::{Namespace, SynthesisError}; use ark_std::borrow::Borrow; /// CCSMatricesVar contains the matrices 'M' of the CCS without the rest of CCS parameters. /// #[derive(Debug, Clone)] pub struct CCSMatricesVar { // we only need native representation, so the constraint field==F pub M: Vec>>, } impl AllocVar, F> for CCSMatricesVar { fn new_variable>>( cs: impl Into>, f: impl FnOnce() -> Result, _mode: AllocationMode, ) -> Result { f().and_then(|val| { let cs = cs.into(); let M: Vec>> = val .borrow() .M .iter() .map(|M| SparseMatrixVar::>::new_constant(cs.clone(), M.clone())) .collect::>()?; Ok(Self { M }) }) } }