Skip to content
This repository has been archived by the owner on Mar 7, 2024. It is now read-only.

Update rand requirement from 0.7 to 0.8 #80

Merged
merged 5 commits into from Apr 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples-unsafe/Cargo.toml
Expand Up @@ -20,7 +20,7 @@ serde = {version = "1.0", features = ["derive"]}
rayon = "1.3.0"
hacspec-dev = { path = "../utils/dev" }
criterion = "^0.3"
rand = "^0.7"
rand = "^0.8"

[[bench]]
name = "benchmarks"
Expand Down
2 changes: 1 addition & 1 deletion lib/Cargo.toml
Expand Up @@ -19,4 +19,4 @@ hacspec-attributes = { path = "../utils/attributes", optional = true, version =
use_attributes = ["hacspec-attributes", "hacspec-attributes/print_attributes"]

[dev-dependencies]
rand = "0.7"
rand = "0.8"
6 changes: 3 additions & 3 deletions lib/tests/test_util.rs
Expand Up @@ -3,7 +3,7 @@

use hacspec_lib::prelude::*;

use rand::{AsByteSliceMut, Rng};
use rand::{Fill, Rng};

pub(crate) fn get_expected(op: &'static str, a: &String, b: &String) -> String {
let expected = std::process::Command::new("python")
Expand All @@ -25,7 +25,7 @@ pub(crate) fn random_hex_string(len: usize) -> String {
let mut res = "".to_string();
let mut rng = rand::thread_rng();
for _ in 0..len {
res.push(HEX_CHARS[rng.gen_range(0, HEX_CHARS.len())]);
res.push(HEX_CHARS[rng.gen_range(0..HEX_CHARS.len())]);
}
res = res.trim_start_matches('0').to_string();
if res.len() == 0 {
Expand All @@ -44,7 +44,7 @@ pub(crate) fn get_random_numbers<T: Integer>() -> (String, T, String, T) {
(a, a_t, b, b_t)
}

pub(crate) fn random_bytes<A: Default + AsByteSliceMut>() -> A {
pub(crate) fn random_bytes<A: Default + Fill>() -> A {
let mut out = A::default();
rand::thread_rng().fill(&mut out);
out
Expand Down
2 changes: 1 addition & 1 deletion utils/dev/Cargo.toml
Expand Up @@ -9,7 +9,7 @@ repository = "https://github.com/hacspec/hacspec"
[dependencies]
hacspec-lib = { path = "../../lib", version = "0.1.0-beta.1" }

rand = "0.7"
rand = "0.8"
num = "0.4"
serde_json = "1.0"
serde = {version = "1.0", features = ["derive"]}
11 changes: 5 additions & 6 deletions utils/dev/src/rand.rs
@@ -1,7 +1,7 @@
use hacspec_lib::prelude::*;
use rand::{
distributions::uniform::SampleBorrow, distributions::uniform::SampleUniform,
distributions::Distribution, distributions::Standard, AsByteSliceMut, Rng,
distributions::Distribution, distributions::Standard, Fill, Rng,
};

/// Random public integer
Expand All @@ -13,12 +13,11 @@ where
}

/// Random public integer in range `[min, max)`
pub fn random_public_integer_range<T, U>(min: U, max: U) -> T
pub fn random_public_integer_range<U>(min: U, max: U) -> U
where
U: SampleBorrow<T> + Sized,
T: SampleUniform,
U: SampleBorrow<U> + Sized + SampleUniform + PartialOrd,
{
rand::thread_rng().gen_range(min, max)
rand::thread_rng().gen_range(min..max)
}

/// Random public byte
Expand All @@ -33,7 +32,7 @@ pub fn random_byte() -> U8 {
}

/// Random array
pub fn random_bytes<A: Default + AsByteSliceMut>() -> A {
pub fn random_bytes<A: Default + Fill>() -> A {
let mut out = A::default();
rand::thread_rng().fill(&mut out);
out
Expand Down
2 changes: 1 addition & 1 deletion utils/evercrypt-provider/Cargo.toml
Expand Up @@ -15,4 +15,4 @@ aead = "0.3"
[dev-dependencies]
serde_json = "1.0"
serde = {version = "1.0", features = ["derive"]}
rand = "0.7"
rand = "0.8"
2 changes: 1 addition & 1 deletion utils/rc-bench/Cargo.toml
Expand Up @@ -11,7 +11,7 @@ evercrypt-provider = { path = "../evercrypt-provider" }
hacspec-provider = { path = "../../provider" }
chacha20poly1305 = "0.7"
criterion = "^0.3"
rand = "^0.7"
rand = "^0.8"

[[bench]]
name = "benchmarks"
Expand Down