@@ -149,28 +149,16 @@ fn invert_batch_internal<
149
149
150
150
/// Linear combination.
151
151
///
152
- /// This trait enables crates to provide an optimized implementation of
153
- /// linear combinations (e.g. Shamir's Trick), or otherwise provides a default
154
- /// non-optimized implementation.
155
- // TODO(tarcieri): replace this with a trait from the `group` crate? (see zkcrypto/group#25)
156
- pub trait LinearCombination : Group {
157
- /// Calculates `x * k + y * l`.
158
- fn lincomb ( x : & Self , k : & Self :: Scalar , y : & Self , l : & Self :: Scalar ) -> Self {
159
- ( * x * k) + ( * y * l)
160
- }
161
- }
162
-
163
- /// Linear combination (extended version).
152
+ /// This trait enables optimized implementations of linear combinations (e.g. Shamir's Trick).
164
153
///
165
- /// This trait enables providing an optimized implementation of
166
- /// linear combinations (e.g. Shamir's Trick).
167
- // TODO(tarcieri): replace the current `LinearCombination` with this in the next release
168
- pub trait LinearCombinationExt < PointsAndScalars > : group:: Curve
154
+ /// It's generic around `PointsAndScalars` to allow overlapping impls. For example, const generic
155
+ /// impls can use the input size to determine the size needed to store temporary variables.
156
+ pub trait LinearCombination < PointsAndScalars > : group:: Curve
169
157
where
170
158
PointsAndScalars : AsRef < [ ( Self , Self :: Scalar ) ] > + ?Sized ,
171
159
{
172
160
/// Calculates `x1 * k1 + ... + xn * kn`.
173
- fn lincomb_ext ( points_and_scalars : & PointsAndScalars ) -> Self {
161
+ fn lincomb ( points_and_scalars : & PointsAndScalars ) -> Self {
174
162
points_and_scalars
175
163
. as_ref ( )
176
164
. iter ( )
@@ -180,14 +168,6 @@ where
180
168
}
181
169
}
182
170
183
- /// Blanket impl of the legacy [`LinearCombination`] trait for types which impl the new
184
- /// [`LinearCombinationExt`] trait for 2-element arrays.
185
- impl < P : LinearCombinationExt < [ ( P , Self :: Scalar ) ; 2 ] > > LinearCombination for P {
186
- fn lincomb ( x : & Self , k : & Self :: Scalar , y : & Self , l : & Self :: Scalar ) -> Self {
187
- Self :: lincomb_ext ( & [ ( * x, * k) , ( * y, * l) ] )
188
- }
189
- }
190
-
191
171
/// Multiplication by the generator.
192
172
///
193
173
/// May use optimizations (e.g. precomputed tables) when available.
0 commit comments