diff --git a/elliptic-curve/src/ecdh.rs b/elliptic-curve/src/ecdh.rs index c64a696a..243c6178 100644 --- a/elliptic-curve/src/ecdh.rs +++ b/elliptic-curve/src/ecdh.rs @@ -30,7 +30,7 @@ use crate::{ point::AffineCoordinates, AffinePoint, Curve, CurveArithmetic, FieldBytes, NonZeroScalar, ProjectivePoint, PublicKey, }; -use core::borrow::Borrow; +use core::{borrow::Borrow, fmt}; use digest::{crypto_common::BlockSizeUser, Digest}; use group::Curve as _; use hkdf::{hmac::SimpleHmac, Hkdf}; @@ -97,6 +97,12 @@ where scalar: NonZeroScalar, } +impl fmt::Debug for EphemeralSecret { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("EphemeralSecret").finish_non_exhaustive() + } +} + impl EphemeralSecret where C: CurveArithmetic, @@ -157,6 +163,12 @@ pub struct SharedSecret { secret_bytes: FieldBytes, } +impl fmt::Debug for SharedSecret { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("SharedSecret").finish_non_exhaustive() + } +} + impl SharedSecret { /// Create a new [`SharedSecret`] from an [`AffinePoint`] for this curve. #[inline] diff --git a/elliptic-curve/src/hash2curve/hash2field/expand_msg.rs b/elliptic-curve/src/hash2curve/hash2field/expand_msg.rs index 58d3c36e..510ce5b2 100644 --- a/elliptic-curve/src/hash2curve/hash2field/expand_msg.rs +++ b/elliptic-curve/src/hash2curve/hash2field/expand_msg.rs @@ -43,6 +43,7 @@ pub trait Expander { /// Implements [section 5.4.3 of `draft-irtf-cfrg-hash-to-curve-13`][dst]. /// /// [dst]: https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-13#section-5.4.3 +#[derive(Debug)] pub(crate) enum Domain<'a, L> where L: ArraySize + IsLess, diff --git a/elliptic-curve/src/hash2curve/hash2field/expand_msg/xmd.rs b/elliptic-curve/src/hash2curve/hash2field/expand_msg/xmd.rs index 745e054d..4d397d4c 100644 --- a/elliptic-curve/src/hash2curve/hash2field/expand_msg/xmd.rs +++ b/elliptic-curve/src/hash2curve/hash2field/expand_msg/xmd.rs @@ -20,6 +20,7 @@ use digest::{ /// - `len_in_bytes == 0` /// - `len_in_bytes > u16::MAX` /// - `len_in_bytes > 255 * HashT::OutputSize` +#[derive(Debug)] pub struct ExpandMsgXmd(PhantomData) where HashT: BlockSizeUser + Default + FixedOutput + HashMarker, @@ -87,6 +88,7 @@ where } /// [`Expander`] type for [`ExpandMsgXmd`]. +#[derive(Debug)] pub struct ExpanderXmd<'a, HashT> where HashT: BlockSizeUser + Default + FixedOutput + HashMarker, diff --git a/elliptic-curve/src/hash2curve/hash2field/expand_msg/xof.rs b/elliptic-curve/src/hash2curve/hash2field/expand_msg/xof.rs index bf429071..96eebe1e 100644 --- a/elliptic-curve/src/hash2curve/hash2field/expand_msg/xof.rs +++ b/elliptic-curve/src/hash2curve/hash2field/expand_msg/xof.rs @@ -2,6 +2,7 @@ use super::{Domain, ExpandMsg, Expander}; use crate::{Error, Result}; +use core::fmt; use digest::{ExtendableOutput, Update, XofReader}; use hybrid_array::typenum::U32; @@ -18,6 +19,18 @@ where reader: ::Reader, } +impl fmt::Debug for ExpandMsgXof +where + HashT: Default + ExtendableOutput + Update, + ::Reader: fmt::Debug, +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("ExpandMsgXof") + .field("reader", &self.reader) + .finish() + } +} + /// ExpandMsgXof implements `expand_message_xof` for the [`ExpandMsg`] trait impl<'a, HashT> ExpandMsg<'a> for ExpandMsgXof where diff --git a/elliptic-curve/src/hash2curve/isogeny.rs b/elliptic-curve/src/hash2curve/isogeny.rs index 6f49f427..0d7e0853 100644 --- a/elliptic-curve/src/hash2curve/isogeny.rs +++ b/elliptic-curve/src/hash2curve/isogeny.rs @@ -7,6 +7,7 @@ use ff::Field; use hybrid_array::{typenum::Unsigned, Array, ArraySize}; /// The coefficients for mapping from one isogenous curve to another +#[derive(Debug)] pub struct IsogenyCoefficients> { /// The coefficients for the x numerator pub xnum: &'static [F], diff --git a/elliptic-curve/src/hash2curve/osswu.rs b/elliptic-curve/src/hash2curve/osswu.rs index 3c3669ac..dc5d16d5 100644 --- a/elliptic-curve/src/hash2curve/osswu.rs +++ b/elliptic-curve/src/hash2curve/osswu.rs @@ -8,6 +8,7 @@ use subtle::ConditionallySelectable; use subtle::ConstantTimeEq; /// The Optimized Simplified Shallue-van de Woestijne-Ulas parameters +#[derive(Debug)] pub struct OsswuMapParams where F: Field, diff --git a/elliptic-curve/src/lib.rs b/elliptic-curve/src/lib.rs index 32ce2fa1..d98bab69 100644 --- a/elliptic-curve/src/lib.rs +++ b/elliptic-curve/src/lib.rs @@ -18,6 +18,7 @@ clippy::panic, clippy::panic_in_result_fn, clippy::unwrap_used, + missing_debug_implementations, missing_docs, rust_2018_idioms, unused_lifetimes, diff --git a/elliptic-curve/src/point/non_identity.rs b/elliptic-curve/src/point/non_identity.rs index 436410d7..a0f1e85f 100644 --- a/elliptic-curve/src/point/non_identity.rs +++ b/elliptic-curve/src/point/non_identity.rs @@ -17,7 +17,7 @@ use crate::{CurveArithmetic, NonZeroScalar, Scalar}; /// /// In the context of ECC, it's useful for ensuring that certain arithmetic /// cannot result in the identity point. -#[derive(Clone, Copy)] +#[derive(Clone, Copy, Debug)] pub struct NonIdentity

{ point: P, } diff --git a/elliptic-curve/src/scalar/blinded.rs b/elliptic-curve/src/scalar/blinded.rs index 29cfea98..914427f5 100644 --- a/elliptic-curve/src/scalar/blinded.rs +++ b/elliptic-curve/src/scalar/blinded.rs @@ -2,6 +2,7 @@ use super::Scalar; use crate::{ops::Invert, CurveArithmetic}; +use core::fmt; use group::ff::Field; use rand_core::CryptoRngCore; use subtle::CtOption; @@ -26,6 +27,12 @@ where mask: Scalar, } +impl fmt::Debug for BlindedScalar { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("BlindedScalar").finish_non_exhaustive() + } +} + impl BlindedScalar where C: CurveArithmetic, diff --git a/elliptic-curve/src/scalar/nonzero.rs b/elliptic-curve/src/scalar/nonzero.rs index dfcd2e77..9fd617e2 100644 --- a/elliptic-curve/src/scalar/nonzero.rs +++ b/elliptic-curve/src/scalar/nonzero.rs @@ -36,6 +36,12 @@ where scalar: Scalar, } +impl fmt::Debug for NonZeroScalar { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("NonZeroScalar").finish_non_exhaustive() + } +} + impl NonZeroScalar where C: CurveArithmetic,