Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions elliptic-curve/src/arithmetic.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
//! Elliptic curve arithmetic traits.

use crate::{
ops::{LinearCombination, MulByGenerator, Reduce, ShrAssign},
ops::{Invert, LinearCombination, MulByGenerator, Reduce, ShrAssign},
point::AffineCoordinates,
scalar::FromUintUnchecked,
scalar::IsHigh,
scalar::{FromUintUnchecked, IsHigh},
Curve, FieldBytes, PrimeCurve, ScalarPrimitive,
};
use core::fmt::Debug;
use subtle::{ConditionallySelectable, ConstantTimeEq};
use subtle::{ConditionallySelectable, ConstantTimeEq, CtOption};
use zeroize::DefaultIsZeroes;

/// Elliptic curve with an arithmetic implementation.
Expand Down Expand Up @@ -69,6 +68,7 @@ pub trait CurveArithmetic: Curve {
+ Into<FieldBytes<Self>>
+ Into<ScalarPrimitive<Self>>
+ Into<Self::Uint>
+ Invert<Output = CtOption<Self::Scalar>>
+ IsHigh
+ PartialOrd
+ Reduce<Self::Uint, Bytes = FieldBytes<Self>>
Expand Down
10 changes: 9 additions & 1 deletion elliptic-curve/src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
bigint::{Limb, U256},
error::{Error, Result},
generic_array::typenum::U32,
ops::{LinearCombination, MulByGenerator, Reduce, ShrAssign},
ops::{Invert, LinearCombination, MulByGenerator, Reduce, ShrAssign},
pkcs8,
point::AffineCoordinates,
rand_core::RngCore,
Expand Down Expand Up @@ -324,6 +324,14 @@ impl<'a> Product<&'a Scalar> for Scalar {
}
}

impl Invert for Scalar {
type Output = CtOption<Scalar>;

fn invert(&self) -> CtOption<Scalar> {
unimplemented!();
}
}

impl Reduce<U256> for Scalar {
type Bytes = FieldBytes;

Expand Down
10 changes: 1 addition & 9 deletions elliptic-curve/src/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pub use core::ops::{Add, AddAssign, Mul, Neg, Shr, ShrAssign, Sub, SubAssign};

use crypto_bigint::Integer;
use {group::Group, subtle::CtOption};
use group::Group;

/// Perform an inversion on a field element (i.e. base field element or scalar)
pub trait Invert {
Expand All @@ -25,14 +25,6 @@ pub trait Invert {
}
}

impl<F: ff::Field> Invert for F {
type Output = CtOption<F>;

fn invert(&self) -> CtOption<F> {
ff::Field::invert(self)
}
}

/// Linear combination.
///
/// This trait enables crates to provide an optimized implementation of
Expand Down