mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-26 08:11:39 +00:00
Bump most dependencies (#1268)
* Bump most dependencies This actually builds 😊. * Bump all dependencies Includes the excellent work of @rschulman in #1265. * Remove use of ed25519-dalek fork * Monomorphize more dependencies * Add compatibility hack for rand Cargo allows a crate to depend on multiple versions of another, but `cargo-web` panics in that situation. Use a wrapper crate to work around the panic. * Use @tomaka’s idea for using a newer `rand` instead of my own ugly hack. * Switch to Parity master as its dependency-bumping PR has been merged. * Update some depenendencies again * Remove unwraps and `#[allow(deprecated)]`. * Remove spurious changes to dependencies Bumping minor or patch versions is not needed, and increases likelyhood of merge conflicts. * Remove some redundant Cargo.toml changes * Replace a retry loop with an expect `ed25519::SecretKey::from_bytes` will never fail for 32-byte inputs. * Revert changes that don’t belong in this PR
This commit is contained in:
committed by
Pierre Krieger
parent
eb7b7bd919
commit
979c82040e
@ -22,6 +22,7 @@
|
||||
|
||||
use ed25519_dalek as ed25519;
|
||||
use failure::Fail;
|
||||
use rand::RngCore;
|
||||
use super::error::DecodingError;
|
||||
use zeroize::Zeroize;
|
||||
use core::fmt;
|
||||
@ -32,7 +33,7 @@ pub struct Keypair(ed25519::Keypair);
|
||||
impl Keypair {
|
||||
/// Generate a new Ed25519 keypair.
|
||||
pub fn generate() -> Keypair {
|
||||
Keypair(ed25519::Keypair::generate(&mut rand::thread_rng()))
|
||||
Keypair::from(SecretKey::generate())
|
||||
}
|
||||
|
||||
/// Encode the keypair into a byte array by concatenating the bytes
|
||||
@ -94,9 +95,9 @@ impl From<Keypair> for SecretKey {
|
||||
/// Promote an Ed25519 secret key into a keypair.
|
||||
impl From<SecretKey> for Keypair {
|
||||
fn from(sk: SecretKey) -> Keypair {
|
||||
let secret = sk.0;
|
||||
let secret: ed25519::ExpandedSecretKey = (&sk.0).into();
|
||||
let public = ed25519::PublicKey::from(&secret);
|
||||
Keypair(ed25519::Keypair { secret, public })
|
||||
Keypair(ed25519::Keypair { secret: sk.0, public })
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,7 +152,10 @@ impl fmt::Debug for SecretKey {
|
||||
impl SecretKey {
|
||||
/// Generate a new Ed25519 secret key.
|
||||
pub fn generate() -> SecretKey {
|
||||
SecretKey(ed25519::SecretKey::generate(&mut rand::thread_rng()))
|
||||
let mut bytes = [0u8; 32];
|
||||
rand::thread_rng().fill_bytes(&mut bytes);
|
||||
SecretKey(ed25519::SecretKey::from_bytes(&bytes)
|
||||
.expect("this returns `Err` only if the length is wrong; the length is correct; qed"))
|
||||
}
|
||||
|
||||
/// Create an Ed25519 secret key from a byte slice, zeroing the input on success.
|
||||
|
Reference in New Issue
Block a user