diff --git a/src/scalar.rs b/src/scalar.rs index a2459a95..f2359d24 100644 --- a/src/scalar.rs +++ b/src/scalar.rs @@ -774,6 +774,18 @@ impl PrimeField for Scalar { } } +impl core::iter::Sum for Scalar +where + T: core::borrow::Borrow, +{ + fn sum(iter: I) -> Self + where + I: Iterator, + { + iter.fold(Self::zero(), |acc, item| acc + item.borrow()) + } +} + #[test] fn test_inv() { // Compute -(q^{-1} mod 2^64) mod 2^64 by exponentiating