mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 14:17:56 +00:00
Update libp2p to v0.3 (#1634)
* Update libp2p * Some more diagnostics * 30 seconds back to 5 seconds * Bump libp2p-core and improve test * Fix runtime Cargo.lock * More work * Finish upgrade to libp2p 0.3 * Add a maximum of 60 seconds for the rounds * Remove env_logger * Update Cargo.lock * Update Cargo.lock in test-runtime * Fix test compilation * Make the test pass * Add identify addresses to Kademlia * Don't connect to nodes we're already connected to * Add warning for non-Substrate nodes * Fix external address not added * Start in Enabled mode
This commit is contained in:
committed by
Arkadiy Paronyan
parent
7d8ae2df5c
commit
b6fd967dfb
@@ -20,7 +20,7 @@
|
||||
|
||||
use untrusted;
|
||||
use blake2_rfc;
|
||||
use ring::{rand, signature};
|
||||
use ring::{rand, signature, signature::KeyPair};
|
||||
use {hash::H512, Ed25519AuthorityId};
|
||||
use base58::{ToBase58, FromBase58};
|
||||
|
||||
@@ -199,9 +199,11 @@ impl Pair {
|
||||
pub fn generate_with_pkcs8() -> (Self, [u8; PKCS_LEN]) {
|
||||
let rng = rand::SystemRandom::new();
|
||||
let pkcs8_bytes = signature::Ed25519KeyPair::generate_pkcs8(&rng).expect("system randomness is available; qed");
|
||||
let pair = Self::from_pkcs8(&pkcs8_bytes).expect("just-generated pkcs#8 data is valid; qed");
|
||||
let pair = Self::from_pkcs8(&pkcs8_bytes.as_ref()).expect("just-generated pkcs#8 data is valid; qed");
|
||||
|
||||
(pair, pkcs8_bytes)
|
||||
let mut out = [0; PKCS_LEN];
|
||||
out.copy_from_slice(pkcs8_bytes.as_ref());
|
||||
(pair, out)
|
||||
}
|
||||
|
||||
/// Generate new secure (random) key pair.
|
||||
@@ -211,7 +213,7 @@ impl Pair {
|
||||
}
|
||||
|
||||
/// Generate from pkcs#8 bytes.
|
||||
pub fn from_pkcs8(pkcs8_bytes: &[u8]) -> Result<Self, ::ring::error::Unspecified> {
|
||||
pub fn from_pkcs8(pkcs8_bytes: &[u8]) -> Result<Self, ::ring::error::KeyRejected> {
|
||||
signature::Ed25519KeyPair::from_pkcs8(untrusted::Input::from(&pkcs8_bytes)).map(Pair)
|
||||
}
|
||||
|
||||
@@ -234,7 +236,7 @@ impl Pair {
|
||||
/// Get the public key.
|
||||
pub fn public(&self) -> Public {
|
||||
let mut r = [0u8; 32];
|
||||
let pk = self.0.public_key_bytes();
|
||||
let pk = self.0.public_key().as_ref();
|
||||
r.copy_from_slice(pk);
|
||||
Public(r)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user