diff --git a/elliptic-curve/src/ops.rs b/elliptic-curve/src/ops.rs index f524a1aca..7892663be 100644 --- a/elliptic-curve/src/ops.rs +++ b/elliptic-curve/src/ops.rs @@ -29,6 +29,18 @@ pub trait BatchInvert: Field { fn batch_invert_in_place(elements: &mut [Self], scratch_space: &mut [Self]) -> Self { BatchInverter::invert_with_external_scratch(elements, scratch_space) } + + /// Variable-time batch inversion. + /// + ///
+ /// Security Warning + /// + /// This should NOT be used on secret values! + /// + fn batch_invert_in_place_vartime(elements: &mut [Self], scratch_space: &mut [Self]) -> Self { + // Call the constant-time implementation by default + Self::batch_invert_in_place(elements, scratch_space) + } } /// Perform a doubling (i.e. `self + self`). diff --git a/elliptic-curve/src/point.rs b/elliptic-curve/src/point.rs index 983f3562f..7cf66006f 100644 --- a/elliptic-curve/src/point.rs +++ b/elliptic-curve/src/point.rs @@ -51,7 +51,20 @@ pub trait BatchNormalize { /// Perform a batched conversion to affine representation on a sequence of projective points /// at an amortized cost that should be practically as efficient as a single conversion. /// Internally, implementors should rely upon `InvertBatch`. - fn batch_normalize(points: &Points) -> >::Output; + fn batch_normalize(points: &Points) -> Self::Output; + + /// Perform a batched conversion to affine representation on a sequence of projective points + /// in variable-time. + /// + ///
+ /// Security Warning + /// + /// This should NOT be used on points which represent secrets! + /// + fn batch_normalize_vartime(points: &Points) -> Self::Output { + // Call the constant-time implementation by default + Self::batch_normalize(points) + } } /// Decompress an elliptic curve point.