Skip to content

Commit

Permalink
ecdsa: move EcdsaCurve trait to toplevel (#791)
Browse files Browse the repository at this point in the history
Moves the trait added in #787 out of the `hazmat` module and into the
toplevel, so it's available regardless of whether or not the `hazmat`
feature has been enabled.
  • Loading branch information
tarcieri committed Jan 17, 2024
1 parent 3992dc3 commit 56b8b7a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 0 additions & 8 deletions ecdsa/src/hazmat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@ use elliptic_curve::{FieldBytesEncoding, ScalarPrimitive};
#[cfg(any(feature = "arithmetic", feature = "digest"))]
use crate::{elliptic_curve::array::ArraySize, Signature};

/// Marker trait for elliptic curves intended for use with ECDSA.
pub trait EcdsaCurve: PrimeCurve {
/// Does this curve use low-S normalized signatures?
///
/// This is typically `false`. See [`Signature::normalize_s`] for more information.
const NORMALIZE_S: bool;
}

/// Try to sign the given prehashed message using ECDSA.
///
/// This trait is intended to be implemented on a type with access to the
Expand Down
8 changes: 8 additions & 0 deletions ecdsa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@ const SHA384_OID: ObjectIdentifier = ObjectIdentifier::new_unwrap("2.16.840.1.10
#[cfg(feature = "digest")]
const SHA512_OID: ObjectIdentifier = ObjectIdentifier::new_unwrap("2.16.840.1.101.3.4.2.3");

/// Marker trait for elliptic curves intended for use with ECDSA.
pub trait EcdsaCurve: PrimeCurve {
/// Does this curve use low-S normalized signatures?
///
/// This is typically `false`. See [`Signature::normalize_s`] for more information.
const NORMALIZE_S: bool;
}

/// Size of a fixed sized signature for the given elliptic curve.
pub type SignatureSize<C> = <FieldBytesSize<C> as Add>::Output;

Expand Down

0 comments on commit 56b8b7a

Please sign in to comment.