Skip to content
Merged
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
ecdsa: add associated sig type to RecoverableSignPrimitive
Adds an associated `RecoverableSignature` type to
`RecoverableSignPrimitive`.

This allows the primitive to handle construction of the full signature,
which makes it possible to add normalization at the generic
`ecdsa::signer::Signer` level.
  • Loading branch information
tarcieri committed Aug 7, 2020
commit 46b0202f4f320d1a19c0ef36fa7bf4f87638e12f
9 changes: 6 additions & 3 deletions ecdsa/src/hazmat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ where
C: Curve + Arithmetic,
SignatureSize<C>: ArrayLength<u8>,
{
/// Type for recoverable signatures
type RecoverableSignature: signature::Signature + Into<Signature<C>>;

/// Try to sign the prehashed message.
///
/// Accepts the same arguments as [`SignPrimitive::try_sign_prehashed`]
Expand All @@ -62,7 +65,7 @@ where
&self,
ephemeral_scalar: &K,
hashed_msg: &ElementBytes<C>,
) -> Result<(Signature<C>, bool), Error>;
) -> Result<Self::RecoverableSignature, Error>;
}

impl<C, T> SignPrimitive<C> for T
Expand All @@ -76,8 +79,8 @@ where
ephemeral_scalar: &K,
hashed_msg: &ElementBytes<C>,
) -> Result<Signature<C>, Error> {
let (sig, _) = self.try_sign_recoverable_prehashed(ephemeral_scalar, hashed_msg)?;
Ok(sig)
self.try_sign_recoverable_prehashed(ephemeral_scalar, hashed_msg)
.map(Into::into)
}
}

Expand Down