pub fn is_sat(
    &self,
    gens: &R1CSGens<G>,
    U: &R1CSInstance<G>,
    W: &R1CSWitness<G>,
  ) -> Result<(), NovaError> {
    assert_eq!(W.W.len(), self.num_vars);
    assert_eq!(U.X.len(), self.num_io);

    // verify if Az * Bz = u*Cz
    let res_eq: bool = {
      let z = concat(vec![W.W.clone(), vec![G::Scalar::one()], U.X.clone()]);
      let (Az, Bz, Cz) = self.multiply_vec(&z)?;
      assert_eq!(Az.len(), self.num_cons);
      assert_eq!(Bz.len(), self.num_cons);
      assert_eq!(Cz.len(), self.num_cons);

      let res: usize = (0..self.num_cons)
        .map(|i| if Az[i] * Bz[i] == Cz[i] { 0 } else { 1 })
        .sum();

      res == 0
    };

    // verify if comm_W is a commitment to W
    let res_comm: bool = U.comm_W == W.W.commit(&gens.gens_W);

    if res_eq && res_comm {
      Ok(())
    } else {
      Err(NovaError::UnSat)
    }
  }
/// Checks if the R1CS instance is satisfiable given a witness and its shape
Checks if the R1CS instance is satisfiable given a witness and its shape
Checks if the R1CS instance is satisfiable given a witness and its shape
pub fn is_sat(
    &self,
    gens: &R1CSGens<G>,
    U: &R1CSInstance<G>,
    W: &R1CSWitness<G>,
  ) -> Result<(), NovaError> {
    assert_eq!(W.W.len(), self.num_vars);
    assert_eq!(U.X.len(), self.num_io);
    // verify if Az * Bz = u*Cz
    let res_eq: bool = {
      let z = concat(vec![W.W.clone(), vec![G::Scalar::one()], U.X.clone()]);
      let (Az, Bz, Cz) = self.multiply_vec(&z)?;
      assert_eq!(Az.len(), self.num_cons);
      assert_eq!(Bz.len(), self.num_cons);
      assert_eq!(Cz.len(), self.num_cons);
      let res: usize = (0..self.num_cons)
        .map(|i| if Az[i] * Bz[i] == Cz[i] { 0 } else { 1 })
        .sum();
      res == 0
    };
    // verify if comm_W is a commitment to W
    let res_comm: bool = U.comm_W == W.W.commit(&gens.gens_W);
    if res_eq && res_comm {
      Ok(())
    } else {
      Err(NovaError::UnSat)
    }
  }
pub fn is_sat ( & self , gens : & R1CSGens < G > , U : & R1CSInstance < G > , W : & R1CSWitness < G > , ) -> Result < ( ) , NovaError > { assert_eq ! ( W W len ( ) self num_vars ) ; assert_eq ! ( U X len ( ) self num_io ) ; // verify if Az * Bz = u*Cz let res_eq : bool = { let z = concat ( vec ! [ W W clone ( ) vec [ G Scalar one ( ) ] U X clone ( ) ] ) ; let ( Az , Bz , Cz ) = self . multiply_vec ( & z ) ? ; assert_eq ! ( Az len ( ) self num_cons ) ; assert_eq ! ( Bz len ( ) self num_cons ) ; assert_eq ! ( Cz len ( ) self num_cons ) ; let res : usize = ( 0 .. self . num_cons ) . map ( | i | if Az [ i ] * Bz [ i ] == Cz [ i ] { 0 } else { 1 } ) . sum ( ) ; res == 0 } ; // verify if comm_W is a commitment to W let res_comm : bool = U . comm_W == W . W . commit ( & gens . gens_W ) ; if res_eq && res_comm { Ok ( ( ) ) } else { Err ( NovaError :: UnSat ) } }
Checks if the R1CS instance is satisfiable given a witness and its shape
Checks if the R1CS instance is satisfiable given a witness and its shape
&self
gens
&R1CSGens<G>
U
&R1CSInstance<G>
W
&R1CSWitness<G>
&self
gens
&R1CSGens<G>
U
&R1CSInstance<G>
W
&R1CSWitness<G>