Add pippenger under multiexp

This commit is contained in:
Luke Parker
2022-06-07 00:02:10 -04:00
parent 670ea3726f
commit 714ce68deb
6 changed files with 286 additions and 149 deletions

View File

@@ -1,5 +1,8 @@
use rand_core::{RngCore, CryptoRng};
use ff::Field;
use group::Group;
use crate::{Curve, MultisigKeys, tests::key_gen};
// Test generation of FROST keys
@@ -18,6 +21,21 @@ fn keys_serialization<R: RngCore + CryptoRng, C: Curve>(rng: &mut R) {
pub fn test_curve<R: RngCore + CryptoRng, C: Curve>(rng: &mut R) {
// TODO: Test the Curve functions themselves
// Test successful multiexp, with enough pairs to trigger its variety of algorithms
// TODO: This should probably be under multiexp
{
let mut pairs = Vec::with_capacity(1000);
let mut sum = C::G::identity();
for _ in 0 .. 10 {
for _ in 0 .. 100 {
pairs.push((C::F::random(&mut *rng), C::GENERATOR * C::F::random(&mut *rng)));
sum += pairs[pairs.len() - 1].1 * pairs[pairs.len() - 1].0;
}
assert_eq!(multiexp::multiexp(&pairs, C::LITTLE_ENDIAN), sum);
assert_eq!(multiexp::multiexp_vartime(&pairs, C::LITTLE_ENDIAN), sum);
}
}
// Test FROST key generation and serialization of MultisigKeys works as expected
key_generation::<_, C>(rng);
keys_serialization::<_, C>(rng);