Skip to content

Commit

Permalink
print out the number of constraints as they get synthesized
Browse files Browse the repository at this point in the history
  • Loading branch information
imikushin committed Jul 29, 2024
1 parent 9099bf0 commit 4fea9f3
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions jolt-core/src/circuits/pairing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,31 +117,41 @@ mod tests {
self,
cs: ConstraintSystemRef<ConstraintF>,
) -> Result<(), SynthesisError> {
// TODO use PairingVar to generate constraints
dbg!(cs.num_constraints());

let r_g1 = P::G1Var::new_witness(cs.clone(), || {
Ok(E::G1::generator() * self.r.ok_or(SynthesisError::AssignmentMissing)?)
})?;
dbg!(cs.num_constraints());

let r_g1_prepared = P::prepare_g1(&r_g1)?;
dbg!(cs.num_constraints());

let minus_one_g1_prepared = P::G1PreparedVar::new_constant(
cs.clone(),
&E::G1Prepared::from(-E::G1::generator()),
)?;
dbg!(cs.num_constraints());

let r_g2 = P::G2Var::new_witness(cs.clone(), || {
Ok(self.r_g2.ok_or(SynthesisError::AssignmentMissing)?)
})?;
dbg!(cs.num_constraints());

let r_g1_prepared = P::prepare_g1(&r_g1)?;
let r_g2_prepared = P::prepare_g2(&r_g2)?;
dbg!(cs.num_constraints());

let one_g2_prepared = P::G2PreparedVar::new_constant(
cs.clone(),
&E::G2Prepared::from(E::G2::generator()),
)?;
let minus_one_g1_prepared = P::G1PreparedVar::new_constant(
cs.clone(),
&E::G1Prepared::from(-E::G1::generator()),
)?;
dbg!(cs.num_constraints());

let result = P::multi_pairing(
&[r_g1_prepared, minus_one_g1_prepared],
&[one_g2_prepared, r_g2_prepared],
)?;
dbg!(cs.num_constraints());

result.enforce_equal(&P::GTVar::one())
}
Expand Down

0 comments on commit 4fea9f3

Please sign in to comment.