From 808f1529c99fa5ffb8c4bc4db08ec4901c42738d Mon Sep 17 00:00:00 2001 From: MozirDmitriy Date: Sat, 18 Jan 2025 19:50:30 +0300 Subject: [PATCH] Replace ConstraintSynthesizer trait with closure type alias Description: Addresses TODO comment by replacing the ConstraintSynthesizer trait with a type alias for a boxed closure. This change: - Simplifies the constraint system interface - Maintains the same functionality - Makes the code more flexible by allowing direct use of closures - Removes unnecessary trait boilerplate since the trait only had one method --- relations/src/r1cs/constraint_system.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/relations/src/r1cs/constraint_system.rs b/relations/src/r1cs/constraint_system.rs index 1b0d54922..b52f318bc 100644 --- a/relations/src/r1cs/constraint_system.rs +++ b/relations/src/r1cs/constraint_system.rs @@ -15,13 +15,9 @@ use ark_std::{ }; /// Computations are expressed in terms of rank-1 constraint systems (R1CS). -/// The `generate_constraints` method is called to generate constraints for -/// both CRS generation and for proving. -// TODO: Think: should we replace this with just a closure? -pub trait ConstraintSynthesizer { - /// Drives generation of new constraints inside `cs`. - fn generate_constraints(self, cs: ConstraintSystemRef) -> crate::r1cs::Result<()>; -} +/// The type represents a closure that generates constraints for both CRS generation +/// and for proving. +pub type ConstraintSynthesizer = Box) -> crate::r1cs::Result<()>>; /// An Rank-One `ConstraintSystem`. Enforces constraints of the form /// `⟨a_i, z⟩ ⋅ ⟨b_i, z⟩ = ⟨c_i, z⟩`, where `a_i`, `b_i`, and `c_i` are linear