mirror of
https://github.com/Qortal/pirate-librustzcash.git
synced 2025-07-30 03:51:22 +00:00
Mask rather than divn, closes #50.
This commit is contained in:
@@ -415,7 +415,10 @@ impl ::rand::Rand for Fq {
|
||||
fn rand<R: ::rand::Rng>(rng: &mut R) -> Self {
|
||||
loop {
|
||||
let mut tmp = Fq(FqRepr::rand(rng));
|
||||
tmp.0.divn(REPR_SHAVE_BITS);
|
||||
|
||||
// Mask away the unused bits at the beginning.
|
||||
tmp.0.as_mut()[5] &= 0xffffffffffffffff >> REPR_SHAVE_BITS;
|
||||
|
||||
if tmp.is_valid() {
|
||||
return tmp
|
||||
}
|
||||
|
@@ -237,7 +237,10 @@ impl ::rand::Rand for Fr {
|
||||
fn rand<R: ::rand::Rng>(rng: &mut R) -> Self {
|
||||
loop {
|
||||
let mut tmp = Fr(FrRepr::rand(rng));
|
||||
tmp.0.divn(REPR_SHAVE_BITS);
|
||||
|
||||
// Mask away the unused bits at the beginning.
|
||||
tmp.0.as_mut()[3] &= 0xffffffffffffffff >> REPR_SHAVE_BITS;
|
||||
|
||||
if tmp.is_valid() {
|
||||
return tmp
|
||||
}
|
||||
|
Reference in New Issue
Block a user