@@ -14,7 +14,7 @@ use std::iter;
1414use std:: marker:: PhantomData ;
1515
1616use ff:: Field ;
17- use group:: { Group , GroupEncoding } ;
17+ use group:: prime :: PrimeGroup ;
1818
1919use crate :: codec:: Shake128DuplexSponge ;
2020use crate :: errors:: Error ;
@@ -68,7 +68,7 @@ pub enum ScalarTerm<G> {
6868 Unit ,
6969}
7070
71- impl < G : Group > ScalarTerm < G > {
71+ impl < G : PrimeGroup > ScalarTerm < G > {
7272 // NOTE: This function is private intentionally as it would be replaced if a ScalarMap struct
7373 // were to be added.
7474 fn value ( self , scalars : & [ G :: Scalar ] ) -> G :: Scalar {
@@ -112,13 +112,13 @@ impl<T> Sum<T> {
112112/// - `w_i` are the constant weight scalars
113113///
114114/// The indices refer to external lists managed by the containing LinearMap.
115- pub type LinearCombination < G > = Sum < Weighted < Term < G > , <G as Group >:: Scalar > > ;
115+ pub type LinearCombination < G > = Sum < Weighted < Term < G > , <G as group :: Group >:: Scalar > > ;
116116
117117/// Ordered mapping of [GroupVar] to group elements assignments.
118118#[ derive( Clone , Debug ) ]
119119pub struct GroupMap < G > ( Vec < Option < G > > ) ;
120120
121- impl < G : Group > GroupMap < G > {
121+ impl < G : PrimeGroup > GroupMap < G > {
122122 /// Assign a group element value to a point variable.
123123 ///
124124 /// # Parameters
@@ -207,7 +207,7 @@ impl<G> Default for GroupMap<G> {
207207 }
208208}
209209
210- impl < G : Group > FromIterator < ( GroupVar < G > , G ) > for GroupMap < G > {
210+ impl < G : PrimeGroup > FromIterator < ( GroupVar < G > , G ) > for GroupMap < G > {
211211 fn from_iter < T : IntoIterator < Item = ( GroupVar < G > , G ) > > ( iter : T ) -> Self {
212212 iter. into_iter ( )
213213 . fold ( Self :: default ( ) , |mut instance, ( var, val) | {
@@ -222,7 +222,7 @@ impl<G: Group> FromIterator<(GroupVar<G>, G)> for GroupMap<G> {
222222/// It supports dynamic allocation of scalars and elements,
223223/// and evaluates by performing multi-scalar multiplications.
224224#[ derive( Clone , Default , Debug ) ]
225- pub struct LinearMap < G : Group > {
225+ pub struct LinearMap < G : PrimeGroup > {
226226 /// The set of linear combination constraints (equations).
227227 pub linear_combinations : Vec < LinearCombination < G > > ,
228228 /// The list of group elements referenced in the linear map.
@@ -246,15 +246,15 @@ pub struct LinearMap<G: Group> {
246246///
247247/// # Returns
248248/// The group element result of the MSM.
249- pub fn msm_pr < G : Group > ( scalars : & [ G :: Scalar ] , bases : & [ G ] ) -> G {
249+ pub fn msm_pr < G : PrimeGroup > ( scalars : & [ G :: Scalar ] , bases : & [ G ] ) -> G {
250250 let mut acc = G :: identity ( ) ;
251251 for ( s, p) in scalars. iter ( ) . zip ( bases. iter ( ) ) {
252252 acc += * p * s;
253253 }
254254 acc
255255}
256256
257- impl < G : Group > LinearMap < G > {
257+ impl < G : PrimeGroup > LinearMap < G > {
258258 /// Creates a new empty [`LinearMap`].
259259 ///
260260 /// # Returns
@@ -291,7 +291,7 @@ impl<G: Group> LinearMap<G> {
291291 /// # Returns
292292 ///
293293 /// A vector of group elements, each being the result of evaluating one linear combination with the scalars.
294- pub fn evaluate ( & self , scalars : & [ < G as Group > :: Scalar ] ) -> Result < Vec < G > , Error > {
294+ pub fn evaluate ( & self , scalars : & [ G :: Scalar ] ) -> Result < Vec < G > , Error > {
295295 self . linear_combinations
296296 . iter ( )
297297 . map ( |lc| {
@@ -320,9 +320,7 @@ impl<G: Group> LinearMap<G> {
320320/// - A list of group elements and linear equations (held in the [`LinearMap`] field),
321321/// - A list of [`GroupVar`] indices (`image`) that specify the expected output for each constraint.
322322#[ derive( Clone , Default , Debug ) ]
323- pub struct LinearRelation < G >
324- where
325- G : Group + GroupEncoding ,
323+ pub struct LinearRelation < G : PrimeGroup >
326324{
327325 /// The underlying linear map describing the structure of the statement.
328326 pub linear_map : LinearMap < G > ,
@@ -338,7 +336,7 @@ where
338336/// This struct represents a normalized form of a linear relation where each
339337/// constraint is of the form: image[i] = Σ (scalar_j * group_element_k)
340338#[ derive( Clone , Debug , Default ) ]
341- pub struct CanonicalLinearRelation < G : Group + GroupEncoding > {
339+ pub struct CanonicalLinearRelation < G : PrimeGroup > {
342340 /// The image group elements (left-hand side of equations)
343341 pub image : Vec < G > ,
344342 /// The constraints, where each constraint is a vector of (scalar_var, group_var) pairs
@@ -350,7 +348,7 @@ pub struct CanonicalLinearRelation<G: Group + GroupEncoding> {
350348 pub num_scalars : usize ,
351349}
352350
353- impl < G : Group + GroupEncoding > CanonicalLinearRelation < G > {
351+ impl < G : PrimeGroup > CanonicalLinearRelation < G > {
354352 /// Create a new empty canonical linear relation
355353 pub fn new ( ) -> Self {
356354 Self {
@@ -514,7 +512,7 @@ impl<G: Group + GroupEncoding> CanonicalLinearRelation<G> {
514512 }
515513}
516514
517- impl < G : Group + GroupEncoding > TryFrom < LinearRelation < G > > for CanonicalLinearRelation < G > {
515+ impl < G : PrimeGroup > TryFrom < LinearRelation < G > > for CanonicalLinearRelation < G > {
518516 type Error = Error ;
519517
520518 fn try_from ( relation : LinearRelation < G > ) -> Result < Self , Self :: Error > {
@@ -545,9 +543,7 @@ impl<G: Group + GroupEncoding> TryFrom<LinearRelation<G>> for CanonicalLinearRel
545543 }
546544}
547545
548- impl < G > LinearRelation < G >
549- where
550- G : Group + GroupEncoding ,
546+ impl < G : PrimeGroup > LinearRelation < G >
551547{
552548 /// Create a new empty [`LinearRelation`].
553549 pub fn new ( ) -> Self {
@@ -675,7 +671,7 @@ where
675671 ///
676672 /// Return `Ok` on success, and an error if unassigned elements prevent the image from being
677673 /// computed. Modifies the group elements assigned in the [LinearRelation].
678- pub fn compute_image ( & mut self , scalars : & [ < G as Group > :: Scalar ] ) -> Result < ( ) , Error > {
674+ pub fn compute_image ( & mut self , scalars : & [ G :: Scalar ] ) -> Result < ( ) , Error > {
679675 if self . linear_map . num_constraints ( ) != self . image . len ( ) {
680676 // NOTE: This is a panic, rather than a returned error, because this can only happen if
681677 // this implementation has a bug.
@@ -761,9 +757,10 @@ where
761757 /// let proof = nizk.prove_batchable(&vec![x], &mut OsRng).unwrap();
762758 /// assert!(nizk.verify_batchable(&proof).is_ok());
763759 /// ```
764- pub fn into_nizk ( self , session_identifier : & [ u8 ] ) -> Nizk < SchnorrProof < G > , Shake128DuplexSponge < G > >
765- where
766- G : group:: GroupEncoding ,
760+ pub fn into_nizk (
761+ self ,
762+ session_identifier : & [ u8 ] ,
763+ ) -> Nizk < SchnorrProof < G > , Shake128DuplexSponge < G > >
767764 {
768765 let schnorr = SchnorrProof :: from ( self ) ;
769766 Nizk :: new ( session_identifier, schnorr)
0 commit comments