From 2ac2d1213d2a2cbafea6ba1645231b319f9d030c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michele=20Orr=C3=B9?= Date: Fri, 11 Aug 2017 15:12:15 +0200 Subject: [PATCH] Some (easy) cleanups as suggested from @daira. Thanks! --- src/bls12_381/ec.rs | 1 + src/bls12_381/fq.rs | 1 + src/bls12_381/fq2.rs | 1 + src/lib.rs | 2 +- 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bls12_381/ec.rs b/src/bls12_381/ec.rs index 9116844..b7041c3 100644 --- a/src/bls12_381/ec.rs +++ b/src/bls12_381/ec.rs @@ -166,6 +166,7 @@ macro_rules! curve_impl { fn into_projective(&self) -> $projective { (*self).into() } + } impl Rand for $projective { diff --git a/src/bls12_381/fq.rs b/src/bls12_381/fq.rs index 8bb2186..cb4f44b 100644 --- a/src/bls12_381/fq.rs +++ b/src/bls12_381/fq.rs @@ -814,6 +814,7 @@ impl SqrtField for Fq { fn legendre(&self) -> ::LegendreSymbol { use ::LegendreSymbol::*; + // s = self^((q - 1) // 2) let s = self.pow([0xdcff7fffffffd555, 0xf55ffff58a9ffff, 0xb39869507b587b12, 0xb23ba5c279c2895f, 0x258dd3db21a5d66b, 0xd0088f51cbff34d]); if s == Fq::zero() { Zero } diff --git a/src/bls12_381/fq2.rs b/src/bls12_381/fq2.rs index 6863a35..3095661 100644 --- a/src/bls12_381/fq2.rs +++ b/src/bls12_381/fq2.rs @@ -432,6 +432,7 @@ fn test_fq2_sqrt() { fn test_fq2_legendre() { use ::LegendreSymbol::*; + assert_eq!(Zero, Fq2::zero().legendre()); // i^2 = -1 let mut m1 = Fq2::one(); m1.negate(); diff --git a/src/lib.rs b/src/lib.rs index e25ae49..9798d0d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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. pub trait SqrtField: Field { - /// Returns the legendre symbol of the field element. + /// Returns the Legendre symbol of the field element. fn legendre(&self) -> LegendreSymbol; /// Returns the square root of the field element, if it is