Skip to content

Commit 449d748

Browse files
authored
ecdsa: provide a SigningKey::try_from_rng (#915)
1 parent 8de0caf commit 449d748

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

Cargo.lock

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+6-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ slh-dsa = { path = "./slh-dsa" }
3131

3232
# https://github.com/RustCrypto/traits/pull/1751
3333
# https://github.com/RustCrypto/traits/pull/1767
34+
# https://github.com/RustCrypto/traits/pull/1774
3435
elliptic-curve = { git = "https://github.com/RustCrypto/traits.git" }
3536
signature = { git = "https://github.com/RustCrypto/traits.git" }
3637

@@ -39,6 +40,10 @@ signature = { git = "https://github.com/RustCrypto/traits.git" }
3940
crypto-bigint = { git = "https://github.com/RustCrypto/crypto-bigint.git" }
4041

4142
# https://github.com/zkcrypto/ff/pull/122
42-
ff = { git = "https://github.com/pinkforest/ff.git", branch = "bump-rand-core" }
43+
# https://github.com/zkcrypto/ff/pull/126
44+
# https://github.com/zkcrypto/ff/pull/127
45+
# https://github.com/zkcrypto/ff/pull/130
46+
ff = { git = "https://github.com/zkcrypto/ff.git", branch = "release-0.14.0" }
47+
4348
# https://github.com/zkcrypto/group/pull/56
4449
group = { git = "https://github.com/pinkforest/group.git", branch = "bump-rand-0.9" }

ecdsa/src/signing.rs

+7
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ where
8585
NonZeroScalar::<C>::random(rng).into()
8686
}
8787

88+
/// Generate a cryptographically random [`SigningKey`].
89+
pub fn try_from_rng<R: TryCryptoRng + ?Sized>(
90+
rng: &mut R,
91+
) -> core::result::Result<Self, R::Error> {
92+
Ok(NonZeroScalar::<C>::try_from_rng(rng)?.into())
93+
}
94+
8895
/// Initialize signing key from a raw scalar serialized as a byte array.
8996
pub fn from_bytes(bytes: &FieldBytes<C>) -> Result<Self> {
9097
SecretKey::<C>::from_bytes(bytes)

0 commit comments

Comments
 (0)