mirror of https://github.com/zcash/halo2.git
Remove rand 0.7 usage
Upstream redjubjub (on which our reddsa dependency is based) has migrated to rand 0.8.
This commit is contained in:
parent
3117187280
commit
012d14073d
|
@ -27,7 +27,6 @@ fpe = "0.4"
|
|||
group = "0.9"
|
||||
proptest = { version = "1.0.0", optional = true }
|
||||
rand = "0.8"
|
||||
rand_7 = { package = "rand", version = "0.7" }
|
||||
nonempty = "0.6"
|
||||
subtle = "2.3"
|
||||
|
||||
|
@ -41,7 +40,7 @@ rev = "b55a6960dfafd7f767e2820ddf1adaa499322f98"
|
|||
|
||||
[dependencies.reddsa]
|
||||
git = "https://github.com/str4d/redjubjub.git"
|
||||
rev = "f1e76dbc9abf2b68cc609e874fe39f2a15b75b12"
|
||||
rev = "daab5355bf8e85289aa37804656bf85182df9eea"
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = "0.3"
|
||||
|
|
|
@ -6,7 +6,7 @@ use std::iter;
|
|||
use ff::Field;
|
||||
use nonempty::NonEmpty;
|
||||
use pasta_curves::pallas;
|
||||
use rand::RngCore;
|
||||
use rand::{CryptoRng, RngCore};
|
||||
|
||||
use crate::{
|
||||
address::Address,
|
||||
|
@ -371,7 +371,7 @@ impl<V> Bundle<Unauthorized, V> {
|
|||
/// Loads the sighash into this bundle, preparing it for signing.
|
||||
///
|
||||
/// This API ensures that all signatures are created over the same sighash.
|
||||
pub fn prepare<R: rand_7::RngCore + rand_7::CryptoRng>(
|
||||
pub fn prepare<R: RngCore + CryptoRng>(
|
||||
self,
|
||||
mut rng: R,
|
||||
sighash: [u8; 32],
|
||||
|
@ -394,7 +394,7 @@ impl<V> Bundle<Unauthorized, V> {
|
|||
}
|
||||
|
||||
/// Applies signatures to this bundle, in order to authorize it.
|
||||
pub fn apply_signatures<R: rand_7::RngCore + rand_7::CryptoRng>(
|
||||
pub fn apply_signatures<R: RngCore + CryptoRng>(
|
||||
self,
|
||||
mut rng: R,
|
||||
sighash: [u8; 32],
|
||||
|
@ -413,11 +413,7 @@ impl<V> Bundle<PartiallyAuthorized, V> {
|
|||
/// Signs this bundle with the given [`SpendAuthorizingKey`].
|
||||
///
|
||||
/// This will apply signatures for all notes controlled by this spending key.
|
||||
pub fn sign<R: rand_7::RngCore + rand_7::CryptoRng>(
|
||||
self,
|
||||
mut rng: R,
|
||||
ask: &SpendAuthorizingKey,
|
||||
) -> Self {
|
||||
pub fn sign<R: RngCore + CryptoRng>(self, mut rng: R, ask: &SpendAuthorizingKey) -> Self {
|
||||
let expected_ak = ask.into();
|
||||
self.authorize(
|
||||
&mut rng,
|
||||
|
@ -492,16 +488,15 @@ pub mod testing {
|
|||
/// from these inputs, but using a `ValueBalance` implementation that
|
||||
/// is defined by the end user.
|
||||
#[derive(Debug)]
|
||||
struct ArbitraryBundleInputs<R, R7> {
|
||||
struct ArbitraryBundleInputs<R> {
|
||||
rng: R,
|
||||
rng_7: R7,
|
||||
sk: SpendingKey,
|
||||
anchor: Anchor,
|
||||
notes: Vec<Note>,
|
||||
recipient_amounts: Vec<(Address, NoteValue)>,
|
||||
}
|
||||
|
||||
impl<R: RngCore + CryptoRng, R7: rand_7::RngCore + rand_7::CryptoRng> ArbitraryBundleInputs<R, R7> {
|
||||
impl<R: RngCore + CryptoRng> ArbitraryBundleInputs<R> {
|
||||
/// Create a bundle from the set of arbitrary bundle inputs.
|
||||
fn into_bundle<V: TryFrom<i64>>(mut self) -> Bundle<Authorized, V> {
|
||||
let fvk = FullViewingKey::from(&self.sk);
|
||||
|
@ -523,8 +518,8 @@ pub mod testing {
|
|||
builder
|
||||
.build(&mut self.rng, &pk)
|
||||
.unwrap()
|
||||
.prepare(&mut self.rng_7, [0; 32])
|
||||
.sign(&mut self.rng_7, &SpendAuthorizingKey::from(&self.sk))
|
||||
.prepare(&mut self.rng, [0; 32])
|
||||
.sign(&mut self.rng, &SpendAuthorizingKey::from(&self.sk))
|
||||
.finalize()
|
||||
.unwrap()
|
||||
}
|
||||
|
@ -552,10 +547,9 @@ pub mod testing {
|
|||
n_recipients as usize
|
||||
),
|
||||
rng_seed in prop::array::uniform32(prop::num::u8::ANY)
|
||||
) -> ArbitraryBundleInputs<StdRng, rand_7::rngs::StdRng> {
|
||||
) -> ArbitraryBundleInputs<StdRng> {
|
||||
ArbitraryBundleInputs {
|
||||
rng: StdRng::from_seed(rng_seed),
|
||||
rng_7: <rand_7::rngs::StdRng as rand_7::SeedableRng>::from_seed(rng_seed),
|
||||
sk: sk.clone(),
|
||||
anchor,
|
||||
notes,
|
||||
|
@ -608,7 +602,7 @@ mod tests {
|
|||
let bundle: Bundle<Authorized, i64> = dbg!(builder
|
||||
.build(&mut rng, &pk)
|
||||
.unwrap()
|
||||
.prepare(rand_7::rngs::OsRng, [0; 32]))
|
||||
.prepare(&mut rng, [0; 32]))
|
||||
.finalize()
|
||||
.unwrap();
|
||||
assert_eq!(bundle.value_balance(), &(-5000))
|
||||
|
|
|
@ -355,7 +355,7 @@ pub struct BundleAuthorizingCommitment;
|
|||
#[cfg(any(test, feature = "test-dependencies"))]
|
||||
pub mod testing {
|
||||
use nonempty::NonEmpty;
|
||||
use rand_7::{rngs::StdRng, SeedableRng};
|
||||
use rand::{rngs::StdRng, SeedableRng};
|
||||
use reddsa::orchard::SpendAuth;
|
||||
|
||||
use proptest::collection::vec;
|
||||
|
|
|
@ -8,7 +8,7 @@ use fpe::ff1::{BinaryNumeralString, FF1};
|
|||
use group::GroupEncoding;
|
||||
use halo2::arithmetic::FieldExt;
|
||||
use pasta_curves::pallas;
|
||||
use rand::RngCore;
|
||||
use rand::{CryptoRng, RngCore};
|
||||
use subtle::CtOption;
|
||||
|
||||
use crate::{
|
||||
|
@ -77,7 +77,7 @@ impl SpendAuthorizingKey {
|
|||
}
|
||||
|
||||
/// Creates a spend authorization signature over the given message.
|
||||
pub fn sign<R: rand_7::RngCore + rand_7::CryptoRng>(
|
||||
pub fn sign<R: RngCore + CryptoRng>(
|
||||
&self,
|
||||
rng: R,
|
||||
msg: &[u8],
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use std::convert::{TryFrom, TryInto};
|
||||
|
||||
use pasta_curves::pallas;
|
||||
use rand_7::{CryptoRng, RngCore};
|
||||
use rand::{CryptoRng, RngCore};
|
||||
|
||||
/// A RedPallas signature type.
|
||||
pub trait SigType: reddsa::SigType + private::Sealed {}
|
||||
|
|
Loading…
Reference in New Issue