group: Default implementation of CurveProjective::batch_normalize

For convenience. Implementations will usually override this to take
advantage of implementation-specific batching optimisations.
This commit is contained in:
Jack Grigg 2020-05-21 11:58:57 +12:00
parent ae2d2b59b9
commit 3759fc8aab
2 changed files with 7 additions and 9 deletions

View File

@ -396,14 +396,6 @@ impl PrimeGroup for Fr {}
impl CurveProjective for Fr {
type Affine = Fr;
fn batch_normalize(p: &[Self], q: &mut [Self::Affine]) {
assert_eq!(p.len(), q.len());
for (p, q) in p.iter().zip(q.iter_mut()) {
*q = p.to_affine();
}
}
fn to_affine(&self) -> Fr {
*self
}

View File

@ -99,7 +99,13 @@ pub trait CurveProjective:
/// Converts a batch of projective elements into affine elements. This function will
/// panic if `p.len() != q.len()`.
fn batch_normalize(p: &[Self], q: &mut [Self::Affine]);
fn batch_normalize(p: &[Self], q: &mut [Self::Affine]) {
assert_eq!(p.len(), q.len());
for (p, q) in p.iter().zip(q.iter_mut()) {
*q = p.to_affine();
}
}
/// Converts this element into its affine representation.
fn to_affine(&self) -> Self::Affine;