Mask rather than divn, closes #50.
This commit is contained in:
parent
291fa71914
commit
93e2a132b5
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user