Skip to content

Commit

Permalink
Merge pull request #380 from narodnik/jubjub_fr_random
Browse files Browse the repository at this point in the history
Replace redundant code with call to Field::random() which does the same as the code.
  • Loading branch information
str4d committed May 4, 2021
2 parents 3b02c8b + da431a0 commit 05bd98b
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions zcash_primitives/src/sapling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub mod util;
use bitvec::{order::Lsb0, view::AsBits};
use blake2s_simd::Params as Blake2sParams;
use byteorder::{LittleEndian, WriteBytesExt};
use ff::PrimeField;
use ff::{Field, PrimeField};
use group::{Curve, Group, GroupEncoding};
use lazy_static::lazy_static;
use rand_core::{CryptoRng, RngCore};
Expand Down Expand Up @@ -470,14 +470,7 @@ impl Note {

pub(crate) fn generate_or_derive_esk_internal<R: RngCore>(&self, rng: &mut R) -> jubjub::Fr {
match self.derive_esk() {
None => {
// create random 64 byte buffer
let mut buffer = [0u8; 64];
rng.fill_bytes(&mut buffer);

// reduce to uniform value
jubjub::Fr::from_bytes_wide(&buffer)
}
None => jubjub::Fr::random(rng),
Some(esk) => esk,
}
}
Expand Down

0 comments on commit 05bd98b

Please sign in to comment.