Replace rand with rand_core where possible

Turns out rand_core offers OsRng.
This commit is contained in:
Luke Parker 2022-07-27 05:43:23 -04:00
parent 023afaf7ce
commit 755dc84859
No known key found for this signature in database
GPG key ID: F9F1386DB1E119B6
14 changed files with 23 additions and 25 deletions

4
Cargo.lock generated
View file

@ -1795,7 +1795,7 @@ dependencies = [
"hex-literal",
"k256",
"modular-frost",
"rand 0.8.5",
"rand_core 0.6.3",
"serde",
"serde_json",
"sha3 0.10.1",
@ -4531,7 +4531,6 @@ dependencies = [
"k256",
"multiexp",
"p256",
"rand 0.8.5",
"rand_core 0.6.3",
"sha2 0.10.2",
"thiserror",
@ -7532,7 +7531,6 @@ dependencies = [
"modular-frost",
"monero",
"monero-serai",
"rand 0.8.5",
"rand_core 0.6.3",
"serde",
"serde_json",

View file

@ -7,22 +7,25 @@ authors = ["Luke Parker <lukeparker5132@gmail.com>", "Elizabeth Binks <elizabeth
edition = "2021"
[dependencies]
hex-literal = "0.3"
thiserror = "1"
rand_core = "0.6"
serde_json = "1.0"
serde = "1.0"
hex-literal = "0.3"
ethers = { version = "0.14", features = ["abigen", "ethers-solc"] }
eyre = "0.6"
sha3 = "0.10"
group = "0.12"
k256 = { version = "0.11", features = ["arithmetic", "keccak256", "ecdsa"] }
frost = { package = "modular-frost", path = "../../crypto/frost", features = ["secp256k1"] }
sha3 = "0.10"
group = "0.12"
eyre = "0.6"
ethers = { version = "0.14", features = ["abigen", "ethers-solc"] }
[dev-dependencies]
rand = "0.8"
tokio = { version = "1.19", features = ["macros"] }
tokio = { version = "1", features = ["macros"] }
[build-dependencies]
ethers-solc = "0.14"

View file

@ -24,7 +24,7 @@ async fn test_ecrecover_hack() {
};
use k256::elliptic_curve::bigint::ArrayEncoding;
use k256::{Scalar, U256};
use rand::rngs::OsRng;
use rand_core::OsRng;
let anvil = Anvil::new().spawn();
let wallet: LocalWallet = anvil.keys()[0].clone().into();

View file

@ -12,7 +12,7 @@ fn test_ecrecover() {
signature::{Signer, Verifier},
SigningKey, VerifyingKey,
};
use rand::rngs::OsRng;
use rand_core::OsRng;
let private = SigningKey::random(&mut OsRng);
let public = VerifyingKey::from(&private);
@ -33,7 +33,7 @@ fn test_signing() {
algorithm::Schnorr,
tests::{algorithm_machines, key_gen, sign},
};
use rand::rngs::OsRng;
use rand_core::OsRng;
let keys = key_gen::<_, Secp256k1>(&mut OsRng);
let _group_key = keys[&1].group_key();
@ -53,7 +53,7 @@ fn test_ecrecover_hack() {
algorithm::Schnorr,
tests::{algorithm_machines, key_gen, sign},
};
use rand::rngs::OsRng;
use rand_core::OsRng;
let keys = key_gen::<_, Secp256k1>(&mut OsRng);
let group_key = keys[&1].group_key();

View file

@ -1,7 +1,7 @@
#[cfg(feature = "multisig")]
use std::sync::{Arc, RwLock};
use rand::{RngCore, rngs::OsRng};
use rand_core::{RngCore, OsRng};
use curve25519_dalek::{constants::ED25519_BASEPOINT_TABLE, scalar::Scalar};

View file

@ -1,4 +1,4 @@
use rand::rngs::OsRng;
use rand_core::OsRng;
use curve25519_dalek::constants::ED25519_BASEPOINT_TABLE;

View file

@ -4,7 +4,7 @@ use std::collections::HashMap;
use lazy_static::lazy_static;
use rand::rngs::OsRng;
use rand_core::OsRng;
#[cfg(feature = "multisig")]
use blake2::{digest::Update, Digest, Blake2b512};

View file

@ -31,8 +31,6 @@ multiexp = { path = "../multiexp", version = "0.2", features = ["batch"] }
dleq = { package = "dleq-serai", path = "../dleq", version = "0.1", features = ["serialize"] }
[dev-dependencies]
rand = "0.8"
sha2 = "0.10"
dalek-ff-group = { path = "../dalek-ff-group" }

View file

@ -1,4 +1,4 @@
use rand::rngs::OsRng;
use rand_core::OsRng;
use crate::{
curve,

View file

@ -1,4 +1,4 @@
use rand::rngs::OsRng;
use rand_core::OsRng;
#[cfg(any(feature = "secp256k1", feature = "p256"))]
use crate::tests::vectors::{Vectors, test_with_vectors};

View file

@ -34,6 +34,5 @@ monero-serai = { path = "../coins/monero", features = ["multisig"] }
[dev-dependencies]
group = "0.12"
rand = "0.8"
futures = "0.3"
tokio = { version = "1", features = ["full"] }

View file

@ -213,7 +213,7 @@ impl Coin for Monero {
#[cfg(test)]
async fn test_send(&self, address: Self::Address) {
use rand::rngs::OsRng;
use rand_core::OsRng;
let height = self.get_height().await.unwrap();

View file

@ -6,7 +6,7 @@ use std::{
use async_trait::async_trait;
use rand::rngs::OsRng;
use rand_core::OsRng;
use crate::{
NetworkError, Network,

View file

@ -30,4 +30,4 @@ sp-api = { git = "https://github.com/serai-dex/substrate" }
serai-runtime = { path = "../runtime" }
tokio = "1.15"
tokio = "1"