Skip to content

Commit 9eda95a

Browse files
authored
ecdsa: add EcdsaCurve marker trait (#787)
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.
1 parent 81adf2e commit 9eda95a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

ecdsa/src/hazmat.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ use elliptic_curve::{FieldBytesEncoding, ScalarPrimitive};
4343
#[cfg(any(feature = "arithmetic", feature = "digest"))]
4444
use crate::{elliptic_curve::array::ArraySize, Signature};
4545

46+
/// Marker trait for elliptic curves intended for use with ECDSA.
47+
#[cfg(feature = "arithmetic")]
48+
pub trait EcdsaCurve: PrimeCurve {
49+
/// Does this curve use low-S normalized signatures?
50+
///
51+
/// This is typically `false`. See [`Signature::normalize_s`] for more information.
52+
const NORMALIZE_S: bool;
53+
}
54+
4655
/// Try to sign the given prehashed message using ECDSA.
4756
///
4857
/// This trait is intended to be implemented on a type with access to the

0 commit comments

Comments
 (0)