diff --git a/Cargo.lock b/Cargo.lock index 27283b9268fc59a8efe0e158be8c6f5013d379e9..3bdb2b4b74fa9161aaf6c5ee57f927d60a4f6fa1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -524,14 +524,6 @@ name = "cfg-if" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "chacha20-poly1305-aead" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "constant_time_eq 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "chrono" version = "0.4.10" @@ -852,10 +844,7 @@ dependencies = [ "bincode 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "bs58 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "chacha20-poly1305-aead 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "durs-common-tools 0.2.0", "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.16.9 (registry+https://github.com/rust-lang/crates.io-index)", "scrypt 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3172,7 +3161,6 @@ dependencies = [ "checksum c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb" "checksum cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)" = "f52a465a666ca3d838ebbf08b241383421412fe7ebb463527bba275526d89f76" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum chacha20-poly1305-aead 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77d2058ba29594f69c75e8a9018e0485e3914ca5084e3613cd64529042f5423b" "checksum chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "31850b4a4d6bae316f7a09e691c944c28299298837edc0a03f755618c23cbc01" "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" diff --git a/lib/core/conf/src/keypairs.rs b/lib/core/conf/src/keypairs.rs index 2d34ba9cf8b15b20a33fa9e8adf10e720b361478..0a6b7fc812c45c845b1bff6ad7317c537e01b784 100644 --- a/lib/core/conf/src/keypairs.rs +++ b/lib/core/conf/src/keypairs.rs @@ -96,7 +96,9 @@ impl DuniterKeyPairs { /// Warning: This function cannot use the macro fatal_error! because the logger is not yet initialized, so it must use panic ! fn generate_random_keypair(algo: KeysAlgo) -> KeyPairEnum { match algo { - KeysAlgo::Ed25519 => KeyPairEnum::Ed25519(ed25519::Ed25519KeyPair::generate_random()), + KeysAlgo::Ed25519 => KeyPairEnum::Ed25519( + ed25519::Ed25519KeyPair::generate_random().expect("unspecified rand error"), + ), KeysAlgo::Schnorr => panic!("Schnorr algo not yet supported !"), } } diff --git a/lib/core/conf/src/lib.rs b/lib/core/conf/src/lib.rs index e7dec054f29104c82fa507805b6e88b8e5e4408f..36a47b915b560efb1943935e342fe1a0f33d7bc1 100644 --- a/lib/core/conf/src/lib.rs +++ b/lib/core/conf/src/lib.rs @@ -230,7 +230,7 @@ impl DursConfTrait for DuRsConf { #[inline] fn generate_random_node_id() -> u32 { - rand::gen_u32() + rand::gen_u32().expect("unspecified rand error") } /// Return the user datas folder name diff --git a/lib/core/conf/src/modules_conf.rs b/lib/core/conf/src/modules_conf.rs index 21a323f3a57d1455164078f9832c24b8a64108d6..521571481c7a08a3cddf2064ec59e86ba7b8edc1 100644 --- a/lib/core/conf/src/modules_conf.rs +++ b/lib/core/conf/src/modules_conf.rs @@ -142,7 +142,9 @@ mod tests { fn keypairs() -> DuniterKeyPairs { DuniterKeyPairs { - network_keypair: KeyPairEnum::Ed25519(ed25519::Ed25519KeyPair::generate_random()), + network_keypair: KeyPairEnum::Ed25519( + ed25519::Ed25519KeyPair::generate_random().expect("unspecified rand error"), + ), member_keypair: None, } } diff --git a/lib/crypto/Cargo.toml b/lib/crypto/Cargo.toml index e5eb0616ee5e798c6c86fdb2af62a73e0a0f2b42..6b6d1212370c54d3936a90f54baa3dd51fa8a6b7 100644 --- a/lib/crypto/Cargo.toml +++ b/lib/crypto/Cargo.toml @@ -2,7 +2,7 @@ name = "dup-crypto" version = "0.7.0" authors = ["nanocryk <nanocryk@duniter.org>", "elois <elois@duniter.org>"] -description = "Manage cryptographic operations for the DUP (DUniter Protocol)." +description = "Manage cryptographic operations for DUPs (DUniter Protocols)." repository = "https://git.duniter.org/nodes/rust/duniter-rs" readme = "README.md" keywords = ["duniter", "keys", "cryptography"] @@ -16,14 +16,11 @@ path = "src/lib.rs" base64 = "0.11.0" bs58 = "0.3.0" byteorder = "1.3.2" -chacha20-poly1305-aead = "0.1.2" failure = "0.1.5" ring = "0.16.9" scrypt = { version = "0.2", default-features = false } serde = "1.0.*" serde_derive = "1.0.*" -durs-common-tools = { path = "../tools/common-tools", version = "0.2.0" } -log = "0.4.*" unwrap = "1.2.1" zeroize = { version = "1.1.0", features = ["zeroize_derive"] } diff --git a/lib/crypto/src/bases/b58.rs b/lib/crypto/src/bases/b58.rs index 0d49f232bab6fe6abdd41db7d49bcb733bae3e34..fea202ca5ebea468c46cefecea6866d2f52edcfc 100644 --- a/lib/crypto/src/bases/b58.rs +++ b/lib/crypto/src/bases/b58.rs @@ -25,7 +25,6 @@ pub trait ToBase58 { /// Create an array of 32 bytes from a Base58 string. pub fn str_base58_to_32bytes(base58_data: &str) -> Result<([u8; 32], usize), BaseConvertionError> { - debug!("str_base58_to_32bytes({});", base58_data); match bs58::decode(base58_data).into_vec() { Ok(result) => { let len = result.len(); diff --git a/lib/crypto/src/errors.rs b/lib/crypto/src/errors.rs index f2aa44ade28087080e56f0b9cdca2cb7d8b2002d..c7cd399bb40a8cf28bbec3fb53ec38f0b71529e7 100644 --- a/lib/crypto/src/errors.rs +++ b/lib/crypto/src/errors.rs @@ -15,6 +15,20 @@ //! Manage cryptographic errors. -#[derive(Clone, Copy, Debug)] -/// Cryptographic error -pub enum CryptoError {} +/// An error with absolutely no details. +/// +/// *dup-crypto* uses this unit type as the error type in most of its results +/// because (a) usually the specific reasons for a failure are obvious or are +/// not useful to know, and/or (b) providing more details about a failure might +/// provide a dangerous side channel, and/or (c) it greatly simplifies the +/// error handling logic. +/// +/// Experience with using and implementing other crypto libraries like has +/// shown that sophisticated error reporting facilities often cause significant +/// bugs themselves, both within the crypto library and within users of the +/// crypto library. This approach attempts to minimize complexity in the hopes +/// of avoiding such problems. In some cases, this approach may be too extreme, +/// and it may be important for an operation to provide some details about the +/// cause of a failure. Users of *dup-crypto* are encouraged to report such cases so +/// that they can be addressed individually. +pub type Unspecified = ring::error::Unspecified; diff --git a/lib/crypto/src/hashs/mod.rs b/lib/crypto/src/hashs/mod.rs index 81e5e43c4d1fef4817ffdea6ed06d4bcf7ddc2f0..c12b43a03fed6d84b9a8cf26ef8fb69767bf9173 100644 --- a/lib/crypto/src/hashs/mod.rs +++ b/lib/crypto/src/hashs/mod.rs @@ -16,7 +16,6 @@ //! Provide wrappers for cryptographic hashs use crate::bases::*; -use durs_common_tools::fatal_error; use ring::{digest, rand}; use std::fmt::{Debug, Display, Error, Formatter}; @@ -50,12 +49,9 @@ impl Hash { /// Generate a random Hash #[inline] - pub fn random() -> Self { - if let Ok(random_bytes) = rand::generate::<[u8; 32]>(&rand::SystemRandom::new()) { - Hash(random_bytes.expose()) - } else { - fatal_error!("System error: fail to generate random hash !") - } + pub fn random() -> Result<Self, crate::errors::Unspecified> { + let random_bytes = rand::generate::<[u8; 32]>(&rand::SystemRandom::new())?; + Ok(Hash(random_bytes.expose())) } /// Compute hash of any binary datas diff --git a/lib/crypto/src/keys/ed25519.rs b/lib/crypto/src/keys/ed25519.rs index d0aac4b714bffbc5aa36a9ad4abce8474b4c6e3f..a9abfe0afc81451dc982f96155f3223c19344c77 100644 --- a/lib/crypto/src/keys/ed25519.rs +++ b/lib/crypto/src/keys/ed25519.rs @@ -309,8 +309,8 @@ impl super::KeyPair for Ed25519KeyPair { impl Ed25519KeyPair { /// Generate random keypair - pub fn generate_random() -> Self { - KeyPairFromSeed32Generator::generate(Seed32::random()) + pub fn generate_random() -> Result<Self, crate::errors::Unspecified> { + Ok(KeyPairFromSeed32Generator::generate(Seed32::random()?)) } } diff --git a/lib/crypto/src/keys/mod.rs b/lib/crypto/src/keys/mod.rs index 1d86286ee7643ae062e760a9887e4e584b007842..b28b431d9072e25a694dc256883cfbe0c499626e 100644 --- a/lib/crypto/src/keys/mod.rs +++ b/lib/crypto/src/keys/mod.rs @@ -56,7 +56,6 @@ pub use crate::seeds::Seed32; use crate::bases::b58::ToBase58; use crate::bases::BaseConvertionError; -use durs_common_tools::fatal_error; use failure::Fail; use std::convert::TryFrom; use std::fmt::Debug; @@ -159,7 +158,7 @@ impl Sig { pub fn size_in_bytes(&self) -> usize { match *self { Sig::Ed25519(_) => *ed25519::SIG_SIZE_IN_BYTES + 2, - Sig::Schnorr() => fatal_error!("Schnorr algo not yet supported !"), + Sig::Schnorr() => panic!("Schnorr algo not yet supported !"), } } } @@ -187,13 +186,13 @@ impl Signature for Sig { fn to_bytes_vector(&self) -> Vec<u8> { match *self { Sig::Ed25519(ed25519_sig) => ed25519_sig.to_bytes_vector(), - Sig::Schnorr() => fatal_error!("Schnorr algo not yet supported !"), + Sig::Schnorr() => panic!("Schnorr algo not yet supported !"), } } fn to_base64(&self) -> String { match *self { Sig::Ed25519(ed25519_sig) => ed25519_sig.to_base64(), - Sig::Schnorr() => fatal_error!("Schnorr algo not yet supported !"), + Sig::Schnorr() => panic!("Schnorr algo not yet supported !"), } } } @@ -258,7 +257,7 @@ impl PubKey { pub fn size_in_bytes(&self) -> usize { match *self { PubKey::Ed25519(_) => ed25519::PUBKEY_SIZE_IN_BYTES + 3, - PubKey::Schnorr() => fatal_error!("Schnorr algo not yet supported !"), + PubKey::Schnorr() => panic!("Schnorr algo not yet supported !"), } } } @@ -282,7 +281,7 @@ impl ToBase58 for PubKey { fn to_base58(&self) -> String { match *self { PubKey::Ed25519(ed25519_pub) => ed25519_pub.to_base58(), - PubKey::Schnorr() => fatal_error!("Schnorr algo not yet supported !"), + PubKey::Schnorr() => panic!("Schnorr algo not yet supported !"), } } } @@ -311,7 +310,7 @@ impl PublicKey for PubKey { fn to_bytes_vector(&self) -> Vec<u8> { match *self { PubKey::Ed25519(ed25519_pubkey) => ed25519_pubkey.to_bytes_vector(), - PubKey::Schnorr() => fatal_error!("Schnorr algo not yet supported !"), + PubKey::Schnorr() => panic!("Schnorr algo not yet supported !"), } } fn verify(&self, message: &[u8], signature: &Self::Signature) -> Result<(), SigError> { @@ -320,10 +319,10 @@ impl PublicKey for PubKey { if let Sig::Ed25519(ed25519_sig) = signature { ed25519_pubkey.verify(message, ed25519_sig) } else { - fatal_error!("Try to verify a signature with public key of a different algorithm !\nSignature={:?}\nPublickey={:?}", signature, self) + Err(SigError::NotSameAlgo) } } - PubKey::Schnorr() => fatal_error!("Schnorr algo not yet supported !"), + PubKey::Schnorr() => panic!("Schnorr algo not yet supported !"), } } } @@ -388,7 +387,7 @@ impl Display for KeyPairEnum { KeyPairEnum::Ed25519(ref ed25519_keypair) => { write!(f, "({}, hidden)", ed25519_keypair.pubkey.to_base58()) } - KeyPairEnum::Schnorr() => fatal_error!("Schnorr algo not yet supported !"), + KeyPairEnum::Schnorr() => panic!("Schnorr algo not yet supported !"), } } } @@ -401,7 +400,7 @@ impl KeyPair for KeyPairEnum { KeyPairEnum::Ed25519(ref ed25519_keypair) => { Ok(SignatorEnum::Ed25519(ed25519_keypair.generate_signator()?)) } - KeyPairEnum::Schnorr() => fatal_error!("Schnorr algo not yet supported !"), + KeyPairEnum::Schnorr() => panic!("Schnorr algo not yet supported !"), } } fn public_key(&self) -> <Self::Signator as Signator>::PublicKey { @@ -409,13 +408,13 @@ impl KeyPair for KeyPairEnum { KeyPairEnum::Ed25519(ref ed25519_keypair) => { PubKey::Ed25519(ed25519_keypair.public_key()) } - KeyPairEnum::Schnorr() => fatal_error!("Schnorr algo not yet supported !"), + KeyPairEnum::Schnorr() => panic!("Schnorr algo not yet supported !"), } } fn seed(&self) -> &Seed32 { match *self { KeyPairEnum::Ed25519(ref ed25519_keypair) => &ed25519_keypair.seed(), - KeyPairEnum::Schnorr() => fatal_error!("Schnorr algo not yet supported !"), + KeyPairEnum::Schnorr() => panic!("Schnorr algo not yet supported !"), } } fn verify(&self, message: &[u8], signature: &Sig) -> Result<(), SigError> { @@ -424,10 +423,10 @@ impl KeyPair for KeyPairEnum { if let Sig::Ed25519(ed25519_sig) = signature { ed25519_keypair.verify(message, ed25519_sig) } else { - fatal_error!("Try to verify a signature with key pair of a different algorithm !\nSignature={:?}\nKeyPair={}", signature, self) + Err(SigError::NotSameAlgo) } } - KeyPairEnum::Schnorr() => fatal_error!("Schnorr algo not yet supported !"), + KeyPairEnum::Schnorr() => panic!("Schnorr algo not yet supported !"), } } } @@ -450,7 +449,7 @@ impl Signator for SignatorEnum { SignatorEnum::Ed25519(ref ed25519_signator) => { PubKey::Ed25519(ed25519_signator.public_key()) } - SignatorEnum::Schnorr() => fatal_error!("Schnorr algo not yet supported !"), + SignatorEnum::Schnorr() => panic!("Schnorr algo not yet supported !"), } } @@ -459,7 +458,7 @@ impl Signator for SignatorEnum { SignatorEnum::Ed25519(ref ed25519_signator) => { Sig::Ed25519(ed25519_signator.sign(message)) } - SignatorEnum::Schnorr() => fatal_error!("Schnorr algo not yet supported !"), + SignatorEnum::Schnorr() => panic!("Schnorr algo not yet supported !"), } } } diff --git a/lib/crypto/src/lib.rs b/lib/crypto/src/lib.rs index 5020ebcc4591dd1de5e48a514920b29b0c7db4a3..ebc1f0aa222bc8e8e943dc7aa7509b022277aa1b 100644 --- a/lib/crypto/src/lib.rs +++ b/lib/crypto/src/lib.rs @@ -33,8 +33,6 @@ extern crate failure; #[macro_use] extern crate serde_derive; -#[macro_use] -extern crate log; pub mod bases; pub mod errors; diff --git a/lib/crypto/src/rand.rs b/lib/crypto/src/rand.rs index e6184dc1884cbd872a30675e21217c5d9cc8a7e2..a0f82b6274c43483f1e1f5081a39c624bd7da04b 100644 --- a/lib/crypto/src/rand.rs +++ b/lib/crypto/src/rand.rs @@ -16,18 +16,14 @@ //! Manage random generation. use byteorder::ByteOrder; -use durs_common_tools::fatal_error; use ring::rand; #[inline] /// Generate random u32 -pub fn gen_u32() -> u32 { +pub fn gen_u32() -> Result<u32, crate::errors::Unspecified> { let rng = rand::SystemRandom::new(); - if let Ok(random_bytes) = rand::generate::<[u8; 4]>(&rng) { - byteorder::BigEndian::read_u32(&random_bytes.expose()) - } else { - fatal_error!("System error: fail to generate random boolean !") - } + let random_bytes = rand::generate::<[u8; 4]>(&rng)?; + Ok(byteorder::BigEndian::read_u32(&random_bytes.expose())) } #[cfg(test)] diff --git a/lib/crypto/src/seeds.rs b/lib/crypto/src/seeds.rs index 7d03033ca6d1b12d5b4a3c33da40afaa9717818a..c35865ac586554a0a575a2bdc441a158b8916463 100644 --- a/lib/crypto/src/seeds.rs +++ b/lib/crypto/src/seeds.rs @@ -17,7 +17,6 @@ use crate::bases::b58::{bytes_to_str_base58, ToBase58}; use crate::bases::*; -use durs_common_tools::fatal_error; use ring::rand; use std::fmt::{self, Debug, Display, Formatter}; use zeroize::Zeroize; @@ -64,12 +63,9 @@ impl Seed32 { } #[inline] /// Generate random seed - pub fn random() -> Seed32 { - if let Ok(random_bytes) = rand::generate::<[u8; 32]>(&rand::SystemRandom::new()) { - Seed32::new(random_bytes.expose()) - } else { - fatal_error!("System error: fail to generate random seed !") - } + pub fn random() -> Result<Seed32, crate::errors::Unspecified> { + let random_bytes = rand::generate::<[u8; 32]>(&rand::SystemRandom::new())?; + Ok(Seed32::new(random_bytes.expose())) } } diff --git a/lib/modules/blockchain/blockchain/tests/revert_blocks.rs b/lib/modules/blockchain/blockchain/tests/revert_blocks.rs index 488371ef7ef8a7c2c4c9af31cf17b3050baceec9..0ff7f9837232282a6444d0fd86c73d278e207fab 100644 --- a/lib/modules/blockchain/blockchain/tests/revert_blocks.rs +++ b/lib/modules/blockchain/blockchain/tests/revert_blocks.rs @@ -66,6 +66,7 @@ fn test_revert_blocks_g1() { // Generate 6 forks blocks from 62 to 67 included let signator = SignatorEnum::Ed25519( dup_crypto::keys::ed25519::Ed25519KeyPair::generate_random() + .expect("unspecified rand error") .generate_signator() .expect("fail to generatye signator"), ); @@ -139,6 +140,7 @@ fn test_revert_blocks_gt() { // Generate 7 forks blocks from 547 to 553 included let signator = SignatorEnum::Ed25519( dup_crypto::keys::ed25519::Ed25519KeyPair::generate_random() + .expect("unspecified rand error") .generate_signator() .expect("fail to generatye signator"), ); diff --git a/lib/modules/ws2p-v1-legacy/src/ws_connections/mod.rs b/lib/modules/ws2p-v1-legacy/src/ws_connections/mod.rs index 1306847329e2b59099455dfbdaef77d42370195c..c598d94e562853ad3712c51d6566415ccde2e2a4 100644 --- a/lib/modules/ws2p-v1-legacy/src/ws_connections/mod.rs +++ b/lib/modules/ws2p-v1-legacy/src/ws_connections/mod.rs @@ -171,7 +171,7 @@ pub fn close_connection( pub fn get_random_connection<S: ::std::hash::BuildHasher>( connections: HashSet<&NodeFullId, S>, ) -> NodeFullId { - let random_usize = rand::gen_u32() as usize; + let random_usize = rand::gen_u32().expect("unspecified rand error") as usize; let mut count = random_usize % connections.len(); let mut last_node_full_id = None; for node_full_id in &connections { diff --git a/lib/modules/ws2p/ws2p-messages/v2/connect.rs b/lib/modules/ws2p/ws2p-messages/v2/connect.rs index 1126b53856b9538b39e9c599fcd89d7797e0d9bf..04e05001c17679ef51c5a66468abfba084e3bae8 100644 --- a/lib/modules/ws2p/ws2p-messages/v2/connect.rs +++ b/lib/modules/ws2p/ws2p-messages/v2/connect.rs @@ -128,7 +128,7 @@ pub struct WS2Pv2ConnectMsg { impl Default for WS2Pv2ConnectMsg { fn default() -> Self { WS2Pv2ConnectMsg { - challenge: Hash::random(), + challenge: Hash::random().expect("unspecified rand error"), api_features: WS2PFeatures([0u8; 4]), flags_queries: WS2PConnectFlags(vec![]), peer_card: None, diff --git a/lib/modules/ws2p/ws2p-messages/v2/mod.rs b/lib/modules/ws2p/ws2p-messages/v2/mod.rs index 391cd1082442e04f11b23ab2717a38819ef1e547..427a97bf6a50df266974158b10761678e30612d5 100644 --- a/lib/modules/ws2p/ws2p-messages/v2/mod.rs +++ b/lib/modules/ws2p/ws2p-messages/v2/mod.rs @@ -91,7 +91,7 @@ mod tests { #[test] fn test_ws2p_message_ack() { test_ws2p_message(WS2Pv2MessagePayload::Ack { - challenge: Hash::random(), + challenge: Hash::random().expect("unspecified rand error"), }); } diff --git a/lib/modules/ws2p/ws2p-messages/v2/secret_flags.rs b/lib/modules/ws2p/ws2p-messages/v2/secret_flags.rs index 78193a97b149d929a93d69833c2065793d975627..0e4a0c0b2cfecf2f2134ff30afd03847f7d612c9 100644 --- a/lib/modules/ws2p/ws2p-messages/v2/secret_flags.rs +++ b/lib/modules/ws2p/ws2p-messages/v2/secret_flags.rs @@ -73,7 +73,7 @@ mod tests { let keypair1 = keypair1(); let signator = SignatorEnum::Ed25519(keypair1.generate_signator().expect("fail to gen signator")); - let challenge = Hash::random(); + let challenge = Hash::random().expect("unspecified rand error"); let msg = WS2Pv2SecretFlagsMsg { secret_flags: WS2Pv2SecretFlags(vec![]), member_proof: Some(MemberProof { diff --git a/lib/modules/ws2p/ws2p/src/controllers/incoming_connections.rs b/lib/modules/ws2p/ws2p/src/controllers/incoming_connections.rs index d3e306d1cc82e071105fe281edf9a09a893f04c8..261acb21e8b74d96050befdb446fe9b21a057b3f 100644 --- a/lib/modules/ws2p/ws2p/src/controllers/incoming_connections.rs +++ b/lib/modules/ws2p/ws2p/src/controllers/incoming_connections.rs @@ -43,7 +43,7 @@ pub fn listen_on_ws2p_v2_endpoint<A: ToSocketAddrs + Debug>( match WS2PController::<DursMsg>::try_new( WS2PControllerId::Incoming, WS2PControllerMetaDatas::new( - Hash::random(), + Hash::random().expect("unspecified rand error"), WS2Pv2ConnectType::Incoming, currency.clone(), self_node.clone(), diff --git a/lib/modules/ws2p/ws2p/src/controllers/outgoing_connections.rs b/lib/modules/ws2p/ws2p/src/controllers/outgoing_connections.rs index dcabd55e52affd675e19ed91e847518f3e0ab21c..8b1a16b5a6f60a58c48bdf49064de8e57c8ecd6e 100644 --- a/lib/modules/ws2p/ws2p/src/controllers/outgoing_connections.rs +++ b/lib/modules/ws2p/ws2p/src/controllers/outgoing_connections.rs @@ -53,7 +53,7 @@ pub fn connect_to_ws2p_v2_endpoint( expected_remote_full_id, }, WS2PControllerMetaDatas::new( - Hash::random(), + Hash::random().expect("unspecified rand error"), WS2Pv2ConnectType::OutgoingServer, currency.clone(), self_node.clone(),