Skip to content

Commit 1a3816a

Browse files
authored
fix(identity): drop rand_core feature in ed25519-dalek
This PR - drops `rand_core` feature dependency from `ed25519-dalek` crate to unblock upgrading `rand` crate to `v0.9`. Pull-Request: #6070.
1 parent d578e08 commit 1a3816a

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

Cargo.lock

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ libp2p-dns = { version = "0.44.0", path = "transports/dns" }
8484
libp2p-floodsub = { version = "0.46.1", path = "protocols/floodsub" }
8585
libp2p-gossipsub = { version = "0.49.0", path = "protocols/gossipsub" }
8686
libp2p-identify = { version = "0.47.0", path = "protocols/identify" }
87-
libp2p-identity = { version = "0.2.11" }
87+
libp2p-identity = { version = "0.2.12" }
8888
libp2p-kad = { version = "0.47.1", path = "protocols/kad" }
8989
libp2p-mdns = { version = "0.48.0", path = "protocols/mdns" }
9090
libp2p-memory-connection-limits = { version = "0.4.0", path = "misc/memory-connection-limits" }

identity/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.2.12
2+
3+
- Avoid depending on the `rand_core` feature in `ed25519-dalek` crate.
4+
See [PR 6070](https://github.com/libp2p/rust-libp2p/pull/6070)
5+
16
## 0.2.11
27

38
- Switch from `libsecp256` to `k256` for secp256k1 support.

identity/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "libp2p-identity"
3-
version = "0.2.11"
3+
version = "0.2.12"
44
edition = "2021" # MUST NOT inherit from workspace because we don't want to publish breaking changes to `libp2p-identity`.
55
description = "Data structures and algorithms for identifying peers in libp2p."
66
rust-version = "1.73.0" # MUST NOT inherit from workspace because we don't want to publish breaking changes to `libp2p-identity`.
@@ -37,7 +37,7 @@ ecdsa = ["dep:p256", "dep:zeroize", "dep:sec1", "dep:sha2", "dep:hkdf"]
3737
rsa = ["dep:ring", "dep:asn1_der", "dep:rand", "dep:zeroize"]
3838
ed25519 = ["dep:ed25519-dalek", "dep:zeroize", "dep:sha2", "dep:hkdf"]
3939
peerid = ["dep:multihash", "dep:bs58", "dep:thiserror", "dep:sha2", "dep:hkdf"]
40-
rand = ["dep:rand", "ed25519-dalek?/rand_core"]
40+
rand = ["dep:rand"]
4141

4242
[dev-dependencies]
4343
quickcheck = { workspace = true }

identity/src/ed25519.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,11 @@ impl SecretKey {
184184
/// Generate a new Ed25519 secret key.
185185
#[cfg(feature = "rand")]
186186
pub fn generate() -> SecretKey {
187-
let signing = ed25519::SigningKey::generate(&mut rand::rngs::OsRng);
188-
SecretKey(signing.to_bytes())
187+
use rand::RngCore as _;
188+
189+
let mut secret = ed25519::SecretKey::default();
190+
rand::rngs::OsRng.fill_bytes(&mut secret);
191+
SecretKey(secret)
189192
}
190193

191194
/// Try to parse an Ed25519 secret key from a byte slice

0 commit comments

Comments
 (0)