feat: introduce libp2p-identity crate

This patch combines the `libp2p_core::identity` and `libp2p_core::peer_id` modules into a new crate: `libp2p-identity`.

Resolves https://github.com/libp2p/rust-libp2p/issues/3349.

Pull-Request: #3350.
This commit is contained in:
Thomas Eizinger
2023-03-13 01:46:58 +11:00
committed by GitHub
parent d81f9476f7
commit 2a14df25eb
180 changed files with 1014 additions and 347 deletions

View File

@ -28,13 +28,13 @@ use libp2p::{
core::{
multiaddr::{Multiaddr, Protocol},
transport::{OrTransport, Transport},
upgrade, PeerId,
upgrade,
},
dcutr,
dns::DnsConfig,
identify, identity, noise, ping, relay,
swarm::{NetworkBehaviour, SwarmBuilder, SwarmEvent},
tcp, yamux,
tcp, yamux, PeerId,
};
use log::info;
use std::error::Error;
@ -281,7 +281,5 @@ fn generate_ed25519(secret_key_seed: u8) -> identity::Keypair {
let mut bytes = [0u8; 32];
bytes[0] = secret_key_seed;
let secret_key = identity::ed25519::SecretKey::from_bytes(&mut bytes)
.expect("this returns `Err` only if the length is wrong; the length is correct; qed");
identity::Keypair::Ed25519(secret_key.into())
identity::Keypair::ed25519_from_bytes(bytes).expect("only errors on wrong length")
}