s/Q/Quadratic/ in LegendreSymbol enum.
Proposed by @ebfull.
This commit is contained in:
parent
6feb0f802f
commit
a86d0b7270
@ -817,8 +817,8 @@ impl SqrtField for Fq {
|
||||
let s = self.pow([0xdcff7fffffffd555, 0xf55ffff58a9ffff, 0xb39869507b587b12,
|
||||
0xb23ba5c279c2895f, 0x258dd3db21a5d66b, 0xd0088f51cbff34d]);
|
||||
if s == Fq::zero() { Zero }
|
||||
else if s == Fq::one() { QResidue }
|
||||
else { QNonResidue }
|
||||
else if s == Fq::one() { QuadraticResidue }
|
||||
else { QuadraticNonResidue }
|
||||
}
|
||||
|
||||
fn sqrt(&self) -> Option<Self> {
|
||||
@ -1796,16 +1796,16 @@ fn fq_repr_tests() {
|
||||
fn test_fq_legendre() {
|
||||
use ::LegendreSymbol::*;
|
||||
|
||||
assert_eq!(QResidue, Fq::one().legendre());
|
||||
assert_eq!(QuadraticResidue, Fq::one().legendre());
|
||||
assert_eq!(Zero, Fq::zero().legendre());
|
||||
|
||||
assert_eq!(QNonResidue, Fq::from_repr(FqRepr::from(2)).unwrap().legendre());
|
||||
assert_eq!(QResidue, Fq::from_repr(FqRepr::from(4)).unwrap().legendre());
|
||||
assert_eq!(QuadraticNonResidue, Fq::from_repr(FqRepr::from(2)).unwrap().legendre());
|
||||
assert_eq!(QuadraticResidue, Fq::from_repr(FqRepr::from(4)).unwrap().legendre());
|
||||
|
||||
let e = FqRepr([0x52a112f249778642, 0xd0bedb989b7991f, 0xdad3b6681aa63c05,
|
||||
0xf2efc0bb4721b283, 0x6057a98f18c24733, 0x1022c2fd122889e4]);
|
||||
assert_eq!(QNonResidue, Fq::from_repr(e).unwrap().legendre());
|
||||
assert_eq!(QuadraticNonResidue, Fq::from_repr(e).unwrap().legendre());
|
||||
let e = FqRepr([0x6dae594e53a96c74, 0x19b16ca9ba64b37b, 0x5c764661a59bfc68,
|
||||
0xaa346e9b31c60a, 0x346059f9d87a9fa9, 0x1d61ac6bfd5c88b]);
|
||||
assert_eq!(QResidue, Fq::from_repr(e).unwrap().legendre());
|
||||
assert_eq!(QuadraticResidue, Fq::from_repr(e).unwrap().legendre());
|
||||
}
|
||||
|
@ -435,9 +435,9 @@ fn test_fq2_legendre() {
|
||||
// i^2 = -1
|
||||
let mut m1 = Fq2::one();
|
||||
m1.negate();
|
||||
assert_eq!(QResidue, m1.legendre());
|
||||
assert_eq!(QuadraticResidue, m1.legendre());
|
||||
m1.mul_by_nonresidue();
|
||||
assert_eq!(QNonResidue, m1.legendre());
|
||||
assert_eq!(QuadraticNonResidue, m1.legendre());
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -556,8 +556,8 @@ impl SqrtField for Fr {
|
||||
fn legendre(&self) -> ::LegendreSymbol {
|
||||
let s = self.pow([0x7fffffff80000000, 0xa9ded2017fff2dff, 0x199cec0404d0ec02, 0x39f6d3a994cebea4]);
|
||||
if s == Self::zero() { Zero }
|
||||
else if s == Self::one() { QResidue }
|
||||
else { QNonResidue }
|
||||
else if s == Self::one() { QuadraticResidue }
|
||||
else { QuadraticNonResidue }
|
||||
}
|
||||
|
||||
fn sqrt(&self) -> Option<Self> {
|
||||
@ -565,8 +565,8 @@ impl SqrtField for Fr {
|
||||
// https://eprint.iacr.org/2012/685.pdf (page 12, algorithm 5)
|
||||
match self.legendre() {
|
||||
Zero => Some(*self),
|
||||
QNonResidue => None,
|
||||
QResidue => {
|
||||
QuadraticNonResidue => None,
|
||||
QuadraticResidue => {
|
||||
let mut c = Fr(ROOT_OF_UNITY);
|
||||
// r = self^((t + 1) // 2)
|
||||
let mut r = self.pow([0x7fff2dff80000000, 0x4d0ec02a9ded201, 0x94cebea4199cec04, 0x39f6d3a9]);
|
||||
@ -785,13 +785,13 @@ fn test_fr_repr_sub_noborrow() {
|
||||
|
||||
#[test]
|
||||
fn test_fr_legendre() {
|
||||
assert_eq!(QResidue, Fr::one().legendre());
|
||||
assert_eq!(QuadraticResidue, Fr::one().legendre());
|
||||
assert_eq!(Zero, Fr::zero().legendre());
|
||||
|
||||
let e = FrRepr([0x0dbc5349cd5664da, 0x8ac5b6296e3ae29d, 0x127cb819feceaa3b, 0x3a6b21fb03867191]);
|
||||
assert_eq!(QResidue, Fr::from_repr(e).unwrap().legendre());
|
||||
assert_eq!(QuadraticResidue, Fr::from_repr(e).unwrap().legendre());
|
||||
let e = FrRepr([0x96341aefd047c045, 0x9b5f4254500a4d65, 0x1ee08223b68ac240, 0x31d9cd545c0ec7c6]);
|
||||
assert_eq!(QNonResidue, Fr::from_repr(e).unwrap().legendre());
|
||||
assert_eq!(QuadraticNonResidue, Fr::from_repr(e).unwrap().legendre());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -416,8 +416,8 @@ pub trait PrimeFieldRepr: Sized +
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum LegendreSymbol {
|
||||
Zero = 0,
|
||||
QResidue = 1,
|
||||
QNonResidue = -1
|
||||
QuadraticResidue = 1,
|
||||
QuadraticNonResidue = -1
|
||||
}
|
||||
|
||||
/// An error that may occur when trying to interpret a `PrimeFieldRepr` as a
|
||||
|
Loading…
Reference in New Issue
Block a user