group: Sum + for<'a> Sum<&'a Self> bounds for Group

This commit is contained in:
Jack Grigg 2020-05-14 20:30:22 +12:00
parent 78db26b713
commit bca06de21c
1 changed files with 13 additions and 0 deletions

View File

@ -4,6 +4,7 @@ use pairing::{Engine, PairingCurveAffine};
use rand_core::RngCore;
use std::fmt;
use std::iter::Sum;
use std::num::Wrapping;
use std::ops::{Add, AddAssign, BitAnd, Mul, MulAssign, Neg, Shr, Sub, SubAssign};
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption};
@ -47,6 +48,18 @@ impl ConditionallySelectable for Fr {
}
}
impl Sum for Fr {
fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
iter.fold(Self::zero(), ::std::ops::Add::add)
}
}
impl<'r> Sum<&'r Fr> for Fr {
fn sum<I: Iterator<Item = &'r Fr>>(iter: I) -> Self {
iter.fold(Self::zero(), ::std::ops::Add::add)
}
}
impl Neg for Fr {
type Output = Self;