Skip to content

Commit

Permalink
fix: require rand feature when generating ecdsa key
Browse files Browse the repository at this point in the history
Using `libp2p-identity` as a crate did not work if `default-features` is `false` and `ecdsa` is included.

The following command also fails:
```
cargo check --no-default-features --features "ecdsa,ed25519,peerid,secp256k1"
```

Now, this command works

Pull-Request: #5212.
  • Loading branch information
Rjected authored Jun 12, 2024
1 parent fc9b1ad commit 5089299
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ libp2p-dns = { version = "0.41.1", path = "transports/dns" }
libp2p-floodsub = { version = "0.44.0", path = "protocols/floodsub" }
libp2p-gossipsub = { version = "0.46.2", path = "protocols/gossipsub" }
libp2p-identify = { version = "0.44.2", path = "protocols/identify" }
libp2p-identity = { version = "0.2.8" }
libp2p-identity = { version = "0.2.9" }
libp2p-kad = { version = "0.46.0", path = "protocols/kad" }
libp2p-mdns = { version = "0.45.1", path = "protocols/mdns" }
libp2p-memory-connection-limits = { version = "0.2.0", path = "misc/memory-connection-limits" }
Expand Down
5 changes: 5 additions & 0 deletions identity/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.2.9

- Add `rand` feature gate to ecdsa methods requiring a random number generator.
See [PR 5212](https://github.com/libp2p/rust-libp2p/pull/5212).

## 0.2.8

- Bump `ring` to `0.17.5.
Expand Down
2 changes: 1 addition & 1 deletion identity/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "libp2p-identity"
version = "0.2.8"
version = "0.2.9"
edition = "2021"
description = "Data structures and algorithms for identifying peers in libp2p."
rust-version = "1.73.0" # MUST NOT inherit from workspace because we don't want to publish breaking changes to `libp2p-identity`.
Expand Down
1 change: 1 addition & 0 deletions identity/src/ecdsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ pub struct SecretKey(SigningKey);

impl SecretKey {
/// Generate a new random ECDSA secret key.
#[cfg(feature = "rand")]
pub fn generate() -> SecretKey {
SecretKey(SigningKey::random(&mut rand::thread_rng()))
}
Expand Down

0 comments on commit 5089299

Please sign in to comment.