diff --git a/chain-vote/src/gang/p256k1.rs b/chain-vote/src/gang/p256k1.rs index 336050590..e218a721a 100644 --- a/chain-vote/src/gang/p256k1.rs +++ b/chain-vote/src/gang/p256k1.rs @@ -147,6 +147,18 @@ impl GroupElement { } sum } + + pub fn vartime_multiscalar_multiplication(scalars: I, points: J) -> Self + where + I: IntoIterator, + J: IntoIterator, + { + let mut sum = GroupElement::zero(); + for (scalar, point) in scalars.into_iter().zip(points.into_iter()) { + sum = sum + scalar * point; + } + sum + } } impl Scalar { diff --git a/chain-vote/src/gang/ristretto255.rs b/chain-vote/src/gang/ristretto255.rs index 112c79fbd..211c75bfb 100644 --- a/chain-vote/src/gang/ristretto255.rs +++ b/chain-vote/src/gang/ristretto255.rs @@ -83,6 +83,10 @@ impl GroupElement { } sum } + + /// Variable time multiscalar multiplication. Takes as input an iterator of scalar, and an + /// iterator over group elements, and computes a variable time multiscalar operation. Should + /// only be used when the scalar are not secret. pub fn vartime_multiscalar_multiplication(scalars: I, points: J) -> Self where I: IntoIterator,