Skip to content

Commit 8ee15a1

Browse files
committed
Blanket impl RandomizedSigner for RandomizedDigestSigner
1 parent 73f2019 commit 8ee15a1

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

.github/workflows/signature.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
strategy:
5252
matrix:
5353
rust:
54-
- 1.85.0 # Minimum Rust version the tests pass on
54+
- 1.85.0 # MSRV
5555
- stable
5656
steps:
5757
- uses: actions/checkout@v4

signature/src/signer.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,21 @@ pub trait RandomizedDigestSigner<D: Digest, S> {
135135
) -> Result<S, Error>;
136136
}
137137

138+
#[cfg(all(feature = "digest", feature = "rand_core"))]
139+
impl<S, T> RandomizedSigner<S> for T
140+
where
141+
S: PrehashSignature,
142+
T: RandomizedDigestSigner<S::Digest, S>,
143+
{
144+
fn try_sign_with_rng<R: TryCryptoRng + ?Sized>(
145+
&self,
146+
rng: &mut R,
147+
msg: &[u8],
148+
) -> Result<S, Error> {
149+
self.try_sign_digest_with_rng(rng, S::Digest::new_with_prefix(msg))
150+
}
151+
}
152+
138153
/// Sign the provided message bytestring using `&mut Self` (e.g. an evolving
139154
/// cryptographic key such as a stateful hash-based signature), and a per-signature
140155
/// randomizer, returning a digital signature.

0 commit comments

Comments
 (0)