parent
a86d0b7270
commit
2ac2d1213d
|
@ -166,6 +166,7 @@ macro_rules! curve_impl {
|
||||||
fn into_projective(&self) -> $projective {
|
fn into_projective(&self) -> $projective {
|
||||||
(*self).into()
|
(*self).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Rand for $projective {
|
impl Rand for $projective {
|
||||||
|
|
|
@ -814,6 +814,7 @@ impl SqrtField for Fq {
|
||||||
fn legendre(&self) -> ::LegendreSymbol {
|
fn legendre(&self) -> ::LegendreSymbol {
|
||||||
use ::LegendreSymbol::*;
|
use ::LegendreSymbol::*;
|
||||||
|
|
||||||
|
// s = self^((q - 1) // 2)
|
||||||
let s = self.pow([0xdcff7fffffffd555, 0xf55ffff58a9ffff, 0xb39869507b587b12,
|
let s = self.pow([0xdcff7fffffffd555, 0xf55ffff58a9ffff, 0xb39869507b587b12,
|
||||||
0xb23ba5c279c2895f, 0x258dd3db21a5d66b, 0xd0088f51cbff34d]);
|
0xb23ba5c279c2895f, 0x258dd3db21a5d66b, 0xd0088f51cbff34d]);
|
||||||
if s == Fq::zero() { Zero }
|
if s == Fq::zero() { Zero }
|
||||||
|
|
|
@ -432,6 +432,7 @@ fn test_fq2_sqrt() {
|
||||||
fn test_fq2_legendre() {
|
fn test_fq2_legendre() {
|
||||||
use ::LegendreSymbol::*;
|
use ::LegendreSymbol::*;
|
||||||
|
|
||||||
|
assert_eq!(Zero, Fq2::zero().legendre());
|
||||||
// i^2 = -1
|
// i^2 = -1
|
||||||
let mut m1 = Fq2::one();
|
let mut m1 = Fq2::one();
|
||||||
m1.negate();
|
m1.negate();
|
||||||
|
|
|
@ -327,7 +327,7 @@ pub trait Field: Sized +
|
||||||
/// This trait represents an element of a field that has a square root operation described for it.
|
/// This trait represents an element of a field that has a square root operation described for it.
|
||||||
pub trait SqrtField: Field
|
pub trait SqrtField: Field
|
||||||
{
|
{
|
||||||
/// Returns the legendre symbol of the field element.
|
/// Returns the Legendre symbol of the field element.
|
||||||
fn legendre(&self) -> LegendreSymbol;
|
fn legendre(&self) -> LegendreSymbol;
|
||||||
|
|
||||||
/// Returns the square root of the field element, if it is
|
/// Returns the square root of the field element, if it is
|
||||||
|
|
Loading…
Reference in New Issue