Merge pull request #15 from zcash/wnaf-group

Enable Pasta curve elements to be used with `group::Wnaf`
This commit is contained in:
str4d 2021-08-06 13:27:11 +01:00 committed by GitHub
commit b786a0c488
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -96,6 +96,25 @@ macro_rules! new_curve_impl {
}
}
impl group::WnafGroup for $name {
fn recommended_wnaf_for_num_scalars(num_scalars: usize) -> usize {
// Copied from bls12_381::g1, should be updated.
const RECOMMENDATIONS: [usize; 12] =
[1, 3, 7, 20, 43, 120, 273, 563, 1630, 3128, 7933, 62569];
let mut ret = 4;
for r in &RECOMMENDATIONS {
if num_scalars > *r {
ret += 1;
} else {
break;
}
}
ret
}
}
impl CurveExt for $name {
type ScalarExt = $scalar;
type Base = $base;