diff --git a/Cargo.lock b/Cargo.lock index dc3a351e..adcbd3f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -369,7 +369,7 @@ checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" [[package]] name = "elliptic-curve" version = "0.14.0-rc.1" -source = "git+https://github.com/RustCrypto/traits.git#28b6e0d3231fa0fb31dc7f6bfdb62d6558bcfdf6" +source = "git+https://github.com/baloo/traits.git?branch=baloo%2Felliptic-curve%2Fscalar-try-from-rng#d4ee8d28491f112071f1ef9647cfb64ea8643508" dependencies = [ "base16ct", "crypto-bigint", @@ -416,7 +416,7 @@ checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" [[package]] name = "ff" version = "0.13.0" -source = "git+https://github.com/pinkforest/ff.git?branch=bump-rand-core#c734f7f21d6639bc6494dde538209d0770207c49" +source = "git+https://github.com/baloo/ff.git?branch=baloo%2Ftry_from_rng#4ccfef5353d0d0e11b4beda9292e0c1722d9f371" dependencies = [ "rand_core 0.9.2", "subtle", diff --git a/Cargo.toml b/Cargo.toml index c565a0b0..84198cd6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,8 @@ sha3 = { git = "https://github.com/RustCrypto/hashes.git" } # https://github.com/RustCrypto/traits/pull/1751 # https://github.com/RustCrypto/traits/pull/1767 -elliptic-curve = { git = "https://github.com/RustCrypto/traits.git" } +# https://github.com/RustCrypto/traits/pull/1774 +elliptic-curve = { git = "https://github.com/baloo/traits.git", branch = "baloo/elliptic-curve/scalar-try-from-rng" } signature = { git = "https://github.com/RustCrypto/traits.git" } # https://github.com/RustCrypto/crypto-bigint/pull/762 @@ -43,7 +44,10 @@ signature = { git = "https://github.com/RustCrypto/traits.git" } crypto-bigint = { git = "https://github.com/RustCrypto/crypto-bigint.git" } # https://github.com/zkcrypto/ff/pull/122 -ff = { git = "https://github.com/pinkforest/ff.git", branch = "bump-rand-core" } +# https://github.com/zkcrypto/ff/pull/126 +# https://github.com/zkcrypto/ff/pull/127 +ff = { git = "https://github.com/baloo/ff.git", branch = "baloo/try_from_rng" } + # https://github.com/zkcrypto/group/pull/56 group = { git = "https://github.com/pinkforest/group.git", branch = "bump-rand-0.9" } diff --git a/ecdsa/src/signing.rs b/ecdsa/src/signing.rs index bc49c301..e6c1f3e5 100644 --- a/ecdsa/src/signing.rs +++ b/ecdsa/src/signing.rs @@ -85,6 +85,13 @@ where NonZeroScalar::::random(rng).into() } + /// Generate a cryptographically random [`SigningKey`]. + pub fn try_from_rng( + rng: &mut R, + ) -> core::result::Result { + Ok(NonZeroScalar::::try_from_rng(rng)?.into()) + } + /// Initialize signing key from a raw scalar serialized as a byte array. pub fn from_bytes(bytes: &FieldBytes) -> Result { SecretKey::::from_bytes(bytes)