Skip to content

Commit

Permalink
Replace ConstraintSynthesizer trait with closure type alias
Browse files Browse the repository at this point in the history
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
  • Loading branch information
MozirDmitriy authored Jan 18, 2025
1 parent 748c0ba commit 808f152
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions relations/src/r1cs/constraint_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<F: Field> {
/// Drives generation of new constraints inside `cs`.
fn generate_constraints(self, cs: ConstraintSystemRef<F>) -> crate::r1cs::Result<()>;
}
/// The type represents a closure that generates constraints for both CRS generation
/// and for proving.
pub type ConstraintSynthesizer<F> = Box<dyn FnOnce(ConstraintSystemRef<F>) -> 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
Expand Down

0 comments on commit 808f152

Please sign in to comment.