Some (easy) cleanups as suggested from @ebfull.
Thanks!
This commit is contained in:
parent
2ac2d1213d
commit
9846ad2d17
@ -158,7 +158,7 @@ impl Field for Fq2 {
|
||||
impl SqrtField for Fq2 {
|
||||
|
||||
fn legendre(&self) -> ::LegendreSymbol {
|
||||
Fq2::norm(&self).legendre()
|
||||
self.norm().legendre()
|
||||
}
|
||||
|
||||
fn sqrt(&self) -> Option<Self> {
|
||||
|
@ -554,6 +554,7 @@ impl Fr {
|
||||
impl SqrtField for Fr {
|
||||
|
||||
fn legendre(&self) -> ::LegendreSymbol {
|
||||
// s = self^((r - 1) // 2)
|
||||
let s = self.pow([0x7fffffff80000000, 0xa9ded2017fff2dff, 0x199cec0404d0ec02, 0x39f6d3a994cebea4]);
|
||||
if s == Self::zero() { Zero }
|
||||
else if s == Self::one() { QuadraticResidue }
|
||||
|
@ -1,5 +1,5 @@
|
||||
use rand::{Rng, SeedableRng, XorShiftRng};
|
||||
use ::{SqrtField, Field, PrimeField};
|
||||
use ::{SqrtField, Field, PrimeField, LegendreSymbol};
|
||||
|
||||
pub fn random_frobenius_tests<F: Field, C: AsRef<[u64]>>(characteristic: C, maxpower: usize) {
|
||||
let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]);
|
||||
@ -26,6 +26,7 @@ pub fn random_sqrt_tests<F: SqrtField>() {
|
||||
let a = F::rand(&mut rng);
|
||||
let mut b = a;
|
||||
b.square();
|
||||
assert_eq!(b.legendre(), LegendreSymbol::QuadraticResidue);
|
||||
|
||||
let b = b.sqrt().unwrap();
|
||||
let mut negb = b;
|
||||
@ -38,6 +39,8 @@ pub fn random_sqrt_tests<F: SqrtField>() {
|
||||
for _ in 0..10000 {
|
||||
let mut b = c;
|
||||
b.square();
|
||||
assert_eq!(b.legendre(), LegendreSymbol::QuadraticResidue);
|
||||
|
||||
b = b.sqrt().unwrap();
|
||||
|
||||
if b != c {
|
||||
|
Loading…
Reference in New Issue
Block a user