pub fn new(
    num_cons: usize,
    num_vars: usize,
    num_io: usize,
    A: &[(usize, usize, G::Scalar)],
    B: &[(usize, usize, G::Scalar)],
    C: &[(usize, usize, G::Scalar)],
  ) -> Result<R1CSShape<G>, NovaError> {
    let is_valid = |num_cons: usize,
                    num_vars: usize,
                    num_io: usize,
                    M: &[(usize, usize, G::Scalar)]|
     -> Result<(), NovaError> {
      let res = (0..M.len())
        .map(|i| {
          let (row, col, _val) = M[i];
          if row >= num_cons || col > num_io + num_vars {
            Err(NovaError::InvalidIndex)
          } else {
            Ok(())
          }
        })
        .collect::<Result<Vec<()>, NovaError>>();

      if res.is_err() {
        Err(NovaError::InvalidIndex)
      } else {
        Ok(())
      }
    };

    let res_A = is_valid(num_cons, num_vars, num_io, A);
    let res_B = is_valid(num_cons, num_vars, num_io, B);
    let res_C = is_valid(num_cons, num_vars, num_io, C);

    if res_A.is_err() || res_B.is_err() || res_C.is_err() {
      return Err(NovaError::InvalidIndex);
    }

    // We require the number of public inputs/outputs to be even
    if num_io % 2 != 0 {
      return Err(NovaError::OddInputLength);
    }

    let digest = Self::compute_digest(num_cons, num_vars, num_io, A, B, C);

    let shape = R1CSShape {
      num_cons,
      num_vars,
      num_io,
      A: A.to_owned(),
      B: B.to_owned(),
      C: C.to_owned(),
      digest,
    };

    Ok(shape)
  }
/// Create an object of type `R1CSShape` from the explicitly specified R1CS matrices
Create an object of type `R1CSShape` from the explicitly specified R1CS matrices
Create an object of type ` R1CSShape ` from the explicitly specified R1CS matrices
pub fn new(
    num_cons: usize,
    num_vars: usize,
    num_io: usize,
    A: &[(usize, usize, G::Scalar)],
    B: &[(usize, usize, G::Scalar)],
    C: &[(usize, usize, G::Scalar)],
  ) -> Result<R1CSShape<G>, NovaError> {
    let is_valid = |num_cons: usize,
                    num_vars: usize,
                    num_io: usize,
                    M: &[(usize, usize, G::Scalar)]|
     -> Result<(), NovaError> {
      let res = (0..M.len())
        .map(|i| {
          let (row, col, _val) = M[i];
          if row >= num_cons || col > num_io + num_vars {
            Err(NovaError::InvalidIndex)
          } else {
            Ok(())
          }
        })
        .collect::<Result<Vec<()>, NovaError>>();
      if res.is_err() {
        Err(NovaError::InvalidIndex)
      } else {
        Ok(())
      }
    };
    let res_A = is_valid(num_cons, num_vars, num_io, A);
    let res_B = is_valid(num_cons, num_vars, num_io, B);
    let res_C = is_valid(num_cons, num_vars, num_io, C);
    if res_A.is_err() || res_B.is_err() || res_C.is_err() {
      return Err(NovaError::InvalidIndex);
    }
    // We require the number of public inputs/outputs to be even
    if num_io % 2 != 0 {
      return Err(NovaError::OddInputLength);
    }
    let digest = Self::compute_digest(num_cons, num_vars, num_io, A, B, C);
    let shape = R1CSShape {
      num_cons,
      num_vars,
      num_io,
      A: A.to_owned(),
      B: B.to_owned(),
      C: C.to_owned(),
      digest,
    };
    Ok(shape)
  }
pub fn new ( num_cons : usize , num_vars : usize , num_io : usize , A : & [ ( usize , usize , G :: Scalar ) ] , B : & [ ( usize , usize , G :: Scalar ) ] , C : & [ ( usize , usize , G :: Scalar ) ] , ) -> Result < R1CSShape < G > , NovaError > { let is_valid = | num_cons : usize , num_vars : usize , num_io : usize , M : & [ ( usize , usize , G :: Scalar ) ] | -> Result < ( ) , NovaError > { let res = ( 0 .. M . len ( ) ) . map ( | i | { let ( row , col , _val ) = M [ i ] ; if row >= num_cons || col > num_io + num_vars { Err ( NovaError :: InvalidIndex ) } else { Ok ( ( ) ) } } ) . collect :: < Result < Vec < ( ) > , NovaError > > ( ) ; if res . is_err ( ) { Err ( NovaError :: InvalidIndex ) } else { Ok ( ( ) ) } } ; let res_A = is_valid ( num_cons , num_vars , num_io , A ) ; let res_B = is_valid ( num_cons , num_vars , num_io , B ) ; let res_C = is_valid ( num_cons , num_vars , num_io , C ) ; if res_A . is_err ( ) || res_B . is_err ( ) || res_C . is_err ( ) { return Err ( NovaError :: InvalidIndex ) ; } // We require the number of public inputs/outputs to be even if num_io % 2 != 0 { return Err ( NovaError :: OddInputLength ) ; } let digest = Self :: compute_digest ( num_cons , num_vars , num_io , A , B , C ) ; let shape = R1CSShape { num_cons , num_vars , num_io , A : A . to_owned ( ) , B : B . to_owned ( ) , C : C . to_owned ( ) , digest , } ; Ok ( shape ) }
Create an object of type `R1CSShape` from the explicitly specified R1CS matrices
Create an object of type ` R1CSShape ` from the explicitly specified R1CS matrices
num_cons
usize
num_vars
usize
num_io
usize
A
&[(usize, usize, G::Scalar)]
B
&[(usize, usize, G::Scalar)]
C
&[(usize, usize, G::Scalar)]
num_cons
usize
num_vars
usize
num_io
usize
A
&[(usize, usize, G::Scalar)]
B
&[(usize, usize, G::Scalar)]
C
&[(usize, usize, G::Scalar)]