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
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion elliptic-curve/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ and public/secret keys composed thereof.

[dependencies]
base16ct = "0.2"
crypto-bigint = { version = "=0.7.0-pre.1", default-features = false, features = ["rand_core", "hybrid-array", "zeroize"] }
crypto-bigint = { version = "=0.7.0-pre.2", default-features = false, features = ["rand_core", "hybrid-array", "zeroize"] }
hybrid-array = { version = "0.3", default-features = false, features = ["zeroize"] }
rand_core = { version = "0.9.0", default-features = false }
subtle = { version = "2.6", default-features = false }
Expand Down
21 changes: 1 addition & 20 deletions elliptic-curve/src/ops.rs
Original file line number Diff line number Diff line change
@@ -1,33 +1,14 @@
//! Traits for arithmetic operations on elliptic curve field elements.

pub use core::ops::{Add, AddAssign, Mul, Neg, Shr, ShrAssign, Sub, SubAssign};
pub use crypto_bigint::Invert;

use crypto_bigint::Integer;
use subtle::{Choice, ConditionallySelectable, CtOption};

#[cfg(feature = "alloc")]
use alloc::vec::Vec;

/// Perform an inversion on a field element (i.e. base field element or scalar)
pub trait Invert {
/// Field element type
type Output;

/// Invert a field element.
fn invert(&self) -> Self::Output;

/// Invert a field element in variable time.
///
/// ⚠️ WARNING!
///
/// This method should not be used with secret values, as its variable-time
/// operation can potentially leak secrets through sidechannels.
fn invert_vartime(&self) -> Self::Output {
// Fall back on constant-time implementation by default.
self.invert()
}
}

/// Perform a batched inversion on a sequence of field elements (i.e. base field elements or scalars)
/// at an amortized cost that should be practically as efficient as a single inversion.
pub trait BatchInvert<FieldElements: ?Sized>: Invert + Sized {
Expand Down