diff --git a/elliptic-curve/src/arithmetic.rs b/elliptic-curve/src/arithmetic.rs index 88769e5dc..ed317882f 100644 --- a/elliptic-curve/src/arithmetic.rs +++ b/elliptic-curve/src/arithmetic.rs @@ -47,8 +47,8 @@ pub trait CurveArithmetic: Curve { + From + From> + Into - + LinearCombination<[(Self::ProjectivePoint, Self::Scalar)]> - + LinearCombination<[(Self::ProjectivePoint, Self::Scalar); 2]> + + for<'a> LinearCombination<'a, [(Self::ProjectivePoint, Self::Scalar)]> + + for<'a> LinearCombination<'a, [(Self::ProjectivePoint, Self::Scalar); 2]> + TryInto, Error = Error> + CurveGroup + Group; diff --git a/elliptic-curve/src/dev.rs b/elliptic-curve/src/dev.rs index e6f6c1418..7953e1653 100644 --- a/elliptic-curve/src/dev.rs +++ b/elliptic-curve/src/dev.rs @@ -752,8 +752,8 @@ impl CurveGroup for ProjectivePoint { } } -impl LinearCombination<[(ProjectivePoint, Scalar)]> for ProjectivePoint {} -impl LinearCombination<[(ProjectivePoint, Scalar); N]> for ProjectivePoint {} +impl LinearCombination<'_, [(ProjectivePoint, Scalar)]> for ProjectivePoint {} +impl LinearCombination<'_, [(ProjectivePoint, Scalar); N]> for ProjectivePoint {} impl Add for ProjectivePoint { type Output = ProjectivePoint; diff --git a/elliptic-curve/src/ops.rs b/elliptic-curve/src/ops.rs index 2e7252d65..9fe97bceb 100644 --- a/elliptic-curve/src/ops.rs +++ b/elliptic-curve/src/ops.rs @@ -160,15 +160,15 @@ pub(crate) fn invert_batch_internal + MulAssign>( /// /// It's generic around `PointsAndScalars` to allow overlapping impls. For example, const generic /// impls can use the input size to determine the size needed to store temporary variables. -pub trait LinearCombination: CurveGroup +pub trait LinearCombination<'a, PointsAndScalars>: CurveGroup where - PointsAndScalars: AsRef<[(Self, Self::Scalar)]> + ?Sized, + PointsAndScalars: ?Sized + 'a, + &'a PointsAndScalars: IntoIterator, { /// Calculates `x1 * k1 + ... + xn * kn`. - fn lincomb(points_and_scalars: &PointsAndScalars) -> Self { + fn lincomb(points_and_scalars: &'a PointsAndScalars) -> Self { points_and_scalars - .as_ref() - .iter() + .into_iter() .copied() .map(|(point, scalar)| point * scalar) .sum()