Skip to main content

elliptic_curve/
ops.rs

1//! Traits for arithmetic operations on elliptic curve field elements.
2
3pub use core::ops::{Add, AddAssign, Mul, Neg, Sub, SubAssign};
4
5use subtle::CtOption;
6
7/// Perform an inversion on a field element (i.e. base field element or scalar)
8pub trait Invert {
9    /// Field element type
10    type Output;
11
12    /// Invert a field element.
13    fn invert(&self) -> CtOption<Self::Output>;
14}
15
16#[cfg(feature = "arithmetic")]
17impl<F: ff::Field> Invert for F {
18    type Output = F;
19
20    fn invert(&self) -> CtOption<F> {
21        ff::Field::invert(self)
22    }
23}