From 3759fc8aabed815edc985f6d0e67894275e0324c Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Thu, 21 May 2020 11:58:57 +1200 Subject: [PATCH] group: Default implementation of CurveProjective::batch_normalize For convenience. Implementations will usually override this to take advantage of implementation-specific batching optimisations. --- bellman/src/groth16/tests/dummy_engine.rs | 8 -------- group/src/lib.rs | 8 +++++++- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/bellman/src/groth16/tests/dummy_engine.rs b/bellman/src/groth16/tests/dummy_engine.rs index e9dcb3a8f..22361d6b5 100644 --- a/bellman/src/groth16/tests/dummy_engine.rs +++ b/bellman/src/groth16/tests/dummy_engine.rs @@ -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 } diff --git a/group/src/lib.rs b/group/src/lib.rs index e9b396bab..8837345f2 100644 --- a/group/src/lib.rs +++ b/group/src/lib.rs @@ -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;