From 46b0202f4f320d1a19c0ef36fa7bf4f87638e12f Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Fri, 7 Aug 2020 12:55:19 -0700 Subject: [PATCH] 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. --- ecdsa/src/hazmat.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ecdsa/src/hazmat.rs b/ecdsa/src/hazmat.rs index 0c157f63..b63ffc57 100644 --- a/ecdsa/src/hazmat.rs +++ b/ecdsa/src/hazmat.rs @@ -52,6 +52,9 @@ where C: Curve + Arithmetic, SignatureSize: ArrayLength, { + /// Type for recoverable signatures + type RecoverableSignature: signature::Signature + Into>; + /// Try to sign the prehashed message. /// /// Accepts the same arguments as [`SignPrimitive::try_sign_prehashed`] @@ -62,7 +65,7 @@ where &self, ephemeral_scalar: &K, hashed_msg: &ElementBytes, - ) -> Result<(Signature, bool), Error>; + ) -> Result; } impl SignPrimitive for T @@ -76,8 +79,8 @@ where ephemeral_scalar: &K, hashed_msg: &ElementBytes, ) -> Result, 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) } }