From d0478d1538d229302f33cc2a6d753ab3c7d73bf3 Mon Sep 17 00:00:00 2001 From: oskarth Date: Fri, 25 Feb 2022 18:25:03 +0800 Subject: [PATCH] When constraints are unsatisfied, show first one (#21) Useful for debugging --- src/circom/builder.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/circom/builder.rs b/src/circom/builder.rs index b0650ef..3cd2ac9 100644 --- a/src/circom/builder.rs +++ b/src/circom/builder.rs @@ -83,7 +83,15 @@ impl CircomBuilder { use ark_relations::r1cs::{ConstraintSynthesizer, ConstraintSystem}; let cs = ConstraintSystem::::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)