mirror of https://github.com/gtank/ristretto255
internal/radix51: make Generate produce random light-reduced elements
This commit is contained in:
parent
5382f6dbc9
commit
d4456f99c1
|
@ -21,17 +21,16 @@ import (
|
||||||
var quickCheckConfig = &quick.Config{MaxCountScale: 1 << 10}
|
var quickCheckConfig = &quick.Config{MaxCountScale: 1 << 10}
|
||||||
|
|
||||||
func generateFieldElement(rand *mathrand.Rand) FieldElement {
|
func generateFieldElement(rand *mathrand.Rand) FieldElement {
|
||||||
// Generation strategy: generate random limb values bounded by
|
// Generation strategy: generate random limb values of [52, 51, 51, 51, 51]
|
||||||
// 2**(51+b), where b is a parameter controlling the bit-excess.
|
// bits, like the ones returned by lightReduce.
|
||||||
// TODO: randomly decide to set the limbs to "weird" values.
|
// TODO: randomly decide to set the limbs to "weird" values.
|
||||||
b := uint64(0) // TODO: set this higher once we know the bounds.
|
const maskLow52Bits = (1 << 52) - 1
|
||||||
mask := (uint64(1) << (51 + b)) - 1
|
|
||||||
return FieldElement{
|
return FieldElement{
|
||||||
rand.Uint64() & mask,
|
rand.Uint64() & maskLow52Bits,
|
||||||
rand.Uint64() & mask,
|
rand.Uint64() & maskLow51Bits,
|
||||||
rand.Uint64() & mask,
|
rand.Uint64() & maskLow51Bits,
|
||||||
rand.Uint64() & mask,
|
rand.Uint64() & maskLow51Bits,
|
||||||
rand.Uint64() & mask,
|
rand.Uint64() & maskLow51Bits,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue