Skip to content

Commit

Permalink
ecdsa: add EcdsaCurve marker trait (#787)
Browse files Browse the repository at this point in the history
This trait is the intended successor to the `SignPrimitive` and
`VerifyPrimitive` traits.

Currently the only reason for a non-default impl of those traits is to
handle low-S normalization. The `EcdsaCurve` trait now not only marks
the curve as being safe for use with ECDSA, but also captures this
decision regarding low-S normalization so it doesn't have to be
expressed in code.
  • Loading branch information
tarcieri authored Jan 17, 2024
1 parent 81adf2e commit 9eda95a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ecdsa/src/hazmat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ 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.
#[cfg(feature = "arithmetic")]
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

0 comments on commit 9eda95a

Please sign in to comment.