Migrate sapling-crypto to rand_core 0.4

This commit is contained in:
Jack Grigg
2019-07-19 00:46:34 +02:00
parent 83e1af104e
commit 60d344a0a7
18 changed files with 115 additions and 79 deletions
+4 -5
View File
@@ -8,9 +8,7 @@ use super::{
montgomery
};
use rand::{
Rng
};
use rand_core::RngCore;
use std::marker::PhantomData;
@@ -185,12 +183,13 @@ impl<E: JubjubEngine> Point<E, Unknown> {
convert_subgroup(&tmp)
}
pub fn rand<R: Rng>(rng: &mut R, params: &E::Params) -> Self
pub fn rand<R: RngCore>(rng: &mut R, params: &E::Params) -> Self
{
loop {
let y = E::Fr::random(rng);
let sign = rng.next_u32() % 2 != 0;
if let Some(p) = Self::get_for_y(y, rng.gen(), params) {
if let Some(p) = Self::get_for_y(y, sign, params) {
return p;
}
}
+4 -2
View File
@@ -4,7 +4,7 @@ use ff::{
LegendreSymbol::{self, *},
PrimeField, PrimeFieldDecodingError, PrimeFieldRepr, SqrtField,
};
use rand::RngCore;
use rand_core::RngCore;
use super::ToUniform;
@@ -620,7 +620,9 @@ fn test_neg_one() {
}
#[cfg(test)]
use rand::{SeedableRng, XorShiftRng};
use rand_core::SeedableRng;
#[cfg(test)]
use rand_xorshift::XorShiftRng;
#[test]
fn test_fs_repr_ordering() {
+4 -5
View File
@@ -8,9 +8,7 @@ use super::{
edwards
};
use rand::{
Rng
};
use rand_core::RngCore;
use std::marker::PhantomData;
@@ -101,12 +99,13 @@ impl<E: JubjubEngine> Point<E, Unknown> {
convert_subgroup(&tmp)
}
pub fn rand<R: Rng>(rng: &mut R, params: &E::Params) -> Self
pub fn rand<R: RngCore>(rng: &mut R, params: &E::Params) -> Self
{
loop {
let x = E::Fr::random(rng);
let sign = rng.next_u32() % 2 != 0;
match Self::get_for_x(x, rng.gen(), params) {
match Self::get_for_x(x, sign, params) {
Some(p) => {
return p
},
+2 -1
View File
@@ -14,7 +14,8 @@ use ff::{
LegendreSymbol
};
use rand::{RngCore, XorShiftRng, SeedableRng};
use rand_core::{RngCore, SeedableRng};
use rand_xorshift::XorShiftRng;
pub fn test_suite<E: JubjubEngine>(params: &E::Params) {
test_back_and_forth::<E>(params);