Skip to content
Closed
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 elliptic-curve-crate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ default-features = false
hex = "0.4"

[features]
default = []
legacy = []
weierstrass = []
std = []

[package.metadata.docs.rs]
all-features = true
features = ["weierstrass", "std"]
rustdoc-args = ["--cfg", "docsrs"]
23 changes: 23 additions & 0 deletions elliptic-curve-crate/src/legacy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//! Traits for implementing legacy protocols.
//!
//! These APIs could be potentially misused when designing new protocols.
//! For that reason, we strongly suggest they aren't used in new protocols, but
//! only as needed when implementing legacy protocols which require them.

/// Reduce the field element representing the x-coordinate of an affine point
/// into the associated scalar type
pub trait ReduceAffineX {
/// Scalar type
type Scalar; // TODO: bounds (should we add a `ScalarArith` marker trait?)

/// Convert the element in the base field representing the x-coordinate
/// to the associated scalar type by lifting it into an integer and then
/// reducing it to an element of the scalar field
fn reduce_x_to_scalar(&self) -> Self::Scalar;
}

/// Determines if the y-coordinate of an affine point is odd
pub trait IsAffineYOdd {
/// Is the y-coordinate odd?
fn is_y_odd(&self) -> bool;
}
7 changes: 5 additions & 2 deletions elliptic-curve-crate/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,18 @@ pub use rand_core;
pub mod error;
pub mod secret_key;

pub use generic_array::{self, typenum::consts};
pub use subtle;
#[cfg(feature = "legacy")]
#[cfg_attr(docsrs, doc(cfg(feature = "legacy")))]
pub mod legacy;

// TODO(tarcieri): other curve forms
#[cfg(feature = "weierstrass")]
#[cfg_attr(docsrs, doc(cfg(feature = "weierstrass")))]
pub mod weierstrass;

pub use self::{error::Error, secret_key::SecretKey};
pub use generic_array::{self, typenum::consts};
pub use subtle;

/// Byte array containing a serialized scalar value (i.e. an integer)
pub type ScalarBytes<Size> = generic_array::GenericArray<u8, Size>;