When constraints are unsatisfied, show first one (#21)

Useful for debugging
This commit is contained in:
oskarth 2022-02-25 18:25:03 +08:00 committed by GitHub
parent e81fd92a67
commit d0478d1538
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -83,7 +83,15 @@ impl<E: PairingEngine> CircomBuilder<E> {
use ark_relations::r1cs::{ConstraintSynthesizer, ConstraintSystem};
let cs = ConstraintSystem::<E::Fr>::new_ref();
circom.clone().generate_constraints(cs.clone()).unwrap();
cs.is_satisfied().unwrap()
let is_satisfied = cs.is_satisfied().unwrap();
if !is_satisfied {
println!(
"Unsatisfied constraint: {:?}",
cs.which_is_unsatisfied().unwrap()
);
}
is_satisfied
});
Ok(circom)