Skip to content

Commit

Permalink
added multiscalar mult interface for p256k1
Browse files Browse the repository at this point in the history
  • Loading branch information
iquerejeta committed Jun 8, 2021
1 parent f90af13 commit 8e1805a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions chain-vote/src/gang/p256k1.rs
Expand Up @@ -147,6 +147,18 @@ impl GroupElement {
}
sum
}

pub fn vartime_multiscalar_multiplication<I, J>(scalars: I, points: J) -> Self
where
I: IntoIterator<Item = Scalar>,
J: IntoIterator<Item = GroupElement>,
{
let mut sum = GroupElement::zero();
for (scalar, point) in scalars.into_iter().zip(points.into_iter()) {
sum = sum + scalar * point;
}
sum
}
}

impl Scalar {
Expand Down
4 changes: 4 additions & 0 deletions chain-vote/src/gang/ristretto255.rs
Expand Up @@ -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<I, J>(scalars: I, points: J) -> Self
where
I: IntoIterator<Item = Scalar>,
Expand Down

0 comments on commit 8e1805a

Please sign in to comment.