mirror of
https://github.com/serai-dex/serai.git
synced 2025-01-05 10:29:40 +00:00
Correct verification share calculation from n * n * t to just n * t
Reduces key gen execution time by a factor of 3.
This commit is contained in:
parent
f6a41d9836
commit
5a1f273cd5
1 changed files with 11 additions and 13 deletions
|
@ -1,4 +1,4 @@
|
||||||
use core::{convert::TryFrom, fmt};
|
use core::fmt;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use rand_core::{RngCore, CryptoRng};
|
use rand_core::{RngCore, CryptoRng};
|
||||||
|
@ -230,19 +230,17 @@ fn complete_r2<R: RngCore + CryptoRng, C: Curve>(
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut verification_shares = HashMap::new();
|
let mut verification_shares = HashMap::new();
|
||||||
for l in 1 ..= params.n() {
|
|
||||||
let mut values = vec![];
|
|
||||||
for i in 1 ..= params.n() {
|
for i in 1 ..= params.n() {
|
||||||
for j in 0 .. params.t() {
|
let i_scalar = C::F::from(i.into());
|
||||||
let mut exp = C::F::one();
|
let mut values = vec![];
|
||||||
for _ in 0 .. j {
|
(0 .. params.t()).into_iter().fold(C::F::one(), |exp, j| {
|
||||||
exp *= C::F::from(u64::try_from(l).unwrap());
|
values.push((
|
||||||
}
|
exp,
|
||||||
values.push((exp, commitments[&i][usize::from(j)]));
|
(1 ..= params.n()).into_iter().map(|l| commitments[&l][usize::from(j)]).sum()
|
||||||
}
|
));
|
||||||
}
|
exp * i_scalar
|
||||||
// Doesn't do a unified multiexp due to needing individual verification shares
|
});
|
||||||
verification_shares.insert(l, multiexp_vartime(values, C::little_endian()));
|
verification_shares.insert(i, multiexp_vartime(values, C::little_endian()));
|
||||||
}
|
}
|
||||||
debug_assert_eq!(C::generator_table() * secret_share, verification_shares[¶ms.i()]);
|
debug_assert_eq!(C::generator_table() * secret_share, verification_shares[¶ms.i()]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue