You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@milagro.apache.org by km...@apache.org on 2019/12/13 16:34:00 UTC
[incubator-milagro-crypto-rust] 02/18: Add gitignore and run cargo
fmt --all
This is an automated email from the ASF dual-hosted git repository.
kmccusker pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-milagro-crypto-rust.git
commit a665a5cec38836d6ed774765e85684ecb926f934
Author: Kirk Baird <ba...@outlook.com>
AuthorDate: Wed Jul 3 11:25:15 2019 +1000
Add gitignore and run cargo fmt --all
---
.gitignore | 1 +
src/aes.rs | 50 +++---
src/big.rs | 14 +-
src/bls.rs | 18 +-
src/bls192.rs | 20 +--
src/bls256.rs | 18 +-
src/dbig.rs | 6 +-
src/ecdh.rs | 11 +-
src/ecp.rs | 31 ++--
src/ecp2.rs | 35 ++--
src/ecp4.rs | 4 +-
src/ecp8.rs | 6 +-
src/ff.rs | 4 +-
src/fp.rs | 38 ++---
src/fp12.rs | 381 ++++++++++++++++++++++++------------------
src/fp16.rs | 22 +--
src/fp2.rs | 26 +--
src/fp24.rs | 360 ++++++++++++++++++++++-----------------
src/fp4.rs | 32 ++--
src/fp48.rs | 362 ++++++++++++++++++++++-----------------
src/fp8.rs | 23 ++-
src/lib.rs | 182 ++++++++++----------
src/mpin.rs | 9 +-
src/mpin192.rs | 9 +-
src/mpin256.rs | 6 +-
src/pair.rs | 101 ++++++-----
src/pair192.rs | 67 ++++----
src/pair256.rs | 65 ++++---
src/roms/rom_anssi_32.rs | 4 +-
src/roms/rom_anssi_64.rs | 4 +-
src/roms/rom_bls24_32.rs | 4 +-
src/roms/rom_bls24_64.rs | 4 +-
src/roms/rom_bls381_32.rs | 4 +-
src/roms/rom_bls381_64.rs | 4 +-
src/roms/rom_bls383_32.rs | 4 +-
src/roms/rom_bls383_64.rs | 4 +-
src/roms/rom_bls461_32.rs | 4 +-
src/roms/rom_bls461_64.rs | 4 +-
src/roms/rom_bls48_32.rs | 4 +-
src/roms/rom_bls48_64.rs | 4 +-
src/roms/rom_bn254CX_32.rs | 4 +-
src/roms/rom_bn254CX_64.rs | 5 +-
src/roms/rom_bn254_32.rs | 4 +-
src/roms/rom_bn254_64.rs | 6 +-
src/roms/rom_brainpool_32.rs | 4 +-
src/roms/rom_brainpool_64.rs | 4 +-
src/roms/rom_c25519_32.rs | 4 +-
src/roms/rom_c25519_64.rs | 4 +-
src/roms/rom_c41417_32.rs | 4 +-
src/roms/rom_c41417_64.rs | 4 +-
src/roms/rom_ed25519_32.rs | 4 +-
src/roms/rom_ed25519_64.rs | 4 +-
src/roms/rom_fp256bn_32.rs | 5 +-
src/roms/rom_fp256bn_64.rs | 4 +-
src/roms/rom_fp512bn_32.rs | 4 +-
src/roms/rom_fp512bn_64.rs | 4 +-
src/roms/rom_goldilocks_32.rs | 4 +-
src/roms/rom_goldilocks_64.rs | 4 +-
src/roms/rom_hifive_32.rs | 4 +-
src/roms/rom_hifive_64.rs | 4 +-
src/roms/rom_nist256_32.rs | 7 +-
src/roms/rom_nist256_64.rs | 4 +-
src/roms/rom_nist384_32.rs | 4 +-
src/roms/rom_nist384_64.rs | 5 +-
src/roms/rom_nist521_32.rs | 4 +-
src/roms/rom_nist521_64.rs | 4 +-
src/roms/rom_nums256e_32.rs | 5 +-
src/roms/rom_nums256e_64.rs | 5 +-
src/roms/rom_nums256w_32.rs | 4 +-
src/roms/rom_nums256w_64.rs | 4 +-
src/roms/rom_nums384e_32.rs | 5 +-
src/roms/rom_nums384e_64.rs | 5 +-
src/roms/rom_nums384w_32.rs | 5 +-
src/roms/rom_nums384w_64.rs | 5 +-
src/roms/rom_nums512e_32.rs | 4 +-
src/roms/rom_nums512e_64.rs | 4 +-
src/roms/rom_nums512w_32.rs | 4 +-
src/roms/rom_nums512w_64.rs | 4 +-
src/roms/rom_rsa2048_32.rs | 2 +-
src/roms/rom_rsa2048_64.rs | 2 +-
src/roms/rom_rsa3072_32.rs | 2 +-
src/roms/rom_rsa3072_64.rs | 2 +-
src/roms/rom_rsa4096_32.rs | 2 +-
src/roms/rom_rsa4096_64.rs | 2 +-
src/roms/rom_secp256k1_32.rs | 4 +-
src/roms/rom_secp256k1_64.rs | 4 +-
src/types.rs | 1 -
87 files changed, 1146 insertions(+), 990 deletions(-)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2f7896d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+target/
diff --git a/src/aes.rs b/src/aes.rs
index eedea79..335a273 100644
--- a/src/aes.rs
+++ b/src/aes.rs
@@ -331,31 +331,31 @@ impl AES {
while j < n {
self.fkey[j] =
self.fkey[j - nk] ^ AES::subbyte(AES::rotl24(self.fkey[j - 1])) ^ (RCO[k] as u32);
- if nk<=6 {
- for i in 1..nk {
- if (i + j) >= n {
- break;
- }
- self.fkey[i + j] = self.fkey[i + j - nk] ^ self.fkey[i + j - 1];
- }
- } else {
- for i in 1..4 {
- if (i + j) >= n {
- break;
- }
- self.fkey[i + j] = self.fkey[i + j - nk] ^ self.fkey[i + j - 1];
- }
-
- if (j + 4) < n {
- self.fkey[j + 4] = self.fkey[j + 4 - nk] ^ AES::subbyte(self.fkey[j + 3]);
- }
- for i in 5..nk {
- if (i + j) >= n {
- break;
- }
- self.fkey[i + j] = self.fkey[i + j - nk] ^ self.fkey[i + j - 1];
- }
- }
+ if nk <= 6 {
+ for i in 1..nk {
+ if (i + j) >= n {
+ break;
+ }
+ self.fkey[i + j] = self.fkey[i + j - nk] ^ self.fkey[i + j - 1];
+ }
+ } else {
+ for i in 1..4 {
+ if (i + j) >= n {
+ break;
+ }
+ self.fkey[i + j] = self.fkey[i + j - nk] ^ self.fkey[i + j - 1];
+ }
+
+ if (j + 4) < n {
+ self.fkey[j + 4] = self.fkey[j + 4 - nk] ^ AES::subbyte(self.fkey[j + 3]);
+ }
+ for i in 5..nk {
+ if (i + j) >= n {
+ break;
+ }
+ self.fkey[i + j] = self.fkey[i + j - nk] ^ self.fkey[i + j - 1];
+ }
+ }
j += nk;
k += 1;
}
diff --git a/src/big.rs b/src/big.rs
index 7267ad4..285d82e 100644
--- a/src/big.rs
+++ b/src/big.rs
@@ -25,8 +25,8 @@ use super::super::arch::DChunk;
use super::dbig::DBIG;
use rand::RAND;
-pub use super::rom::MODBYTES;
pub use super::rom::BASEBITS;
+pub use super::rom::MODBYTES;
use std::cmp::Ordering;
use std::fmt;
@@ -44,7 +44,9 @@ pub struct BIG {
}
impl Clone for BIG {
- fn clone(&self) -> BIG { *self }
+ fn clone(&self) -> BIG {
+ *self
+ }
}
impl fmt::Display for BIG {
@@ -63,7 +65,7 @@ impl fmt::Debug for BIG {
impl PartialEq for BIG {
fn eq(&self, other: &BIG) -> bool {
- if BIG::comp(self,other)==0 {
+ if BIG::comp(self, other) == 0 {
return true;
} else {
return false;
@@ -84,7 +86,7 @@ impl Ord for BIG {
}
}
-impl Eq for BIG { }
+impl Eq for BIG {}
impl PartialOrd for BIG {
fn partial_cmp(&self, other: &BIG) -> Option<Ordering> {
@@ -345,7 +347,7 @@ impl BIG {
res.w[0] += n as Chunk;
for i in 1..len {
res.shl(4);
- let op = &val[i..i+1];
+ let op = &val[i..i + 1];
let n = u8::from_str_radix(op, 16).unwrap();
res.w[0] += n as Chunk;
}
@@ -355,7 +357,7 @@ impl BIG {
pub fn from_hex(val: String) -> BIG {
BIG::fromstring(val)
}
-
+
pub fn to_hex(&mut self) -> String {
self.tostring()
}
diff --git a/src/bls.rs b/src/bls.rs
index 7e7fd7a..c5c1b33 100644
--- a/src/bls.rs
+++ b/src/bls.rs
@@ -16,13 +16,13 @@ KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
-use std::str;
use super::ecp::ECP;
use super::ecp2::ECP2;
+use std::str;
//use super::fp12::FP12;
+use super::big;
use super::big::BIG;
use super::pair;
-use super::big;
use super::rom;
use rand::RAND;
@@ -79,14 +79,14 @@ pub fn verify(sig: &[u8], m: &str, w: &[u8]) -> isize {
let pk = ECP2::frombytes(&w);
d.neg();
-// Use new multi-pairing mechanism
- let mut r=pair::initmp();
- pair::another(&mut r,&g,&d);
- pair::another(&mut r,&pk,&hm);
- let mut v=pair::miller(&r);
+ // Use new multi-pairing mechanism
+ let mut r = pair::initmp();
+ pair::another(&mut r, &g, &d);
+ pair::another(&mut r, &pk, &hm);
+ let mut v = pair::miller(&r);
-//.. or alternatively
-// let mut v = pair::ate2(&g, &d, &pk, &hm);
+ //.. or alternatively
+ // let mut v = pair::ate2(&g, &d, &pk, &hm);
v = pair::fexp(&v);
if v.isunity() {
diff --git a/src/bls192.rs b/src/bls192.rs
index 20ee92e..e981ab3 100644
--- a/src/bls192.rs
+++ b/src/bls192.rs
@@ -16,13 +16,13 @@ KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
-use std::str;
use super::ecp::ECP;
use super::ecp4::ECP4;
+use std::str;
//use super::fp24::FP24;
+use super::big;
use super::big::BIG;
use super::pair192;
-use super::big;
use super::rom;
use rand::RAND;
@@ -79,15 +79,15 @@ pub fn verify(sig: &[u8], m: &str, w: &[u8]) -> isize {
let pk = ECP4::frombytes(&w);
d.neg();
-// Use new multi-pairing mechanism
- let mut r=pair192::initmp();
- pair192::another(&mut r,&g,&d);
- pair192::another(&mut r,&pk,&hm);
- let mut v=pair192::miller(&r);
+ // Use new multi-pairing mechanism
+ let mut r = pair192::initmp();
+ pair192::another(&mut r, &g, &d);
+ pair192::another(&mut r, &pk, &hm);
+ let mut v = pair192::miller(&r);
+
+ //.. or alternatively
+ // let mut v = pair192::ate2(&g, &d, &pk, &hm);
-//.. or alternatively
-// let mut v = pair192::ate2(&g, &d, &pk, &hm);
-
v = pair192::fexp(&v);
if v.isunity() {
return BLS_OK;
diff --git a/src/bls256.rs b/src/bls256.rs
index cdb553d..f9e4815 100644
--- a/src/bls256.rs
+++ b/src/bls256.rs
@@ -16,13 +16,13 @@ KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
-use std::str;
use super::ecp::ECP;
use super::ecp8::ECP8;
+use std::str;
//use super::fp48::FP48;
+use super::big;
use super::big::BIG;
use super::pair256;
-use super::big;
use super::rom;
use rand::RAND;
@@ -79,14 +79,14 @@ pub fn verify(sig: &[u8], m: &str, w: &[u8]) -> isize {
let pk = ECP8::frombytes(&w);
d.neg();
-// Use new multi-pairing mechanism
- let mut r=pair256::initmp();
- pair256::another(&mut r,&g,&d);
- pair256::another(&mut r,&pk,&hm);
- let mut v=pair256::miller(&r);
+ // Use new multi-pairing mechanism
+ let mut r = pair256::initmp();
+ pair256::another(&mut r, &g, &d);
+ pair256::another(&mut r, &pk, &hm);
+ let mut v = pair256::miller(&r);
-//.. or alternatively
-// let mut v = pair256::ate2(&g, &d, &pk, &hm);
+ //.. or alternatively
+ // let mut v = pair256::ate2(&g, &d, &pk, &hm);
v = pair256::fexp(&v);
if v.isunity() {
diff --git a/src/dbig.rs b/src/dbig.rs
index 353443a..2f5ad31 100644
--- a/src/dbig.rs
+++ b/src/dbig.rs
@@ -18,9 +18,9 @@ under the License.
*/
use super::super::arch;
+use super::super::arch::Chunk;
use super::big;
use super::big::BIG;
-use super::super::arch::Chunk;
#[derive(Copy)]
pub struct DBIG {
@@ -28,7 +28,9 @@ pub struct DBIG {
}
impl Clone for DBIG {
- fn clone(&self) -> DBIG { *self }
+ fn clone(&self) -> DBIG {
+ *self
+ }
}
impl DBIG {
diff --git a/src/ecdh.rs b/src/ecdh.rs
index 9b49e18..2f9e516 100644
--- a/src/ecdh.rs
+++ b/src/ecdh.rs
@@ -17,19 +17,18 @@ specific language governing permissions and limitations
under the License.
*/
+use super::big;
+use super::big::BIG;
use super::ecp;
use super::ecp::ECP;
-use super::big::BIG;
use super::rom;
-use super::big;
-use rand::RAND;
+use aes;
+use aes::AES;
use hash256::HASH256;
use hash384::HASH384;
use hash512::HASH512;
-use aes;
-use aes::AES;
-
+use rand::RAND;
pub const INVALID_PUBLIC_KEY: isize = -2;
pub const ERROR: isize = -3;
diff --git a/src/ecp.rs b/src/ecp.rs
index 9e7b29c..a5c90c8 100644
--- a/src/ecp.rs
+++ b/src/ecp.rs
@@ -17,15 +17,15 @@ specific language governing permissions and limitations
under the License.
*/
-use super::fp::FP;
-use super::big::BIG;
use super::big;
+use super::big::BIG;
+use super::fp::FP;
use super::rom;
-pub use super::rom::{CURVETYPE, CURVE_PAIRING_TYPE, SEXTIC_TWIST, SIGN_OF_X, HASH_TYPE, AESKEY};
-pub use types::CurveType;
-use std::str::SplitWhitespace;
+pub use super::rom::{AESKEY, CURVETYPE, CURVE_PAIRING_TYPE, HASH_TYPE, SEXTIC_TWIST, SIGN_OF_X};
use std::fmt;
+use std::str::SplitWhitespace;
+pub use types::CurveType;
#[derive(Copy, Clone)]
pub struct ECP {
@@ -41,15 +41,15 @@ impl PartialEq for ECP {
}
impl fmt::Display for ECP {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "ECP: [ {}, {}, {} ]", self.x, self.y, self.z)
- }
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ write!(f, "ECP: [ {}, {}, {} ]", self.x, self.y, self.z)
+ }
}
impl fmt::Debug for ECP {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "ECP: [ {}, {}, {} ]", self.x, self.y, self.z)
- }
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ write!(f, "ECP: [ {}, {}, {} ]", self.x, self.y, self.z)
+ }
}
#[allow(non_snake_case)]
@@ -193,7 +193,7 @@ impl ECP {
/* test for O point-at-infinity */
pub fn is_infinity(&self) -> bool {
match CURVETYPE {
- CurveType::EDWARDS=> self.x.iszilch() && self.y.equals(&self.z),
+ CurveType::EDWARDS => self.x.iszilch() && self.y.equals(&self.z),
CurveType::WEIERSTRASS => self.x.iszilch() && self.z.iszilch(),
CurveType::MONTGOMERY => self.z.iszilch(),
}
@@ -440,7 +440,12 @@ impl ECP {
}
pub fn to_hex(&self) -> String {
- format!("{} {} {}", self.x.to_hex(), self.y.to_hex(), self.z.to_hex())
+ format!(
+ "{} {} {}",
+ self.x.to_hex(),
+ self.y.to_hex(),
+ self.z.to_hex()
+ )
}
pub fn from_hex_iter(iter: &mut SplitWhitespace) -> ECP {
diff --git a/src/ecp2.rs b/src/ecp2.rs
index afd9376..c7445fa 100644
--- a/src/ecp2.rs
+++ b/src/ecp2.rs
@@ -17,14 +17,14 @@ specific language governing permissions and limitations
under the License.
*/
-use super::rom;
use super::big;
+use super::big::BIG;
use super::ecp;
use super::fp2::FP2;
-use super::big::BIG;
-use types::{SexticTwist, CurvePairingType, SignOfX};
-use std::str::SplitWhitespace;
+use super::rom;
use std::fmt;
+use std::str::SplitWhitespace;
+use types::{CurvePairingType, SexticTwist, SignOfX};
#[derive(Copy, Clone)]
pub struct ECP2 {
@@ -34,21 +34,21 @@ pub struct ECP2 {
}
impl PartialEq for ECP2 {
- fn eq(&self, other: &ECP2) -> bool {
- self.equals(other)
- }
+ fn eq(&self, other: &ECP2) -> bool {
+ self.equals(other)
+ }
}
impl fmt::Display for ECP2 {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "ECP2: [ {}, {}, {} ]", self.x, self.y, self.z)
- }
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ write!(f, "ECP2: [ {}, {}, {} ]", self.x, self.y, self.z)
+ }
}
impl fmt::Debug for ECP2 {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "ECP2: [ {}, {}, {} ]", self.x, self.y, self.z)
- }
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ write!(f, "ECP2: [ {}, {}, {} ]", self.x, self.y, self.z)
+ }
}
#[allow(non_snake_case)]
@@ -291,14 +291,19 @@ impl ECP2 {
}
pub fn to_hex(&self) -> String {
- format!("{} {} {}", self.x.to_hex(), self.y.to_hex(), self.z.to_hex())
+ format!(
+ "{} {} {}",
+ self.x.to_hex(),
+ self.y.to_hex(),
+ self.z.to_hex()
+ )
}
pub fn from_hex_iter(iter: &mut SplitWhitespace) -> ECP2 {
ECP2 {
x: FP2::from_hex_iter(iter),
y: FP2::from_hex_iter(iter),
- z: FP2::from_hex_iter(iter)
+ z: FP2::from_hex_iter(iter),
}
}
diff --git a/src/ecp4.rs b/src/ecp4.rs
index d34b0fd..31a92e1 100644
--- a/src/ecp4.rs
+++ b/src/ecp4.rs
@@ -17,12 +17,12 @@ specific language governing permissions and limitations
under the License.
*/
-use super::rom;
use super::big;
+use super::big::BIG;
use super::ecp;
use super::fp2::FP2;
use super::fp4::FP4;
-use super::big::BIG;
+use super::rom;
use types::{SexticTwist, SignOfX};
//use std::str::SplitWhitespace;
diff --git a/src/ecp8.rs b/src/ecp8.rs
index a6d32a4..99953dc 100644
--- a/src/ecp8.rs
+++ b/src/ecp8.rs
@@ -17,13 +17,13 @@ specific language governing permissions and limitations
under the License.
*/
-use super::rom;
use super::big;
+use super::big::BIG;
use super::ecp;
use super::fp2::FP2;
use super::fp4::FP4;
use super::fp8::FP8;
-use super::big::BIG;
+use super::rom;
use types::{SexticTwist, SignOfX};
pub struct ECP8 {
@@ -914,7 +914,7 @@ impl ECP8 {
// Number of bits
mt.zero();
for i in 0..16 {
- t[i].norm();
+ t[i].norm();
mt.or(&t[i]);
}
diff --git a/src/ff.rs b/src/ff.rs
index 4737ee8..f1abc00 100644
--- a/src/ff.rs
+++ b/src/ff.rs
@@ -17,10 +17,10 @@ specific language governing permissions and limitations
under the License.
*/
+use super::super::arch::Chunk;
use super::big;
-use super::dbig::DBIG;
use super::big::BIG;
-use super::super::arch::Chunk;
+use super::dbig::DBIG;
use rand::RAND;
use super::super::arch::DChunk;
diff --git a/src/fp.rs b/src/fp.rs
index 57345c1..bd790d3 100644
--- a/src/fp.rs
+++ b/src/fp.rs
@@ -17,14 +17,14 @@ specific language governing permissions and limitations
under the License.
*/
+use super::super::arch;
+use super::super::arch::Chunk;
use super::big;
use super::big::BIG;
use super::dbig::DBIG;
use super::rom;
-use super::super::arch::Chunk;
-use super::super::arch;
-use types::ModType;
use std::str::FromStr;
+use types::ModType;
#[derive(Copy, Clone)]
pub struct FP {
@@ -50,14 +50,14 @@ impl fmt::Debug for FP {
}
}
-pub use super::rom::{MODBITS, MOD8, MODTYPE, SH};
-use std::str::SplitWhitespace;
+pub use super::rom::{MOD8, MODBITS, MODTYPE, SH};
use std::fmt;
+use std::str::SplitWhitespace;
-pub const FEXCESS:i32 = (((1 as i32)<<SH)-1);
-pub const OMASK:Chunk = (-1)<<(MODBITS%big::BASEBITS);
-pub const TBITS:usize=MODBITS%big::BASEBITS; // Number of active bits in top word
-pub const TMASK:Chunk=(1<<TBITS)-1;
+pub const FEXCESS: i32 = (((1 as i32) << SH) - 1);
+pub const OMASK: Chunk = (-1) << (MODBITS % big::BASEBITS);
+pub const TBITS: usize = MODBITS % big::BASEBITS; // Number of active bits in top word
+pub const TMASK: Chunk = (1 << TBITS) - 1;
impl FP {
/* Constructors */
@@ -91,8 +91,8 @@ impl FP {
pub fn nres(&mut self) {
if MODTYPE != ModType::PSEUDO_MERSENNE && MODTYPE != ModType::GENERALISED_MERSENNE {
- let r=BIG::new_ints(&rom::R2MODP);
- let mut d=BIG::mul(&(self.x),&r);
+ let r = BIG::new_ints(&rom::R2MODP);
+ let mut d = BIG::mul(&(self.x), &r);
self.x.copy(&FP::modulo(&mut d));
self.xes = 2;
} else {
@@ -105,7 +105,7 @@ impl FP {
let x = iter.next().unwrap();
FP {
x: BIG::from_hex(x.to_string()),
- xes
+ xes,
}
}
@@ -120,10 +120,10 @@ impl FP {
format!("{} {}", self.xes, big)
}
-/* convert back to regular form */
+ /* convert back to regular form */
pub fn redc(&mut self) -> BIG {
if MODTYPE != ModType::PSEUDO_MERSENNE && MODTYPE != ModType::GENERALISED_MERSENNE {
- let mut d=DBIG::new_scopy(&(self.x));
+ let mut d = DBIG::new_scopy(&(self.x));
return FP::modulo(&mut d);
} else {
let r = BIG::new_copy(&(self.x));
@@ -134,9 +134,9 @@ impl FP {
/* reduce a DBIG to a BIG using the appropriate form of the modulus */
/* dd */
pub fn modulo(d: &mut DBIG) -> BIG {
- if MODTYPE==ModType::PSEUDO_MERSENNE {
- let mut b=BIG::new();
- let mut t=d.split(MODBITS);
+ if MODTYPE == ModType::PSEUDO_MERSENNE {
+ let mut b = BIG::new();
+ let mut t = d.split(MODBITS);
b.dcopy(&d);
let v = t.pmul(rom::MCONST as isize);
@@ -149,8 +149,8 @@ impl FP {
t.norm();
return t;
}
-
- if MODTYPE==ModType::MONTGOMERY_FRIENDLY {
+
+ if MODTYPE == ModType::MONTGOMERY_FRIENDLY {
let mut b = BIG::new();
for i in 0..big::NLEN {
let x = d.w[i];
diff --git a/src/fp12.rs b/src/fp12.rs
index 9c06a3e..745814f 100644
--- a/src/fp12.rs
+++ b/src/fp12.rs
@@ -18,19 +18,19 @@ under the License.
*/
use super::big;
+use super::big::BIG;
+use super::ecp;
use super::fp2::FP2;
use super::fp4::FP4;
-use super::big::BIG;
use super::rom;
-use types::SexticTwist;
use std::str::SplitWhitespace;
-use super::ecp;
+use types::SexticTwist;
-pub const ZERO: usize=0;
-pub const ONE: usize=1;
-pub const SPARSER: usize=2;
-pub const SPARSE: usize=3;
-pub const DENSE: usize=4;
+pub const ZERO: usize = 0;
+pub const ONE: usize = 1;
+pub const SPARSER: usize = 2;
+pub const SPARSE: usize = 3;
+pub const DENSE: usize = 4;
#[derive(Copy, Clone)]
pub struct FP12 {
@@ -41,9 +41,9 @@ pub struct FP12 {
}
impl PartialEq for FP12 {
- fn eq(&self, other: &FP12) -> bool {
- self.equals(other)
- }
+ fn eq(&self, other: &FP12) -> bool {
+ self.equals(other)
+ }
}
impl FP12 {
@@ -52,12 +52,12 @@ impl FP12 {
a: FP4::new(),
b: FP4::new(),
c: FP4::new(),
- stype: ZERO,
+ stype: ZERO,
}
}
- pub fn settype(&mut self,t: usize) {
- self.stype = t;
+ pub fn settype(&mut self, t: usize) {
+ self.stype = t;
}
pub fn gettype(&self) -> usize {
@@ -69,11 +69,11 @@ impl FP12 {
f.a.copy(&FP4::new_int(a));
f.b.zero();
f.c.zero();
- if a == 1 {
- f.stype=ONE;
- } else {
- f.stype=SPARSER;
- }
+ if a == 1 {
+ f.stype = ONE;
+ } else {
+ f.stype = SPARSER;
+ }
return f;
}
@@ -82,7 +82,7 @@ impl FP12 {
f.a.copy(&x.a);
f.b.copy(&x.b);
f.c.copy(&x.c);
- f.stype=x.stype;
+ f.stype = x.stype;
return f;
}
@@ -91,7 +91,7 @@ impl FP12 {
g.a.copy(d);
g.b.copy(e);
g.c.copy(f);
- g.stype=DENSE;
+ g.stype = DENSE;
return g;
}
@@ -100,7 +100,7 @@ impl FP12 {
g.a.copy(d);
g.b.zero();
g.c.zero();
- g.stype=SPARSER;
+ g.stype = SPARSER;
return g;
}
@@ -129,9 +129,9 @@ impl FP12 {
self.a.cmove(&g.a, d);
self.b.cmove(&g.b, d);
self.c.cmove(&g.c, d);
- let mut u=d as usize;
- u=!(u-1);
- self.stype^=(self.stype^g.stype)&u;
+ let mut u = d as usize;
+ u = !(u - 1);
+ self.stype ^= (self.stype ^ g.stype) & u;
}
/* return 1 if b==c, no branching */
@@ -175,20 +175,20 @@ impl FP12 {
pub fn geta(&mut self) -> FP4 {
return self.a;
-// let f = FP4::new_copy(&self.a);
-// return f;
+ // let f = FP4::new_copy(&self.a);
+ // return f;
}
pub fn getb(&mut self) -> FP4 {
return self.b;
-// let f = FP4::new_copy(&self.b);
-// return f;
+ // let f = FP4::new_copy(&self.b);
+ // return f;
}
pub fn getc(&mut self) -> FP4 {
return self.c;
-// let f = FP4::new_copy(&self.c);
-// return f;
+ // let f = FP4::new_copy(&self.c);
+ // return f;
}
/* copy self=x */
@@ -196,7 +196,7 @@ impl FP12 {
self.a.copy(&x.a);
self.b.copy(&x.b);
self.c.copy(&x.c);
- self.stype=x.stype;
+ self.stype = x.stype;
}
/* set self=1 */
@@ -204,7 +204,7 @@ impl FP12 {
self.a.one();
self.b.zero();
self.c.zero();
- self.stype=ONE;
+ self.stype = ONE;
}
/* set self=0 */
@@ -212,7 +212,7 @@ impl FP12 {
self.a.zero();
self.b.zero();
self.c.zero();
- self.stype=ZERO;
+ self.stype = ZERO;
}
/* this=conj(this) */
@@ -260,13 +260,13 @@ impl FP12 {
self.c.dbl();
self.b.add(&b);
self.c.add(&c);
- self.stype=DENSE;
+ self.stype = DENSE;
self.reduce();
}
/* Chung-Hasan SQR2 method from http://cacr.uwaterloo.ca/techreports/2006/cacr2006-24.pdf */
pub fn sqr(&mut self) {
- if self.stype==ONE {
+ if self.stype == ONE {
return;
}
@@ -304,10 +304,10 @@ impl FP12 {
self.b.copy(&c);
self.b.add(&d);
self.c.add(&a);
- if self.stype==SPARSER {
- self.stype=SPARSE;
+ if self.stype == SPARSER {
+ self.stype = SPARSE;
} else {
- self.stype=DENSE;
+ self.stype = DENSE;
}
self.norm();
}
@@ -379,128 +379,144 @@ impl FP12 {
z3.times_i();
self.a.copy(&z0);
self.a.add(&z3);
- self.stype=DENSE;
+ self.stype = DENSE;
self.norm();
}
-
-/* FP12 full multiplication w=w*y */
-/* Supports sparse multiplicands */
-/* Usually w is denser than y */
+ /* FP12 full multiplication w=w*y */
+ /* Supports sparse multiplicands */
+ /* Usually w is denser than y */
pub fn ssmul(&mut self, y: &FP12) {
- if self.stype==ONE {
+ if self.stype == ONE {
self.copy(&y);
return;
}
- if y.stype==ONE {
+ if y.stype == ONE {
return;
}
- if y.stype>=SPARSE {
- let mut z0=FP4::new_copy(&self.a);
- let mut z1=FP4::new_int(0);
- let mut z2=FP4::new_int(0);
- let mut z3=FP4::new_int(0);
+ if y.stype >= SPARSE {
+ let mut z0 = FP4::new_copy(&self.a);
+ let mut z1 = FP4::new_int(0);
+ let mut z2 = FP4::new_int(0);
+ let mut z3 = FP4::new_int(0);
z0.mul(&y.a);
- if ecp::SEXTIC_TWIST==SexticTwist::M_TYPE {
- if y.stype==SPARSE || self.stype==SPARSE {
-
- let mut ga=FP2::new_int(0);
- let mut gb=FP2::new_int(0);
+ if ecp::SEXTIC_TWIST == SexticTwist::M_TYPE {
+ if y.stype == SPARSE || self.stype == SPARSE {
+ let mut ga = FP2::new_int(0);
+ let mut gb = FP2::new_int(0);
gb.copy(&self.b.getb());
gb.mul(&y.b.getb());
ga.zero();
- if y.stype!=SPARSE {
+ if y.stype != SPARSE {
ga.copy(&self.b.getb());
ga.mul(&y.b.geta());
}
- if self.stype!=SPARSE {
+ if self.stype != SPARSE {
ga.copy(&self.b.geta());
ga.mul(&y.b.getb());
}
- z2.set_fp2s(&ga,&gb);
+ z2.set_fp2s(&ga, &gb);
z2.times_i();
} else {
z2.copy(&self.b);
z2.mul(&y.b);
}
- } else {
- z2.copy(&self.b);
- z2.mul(&y.b);
+ } else {
+ z2.copy(&self.b);
+ z2.mul(&y.b);
}
- let mut t0=FP4::new_copy(&self.a);
- let mut t1=FP4::new_copy(&y.a);
- t0.add(&self.b); t0.norm();
- t1.add(&y.b); t1.norm();
-
- z1.copy(&t0); z1.mul(&t1);
- t0.copy(&self.b); t0.add(&self.c); t0.norm();
- t1.copy(&y.b); t1.add(&y.c); t1.norm();
-
- z3.copy(&t0); z3.mul(&t1);
+ let mut t0 = FP4::new_copy(&self.a);
+ let mut t1 = FP4::new_copy(&y.a);
+ t0.add(&self.b);
+ t0.norm();
+ t1.add(&y.b);
+ t1.norm();
+
+ z1.copy(&t0);
+ z1.mul(&t1);
+ t0.copy(&self.b);
+ t0.add(&self.c);
+ t0.norm();
+ t1.copy(&y.b);
+ t1.add(&y.c);
+ t1.norm();
+
+ z3.copy(&t0);
+ z3.mul(&t1);
+
+ t0.copy(&z0);
+ t0.neg();
+ t1.copy(&z2);
+ t1.neg();
- t0.copy(&z0); t0.neg();
- t1.copy(&z2); t1.neg();
-
z1.add(&t0);
- self.b.copy(&z1); self.b.add(&t1);
+ self.b.copy(&z1);
+ self.b.add(&t1);
z3.add(&t1);
z2.add(&t0);
- t0.copy(&self.a); t0.add(&self.c); t0.norm();
- t1.copy(&y.a); t1.add(&y.c); t1.norm();
-
+ t0.copy(&self.a);
+ t0.add(&self.c);
+ t0.norm();
+ t1.copy(&y.a);
+ t1.add(&y.c);
+ t1.norm();
+
t0.mul(&t1);
z2.add(&t0);
- if ecp::SEXTIC_TWIST==SexticTwist::D_TYPE {
- if y.stype==SPARSE || self.stype==SPARSE {
-
- let mut ga=FP2::new_int(0);
- let mut gb=FP2::new_int(0);
+ if ecp::SEXTIC_TWIST == SexticTwist::D_TYPE {
+ if y.stype == SPARSE || self.stype == SPARSE {
+ let mut ga = FP2::new_int(0);
+ let mut gb = FP2::new_int(0);
ga.copy(&self.c.geta());
ga.mul(&y.c.geta());
gb.zero();
- if y.stype!=SPARSE {
+ if y.stype != SPARSE {
gb.copy(&self.c.geta());
gb.mul(&y.c.getb());
}
- if self.stype!=SPARSE {
+ if self.stype != SPARSE {
gb.copy(&self.c.getb());
gb.mul(&y.c.geta());
}
- t0.set_fp2s(&ga,&gb);
+ t0.set_fp2s(&ga, &gb);
} else {
t0.copy(&self.c);
t0.mul(&y.c);
}
- } else {
+ } else {
t0.copy(&self.c);
t0.mul(&y.c);
}
- t1.copy(&t0); t1.neg();
+ t1.copy(&t0);
+ t1.neg();
- self.c.copy(&z2); self.c.add(&t1);
+ self.c.copy(&z2);
+ self.c.add(&t1);
z3.add(&t1);
t0.times_i();
self.b.add(&t0);
z3.norm();
z3.times_i();
- self.a.copy(&z0); self.a.add(&z3);
+ self.a.copy(&z0);
+ self.a.add(&z3);
} else {
- if self.stype==SPARSER {
+ if self.stype == SPARSER {
self.smul(&y);
return;
}
- if ecp::SEXTIC_TWIST==SexticTwist::D_TYPE { // dense by sparser - 13m
- let mut z0=FP4::new_copy(&self.a);
- let mut z2=FP4::new_copy(&self.b);
- let mut z3=FP4::new_copy(&self.b);
- let mut t0=FP4::new_int(0);
- let mut t1=FP4::new_copy(&y.a);
+ if ecp::SEXTIC_TWIST == SexticTwist::D_TYPE {
+ // dense by sparser - 13m
+ let mut z0 = FP4::new_copy(&self.a);
+ let mut z2 = FP4::new_copy(&self.b);
+ let mut z3 = FP4::new_copy(&self.b);
+ let mut t0 = FP4::new_int(0);
+ let mut t1 = FP4::new_copy(&y.a);
z0.mul(&y.a);
z2.pmul(&y.b.geta());
@@ -514,8 +530,10 @@ impl FP12 {
z3.norm();
z3.pmul(&y.b.geta());
- t0.copy(&z0); t0.neg();
- t1.copy(&z2); t1.neg();
+ t0.copy(&z0);
+ t0.neg();
+ t1.copy(&z2);
+ t1.neg();
self.b.add(&t0);
@@ -523,97 +541,121 @@ impl FP12 {
z3.add(&t1);
z2.add(&t0);
- t0.copy(&self.a); t0.add(&self.c); t0.norm();
+ t0.copy(&self.a);
+ t0.add(&self.c);
+ t0.norm();
z3.norm();
t0.mul(&y.a);
- self.c.copy(&z2); self.c.add(&t0);
+ self.c.copy(&z2);
+ self.c.add(&t0);
z3.times_i();
- self.a.copy(&z0); self.a.add(&z3);
+ self.a.copy(&z0);
+ self.a.add(&z3);
}
- if ecp::SEXTIC_TWIST==SexticTwist::M_TYPE {
-
+ if ecp::SEXTIC_TWIST == SexticTwist::M_TYPE {
let mut z0 = FP4::new_copy(&self.a);
let mut z1 = FP4::new();
let mut z2 = FP4::new();
let mut z3 = FP4::new();
let mut t0 = FP4::new_copy(&self.a);
let mut t1 = FP4::new();
-
+
z0.mul(&y.a);
- t0.add(&self.b); t0.norm();
+ t0.add(&self.b);
+ t0.norm();
- z1.copy(&t0); z1.mul(&y.a);
- t0.copy(&self.b); t0.add(&self.c);
+ z1.copy(&t0);
+ z1.mul(&y.a);
+ t0.copy(&self.b);
+ t0.add(&self.c);
t0.norm();
z3.copy(&t0);
z3.pmul(&y.c.getb());
z3.times_i();
- t0.copy(&z0); t0.neg();
+ t0.copy(&z0);
+ t0.neg();
z1.add(&t0);
self.b.copy(&z1);
z2.copy(&t0);
- t0.copy(&self.a); t0.add(&self.c); t0.norm();
- t1.copy(&y.a); t1.add(&y.c); t1.norm();
+ t0.copy(&self.a);
+ t0.add(&self.c);
+ t0.norm();
+ t1.copy(&y.a);
+ t1.add(&y.c);
+ t1.norm();
t0.mul(&t1);
z2.add(&t0);
t0.copy(&self.c);
-
+
t0.pmul(&y.c.getb());
t0.times_i();
- t1.copy(&t0); t1.neg();
+ t1.copy(&t0);
+ t1.neg();
- self.c.copy(&z2); self.c.add(&t1);
+ self.c.copy(&z2);
+ self.c.add(&t1);
z3.add(&t1);
t0.times_i();
self.b.add(&t0);
z3.norm();
z3.times_i();
- self.a.copy(&z0); self.a.add(&z3);
- }
+ self.a.copy(&z0);
+ self.a.add(&z3);
+ }
}
- self.stype=DENSE;
+ self.stype = DENSE;
self.norm();
}
/* Special case of multiplication arises from special form of ATE pairing line function */
pub fn smul(&mut self, y: &FP12) {
- if ecp::SEXTIC_TWIST==SexticTwist::D_TYPE {
- let mut w1=FP2::new_copy(&self.a.geta());
- let mut w2=FP2::new_copy(&self.a.getb());
- let mut w3=FP2::new_copy(&self.b.geta());
+ if ecp::SEXTIC_TWIST == SexticTwist::D_TYPE {
+ let mut w1 = FP2::new_copy(&self.a.geta());
+ let mut w2 = FP2::new_copy(&self.a.getb());
+ let mut w3 = FP2::new_copy(&self.b.geta());
w1.mul(&y.a.geta());
w2.mul(&y.a.getb());
w3.mul(&y.b.geta());
- let mut ta=FP2::new_copy(&self.a.geta());
- let mut tb=FP2::new_copy(&y.a.geta());
- ta.add(&self.a.getb()); ta.norm();
- tb.add(&y.a.getb()); tb.norm();
- let mut tc=FP2::new_copy(&ta);
+ let mut ta = FP2::new_copy(&self.a.geta());
+ let mut tb = FP2::new_copy(&y.a.geta());
+ ta.add(&self.a.getb());
+ ta.norm();
+ tb.add(&y.a.getb());
+ tb.norm();
+ let mut tc = FP2::new_copy(&ta);
tc.mul(&tb);
- let mut t=FP2::new_copy(&w1);
+ let mut t = FP2::new_copy(&w1);
t.add(&w2);
t.neg();
tc.add(&t);
- ta.copy(&self.a.geta()); ta.add(&self.b.geta()); ta.norm();
- tb.copy(&y.a.geta()); tb.add(&y.b.geta()); tb.norm();
- let mut td=FP2::new_copy(&ta);
+ ta.copy(&self.a.geta());
+ ta.add(&self.b.geta());
+ ta.norm();
+ tb.copy(&y.a.geta());
+ tb.add(&y.b.geta());
+ tb.norm();
+ let mut td = FP2::new_copy(&ta);
td.mul(&tb);
t.copy(&w1);
t.add(&w3);
t.neg();
td.add(&t);
- ta.copy(&self.a.getb()); ta.add(&self.b.geta()); ta.norm();
- tb.copy(&y.a.getb()); tb.add(&y.b.geta()); tb.norm();
- let mut te=FP2::new_copy(&ta);
+ ta.copy(&self.a.getb());
+ ta.add(&self.b.geta());
+ ta.norm();
+ tb.copy(&y.a.getb());
+ tb.add(&y.b.geta());
+ tb.norm();
+ let mut te = FP2::new_copy(&ta);
te.mul(&tb);
t.copy(&w2);
t.add(&w3);
@@ -623,44 +665,54 @@ impl FP12 {
w2.mul_ip();
w1.add(&w2);
- self.a.set_fp2s(&w1,&tc);
- self.b.set_fp2s(&td,&te);
- self.c.set_fp2(&w3);
-
+ self.a.set_fp2s(&w1, &tc);
+ self.b.set_fp2s(&td, &te);
+ self.c.set_fp2(&w3);
+
self.a.norm();
self.b.norm();
} else {
- let mut w1=FP2::new_copy(&self.a.geta());
- let mut w2=FP2::new_copy(&self.a.getb());
- let mut w3=FP2::new_copy(&self.c.getb());
+ let mut w1 = FP2::new_copy(&self.a.geta());
+ let mut w2 = FP2::new_copy(&self.a.getb());
+ let mut w3 = FP2::new_copy(&self.c.getb());
w1.mul(&y.a.geta());
w2.mul(&y.a.getb());
w3.mul(&y.c.getb());
- let mut ta=FP2::new_copy(&self.a.geta());
- let mut tb=FP2::new_copy(&y.a.geta());
- ta.add(&self.a.getb()); ta.norm();
- tb.add(&y.a.getb()); tb.norm();
- let mut tc=FP2::new_copy(&ta);
+ let mut ta = FP2::new_copy(&self.a.geta());
+ let mut tb = FP2::new_copy(&y.a.geta());
+ ta.add(&self.a.getb());
+ ta.norm();
+ tb.add(&y.a.getb());
+ tb.norm();
+ let mut tc = FP2::new_copy(&ta);
tc.mul(&tb);
- let mut t=FP2::new_copy(&w1);
+ let mut t = FP2::new_copy(&w1);
t.add(&w2);
t.neg();
tc.add(&t);
- ta.copy(&self.a.geta()); ta.add(&self.c.getb()); ta.norm();
- tb.copy(&y.a.geta()); tb.add(&y.c.getb()); tb.norm();
- let mut td=FP2::new_copy(&ta);
+ ta.copy(&self.a.geta());
+ ta.add(&self.c.getb());
+ ta.norm();
+ tb.copy(&y.a.geta());
+ tb.add(&y.c.getb());
+ tb.norm();
+ let mut td = FP2::new_copy(&ta);
td.mul(&tb);
t.copy(&w1);
t.add(&w3);
t.neg();
td.add(&t);
- ta.copy(&self.a.getb()); ta.add(&self.c.getb()); ta.norm();
- tb.copy(&y.a.getb()); tb.add(&y.c.getb()); tb.norm();
- let mut te=FP2::new_copy(&ta);
+ ta.copy(&self.a.getb());
+ ta.add(&self.c.getb());
+ ta.norm();
+ tb.copy(&y.a.getb());
+ tb.add(&y.c.getb());
+ tb.norm();
+ let mut te = FP2::new_copy(&ta);
te.mul(&tb);
t.copy(&w2);
t.add(&w3);
@@ -669,20 +721,20 @@ impl FP12 {
w2.mul_ip();
w1.add(&w2);
- self.a.set_fp2s(&w1,&tc);
+ self.a.set_fp2s(&w1, &tc);
w3.mul_ip();
w3.norm();
- self.b.set_fp2h(&w3);
+ self.b.set_fp2h(&w3);
te.norm();
te.mul_ip();
- self.c.set_fp2s(&te,&td);
+ self.c.set_fp2s(&te, &td);
self.a.norm();
self.c.norm();
- }
- self.stype=SPARSE;
+ }
+ self.stype = SPARSE;
}
/* self=1/self */
@@ -730,7 +782,7 @@ impl FP12 {
self.b.mul(&f3);
self.c.copy(&f2);
self.c.mul(&f3);
- self.stype=DENSE;
+ self.stype = DENSE;
}
/* self=self^p using Frobenius */
@@ -747,7 +799,7 @@ impl FP12 {
self.b.pmul(f);
self.c.pmul(&f2);
- self.stype=DENSE;
+ self.stype = DENSE;
}
/* trace function */
@@ -902,7 +954,12 @@ impl FP12 {
}
pub fn to_hex(&self) -> String {
- format!("{} {} {}", self.a.to_hex(), self.b.to_hex(), self.c.to_hex())
+ format!(
+ "{} {} {}",
+ self.a.to_hex(),
+ self.b.to_hex(),
+ self.c.to_hex()
+ )
}
pub fn from_hex_iter(iter: &mut SplitWhitespace) -> FP12 {
@@ -910,7 +967,7 @@ impl FP12 {
a: FP4::from_hex_iter(iter),
b: FP4::from_hex_iter(iter),
c: FP4::from_hex_iter(iter),
- stype: DENSE
+ stype: DENSE,
}
}
diff --git a/src/fp16.rs b/src/fp16.rs
index c579db4..4ecf744 100644
--- a/src/fp16.rs
+++ b/src/fp16.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
+use super::big::BIG;
use super::fp2::FP2;
use super::fp8::FP8;
-use super::big::BIG;
//use std::str::SplitWhitespace;
#[derive(Copy, Clone)]
@@ -64,19 +64,19 @@ impl FP16 {
return f;
}
- pub fn set_fp8s(&mut self,c: &FP8, d: &FP8) {
+ pub fn set_fp8s(&mut self, c: &FP8, d: &FP8) {
self.a.copy(&c);
- self.b.copy(&d);
+ self.b.copy(&d);
}
- pub fn set_fp8(&mut self,c: &FP8) {
+ pub fn set_fp8(&mut self, c: &FP8) {
self.a.copy(&c);
- self.b.zero();
+ self.b.zero();
}
- pub fn set_fp8h(&mut self,c: &FP8) {
+ pub fn set_fp8h(&mut self, c: &FP8) {
self.b.copy(&c);
- self.a.zero();
+ self.a.zero();
}
/* reduce components mod Modulus */
@@ -119,14 +119,14 @@ impl FP16 {
pub fn geta(&self) -> FP8 {
return self.a;
-// let f = FP8::new_copy(&self.a);
-// return f;
+ // let f = FP8::new_copy(&self.a);
+ // return f;
}
/* extract imaginary part b */
pub fn getb(&self) -> FP8 {
return self.b;
-// let f = FP8::new_copy(&self.b);
-// return f;
+ // let f = FP8::new_copy(&self.b);
+ // return f;
}
/* test self=x */
diff --git a/src/fp2.rs b/src/fp2.rs
index c848f19..be6c1df 100644
--- a/src/fp2.rs
+++ b/src/fp2.rs
@@ -17,13 +17,13 @@ specific language governing permissions and limitations
under the License.
*/
-use super::fp;
-use super::fp::FP;
use super::big::BIG;
use super::dbig::DBIG;
+use super::fp;
+use super::fp::FP;
use super::rom;
-use std::str::SplitWhitespace;
use std::fmt;
+use std::str::SplitWhitespace;
#[derive(Copy, Clone)]
pub struct FP2 {
@@ -32,21 +32,21 @@ pub struct FP2 {
}
impl PartialEq for FP2 {
- fn eq(&self, other: &FP2) -> bool {
- self.equals(other)
- }
+ fn eq(&self, other: &FP2) -> bool {
+ self.equals(other)
+ }
}
impl fmt::Display for FP2 {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "FP2: [ {}, {} ]", self.a, self.b)
- }
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ write!(f, "FP2: [ {}, {} ]", self.a, self.b)
+ }
}
impl fmt::Debug for FP2 {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "FP2: [ {}, {} ]", self.a, self.b)
- }
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ write!(f, "FP2: [ {}, {} ]", self.a, self.b)
+ }
}
impl FP2 {
@@ -331,7 +331,7 @@ impl FP2 {
pub fn from_hex_iter(iter: &mut SplitWhitespace) -> FP2 {
FP2 {
a: FP::from_hex_iter(iter),
- b: FP::from_hex_iter(iter)
+ b: FP::from_hex_iter(iter),
}
}
diff --git a/src/fp24.rs b/src/fp24.rs
index 5f154b3..4041b1f 100644
--- a/src/fp24.rs
+++ b/src/fp24.rs
@@ -18,20 +18,20 @@ under the License.
*/
use super::big;
+use super::big::BIG;
use super::ecp;
use super::fp2::FP2;
use super::fp4::FP4;
use super::fp8::FP8;
-use super::big::BIG;
use super::rom;
-use types::{SexticTwist};
+use types::SexticTwist;
//use std::str::SplitWhitespace;
-pub const ZERO: usize=0;
-pub const ONE: usize=1;
-pub const SPARSER: usize=2;
-pub const SPARSE: usize=3;
-pub const DENSE: usize=4;
+pub const ZERO: usize = 0;
+pub const ONE: usize = 1;
+pub const SPARSER: usize = 2;
+pub const SPARSE: usize = 3;
+pub const DENSE: usize = 4;
#[derive(Copy, Clone)]
pub struct FP24 {
@@ -51,8 +51,8 @@ impl FP24 {
}
}
- pub fn settype(&mut self,t: usize) {
- self.stype = t;
+ pub fn settype(&mut self, t: usize) {
+ self.stype = t;
}
pub fn gettype(&self) -> usize {
@@ -64,11 +64,11 @@ impl FP24 {
f.a.copy(&FP8::new_int(a));
f.b.zero();
f.c.zero();
- if a == 1 {
- f.stype=ONE;
- } else {
- f.stype=SPARSER;
- }
+ if a == 1 {
+ f.stype = ONE;
+ } else {
+ f.stype = SPARSER;
+ }
return f;
}
@@ -77,7 +77,7 @@ impl FP24 {
f.a.copy(&x.a);
f.b.copy(&x.b);
f.c.copy(&x.c);
- f.stype=x.stype;
+ f.stype = x.stype;
return f;
}
@@ -86,7 +86,7 @@ impl FP24 {
g.a.copy(d);
g.b.copy(e);
g.c.copy(f);
- g.stype=DENSE;
+ g.stype = DENSE;
return g;
}
@@ -95,7 +95,7 @@ impl FP24 {
g.a.copy(d);
g.b.zero();
g.c.zero();
- g.stype=SPARSER;
+ g.stype = SPARSER;
return g;
}
@@ -123,9 +123,9 @@ impl FP24 {
self.a.cmove(&g.a, d);
self.b.cmove(&g.b, d);
self.c.cmove(&g.c, d);
- let mut u=d as usize;
- u=!(u-1);
- self.stype^=(self.stype^g.stype)&u;
+ let mut u = d as usize;
+ u = !(u - 1);
+ self.stype ^= (self.stype ^ g.stype) & u;
}
/* return 1 if b==c, no branching */
@@ -169,20 +169,20 @@ impl FP24 {
pub fn geta(&mut self) -> FP8 {
return self.a;
-// let f = FP8::new_copy(&self.a);
-// return f;
+ // let f = FP8::new_copy(&self.a);
+ // return f;
}
pub fn getb(&mut self) -> FP8 {
return self.b;
-// let f = FP8::new_copy(&self.b);
-// return f;
+ // let f = FP8::new_copy(&self.b);
+ // return f;
}
pub fn getc(&mut self) -> FP8 {
return self.c;
-// let f = FP8::new_copy(&self.c);
-// return f;
+ // let f = FP8::new_copy(&self.c);
+ // return f;
}
/* copy self=x */
@@ -190,7 +190,7 @@ impl FP24 {
self.a.copy(&x.a);
self.b.copy(&x.b);
self.c.copy(&x.c);
- self.stype=x.stype;
+ self.stype = x.stype;
}
/* set self=1 */
@@ -198,7 +198,7 @@ impl FP24 {
self.a.one();
self.b.zero();
self.c.zero();
- self.stype=ONE;
+ self.stype = ONE;
}
/* set self=0 */
@@ -206,7 +206,7 @@ impl FP24 {
self.a.zero();
self.b.zero();
self.c.zero();
- self.stype=ZERO;
+ self.stype = ZERO;
}
/* this=conj(this) */
@@ -254,13 +254,13 @@ impl FP24 {
self.c.dbl();
self.b.add(&b);
self.c.add(&c);
- self.stype=DENSE;
+ self.stype = DENSE;
self.reduce();
}
/* Chung-Hasan SQR2 method from http://cacr.uwaterloo.ca/techreports/2006/cacr2006-24.pdf */
pub fn sqr(&mut self) {
- if self.stype==ONE {
+ if self.stype == ONE {
return;
}
let mut a = FP8::new_copy(&self.a);
@@ -297,10 +297,10 @@ impl FP24 {
self.b.copy(&c);
self.b.add(&d);
self.c.add(&a);
- if self.stype==SPARSER {
- self.stype=SPARSE;
+ if self.stype == SPARSER {
+ self.stype = SPARSE;
} else {
- self.stype=DENSE;
+ self.stype = DENSE;
}
self.norm();
}
@@ -373,127 +373,144 @@ impl FP24 {
z3.times_i();
self.a.copy(&z0);
self.a.add(&z3);
- self.stype=DENSE;
+ self.stype = DENSE;
self.norm();
}
-/* FP24 full multiplication w=w*y */
-/* Supports sparse multiplicands */
-/* Usually w is denser than y */
+ /* FP24 full multiplication w=w*y */
+ /* Supports sparse multiplicands */
+ /* Usually w is denser than y */
pub fn ssmul(&mut self, y: &FP24) {
- if self.stype==ONE {
+ if self.stype == ONE {
self.copy(&y);
return;
}
- if y.stype==ONE {
+ if y.stype == ONE {
return;
}
- if y.stype>=SPARSE {
- let mut z0=FP8::new_copy(&self.a);
- let mut z1=FP8::new_int(0);
- let mut z2=FP8::new_int(0);
- let mut z3=FP8::new_int(0);
+ if y.stype >= SPARSE {
+ let mut z0 = FP8::new_copy(&self.a);
+ let mut z1 = FP8::new_int(0);
+ let mut z2 = FP8::new_int(0);
+ let mut z3 = FP8::new_int(0);
z0.mul(&y.a);
- if ecp::SEXTIC_TWIST==SexticTwist::M_TYPE {
- if y.stype==SPARSE || self.stype==SPARSE {
-
- let mut ga=FP4::new_int(0);
- let mut gb=FP4::new_int(0);
+ if ecp::SEXTIC_TWIST == SexticTwist::M_TYPE {
+ if y.stype == SPARSE || self.stype == SPARSE {
+ let mut ga = FP4::new_int(0);
+ let mut gb = FP4::new_int(0);
gb.copy(&self.b.getb());
gb.mul(&y.b.getb());
ga.zero();
- if y.stype!=SPARSE {
+ if y.stype != SPARSE {
ga.copy(&self.b.getb());
ga.mul(&y.b.geta());
}
- if self.stype!=SPARSE {
+ if self.stype != SPARSE {
ga.copy(&self.b.geta());
ga.mul(&y.b.getb());
}
- z2.set_fp4s(&ga,&gb);
+ z2.set_fp4s(&ga, &gb);
z2.times_i();
} else {
z2.copy(&self.b);
z2.mul(&y.b);
}
- } else {
- z2.copy(&self.b);
- z2.mul(&y.b);
+ } else {
+ z2.copy(&self.b);
+ z2.mul(&y.b);
}
- let mut t0=FP8::new_copy(&self.a);
- let mut t1=FP8::new_copy(&y.a);
- t0.add(&self.b); t0.norm();
- t1.add(&y.b); t1.norm();
+ let mut t0 = FP8::new_copy(&self.a);
+ let mut t1 = FP8::new_copy(&y.a);
+ t0.add(&self.b);
+ t0.norm();
+ t1.add(&y.b);
+ t1.norm();
+
+ z1.copy(&t0);
+ z1.mul(&t1);
+ t0.copy(&self.b);
+ t0.add(&self.c);
+ t0.norm();
+ t1.copy(&y.b);
+ t1.add(&y.c);
+ t1.norm();
+
+ z3.copy(&t0);
+ z3.mul(&t1);
+
+ t0.copy(&z0);
+ t0.neg();
+ t1.copy(&z2);
+ t1.neg();
- z1.copy(&t0); z1.mul(&t1);
- t0.copy(&self.b); t0.add(&self.c); t0.norm();
- t1.copy(&y.b); t1.add(&y.c); t1.norm();
-
- z3.copy(&t0); z3.mul(&t1);
-
- t0.copy(&z0); t0.neg();
- t1.copy(&z2); t1.neg();
-
z1.add(&t0);
- self.b.copy(&z1); self.b.add(&t1);
+ self.b.copy(&z1);
+ self.b.add(&t1);
z3.add(&t1);
z2.add(&t0);
- t0.copy(&self.a); t0.add(&self.c); t0.norm();
- t1.copy(&y.a); t1.add(&y.c); t1.norm();
-
+ t0.copy(&self.a);
+ t0.add(&self.c);
+ t0.norm();
+ t1.copy(&y.a);
+ t1.add(&y.c);
+ t1.norm();
+
t0.mul(&t1);
z2.add(&t0);
- if ecp::SEXTIC_TWIST==SexticTwist::D_TYPE {
- if y.stype==SPARSE || self.stype==SPARSE {
-
- let mut ga=FP4::new_int(0);
- let mut gb=FP4::new_int(0);
+ if ecp::SEXTIC_TWIST == SexticTwist::D_TYPE {
+ if y.stype == SPARSE || self.stype == SPARSE {
+ let mut ga = FP4::new_int(0);
+ let mut gb = FP4::new_int(0);
ga.copy(&self.c.geta());
ga.mul(&y.c.geta());
gb.zero();
- if y.stype!=SPARSE {
+ if y.stype != SPARSE {
gb.copy(&self.c.geta());
gb.mul(&y.c.getb());
}
- if self.stype!=SPARSE {
+ if self.stype != SPARSE {
gb.copy(&self.c.getb());
gb.mul(&y.c.geta());
}
- t0.set_fp4s(&ga,&gb);
+ t0.set_fp4s(&ga, &gb);
} else {
t0.copy(&self.c);
t0.mul(&y.c);
}
- } else {
+ } else {
t0.copy(&self.c);
t0.mul(&y.c);
}
- t1.copy(&t0); t1.neg();
+ t1.copy(&t0);
+ t1.neg();
- self.c.copy(&z2); self.c.add(&t1);
+ self.c.copy(&z2);
+ self.c.add(&t1);
z3.add(&t1);
t0.times_i();
self.b.add(&t0);
z3.norm();
z3.times_i();
- self.a.copy(&z0); self.a.add(&z3);
+ self.a.copy(&z0);
+ self.a.add(&z3);
} else {
- if self.stype==SPARSER {
+ if self.stype == SPARSER {
self.smul(&y);
return;
}
- if ecp::SEXTIC_TWIST==SexticTwist::D_TYPE { // dense by sparser - 13m
- let mut z0=FP8::new_copy(&self.a);
- let mut z2=FP8::new_copy(&self.b);
- let mut z3=FP8::new_copy(&self.b);
- let mut t0=FP8::new_int(0);
- let mut t1=FP8::new_copy(&y.a);
+ if ecp::SEXTIC_TWIST == SexticTwist::D_TYPE {
+ // dense by sparser - 13m
+ let mut z0 = FP8::new_copy(&self.a);
+ let mut z2 = FP8::new_copy(&self.b);
+ let mut z3 = FP8::new_copy(&self.b);
+ let mut t0 = FP8::new_int(0);
+ let mut t1 = FP8::new_copy(&y.a);
z0.mul(&y.a);
z2.pmul(&y.b.geta());
@@ -507,8 +524,10 @@ impl FP24 {
z3.norm();
z3.pmul(&y.b.geta());
- t0.copy(&z0); t0.neg();
- t1.copy(&z2); t1.neg();
+ t0.copy(&z0);
+ t0.neg();
+ t1.copy(&z2);
+ t1.neg();
self.b.add(&t0);
@@ -516,98 +535,121 @@ impl FP24 {
z3.add(&t1);
z2.add(&t0);
- t0.copy(&self.a); t0.add(&self.c); t0.norm();
+ t0.copy(&self.a);
+ t0.add(&self.c);
+ t0.norm();
z3.norm();
t0.mul(&y.a);
- self.c.copy(&z2); self.c.add(&t0);
+ self.c.copy(&z2);
+ self.c.add(&t0);
z3.times_i();
- self.a.copy(&z0); self.a.add(&z3);
+ self.a.copy(&z0);
+ self.a.add(&z3);
}
- if ecp::SEXTIC_TWIST==SexticTwist::M_TYPE {
-
+ if ecp::SEXTIC_TWIST == SexticTwist::M_TYPE {
let mut z0 = FP8::new_copy(&self.a);
let mut z1 = FP8::new();
let mut z2 = FP8::new();
let mut z3 = FP8::new();
let mut t0 = FP8::new_copy(&self.a);
let mut t1 = FP8::new();
-
+
z0.mul(&y.a);
- t0.add(&self.b); t0.norm();
+ t0.add(&self.b);
+ t0.norm();
- z1.copy(&t0); z1.mul(&y.a);
- t0.copy(&self.b); t0.add(&self.c);
+ z1.copy(&t0);
+ z1.mul(&y.a);
+ t0.copy(&self.b);
+ t0.add(&self.c);
t0.norm();
z3.copy(&t0);
z3.pmul(&y.c.getb());
z3.times_i();
- t0.copy(&z0); t0.neg();
+ t0.copy(&z0);
+ t0.neg();
z1.add(&t0);
self.b.copy(&z1);
z2.copy(&t0);
- t0.copy(&self.a); t0.add(&self.c); t0.norm();
- t1.copy(&y.a); t1.add(&y.c); t1.norm();
+ t0.copy(&self.a);
+ t0.add(&self.c);
+ t0.norm();
+ t1.copy(&y.a);
+ t1.add(&y.c);
+ t1.norm();
t0.mul(&t1);
z2.add(&t0);
t0.copy(&self.c);
-
+
t0.pmul(&y.c.getb());
t0.times_i();
- t1.copy(&t0); t1.neg();
+ t1.copy(&t0);
+ t1.neg();
- self.c.copy(&z2); self.c.add(&t1);
+ self.c.copy(&z2);
+ self.c.add(&t1);
z3.add(&t1);
t0.times_i();
self.b.add(&t0);
z3.norm();
z3.times_i();
- self.a.copy(&z0); self.a.add(&z3);
- }
+ self.a.copy(&z0);
+ self.a.add(&z3);
+ }
}
- self.stype=DENSE;
+ self.stype = DENSE;
self.norm();
}
-
/* Special case of multiplication arises from special form of ATE pairing line function */
pub fn smul(&mut self, y: &FP24) {
- if ecp::SEXTIC_TWIST==SexticTwist::D_TYPE {
- let mut w1=FP4::new_copy(&self.a.geta());
- let mut w2=FP4::new_copy(&self.a.getb());
- let mut w3=FP4::new_copy(&self.b.geta());
+ if ecp::SEXTIC_TWIST == SexticTwist::D_TYPE {
+ let mut w1 = FP4::new_copy(&self.a.geta());
+ let mut w2 = FP4::new_copy(&self.a.getb());
+ let mut w3 = FP4::new_copy(&self.b.geta());
w1.mul(&y.a.geta());
w2.mul(&y.a.getb());
w3.mul(&y.b.geta());
- let mut ta=FP4::new_copy(&self.a.geta());
- let mut tb=FP4::new_copy(&y.a.geta());
- ta.add(&self.a.getb()); ta.norm();
- tb.add(&y.a.getb()); tb.norm();
- let mut tc=FP4::new_copy(&ta);
+ let mut ta = FP4::new_copy(&self.a.geta());
+ let mut tb = FP4::new_copy(&y.a.geta());
+ ta.add(&self.a.getb());
+ ta.norm();
+ tb.add(&y.a.getb());
+ tb.norm();
+ let mut tc = FP4::new_copy(&ta);
tc.mul(&tb);
- let mut t=FP4::new_copy(&w1);
+ let mut t = FP4::new_copy(&w1);
t.add(&w2);
t.neg();
tc.add(&t);
- ta.copy(&self.a.geta()); ta.add(&self.b.geta()); ta.norm();
- tb.copy(&y.a.geta()); tb.add(&y.b.geta()); tb.norm();
- let mut td=FP4::new_copy(&ta);
+ ta.copy(&self.a.geta());
+ ta.add(&self.b.geta());
+ ta.norm();
+ tb.copy(&y.a.geta());
+ tb.add(&y.b.geta());
+ tb.norm();
+ let mut td = FP4::new_copy(&ta);
td.mul(&tb);
t.copy(&w1);
t.add(&w3);
t.neg();
td.add(&t);
- ta.copy(&self.a.getb()); ta.add(&self.b.geta()); ta.norm();
- tb.copy(&y.a.getb()); tb.add(&y.b.geta()); tb.norm();
- let mut te=FP4::new_copy(&ta);
+ ta.copy(&self.a.getb());
+ ta.add(&self.b.geta());
+ ta.norm();
+ tb.copy(&y.a.getb());
+ tb.add(&y.b.geta());
+ tb.norm();
+ let mut te = FP4::new_copy(&ta);
te.mul(&tb);
t.copy(&w2);
t.add(&w3);
@@ -617,44 +659,54 @@ impl FP24 {
w2.times_i();
w1.add(&w2);
- self.a.set_fp4s(&w1,&tc);
- self.b.set_fp4s(&td,&te);
- self.c.set_fp4(&w3);
+ self.a.set_fp4s(&w1, &tc);
+ self.b.set_fp4s(&td, &te);
+ self.c.set_fp4(&w3);
self.a.norm();
self.b.norm();
} else {
- let mut w1=FP4::new_copy(&self.a.geta());
- let mut w2=FP4::new_copy(&self.a.getb());
- let mut w3=FP4::new_copy(&self.c.getb());
+ let mut w1 = FP4::new_copy(&self.a.geta());
+ let mut w2 = FP4::new_copy(&self.a.getb());
+ let mut w3 = FP4::new_copy(&self.c.getb());
w1.mul(&y.a.geta());
w2.mul(&y.a.getb());
w3.mul(&y.c.getb());
- let mut ta=FP4::new_copy(&self.a.geta());
- let mut tb=FP4::new_copy(&y.a.geta());
- ta.add(&self.a.getb()); ta.norm();
- tb.add(&y.a.getb()); tb.norm();
- let mut tc=FP4::new_copy(&ta);
+ let mut ta = FP4::new_copy(&self.a.geta());
+ let mut tb = FP4::new_copy(&y.a.geta());
+ ta.add(&self.a.getb());
+ ta.norm();
+ tb.add(&y.a.getb());
+ tb.norm();
+ let mut tc = FP4::new_copy(&ta);
tc.mul(&tb);
- let mut t=FP4::new_copy(&w1);
+ let mut t = FP4::new_copy(&w1);
t.add(&w2);
t.neg();
tc.add(&t);
- ta.copy(&self.a.geta()); ta.add(&self.c.getb()); ta.norm();
- tb.copy(&y.a.geta()); tb.add(&y.c.getb()); tb.norm();
- let mut td=FP4::new_copy(&ta);
+ ta.copy(&self.a.geta());
+ ta.add(&self.c.getb());
+ ta.norm();
+ tb.copy(&y.a.geta());
+ tb.add(&y.c.getb());
+ tb.norm();
+ let mut td = FP4::new_copy(&ta);
td.mul(&tb);
t.copy(&w1);
t.add(&w3);
t.neg();
td.add(&t);
- ta.copy(&self.a.getb()); ta.add(&self.c.getb()); ta.norm();
- tb.copy(&y.a.getb()); tb.add(&y.c.getb()); tb.norm();
- let mut te=FP4::new_copy(&ta);
+ ta.copy(&self.a.getb());
+ ta.add(&self.c.getb());
+ ta.norm();
+ tb.copy(&y.a.getb());
+ tb.add(&y.c.getb());
+ tb.norm();
+ let mut te = FP4::new_copy(&ta);
te.mul(&tb);
t.copy(&w2);
t.add(&w3);
@@ -663,20 +715,20 @@ impl FP24 {
w2.times_i();
w1.add(&w2);
- self.a.set_fp4s(&w1,&tc);
+ self.a.set_fp4s(&w1, &tc);
w3.times_i();
w3.norm();
- self.b.set_fp4h(&w3);
+ self.b.set_fp4h(&w3);
te.norm();
te.times_i();
- self.c.set_fp4s(&te,&td);
+ self.c.set_fp4s(&te, &td);
self.a.norm();
self.c.norm();
- }
- self.stype=SPARSE;
+ }
+ self.stype = SPARSE;
}
/* self=1/self */
@@ -724,7 +776,7 @@ impl FP24 {
self.b.mul(&f3);
self.c.copy(&f2);
self.c.mul(&f3);
- self.stype=DENSE;
+ self.stype = DENSE;
}
/* self=self^p using Frobenius */
@@ -749,7 +801,7 @@ impl FP24 {
self.c.times_i2();
self.c.times_i2();
}
- self.stype=DENSE;
+ self.stype = DENSE;
}
/* trace function */
diff --git a/src/fp4.rs b/src/fp4.rs
index 1db4b73..1e5f847 100644
--- a/src/fp4.rs
+++ b/src/fp4.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
+use super::big::BIG;
use super::fp::FP;
use super::fp2::FP2;
-use super::big::BIG;
use std::str::SplitWhitespace;
#[derive(Copy, Clone)]
@@ -29,9 +29,9 @@ pub struct FP4 {
}
impl PartialEq for FP4 {
- fn eq(&self, other: &FP4) -> bool {
- self.equals(other)
- }
+ fn eq(&self, other: &FP4) -> bool {
+ self.equals(other)
+ }
}
impl FP4 {
@@ -69,20 +69,20 @@ impl FP4 {
f.b.zero();
return f;
}
-
- pub fn set_fp2s(&mut self,c: &FP2, d: &FP2) {
+
+ pub fn set_fp2s(&mut self, c: &FP2, d: &FP2) {
self.a.copy(&c);
- self.b.copy(&d);
+ self.b.copy(&d);
}
- pub fn set_fp2(&mut self,c: &FP2) {
+ pub fn set_fp2(&mut self, c: &FP2) {
self.a.copy(&c);
- self.b.zero();
+ self.b.zero();
}
- pub fn set_fp2h(&mut self,c: &FP2) {
+ pub fn set_fp2h(&mut self, c: &FP2) {
self.b.copy(&c);
- self.a.zero();
+ self.a.zero();
}
/* reduce components mod Modulus */
@@ -125,14 +125,14 @@ impl FP4 {
pub fn geta(&self) -> FP2 {
return self.a;
-// let f = FP2::new_copy(&self.a);
-// return f;
+ // let f = FP2::new_copy(&self.a);
+ // return f;
}
/* extract imaginary part b */
pub fn getb(&self) -> FP2 {
return self.b;
-// let f = FP2::new_copy(&self.b);
-// return f;
+ // let f = FP2::new_copy(&self.b);
+ // return f;
}
/* test self=x */
@@ -313,7 +313,7 @@ impl FP4 {
pub fn from_hex_iter(iter: &mut SplitWhitespace) -> FP4 {
FP4 {
a: FP2::from_hex_iter(iter),
- b: FP2::from_hex_iter(iter)
+ b: FP2::from_hex_iter(iter),
}
}
diff --git a/src/fp48.rs b/src/fp48.rs
index c72ee4c..96174b0 100644
--- a/src/fp48.rs
+++ b/src/fp48.rs
@@ -18,21 +18,21 @@ under the License.
*/
use super::big;
+use super::big::BIG;
use super::ecp;
+use super::fp16::FP16;
use super::fp2::FP2;
use super::fp4::FP4;
use super::fp8::FP8;
-use super::fp16::FP16;
-use super::big::BIG;
use super::rom;
use types::SexticTwist;
//use std::str::SplitWhitespace;
-pub const ZERO: usize=0;
-pub const ONE: usize=1;
-pub const SPARSER: usize=2;
-pub const SPARSE: usize=3;
-pub const DENSE: usize=4;
+pub const ZERO: usize = 0;
+pub const ONE: usize = 1;
+pub const SPARSER: usize = 2;
+pub const SPARSE: usize = 3;
+pub const DENSE: usize = 4;
#[derive(Copy, Clone)]
pub struct FP48 {
@@ -48,12 +48,12 @@ impl FP48 {
a: FP16::new(),
b: FP16::new(),
c: FP16::new(),
- stype: ZERO,
+ stype: ZERO,
}
}
- pub fn settype(&mut self,t: usize) {
- self.stype = t;
+ pub fn settype(&mut self, t: usize) {
+ self.stype = t;
}
pub fn gettype(&self) -> usize {
@@ -65,11 +65,11 @@ impl FP48 {
f.a.copy(&FP16::new_int(a));
f.b.zero();
f.c.zero();
- if a == 1 {
- f.stype=ONE;
- } else {
- f.stype=SPARSER;
- }
+ if a == 1 {
+ f.stype = ONE;
+ } else {
+ f.stype = SPARSER;
+ }
return f;
}
@@ -78,7 +78,7 @@ impl FP48 {
f.a.copy(&x.a);
f.b.copy(&x.b);
f.c.copy(&x.c);
- f.stype=x.stype;
+ f.stype = x.stype;
return f;
}
@@ -87,7 +87,7 @@ impl FP48 {
g.a.copy(d);
g.b.copy(e);
g.c.copy(f);
- g.stype=DENSE;
+ g.stype = DENSE;
return g;
}
@@ -96,7 +96,7 @@ impl FP48 {
g.a.copy(d);
g.b.zero();
g.c.zero();
- g.stype=SPARSER;
+ g.stype = SPARSER;
return g;
}
@@ -124,9 +124,9 @@ impl FP48 {
self.a.cmove(&g.a, d);
self.b.cmove(&g.b, d);
self.c.cmove(&g.c, d);
- let mut u=d as usize;
- u=!(u-1);
- self.stype^=(self.stype^g.stype)&u;
+ let mut u = d as usize;
+ u = !(u - 1);
+ self.stype ^= (self.stype ^ g.stype) & u;
}
/* return 1 if b==c, no branching */
@@ -170,20 +170,20 @@ impl FP48 {
pub fn geta(&mut self) -> FP16 {
return self.a;
-// let f = FP16::new_copy(&self.a);
-// return f;
+ // let f = FP16::new_copy(&self.a);
+ // return f;
}
pub fn getb(&mut self) -> FP16 {
return self.b;
-// let f = FP16::new_copy(&self.b);
-// return f;
+ // let f = FP16::new_copy(&self.b);
+ // return f;
}
pub fn getc(&mut self) -> FP16 {
return self.c;
-// let f = FP16::new_copy(&self.c);
-// return f;
+ // let f = FP16::new_copy(&self.c);
+ // return f;
}
/* copy self=x */
@@ -191,7 +191,7 @@ impl FP48 {
self.a.copy(&x.a);
self.b.copy(&x.b);
self.c.copy(&x.c);
- self.stype=x.stype;
+ self.stype = x.stype;
}
/* set self=1 */
@@ -199,7 +199,7 @@ impl FP48 {
self.a.one();
self.b.zero();
self.c.zero();
- self.stype=ONE;
+ self.stype = ONE;
}
/* set self=0 */
@@ -207,7 +207,7 @@ impl FP48 {
self.a.zero();
self.b.zero();
self.c.zero();
- self.stype=ZERO;
+ self.stype = ZERO;
}
/* this=conj(this) */
@@ -255,13 +255,13 @@ impl FP48 {
self.c.dbl();
self.b.add(&b);
self.c.add(&c);
- self.stype=DENSE;
+ self.stype = DENSE;
self.reduce();
}
/* Chung-Hasan SQR2 method from http://cacr.uwaterloo.ca/techreports/2006/cacr2006-24.pdf */
pub fn sqr(&mut self) {
- if self.stype==ONE {
+ if self.stype == ONE {
return;
}
let mut a = FP16::new_copy(&self.a);
@@ -298,10 +298,10 @@ impl FP48 {
self.b.copy(&c);
self.b.add(&d);
self.c.add(&a);
- if self.stype==SPARSER {
- self.stype=SPARSE;
+ if self.stype == SPARSER {
+ self.stype = SPARSE;
} else {
- self.stype=DENSE;
+ self.stype = DENSE;
}
self.norm();
}
@@ -373,127 +373,144 @@ impl FP48 {
z3.times_i();
self.a.copy(&z0);
self.a.add(&z3);
- self.stype=DENSE;
+ self.stype = DENSE;
self.norm();
}
-/* FP48 full multiplication w=w*y */
-/* Supports sparse multiplicands */
-/* Usually w is denser than y */
+ /* FP48 full multiplication w=w*y */
+ /* Supports sparse multiplicands */
+ /* Usually w is denser than y */
pub fn ssmul(&mut self, y: &FP48) {
- if self.stype==ONE {
+ if self.stype == ONE {
self.copy(&y);
return;
}
- if y.stype==ONE {
+ if y.stype == ONE {
return;
}
- if y.stype>=SPARSE {
- let mut z0=FP16::new_copy(&self.a);
- let mut z1=FP16::new_int(0);
- let mut z2=FP16::new_int(0);
- let mut z3=FP16::new_int(0);
+ if y.stype >= SPARSE {
+ let mut z0 = FP16::new_copy(&self.a);
+ let mut z1 = FP16::new_int(0);
+ let mut z2 = FP16::new_int(0);
+ let mut z3 = FP16::new_int(0);
z0.mul(&y.a);
- if ecp::SEXTIC_TWIST==SexticTwist::M_TYPE {
- if y.stype==SPARSE || self.stype==SPARSE {
-
- let mut ga=FP8::new_int(0);
- let mut gb=FP8::new_int(0);
+ if ecp::SEXTIC_TWIST == SexticTwist::M_TYPE {
+ if y.stype == SPARSE || self.stype == SPARSE {
+ let mut ga = FP8::new_int(0);
+ let mut gb = FP8::new_int(0);
gb.copy(&self.b.getb());
gb.mul(&y.b.getb());
ga.zero();
- if y.stype!=SPARSE {
+ if y.stype != SPARSE {
ga.copy(&self.b.getb());
ga.mul(&y.b.geta());
}
- if self.stype!=SPARSE {
+ if self.stype != SPARSE {
ga.copy(&self.b.geta());
ga.mul(&y.b.getb());
}
- z2.set_fp8s(&ga,&gb);
+ z2.set_fp8s(&ga, &gb);
z2.times_i();
} else {
z2.copy(&self.b);
z2.mul(&y.b);
}
- } else {
- z2.copy(&self.b);
- z2.mul(&y.b);
+ } else {
+ z2.copy(&self.b);
+ z2.mul(&y.b);
}
- let mut t0=FP16::new_copy(&self.a);
- let mut t1=FP16::new_copy(&y.a);
- t0.add(&self.b); t0.norm();
- t1.add(&y.b); t1.norm();
-
- z1.copy(&t0); z1.mul(&t1);
- t0.copy(&self.b); t0.add(&self.c); t0.norm();
- t1.copy(&y.b); t1.add(&y.c); t1.norm();
-
- z3.copy(&t0); z3.mul(&t1);
+ let mut t0 = FP16::new_copy(&self.a);
+ let mut t1 = FP16::new_copy(&y.a);
+ t0.add(&self.b);
+ t0.norm();
+ t1.add(&y.b);
+ t1.norm();
+
+ z1.copy(&t0);
+ z1.mul(&t1);
+ t0.copy(&self.b);
+ t0.add(&self.c);
+ t0.norm();
+ t1.copy(&y.b);
+ t1.add(&y.c);
+ t1.norm();
+
+ z3.copy(&t0);
+ z3.mul(&t1);
+
+ t0.copy(&z0);
+ t0.neg();
+ t1.copy(&z2);
+ t1.neg();
- t0.copy(&z0); t0.neg();
- t1.copy(&z2); t1.neg();
-
z1.add(&t0);
- self.b.copy(&z1); self.b.add(&t1);
+ self.b.copy(&z1);
+ self.b.add(&t1);
z3.add(&t1);
z2.add(&t0);
- t0.copy(&self.a); t0.add(&self.c); t0.norm();
- t1.copy(&y.a); t1.add(&y.c); t1.norm();
-
+ t0.copy(&self.a);
+ t0.add(&self.c);
+ t0.norm();
+ t1.copy(&y.a);
+ t1.add(&y.c);
+ t1.norm();
+
t0.mul(&t1);
z2.add(&t0);
- if ecp::SEXTIC_TWIST==SexticTwist::D_TYPE {
- if y.stype==SPARSE || self.stype==SPARSE {
-
- let mut ga=FP8::new_int(0);
- let mut gb=FP8::new_int(0);
+ if ecp::SEXTIC_TWIST == SexticTwist::D_TYPE {
+ if y.stype == SPARSE || self.stype == SPARSE {
+ let mut ga = FP8::new_int(0);
+ let mut gb = FP8::new_int(0);
ga.copy(&self.c.geta());
ga.mul(&y.c.geta());
gb.zero();
- if y.stype!=SPARSE {
+ if y.stype != SPARSE {
gb.copy(&self.c.geta());
gb.mul(&y.c.getb());
}
- if self.stype!=SPARSE {
+ if self.stype != SPARSE {
gb.copy(&self.c.getb());
gb.mul(&y.c.geta());
}
- t0.set_fp8s(&ga,&gb);
+ t0.set_fp8s(&ga, &gb);
} else {
t0.copy(&self.c);
t0.mul(&y.c);
}
- } else {
+ } else {
t0.copy(&self.c);
t0.mul(&y.c);
}
- t1.copy(&t0); t1.neg();
+ t1.copy(&t0);
+ t1.neg();
- self.c.copy(&z2); self.c.add(&t1);
+ self.c.copy(&z2);
+ self.c.add(&t1);
z3.add(&t1);
t0.times_i();
self.b.add(&t0);
z3.norm();
z3.times_i();
- self.a.copy(&z0); self.a.add(&z3);
+ self.a.copy(&z0);
+ self.a.add(&z3);
} else {
- if self.stype==SPARSER {
+ if self.stype == SPARSER {
self.smul(&y);
return;
}
- if ecp::SEXTIC_TWIST==SexticTwist::D_TYPE { // dense by sparser - 13m
- let mut z0=FP16::new_copy(&self.a);
- let mut z2=FP16::new_copy(&self.b);
- let mut z3=FP16::new_copy(&self.b);
- let mut t0=FP16::new_int(0);
- let mut t1=FP16::new_copy(&y.a);
+ if ecp::SEXTIC_TWIST == SexticTwist::D_TYPE {
+ // dense by sparser - 13m
+ let mut z0 = FP16::new_copy(&self.a);
+ let mut z2 = FP16::new_copy(&self.b);
+ let mut z3 = FP16::new_copy(&self.b);
+ let mut t0 = FP16::new_int(0);
+ let mut t1 = FP16::new_copy(&y.a);
z0.mul(&y.a);
z2.pmul(&y.b.geta());
@@ -507,8 +524,10 @@ impl FP48 {
z3.norm();
z3.pmul(&y.b.geta());
- t0.copy(&z0); t0.neg();
- t1.copy(&z2); t1.neg();
+ t0.copy(&z0);
+ t0.neg();
+ t1.copy(&z2);
+ t1.neg();
self.b.add(&t0);
@@ -516,98 +535,121 @@ impl FP48 {
z3.add(&t1);
z2.add(&t0);
- t0.copy(&self.a); t0.add(&self.c); t0.norm();
+ t0.copy(&self.a);
+ t0.add(&self.c);
+ t0.norm();
z3.norm();
t0.mul(&y.a);
- self.c.copy(&z2); self.c.add(&t0);
+ self.c.copy(&z2);
+ self.c.add(&t0);
z3.times_i();
- self.a.copy(&z0); self.a.add(&z3);
+ self.a.copy(&z0);
+ self.a.add(&z3);
}
- if ecp::SEXTIC_TWIST==SexticTwist::M_TYPE {
-
+ if ecp::SEXTIC_TWIST == SexticTwist::M_TYPE {
let mut z0 = FP16::new_copy(&self.a);
let mut z1 = FP16::new();
let mut z2 = FP16::new();
let mut z3 = FP16::new();
let mut t0 = FP16::new_copy(&self.a);
let mut t1 = FP16::new();
-
+
z0.mul(&y.a);
- t0.add(&self.b); t0.norm();
+ t0.add(&self.b);
+ t0.norm();
- z1.copy(&t0); z1.mul(&y.a);
- t0.copy(&self.b); t0.add(&self.c);
+ z1.copy(&t0);
+ z1.mul(&y.a);
+ t0.copy(&self.b);
+ t0.add(&self.c);
t0.norm();
z3.copy(&t0);
z3.pmul(&y.c.getb());
z3.times_i();
- t0.copy(&z0); t0.neg();
+ t0.copy(&z0);
+ t0.neg();
z1.add(&t0);
self.b.copy(&z1);
z2.copy(&t0);
- t0.copy(&self.a); t0.add(&self.c); t0.norm();
- t1.copy(&y.a); t1.add(&y.c); t1.norm();
+ t0.copy(&self.a);
+ t0.add(&self.c);
+ t0.norm();
+ t1.copy(&y.a);
+ t1.add(&y.c);
+ t1.norm();
t0.mul(&t1);
z2.add(&t0);
t0.copy(&self.c);
-
+
t0.pmul(&y.c.getb());
t0.times_i();
- t1.copy(&t0); t1.neg();
+ t1.copy(&t0);
+ t1.neg();
- self.c.copy(&z2); self.c.add(&t1);
+ self.c.copy(&z2);
+ self.c.add(&t1);
z3.add(&t1);
t0.times_i();
self.b.add(&t0);
z3.norm();
z3.times_i();
- self.a.copy(&z0); self.a.add(&z3);
- }
+ self.a.copy(&z0);
+ self.a.add(&z3);
+ }
}
- self.stype=DENSE;
+ self.stype = DENSE;
self.norm();
}
-
/* Special case of multiplication arises from special form of ATE pairing line function */
pub fn smul(&mut self, y: &FP48) {
- if ecp::SEXTIC_TWIST==SexticTwist::D_TYPE {
- let mut w1=FP8::new_copy(&self.a.geta());
- let mut w2=FP8::new_copy(&self.a.getb());
- let mut w3=FP8::new_copy(&self.b.geta());
+ if ecp::SEXTIC_TWIST == SexticTwist::D_TYPE {
+ let mut w1 = FP8::new_copy(&self.a.geta());
+ let mut w2 = FP8::new_copy(&self.a.getb());
+ let mut w3 = FP8::new_copy(&self.b.geta());
w1.mul(&y.a.geta());
w2.mul(&y.a.getb());
w3.mul(&y.b.geta());
- let mut ta=FP8::new_copy(&self.a.geta());
- let mut tb=FP8::new_copy(&y.a.geta());
- ta.add(&self.a.getb()); ta.norm();
- tb.add(&y.a.getb()); tb.norm();
- let mut tc=FP8::new_copy(&ta);
+ let mut ta = FP8::new_copy(&self.a.geta());
+ let mut tb = FP8::new_copy(&y.a.geta());
+ ta.add(&self.a.getb());
+ ta.norm();
+ tb.add(&y.a.getb());
+ tb.norm();
+ let mut tc = FP8::new_copy(&ta);
tc.mul(&tb);
- let mut t=FP8::new_copy(&w1);
+ let mut t = FP8::new_copy(&w1);
t.add(&w2);
t.neg();
tc.add(&t);
- ta.copy(&self.a.geta()); ta.add(&self.b.geta()); ta.norm();
- tb.copy(&y.a.geta()); tb.add(&y.b.geta()); tb.norm();
- let mut td=FP8::new_copy(&ta);
+ ta.copy(&self.a.geta());
+ ta.add(&self.b.geta());
+ ta.norm();
+ tb.copy(&y.a.geta());
+ tb.add(&y.b.geta());
+ tb.norm();
+ let mut td = FP8::new_copy(&ta);
td.mul(&tb);
t.copy(&w1);
t.add(&w3);
t.neg();
td.add(&t);
- ta.copy(&self.a.getb()); ta.add(&self.b.geta()); ta.norm();
- tb.copy(&y.a.getb()); tb.add(&y.b.geta()); tb.norm();
- let mut te=FP8::new_copy(&ta);
+ ta.copy(&self.a.getb());
+ ta.add(&self.b.geta());
+ ta.norm();
+ tb.copy(&y.a.getb());
+ tb.add(&y.b.geta());
+ tb.norm();
+ let mut te = FP8::new_copy(&ta);
te.mul(&tb);
t.copy(&w2);
t.add(&w3);
@@ -617,44 +659,54 @@ impl FP48 {
w2.times_i();
w1.add(&w2);
- self.a.set_fp8s(&w1,&tc);
- self.b.set_fp8s(&td,&te);
- self.c.set_fp8(&w3);
+ self.a.set_fp8s(&w1, &tc);
+ self.b.set_fp8s(&td, &te);
+ self.c.set_fp8(&w3);
self.a.norm();
self.b.norm();
} else {
- let mut w1=FP8::new_copy(&self.a.geta());
- let mut w2=FP8::new_copy(&self.a.getb());
- let mut w3=FP8::new_copy(&self.c.getb());
+ let mut w1 = FP8::new_copy(&self.a.geta());
+ let mut w2 = FP8::new_copy(&self.a.getb());
+ let mut w3 = FP8::new_copy(&self.c.getb());
w1.mul(&y.a.geta());
w2.mul(&y.a.getb());
w3.mul(&y.c.getb());
- let mut ta=FP8::new_copy(&self.a.geta());
- let mut tb=FP8::new_copy(&y.a.geta());
- ta.add(&self.a.getb()); ta.norm();
- tb.add(&y.a.getb()); tb.norm();
- let mut tc=FP8::new_copy(&ta);
+ let mut ta = FP8::new_copy(&self.a.geta());
+ let mut tb = FP8::new_copy(&y.a.geta());
+ ta.add(&self.a.getb());
+ ta.norm();
+ tb.add(&y.a.getb());
+ tb.norm();
+ let mut tc = FP8::new_copy(&ta);
tc.mul(&tb);
- let mut t=FP8::new_copy(&w1);
+ let mut t = FP8::new_copy(&w1);
t.add(&w2);
t.neg();
tc.add(&t);
- ta.copy(&self.a.geta()); ta.add(&self.c.getb()); ta.norm();
- tb.copy(&y.a.geta()); tb.add(&y.c.getb()); tb.norm();
- let mut td=FP8::new_copy(&ta);
+ ta.copy(&self.a.geta());
+ ta.add(&self.c.getb());
+ ta.norm();
+ tb.copy(&y.a.geta());
+ tb.add(&y.c.getb());
+ tb.norm();
+ let mut td = FP8::new_copy(&ta);
td.mul(&tb);
t.copy(&w1);
t.add(&w3);
t.neg();
td.add(&t);
- ta.copy(&self.a.getb()); ta.add(&self.c.getb()); ta.norm();
- tb.copy(&y.a.getb()); tb.add(&y.c.getb()); tb.norm();
- let mut te=FP8::new_copy(&ta);
+ ta.copy(&self.a.getb());
+ ta.add(&self.c.getb());
+ ta.norm();
+ tb.copy(&y.a.getb());
+ tb.add(&y.c.getb());
+ tb.norm();
+ let mut te = FP8::new_copy(&ta);
te.mul(&tb);
t.copy(&w2);
t.add(&w3);
@@ -663,20 +715,20 @@ impl FP48 {
w2.times_i();
w1.add(&w2);
- self.a.set_fp8s(&w1,&tc);
+ self.a.set_fp8s(&w1, &tc);
w3.times_i();
w3.norm();
- self.b.set_fp8h(&w3);
+ self.b.set_fp8h(&w3);
te.norm();
te.times_i();
- self.c.set_fp8s(&te,&td);
+ self.c.set_fp8s(&te, &td);
self.a.norm();
self.c.norm();
- }
- self.stype=SPARSE;
+ }
+ self.stype = SPARSE;
}
/* self=1/self */
@@ -724,7 +776,7 @@ impl FP48 {
self.b.mul(&f3);
self.c.copy(&f2);
self.c.mul(&f3);
- self.stype=DENSE;
+ self.stype = DENSE;
}
/* self=self^p using Frobenius */
@@ -753,7 +805,7 @@ impl FP48 {
self.c.times_i4();
self.c.times_i4();
}
- self.stype=DENSE;
+ self.stype = DENSE;
}
/* trace function */
diff --git a/src/fp8.rs b/src/fp8.rs
index dfc84d1..e693b13 100644
--- a/src/fp8.rs
+++ b/src/fp8.rs
@@ -17,10 +17,10 @@ specific language governing permissions and limitations
under the License.
*/
+use super::big::BIG;
use super::fp::FP;
use super::fp2::FP2;
use super::fp4::FP4;
-use super::big::BIG;
//use std::str::SplitWhitespace;
#[derive(Copy, Clone)]
@@ -65,22 +65,21 @@ impl FP8 {
return f;
}
- pub fn set_fp4s(&mut self,c: &FP4, d: &FP4) {
+ pub fn set_fp4s(&mut self, c: &FP4, d: &FP4) {
self.a.copy(&c);
- self.b.copy(&d);
+ self.b.copy(&d);
}
- pub fn set_fp4(&mut self,c: &FP4) {
+ pub fn set_fp4(&mut self, c: &FP4) {
self.a.copy(&c);
- self.b.zero();
+ self.b.zero();
}
- pub fn set_fp4h(&mut self,c: &FP4) {
+ pub fn set_fp4h(&mut self, c: &FP4) {
self.b.copy(&c);
- self.a.zero();
+ self.a.zero();
}
-
/* reduce components mod Modulus */
pub fn reduce(&mut self) {
self.a.reduce();
@@ -121,14 +120,14 @@ impl FP8 {
pub fn geta(&self) -> FP4 {
return self.a;
-// let f = FP4::new_copy(&self.a);
-// return f;
+ // let f = FP4::new_copy(&self.a);
+ // return f;
}
/* extract imaginary part b */
pub fn getb(&self) -> FP4 {
return self.b;
-// let f = FP4::new_copy(&self.b);
-// return f;
+ // let f = FP4::new_copy(&self.b);
+ // return f;
}
/* test self=x */
diff --git a/src/lib.rs b/src/lib.rs
index 108057b..c68a165 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,18 +1,18 @@
pub mod aes;
+#[cfg(target_pointer_width = "32")]
+#[path = "arch/arch32.rs"]
+pub mod arch;
+#[cfg(target_pointer_width = "64")]
+#[path = "arch/arch64.rs"]
+pub mod arch;
pub mod gcm;
pub mod hash256;
pub mod hash384;
pub mod hash512;
+pub mod nhs;
pub mod rand;
pub mod sha3;
-pub mod nhs;
pub mod types;
-#[cfg(target_pointer_width = "32")]
-#[path = "arch/arch32.rs"]
-pub mod arch;
-#[cfg(target_pointer_width = "64")]
-#[path = "arch/arch64.rs"]
-pub mod arch;
#[cfg(feature = "bls48")]
#[path = "./"]
@@ -25,18 +25,18 @@ pub mod bls48 {
pub mod rom;
pub mod big;
+ pub mod bls256;
pub mod dbig;
- pub mod fp;
pub mod ecp;
pub mod ecp8;
+ pub mod fp;
+ pub mod fp16;
pub mod fp2;
pub mod fp4;
- pub mod fp8;
- pub mod fp16;
pub mod fp48;
- pub mod pair256;
+ pub mod fp8;
pub mod mpin256;
- pub mod bls256;
+ pub mod pair256;
}
#[cfg(feature = "bls461")]
@@ -50,16 +50,16 @@ pub mod bls461 {
pub mod rom;
pub mod big;
+ pub mod bls;
pub mod dbig;
- pub mod fp;
pub mod ecp;
pub mod ecp2;
+ pub mod fp;
+ pub mod fp12;
pub mod fp2;
pub mod fp4;
- pub mod fp12;
- pub mod pair;
pub mod mpin;
- pub mod bls;
+ pub mod pair;
}
#[cfg(feature = "bls383")]
@@ -73,16 +73,16 @@ pub mod bls383 {
pub mod rom;
pub mod big;
+ pub mod bls;
pub mod dbig;
- pub mod fp;
pub mod ecp;
pub mod ecp2;
+ pub mod fp;
+ pub mod fp12;
pub mod fp2;
pub mod fp4;
- pub mod fp12;
- pub mod pair;
pub mod mpin;
- pub mod bls;
+ pub mod pair;
}
#[cfg(feature = "bls381")]
@@ -96,16 +96,16 @@ pub mod bls381 {
pub mod rom;
pub mod big;
+ pub mod bls;
pub mod dbig;
- pub mod fp;
pub mod ecp;
pub mod ecp2;
+ pub mod fp;
+ pub mod fp12;
pub mod fp2;
pub mod fp4;
- pub mod fp12;
- pub mod pair;
pub mod mpin;
- pub mod bls;
+ pub mod pair;
}
#[cfg(feature = "fp512bn")]
@@ -119,16 +119,16 @@ pub mod fp512bn {
pub mod rom;
pub mod big;
+ pub mod bls;
pub mod dbig;
- pub mod fp;
pub mod ecp;
pub mod ecp2;
+ pub mod fp;
+ pub mod fp12;
pub mod fp2;
pub mod fp4;
- pub mod fp12;
- pub mod pair;
pub mod mpin;
- pub mod bls;
+ pub mod pair;
}
#[cfg(feature = "fp256bn")]
@@ -142,16 +142,16 @@ pub mod fp256bn {
pub mod rom;
pub mod big;
+ pub mod bls;
pub mod dbig;
- pub mod fp;
pub mod ecp;
pub mod ecp2;
+ pub mod fp;
+ pub mod fp12;
pub mod fp2;
pub mod fp4;
- pub mod fp12;
- pub mod pair;
pub mod mpin;
- pub mod bls;
+ pub mod pair;
}
#[cfg(feature = "bls24")]
@@ -165,17 +165,17 @@ pub mod bls24 {
pub mod rom;
pub mod big;
+ pub mod bls192;
pub mod dbig;
+ pub mod ecp;
+ pub mod ecp4;
pub mod fp;
pub mod fp2;
+ pub mod fp24;
pub mod fp4;
pub mod fp8;
- pub mod fp24;
- pub mod ecp;
- pub mod ecp4;
- pub mod pair192;
pub mod mpin192;
- pub mod bls192;
+ pub mod pair192;
}
#[cfg(feature = "anssi")]
@@ -190,9 +190,9 @@ pub mod anssi {
pub mod big;
pub mod dbig;
- pub mod fp;
- pub mod ecp;
pub mod ecdh;
+ pub mod ecp;
+ pub mod fp;
}
#[cfg(feature = "brainpool")]
@@ -207,9 +207,9 @@ pub mod brainpool {
pub mod big;
pub mod dbig;
- pub mod fp;
- pub mod ecp;
pub mod ecdh;
+ pub mod ecp;
+ pub mod fp;
}
#[cfg(feature = "goldilocks")]
@@ -224,9 +224,9 @@ pub mod goldilocks {
pub mod big;
pub mod dbig;
- pub mod fp;
- pub mod ecp;
pub mod ecdh;
+ pub mod ecp;
+ pub mod fp;
}
#[cfg(feature = "hifive")]
@@ -241,9 +241,9 @@ pub mod hifive {
pub mod big;
pub mod dbig;
- pub mod fp;
- pub mod ecp;
pub mod ecdh;
+ pub mod ecp;
+ pub mod fp;
}
#[cfg(feature = "nist256")]
@@ -258,9 +258,9 @@ pub mod nist256 {
pub mod big;
pub mod dbig;
- pub mod fp;
- pub mod ecp;
pub mod ecdh;
+ pub mod ecp;
+ pub mod fp;
}
#[cfg(feature = "nist384")]
@@ -275,9 +275,9 @@ pub mod nist384 {
pub mod big;
pub mod dbig;
- pub mod fp;
- pub mod ecp;
pub mod ecdh;
+ pub mod ecp;
+ pub mod fp;
}
#[cfg(feature = "nist521")]
@@ -292,9 +292,9 @@ pub mod nist521 {
pub mod big;
pub mod dbig;
- pub mod fp;
- pub mod ecp;
pub mod ecdh;
+ pub mod ecp;
+ pub mod fp;
}
#[cfg(feature = "nums256e")]
@@ -309,9 +309,9 @@ pub mod nums256e {
pub mod big;
pub mod dbig;
- pub mod fp;
- pub mod ecp;
pub mod ecdh;
+ pub mod ecp;
+ pub mod fp;
}
#[cfg(feature = "nums256w")]
@@ -326,9 +326,9 @@ pub mod nums256w {
pub mod big;
pub mod dbig;
- pub mod fp;
- pub mod ecp;
pub mod ecdh;
+ pub mod ecp;
+ pub mod fp;
}
#[cfg(feature = "nums384e")]
@@ -343,9 +343,9 @@ pub mod nums384e {
pub mod big;
pub mod dbig;
- pub mod fp;
- pub mod ecp;
pub mod ecdh;
+ pub mod ecp;
+ pub mod fp;
}
#[cfg(feature = "nums384w")]
@@ -360,9 +360,9 @@ pub mod nums384w {
pub mod big;
pub mod dbig;
- pub mod fp;
- pub mod ecp;
pub mod ecdh;
+ pub mod ecp;
+ pub mod fp;
}
#[cfg(feature = "nums512w")]
@@ -377,9 +377,9 @@ pub mod nums512w {
pub mod big;
pub mod dbig;
- pub mod fp;
- pub mod ecp;
pub mod ecdh;
+ pub mod ecp;
+ pub mod fp;
}
#[cfg(feature = "nums512e")]
@@ -394,9 +394,9 @@ pub mod nums512e {
pub mod big;
pub mod dbig;
- pub mod fp;
- pub mod ecp;
pub mod ecdh;
+ pub mod ecp;
+ pub mod fp;
}
#[cfg(feature = "secp256k1")]
@@ -411,9 +411,9 @@ pub mod secp256k1 {
pub mod big;
pub mod dbig;
- pub mod fp;
- pub mod ecp;
pub mod ecdh;
+ pub mod ecp;
+ pub mod fp;
}
#[cfg(feature = "c25519")]
@@ -428,9 +428,9 @@ pub mod c25519 {
pub mod big;
pub mod dbig;
- pub mod fp;
- pub mod ecp;
pub mod ecdh;
+ pub mod ecp;
+ pub mod fp;
}
#[cfg(feature = "c41417")]
@@ -445,9 +445,9 @@ pub mod c41417 {
pub mod big;
pub mod dbig;
- pub mod fp;
- pub mod ecp;
pub mod ecdh;
+ pub mod ecp;
+ pub mod fp;
}
#[cfg(feature = "ed25519")]
@@ -462,9 +462,9 @@ pub mod ed25519 {
pub mod big;
pub mod dbig;
- pub mod fp;
- pub mod ecp;
pub mod ecdh;
+ pub mod ecp;
+ pub mod fp;
}
#[cfg(feature = "bn254CX")]
@@ -478,17 +478,17 @@ pub mod bn254CX {
pub mod rom;
pub mod big;
+ pub mod bls;
pub mod dbig;
- pub mod fp;
- pub mod ecp;
pub mod ecdh;
+ pub mod ecp;
pub mod ecp2;
+ pub mod fp;
+ pub mod fp12;
pub mod fp2;
pub mod fp4;
- pub mod fp12;
- pub mod pair;
pub mod mpin;
- pub mod bls;
+ pub mod pair;
}
#[cfg(feature = "bn254")]
@@ -502,60 +502,60 @@ pub mod bn254 {
pub mod rom;
pub mod big;
+ pub mod bls;
pub mod dbig;
- pub mod fp;
- pub mod ecp;
pub mod ecdh;
+ pub mod ecp;
pub mod ecp2;
+ pub mod fp;
+ pub mod fp12;
pub mod fp2;
pub mod fp4;
- pub mod fp12;
- pub mod pair;
pub mod mpin;
- pub mod bls;
+ pub mod pair;
}
#[cfg(feature = "rsa2048")]
#[path = "./"]
pub mod rsa2048 {
+ pub mod big;
+ pub mod dbig;
+ pub mod ff;
#[cfg(target_pointer_width = "32")]
#[path = "roms/rom_rsa2048_32.rs"]
pub mod rom;
#[cfg(target_pointer_width = "64")]
#[path = "roms/rom_rsa2048_64.rs"]
pub mod rom;
- pub mod big;
- pub mod dbig;
- pub mod ff;
pub mod rsa;
}
#[cfg(feature = "rsa3072")]
#[path = "./"]
pub mod rsa3072 {
+ pub mod big;
+ pub mod dbig;
+ pub mod ff;
#[cfg(target_pointer_width = "32")]
#[path = "roms/rom_rsa3072_32.rs"]
pub mod rom;
#[cfg(target_pointer_width = "64")]
#[path = "roms/rom_rsa3072_64.rs"]
pub mod rom;
- pub mod big;
- pub mod dbig;
- pub mod ff;
pub mod rsa;
}
#[cfg(feature = "rsa4096")]
#[path = "./"]
pub mod rsa4096 {
+ pub mod big;
+ pub mod dbig;
+ pub mod ff;
#[cfg(target_pointer_width = "32")]
#[path = "roms/rom_rsa4096_32.rs"]
mod rom;
#[cfg(target_pointer_width = "64")]
#[path = "roms/rom_rsa4096_64.rs"]
mod rom;
- pub mod big;
- pub mod dbig;
- pub mod ff;
pub mod rsa;
-}
\ No newline at end of file
+}
diff --git a/src/mpin.rs b/src/mpin.rs
index 6d7e9ca..dbb713b 100644
--- a/src/mpin.rs
+++ b/src/mpin.rs
@@ -20,21 +20,20 @@ under the License.
use std::time::SystemTime;
use std::time::UNIX_EPOCH;
+use super::big;
+use super::big::BIG;
use super::ecp;
use super::ecp::ECP;
use super::ecp2::ECP2;
-use super::fp4::FP4;
use super::fp12::FP12;
-use super::big::BIG;
+use super::fp4::FP4;
use super::pair;
-use super::big;
use super::rom;
-use rand::RAND;
use hash256::HASH256;
use hash384::HASH384;
use hash512::HASH512;
-
+use rand::RAND;
/* MPIN API Functions */
diff --git a/src/mpin192.rs b/src/mpin192.rs
index 276a560..3278b30 100644
--- a/src/mpin192.rs
+++ b/src/mpin192.rs
@@ -20,21 +20,20 @@ under the License.
use std::time::SystemTime;
use std::time::UNIX_EPOCH;
+use super::big;
+use super::big::BIG;
use super::ecp;
use super::ecp::ECP;
use super::ecp4::ECP4;
-use super::fp8::FP8;
use super::fp24::FP24;
-use super::big::BIG;
+use super::fp8::FP8;
use super::pair192;
-use super::big;
use super::rom;
-use rand::RAND;
use hash256::HASH256;
use hash384::HASH384;
use hash512::HASH512;
-
+use rand::RAND;
/* MPIN API Functions */
diff --git a/src/mpin256.rs b/src/mpin256.rs
index b4928e9..76340c7 100644
--- a/src/mpin256.rs
+++ b/src/mpin256.rs
@@ -20,20 +20,20 @@ under the License.
use std::time::SystemTime;
use std::time::UNIX_EPOCH;
+use super::big;
+use super::big::BIG;
use super::ecp;
use super::ecp::ECP;
use super::ecp8::ECP8;
use super::fp16::FP16;
use super::fp48::FP48;
-use super::big::BIG;
use super::pair256;
-use super::big;
use super::rom;
-use rand::RAND;
use hash256::HASH256;
use hash384::HASH384;
use hash512::HASH512;
+use rand::RAND;
/* MPIN API Functions */
diff --git a/src/pair.rs b/src/pair.rs
index 2050296..ce59f0d 100644
--- a/src/pair.rs
+++ b/src/pair.rs
@@ -17,19 +17,18 @@ specific language governing permissions and limitations
under the License.
*/
-
-use super::fp::FP;
+use super::big::BIG;
+use super::dbig::DBIG;
+use super::ecp;
use super::ecp::ECP;
-use super::fp2::FP2;
use super::ecp2::ECP2;
-use super::fp4::FP4;
+use super::fp::FP;
use super::fp12;
use super::fp12::FP12;
-use super::big::BIG;
-use super::dbig::DBIG;
-use super::ecp;
+use super::fp2::FP2;
+use super::fp4::FP4;
use super::rom;
-use types::{SexticTwist, CurvePairingType, SignOfX};
+use types::{CurvePairingType, SexticTwist, SignOfX};
#[allow(non_snake_case)]
fn linedbl(A: &mut ECP2, qx: &FP, qy: &FP) -> FP12 {
@@ -81,7 +80,7 @@ fn linedbl(A: &mut ECP2, qx: &FP, qy: &FP) -> FP12 {
c.times_i();
}
A.dbl();
- let mut res= FP12::new_fp4s(&a, &b, &c);
+ let mut res = FP12::new_fp4s(&a, &b, &c);
res.settype(fp12::SPARSER);
return res;
}
@@ -132,18 +131,18 @@ fn lineadd(A: &mut ECP2, B: &ECP2, qx: &FP, qy: &FP) -> FP12 {
}
A.add(B);
- let mut res= FP12::new_fp4s(&a, &b, &c);
+ let mut res = FP12::new_fp4s(&a, &b, &c);
res.settype(fp12::SPARSER);
return res;
}
/* prepare ate parameter, n=6u+2 (BN) or n=u (BLS), n3=3*n */
#[allow(non_snake_case)]
-fn lbits(n3: &mut BIG,n: &mut BIG) -> usize {
+fn lbits(n3: &mut BIG, n: &mut BIG) -> usize {
n.copy(&BIG::new_ints(&rom::CURVE_BNX));
- if ecp::CURVE_PAIRING_TYPE==CurvePairingType::BN {
+ if ecp::CURVE_PAIRING_TYPE == CurvePairingType::BN {
n.pmul(6);
- if ecp::SIGN_OF_X==SignOfX::POSITIVEX {
+ if ecp::SIGN_OF_X == SignOfX::POSITIVEX {
n.inc(2);
} else {
n.dec(2);
@@ -159,18 +158,18 @@ fn lbits(n3: &mut BIG,n: &mut BIG) -> usize {
/* prepare for multi-pairing */
pub fn initmp() -> [FP12; rom::ATE_BITS] {
let r: [FP12; rom::ATE_BITS] = [FP12::new_int(1); rom::ATE_BITS];
- return r
+ return r;
}
/* basic Miller loop */
-pub fn miller(r:&[FP12]) -> FP12 {
- let mut res=FP12::new_int(1);
+pub fn miller(r: &[FP12]) -> FP12 {
+ let mut res = FP12::new_int(1);
for i in (1..rom::ATE_BITS).rev() {
res.sqr();
res.ssmul(&r[i]);
}
- if ecp::SIGN_OF_X==SignOfX::NEGATIVEX {
+ if ecp::SIGN_OF_X == SignOfX::NEGATIVEX {
res.conj();
}
res.ssmul(&r[0]);
@@ -179,14 +178,13 @@ pub fn miller(r:&[FP12]) -> FP12 {
/* Accumulate another set of line functions for n-pairing */
#[allow(non_snake_case)]
-pub fn another(r:&mut [FP12],P1: &ECP2,Q1: &ECP) {
+pub fn another(r: &mut [FP12], P1: &ECP2, Q1: &ECP) {
let mut f = FP2::new_bigs(&BIG::new_ints(&rom::FRA), &BIG::new_ints(&rom::FRB));
let mut n = BIG::new();
let mut n3 = BIG::new();
let mut K = ECP2::new();
-
-// P is needed in affine form for line function, Q for (Qx,Qy) extraction
+ // P is needed in affine form for line function, Q for (Qx,Qy) extraction
let mut P = ECP2::new();
P.copy(P1);
P.affine();
@@ -194,8 +192,8 @@ pub fn another(r:&mut [FP12],P1: &ECP2,Q1: &ECP) {
Q.copy(Q1);
Q.affine();
- if ecp::CURVE_PAIRING_TYPE==CurvePairingType::BN {
- if ecp::SEXTIC_TWIST==SexticTwist::M_TYPE {
+ if ecp::CURVE_PAIRING_TYPE == CurvePairingType::BN {
+ if ecp::SEXTIC_TWIST == SexticTwist::M_TYPE {
f.inverse();
f.norm();
}
@@ -210,37 +208,37 @@ pub fn another(r:&mut [FP12],P1: &ECP2,Q1: &ECP) {
NP.copy(&P);
NP.neg();
- let nb=lbits(&mut n3,&mut n);
+ let nb = lbits(&mut n3, &mut n);
- for i in (1..nb-1).rev() {
- let mut lv=linedbl(&mut A,&qx,&qy);
+ for i in (1..nb - 1).rev() {
+ let mut lv = linedbl(&mut A, &qx, &qy);
- let bt=n3.bit(i)-n.bit(i);
- if bt==1 {
- let lv2=lineadd(&mut A,&P,&qx,&qy);
+ let bt = n3.bit(i) - n.bit(i);
+ if bt == 1 {
+ let lv2 = lineadd(&mut A, &P, &qx, &qy);
lv.smul(&lv2);
}
- if bt==-1 {
- let lv2=lineadd(&mut A,&NP,&qx,&qy);
+ if bt == -1 {
+ let lv2 = lineadd(&mut A, &NP, &qx, &qy);
lv.smul(&lv2);
}
r[i].ssmul(&lv);
}
-/* R-ate fixup required for BN curves */
- if ecp::CURVE_PAIRING_TYPE==CurvePairingType::BN {
- if ecp::SIGN_OF_X==SignOfX::NEGATIVEX {
+ /* R-ate fixup required for BN curves */
+ if ecp::CURVE_PAIRING_TYPE == CurvePairingType::BN {
+ if ecp::SIGN_OF_X == SignOfX::NEGATIVEX {
A.neg();
}
K.copy(&P);
K.frob(&f);
- let mut lv=lineadd(&mut A,&K,&qx,&qy);
+ let mut lv = lineadd(&mut A, &K, &qx, &qy);
K.frob(&f);
K.neg();
- let lv2=lineadd(&mut A,&K,&qx,&qy);
+ let lv2 = lineadd(&mut A, &K, &qx, &qy);
lv.smul(&lv2);
- r[0].ssmul(&lv);
- }
+ r[0].ssmul(&lv);
+ }
}
#[allow(non_snake_case)]
@@ -256,7 +254,7 @@ pub fn ate(P1: &ECP2, Q1: &ECP) -> FP12 {
f.inverse();
f.norm();
}
- }
+ }
let mut P = ECP2::new();
P.copy(P1);
P.affine();
@@ -275,7 +273,7 @@ pub fn ate(P1: &ECP2, Q1: &ECP) -> FP12 {
NP.copy(&P);
NP.neg();
- let nb=lbits(&mut n3,&mut n);
+ let nb = lbits(&mut n3, &mut n);
for i in (1..nb - 1).rev() {
r.sqr();
@@ -310,7 +308,7 @@ pub fn ate(P1: &ECP2, Q1: &ECP) -> FP12 {
K.frob(&f);
K.neg();
let lv2 = lineadd(&mut A, &K, &qx, &qy);
- lv.smul(&lv2);
+ lv.smul(&lv2);
r.ssmul(&lv);
}
@@ -330,7 +328,7 @@ pub fn ate2(P1: &ECP2, Q1: &ECP, R1: &ECP2, S1: &ECP) -> FP12 {
f.inverse();
f.norm();
}
- }
+ }
let mut P = ECP2::new();
P.copy(P1);
@@ -365,25 +363,25 @@ pub fn ate2(P1: &ECP2, Q1: &ECP, R1: &ECP2, S1: &ECP) -> FP12 {
NR.copy(&R);
NR.neg();
- let nb=lbits(&mut n3,&mut n);
+ let nb = lbits(&mut n3, &mut n);
for i in (1..nb - 1).rev() {
r.sqr();
let mut lv = linedbl(&mut A, &qx, &qy);
let lv2 = linedbl(&mut B, &sx, &sy);
- lv.smul(&lv2);
+ lv.smul(&lv2);
r.ssmul(&lv);
let bt = n3.bit(i) - n.bit(i);
if bt == 1 {
lv = lineadd(&mut A, &P, &qx, &qy);
let lv2 = lineadd(&mut B, &R, &sx, &sy);
- lv.smul(&lv2);
+ lv.smul(&lv2);
r.ssmul(&lv);
}
if bt == -1 {
lv = lineadd(&mut A, &NP, &qx, &qy);
let lv2 = lineadd(&mut B, &NR, &sx, &sy);
- lv.smul(&lv2);
+ lv.smul(&lv2);
r.ssmul(&lv);
}
}
@@ -405,7 +403,7 @@ pub fn ate2(P1: &ECP2, Q1: &ECP, R1: &ECP2, S1: &ECP) -> FP12 {
K.frob(&f);
K.neg();
let mut lv2 = lineadd(&mut A, &K, &qx, &qy);
- lv.smul(&lv2);
+ lv.smul(&lv2);
r.ssmul(&lv);
K.copy(&R);
@@ -415,9 +413,8 @@ pub fn ate2(P1: &ECP2, Q1: &ECP, R1: &ECP2, S1: &ECP) -> FP12 {
K.frob(&f);
K.neg();
lv2 = lineadd(&mut B, &K, &sx, &sy);
- lv.smul(&lv2);
+ lv.smul(&lv2);
r.ssmul(&lv);
-
}
return r;
@@ -439,10 +436,10 @@ pub fn fexp(m: &FP12) -> FP12 {
r.frob(&f);
r.frob(&f);
r.mul(&lv);
-// if r.isunity() {
-// r.zero();
-// return r;
-// }
+ // if r.isunity() {
+ // r.zero();
+ // return r;
+ // }
/* Hard part of final exp */
if ecp::CURVE_PAIRING_TYPE == CurvePairingType::BN {
diff --git a/src/pair192.rs b/src/pair192.rs
index 4310b6b..3883b90 100644
--- a/src/pair192.rs
+++ b/src/pair192.rs
@@ -17,17 +17,16 @@ specific language governing permissions and limitations
under the License.
*/
-
-use super::fp::FP;
+use super::big::BIG;
+use super::ecp;
use super::ecp::ECP;
-use super::fp2::FP2;
use super::ecp4::ECP4;
-use super::fp4::FP4;
-use super::fp8::FP8;
+use super::fp::FP;
+use super::fp2::FP2;
use super::fp24;
use super::fp24::FP24;
-use super::big::BIG;
-use super::ecp;
+use super::fp4::FP4;
+use super::fp8::FP8;
use super::rom;
use types::{SexticTwist, SignOfX};
@@ -80,7 +79,7 @@ fn linedbl(A: &mut ECP4, qx: &FP, qy: &FP) -> FP24 {
c.times_i();
}
A.dbl();
- let mut res= FP24::new_fp8s(&a, &b, &c);
+ let mut res = FP24::new_fp8s(&a, &b, &c);
res.settype(fp24::SPARSER);
return res;
}
@@ -130,14 +129,14 @@ fn lineadd(A: &mut ECP4, B: &ECP4, qx: &FP, qy: &FP) -> FP24 {
}
A.add(B);
- let mut res= FP24::new_fp8s(&a, &b, &c);
+ let mut res = FP24::new_fp8s(&a, &b, &c);
res.settype(fp24::SPARSER);
return res;
}
/* prepare ate parameter, n=6u+2 (BN) or n=u (BLS), n3=3*n */
#[allow(non_snake_case)]
-fn lbits(n3: &mut BIG,n: &mut BIG) -> usize {
+fn lbits(n3: &mut BIG, n: &mut BIG) -> usize {
n.copy(&BIG::new_ints(&rom::CURVE_BNX));
n3.copy(&n);
n3.pmul(3);
@@ -148,18 +147,18 @@ fn lbits(n3: &mut BIG,n: &mut BIG) -> usize {
/* prepare for multi-pairing */
pub fn initmp() -> [FP24; rom::ATE_BITS] {
let r: [FP24; rom::ATE_BITS] = [FP24::new_int(1); rom::ATE_BITS];
- return r
+ return r;
}
/* basic Miller loop */
-pub fn miller(r:&[FP24]) -> FP24 {
- let mut res=FP24::new_int(1);
+pub fn miller(r: &[FP24]) -> FP24 {
+ let mut res = FP24::new_int(1);
for i in (1..rom::ATE_BITS).rev() {
res.sqr();
res.ssmul(&r[i]);
}
- if ecp::SIGN_OF_X==SignOfX::NEGATIVEX {
+ if ecp::SIGN_OF_X == SignOfX::NEGATIVEX {
res.conj();
}
res.ssmul(&r[0]);
@@ -168,11 +167,11 @@ pub fn miller(r:&[FP24]) -> FP24 {
/* Accumulate another set of line functions for n-pairing */
#[allow(non_snake_case)]
-pub fn another(r:&mut [FP24],P1: &ECP4,Q1: &ECP) {
+pub fn another(r: &mut [FP24], P1: &ECP4, Q1: &ECP) {
let mut n = BIG::new();
let mut n3 = BIG::new();
-
-// P is needed in affine form for line function, Q for (Qx,Qy) extraction
+
+ // P is needed in affine form for line function, Q for (Qx,Qy) extraction
let mut P = ECP4::new();
P.copy(P1);
P.affine();
@@ -189,18 +188,18 @@ pub fn another(r:&mut [FP24],P1: &ECP4,Q1: &ECP) {
NP.copy(&P);
NP.neg();
- let nb=lbits(&mut n3,&mut n);
+ let nb = lbits(&mut n3, &mut n);
- for i in (1..nb-1).rev() {
- let mut lv=linedbl(&mut A,&qx,&qy);
+ for i in (1..nb - 1).rev() {
+ let mut lv = linedbl(&mut A, &qx, &qy);
- let bt=n3.bit(i)-n.bit(i);
- if bt==1 {
- let lv2=lineadd(&mut A,&P,&qx,&qy);
+ let bt = n3.bit(i) - n.bit(i);
+ if bt == 1 {
+ let lv2 = lineadd(&mut A, &P, &qx, &qy);
lv.smul(&lv2);
}
- if bt==-1 {
- let lv2=lineadd(&mut A,&NP,&qx,&qy);
+ if bt == -1 {
+ let lv2 = lineadd(&mut A, &NP, &qx, &qy);
lv.smul(&lv2);
}
r[i].ssmul(&lv);
@@ -231,7 +230,7 @@ pub fn ate(P1: &ECP4, Q1: &ECP) -> FP24 {
NP.copy(&P);
NP.neg();
- let nb=lbits(&mut n3,&mut n);
+ let nb = lbits(&mut n3, &mut n);
for i in (1..nb - 1).rev() {
r.sqr();
@@ -296,25 +295,25 @@ pub fn ate2(P1: &ECP4, Q1: &ECP, R1: &ECP4, S1: &ECP) -> FP24 {
NR.copy(&R);
NR.neg();
- let nb=lbits(&mut n3,&mut n);
+ let nb = lbits(&mut n3, &mut n);
for i in (1..nb - 1).rev() {
r.sqr();
let mut lv = linedbl(&mut A, &qx, &qy);
let lv2 = linedbl(&mut B, &sx, &sy);
- lv.smul(&lv2);
+ lv.smul(&lv2);
r.ssmul(&lv);
let bt = n3.bit(i) - n.bit(i);
if bt == 1 {
lv = lineadd(&mut A, &P, &qx, &qy);
let lv2 = lineadd(&mut B, &R, &sx, &sy);
- lv.smul(&lv2);
+ lv.smul(&lv2);
r.ssmul(&lv);
}
if bt == -1 {
lv = lineadd(&mut A, &NP, &qx, &qy);
let lv2 = lineadd(&mut B, &NR, &sx, &sy);
- lv.smul(&lv2);
+ lv.smul(&lv2);
r.ssmul(&lv);
}
}
@@ -341,10 +340,10 @@ pub fn fexp(m: &FP24) -> FP24 {
lv.copy(&r);
r.frob(&f, 4);
r.mul(&lv);
-// if r.isunity() {
-// r.zero();
-// return r;
-// }
+ // if r.isunity() {
+ // r.zero();
+ // return r;
+ // }
/* Hard part of final exp */
// Ghamman & Fouotsa Method
diff --git a/src/pair256.rs b/src/pair256.rs
index 7cdca72..9353fe6 100644
--- a/src/pair256.rs
+++ b/src/pair256.rs
@@ -17,19 +17,18 @@ specific language governing permissions and limitations
under the License.
*/
-
-use super::fp::FP;
+use super::big::BIG;
+use super::ecp;
use super::ecp::ECP;
-use super::fp2::FP2;
use super::ecp8::ECP8;
-use super::fp8::FP8;
+use super::fp::FP;
use super::fp16::FP16;
+use super::fp2::FP2;
use super::fp48;
use super::fp48::FP48;
-use super::big::BIG;
-use super::ecp;
+use super::fp8::FP8;
use super::rom;
-use types::{SignOfX, SexticTwist};
+use types::{SexticTwist, SignOfX};
#[allow(non_snake_case)]
fn linedbl(A: &mut ECP8, qx: &FP, qy: &FP) -> FP48 {
@@ -80,7 +79,7 @@ fn linedbl(A: &mut ECP8, qx: &FP, qy: &FP) -> FP48 {
c.times_i();
}
A.dbl();
- let mut res= FP48::new_fp16s(&a, &b, &c);
+ let mut res = FP48::new_fp16s(&a, &b, &c);
res.settype(fp48::SPARSER);
return res;
}
@@ -130,14 +129,14 @@ fn lineadd(A: &mut ECP8, B: &ECP8, qx: &FP, qy: &FP) -> FP48 {
}
A.add(B);
- let mut res= FP48::new_fp16s(&a, &b, &c);
+ let mut res = FP48::new_fp16s(&a, &b, &c);
res.settype(fp48::SPARSER);
return res;
}
/* prepare ate parameter, n=6u+2 (BN) or n=u (BLS), n3=3*n */
#[allow(non_snake_case)]
-fn lbits(n3: &mut BIG,n: &mut BIG) -> usize {
+fn lbits(n3: &mut BIG, n: &mut BIG) -> usize {
n.copy(&BIG::new_ints(&rom::CURVE_BNX));
n3.copy(&n);
n3.pmul(3);
@@ -148,18 +147,18 @@ fn lbits(n3: &mut BIG,n: &mut BIG) -> usize {
/* prepare for multi-pairing */
pub fn initmp() -> [FP48; rom::ATE_BITS] {
let r: [FP48; rom::ATE_BITS] = [FP48::new_int(1); rom::ATE_BITS];
- return r
+ return r;
}
/* basic Miller loop */
-pub fn miller(r:&[FP48]) -> FP48 {
- let mut res=FP48::new_int(1);
+pub fn miller(r: &[FP48]) -> FP48 {
+ let mut res = FP48::new_int(1);
for i in (1..rom::ATE_BITS).rev() {
res.sqr();
res.ssmul(&r[i]);
}
- if ecp::SIGN_OF_X==SignOfX::NEGATIVEX {
+ if ecp::SIGN_OF_X == SignOfX::NEGATIVEX {
res.conj();
}
res.ssmul(&r[0]);
@@ -168,11 +167,11 @@ pub fn miller(r:&[FP48]) -> FP48 {
/* Accumulate another set of line functions for n-pairing */
#[allow(non_snake_case)]
-pub fn another(r:&mut [FP48],P1: &ECP8,Q1: &ECP) {
+pub fn another(r: &mut [FP48], P1: &ECP8, Q1: &ECP) {
let mut n = BIG::new();
let mut n3 = BIG::new();
-// P is needed in affine form for line function, Q for (Qx,Qy) extraction
+ // P is needed in affine form for line function, Q for (Qx,Qy) extraction
let mut P = ECP8::new();
P.copy(P1);
P.affine();
@@ -189,18 +188,18 @@ pub fn another(r:&mut [FP48],P1: &ECP8,Q1: &ECP) {
NP.copy(&P);
NP.neg();
- let nb=lbits(&mut n3,&mut n);
+ let nb = lbits(&mut n3, &mut n);
- for i in (1..nb-1).rev() {
- let mut lv=linedbl(&mut A,&qx,&qy);
+ for i in (1..nb - 1).rev() {
+ let mut lv = linedbl(&mut A, &qx, &qy);
- let bt=n3.bit(i)-n.bit(i);
- if bt==1 {
- let lv2=lineadd(&mut A,&P,&qx,&qy);
+ let bt = n3.bit(i) - n.bit(i);
+ if bt == 1 {
+ let lv2 = lineadd(&mut A, &P, &qx, &qy);
lv.smul(&lv2);
}
- if bt==-1 {
- let lv2=lineadd(&mut A,&NP,&qx,&qy);
+ if bt == -1 {
+ let lv2 = lineadd(&mut A, &NP, &qx, &qy);
lv.smul(&lv2);
}
r[i].ssmul(&lv);
@@ -231,7 +230,7 @@ pub fn ate(P1: &ECP8, Q1: &ECP) -> FP48 {
NP.copy(&P);
NP.neg();
- let nb=lbits(&mut n3,&mut n);
+ let nb = lbits(&mut n3, &mut n);
for i in (1..nb - 1).rev() {
r.sqr();
@@ -294,25 +293,25 @@ pub fn ate2(P1: &ECP8, Q1: &ECP, R1: &ECP8, S1: &ECP) -> FP48 {
NR.copy(&R);
NR.neg();
- let nb=lbits(&mut n3,&mut n);
+ let nb = lbits(&mut n3, &mut n);
for i in (1..nb - 1).rev() {
r.sqr();
let mut lv = linedbl(&mut A, &qx, &qy);
let lv2 = linedbl(&mut B, &sx, &sy);
- lv.smul(&lv2);
+ lv.smul(&lv2);
r.ssmul(&lv);
let bt = n3.bit(i) - n.bit(i);
if bt == 1 {
lv = lineadd(&mut A, &P, &qx, &qy);
let lv2 = lineadd(&mut B, &R, &sx, &sy);
- lv.smul(&lv2);
+ lv.smul(&lv2);
r.ssmul(&lv);
}
if bt == -1 {
lv = lineadd(&mut A, &NP, &qx, &qy);
let lv2 = lineadd(&mut B, &NR, &sx, &sy);
- lv.smul(&lv2);
+ lv.smul(&lv2);
r.ssmul(&lv);
}
}
@@ -339,10 +338,10 @@ pub fn fexp(m: &FP48) -> FP48 {
lv.copy(&r);
r.frob(&f, 8);
r.mul(&lv);
-// if r.isunity() {
-// r.zero();
-// return r;
-// }
+ // if r.isunity() {
+ // r.zero();
+ // return r;
+ // }
/* Hard part of final exp */
// Ghamman & Fouotsa Method
diff --git a/src/roms/rom_anssi_32.rs b/src/roms/rom_anssi_32.rs
index 403fb04..d64b4fc 100644
--- a/src/roms/rom_anssi_32.rs
+++ b/src/roms/rom_anssi_32.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use anssi::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use anssi::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 28
// anssi Modulus
diff --git a/src/roms/rom_anssi_64.rs b/src/roms/rom_anssi_64.rs
index b0add0f..654ad6f 100644
--- a/src/roms/rom_anssi_64.rs
+++ b/src/roms/rom_anssi_64.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use anssi::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use anssi::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 56
// anssi Modulus
diff --git a/src/roms/rom_bls24_32.rs b/src/roms/rom_bls24_32.rs
index 72afe58..afdc8b9 100644
--- a/src/roms/rom_bls24_32.rs
+++ b/src/roms/rom_bls24_32.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use bls24::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use bls24::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 29
// bls24 Modulus
diff --git a/src/roms/rom_bls24_64.rs b/src/roms/rom_bls24_64.rs
index 0c500da..33a6f13 100644
--- a/src/roms/rom_bls24_64.rs
+++ b/src/roms/rom_bls24_64.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use bls24::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use bls24::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 56
// bls24 Modulus
diff --git a/src/roms/rom_bls381_32.rs b/src/roms/rom_bls381_32.rs
index 1ba0fe5..61f3140 100644
--- a/src/roms/rom_bls381_32.rs
+++ b/src/roms/rom_bls381_32.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use bls381::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use bls381::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 29
// bls381 Modulus
diff --git a/src/roms/rom_bls381_64.rs b/src/roms/rom_bls381_64.rs
index 08df12c..cea1446 100644
--- a/src/roms/rom_bls381_64.rs
+++ b/src/roms/rom_bls381_64.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use bls381::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use bls381::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 58
// bls381 Modulus
diff --git a/src/roms/rom_bls383_32.rs b/src/roms/rom_bls383_32.rs
index 0ccb42d..4fd502e 100644
--- a/src/roms/rom_bls383_32.rs
+++ b/src/roms/rom_bls383_32.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use bls383::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use bls383::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 29
pub const MODULUS: [Chunk; NLEN] = [
diff --git a/src/roms/rom_bls383_64.rs b/src/roms/rom_bls383_64.rs
index 71bef66..5b3b97d 100644
--- a/src/roms/rom_bls383_64.rs
+++ b/src/roms/rom_bls383_64.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use bls383::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use bls383::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 58
pub const MODULUS: [Chunk; NLEN] = [
diff --git a/src/roms/rom_bls461_32.rs b/src/roms/rom_bls461_32.rs
index c452a9f..3a07a56 100644
--- a/src/roms/rom_bls461_32.rs
+++ b/src/roms/rom_bls461_32.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use bls461::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use bls461::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 28
// bls461 Modulus
diff --git a/src/roms/rom_bls461_64.rs b/src/roms/rom_bls461_64.rs
index 500ef04..b6d822c 100644
--- a/src/roms/rom_bls461_64.rs
+++ b/src/roms/rom_bls461_64.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use bls461::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use bls461::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 60
// bls461 Modulus
diff --git a/src/roms/rom_bls48_32.rs b/src/roms/rom_bls48_32.rs
index 83517a8..73cedc4 100644
--- a/src/roms/rom_bls48_32.rs
+++ b/src/roms/rom_bls48_32.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use bls48::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use bls48::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 29
// bls48 Modulus
diff --git a/src/roms/rom_bls48_64.rs b/src/roms/rom_bls48_64.rs
index 129c776..fe41cb4 100644
--- a/src/roms/rom_bls48_64.rs
+++ b/src/roms/rom_bls48_64.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use bls48::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use bls48::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 58
// bls48 Modulus
diff --git a/src/roms/rom_bn254CX_32.rs b/src/roms/rom_bn254CX_32.rs
index e1cff0d..e0ebba9 100644
--- a/src/roms/rom_bn254CX_32.rs
+++ b/src/roms/rom_bn254CX_32.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use bn254CX::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use bn254CX::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 28
// bn254CX Modulus
diff --git a/src/roms/rom_bn254CX_64.rs b/src/roms/rom_bn254CX_64.rs
index 7f6d274..fa9e221 100644
--- a/src/roms/rom_bn254CX_64.rs
+++ b/src/roms/rom_bn254CX_64.rs
@@ -17,10 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use bn254CX::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
-
+use bn254CX::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 56
// bn254CX Modulus
diff --git a/src/roms/rom_bn254_32.rs b/src/roms/rom_bn254_32.rs
index c9ae5ec..e31eb7e 100644
--- a/src/roms/rom_bn254_32.rs
+++ b/src/roms/rom_bn254_32.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use bn254::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use bn254::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 28
pub const MODULUS: [Chunk; NLEN] = [
diff --git a/src/roms/rom_bn254_64.rs b/src/roms/rom_bn254_64.rs
index f61b542..ce48907 100644
--- a/src/roms/rom_bn254_64.rs
+++ b/src/roms/rom_bn254_64.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use bn254::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use bn254::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// BN254 Modulus
// Base Bits= 56
@@ -205,4 +205,4 @@ pub const SEXTIC_TWIST: SexticTwist = SexticTwist::D_TYPE;
pub const ATE_BITS: usize = 66;
pub const SIGN_OF_X: SignOfX = SignOfX::NEGATIVEX;
pub const HASH_TYPE: usize = 32;
-pub const AESKEY: usize = 16;
\ No newline at end of file
+pub const AESKEY: usize = 16;
diff --git a/src/roms/rom_brainpool_32.rs b/src/roms/rom_brainpool_32.rs
index b788632..440c8e8 100644
--- a/src/roms/rom_brainpool_32.rs
+++ b/src/roms/rom_brainpool_32.rs
@@ -19,9 +19,9 @@ under the License.
/* Note that the original curve has been transformed to an isomorphic curve with A=-3 */
-use brainpool::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use brainpool::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 28
// brainpool Modulus
diff --git a/src/roms/rom_brainpool_64.rs b/src/roms/rom_brainpool_64.rs
index 8191561..804e479 100644
--- a/src/roms/rom_brainpool_64.rs
+++ b/src/roms/rom_brainpool_64.rs
@@ -19,9 +19,9 @@ under the License.
/* Note that the original curve has been transformed to an isomorphic curve with A=-3 */
-use brainpool::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use brainpool::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 56
// brainpool Modulus
diff --git a/src/roms/rom_c25519_32.rs b/src/roms/rom_c25519_32.rs
index 6da6a05..ca6d72c 100644
--- a/src/roms/rom_c25519_32.rs
+++ b/src/roms/rom_c25519_32.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use c25519::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use c25519::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 29
// Curve25519 Modulus
diff --git a/src/roms/rom_c25519_64.rs b/src/roms/rom_c25519_64.rs
index 9a8c59f..bf3eb59 100644
--- a/src/roms/rom_c25519_64.rs
+++ b/src/roms/rom_c25519_64.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use c25519::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use c25519::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 56
// Curve25519 Modulus
diff --git a/src/roms/rom_c41417_32.rs b/src/roms/rom_c41417_32.rs
index a8330cb..bd177c8 100644
--- a/src/roms/rom_c41417_32.rs
+++ b/src/roms/rom_c41417_32.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use c41417::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use c41417::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 29
// c41417 Modulus
diff --git a/src/roms/rom_c41417_64.rs b/src/roms/rom_c41417_64.rs
index 52b51b1..5c08731 100644
--- a/src/roms/rom_c41417_64.rs
+++ b/src/roms/rom_c41417_64.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use c41417::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use c41417::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 60
// c41417 Modulus
diff --git a/src/roms/rom_ed25519_32.rs b/src/roms/rom_ed25519_32.rs
index be1d156..d92afa1 100644
--- a/src/roms/rom_ed25519_32.rs
+++ b/src/roms/rom_ed25519_32.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use ed25519::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use ed25519::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 29
// Curve25519 Modulus
diff --git a/src/roms/rom_ed25519_64.rs b/src/roms/rom_ed25519_64.rs
index cf23672..cf6f1f9 100644
--- a/src/roms/rom_ed25519_64.rs
+++ b/src/roms/rom_ed25519_64.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use ed25519::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use ed25519::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 56
// Curve25519 Modulus
diff --git a/src/roms/rom_fp256bn_32.rs b/src/roms/rom_fp256bn_32.rs
index e3cabe1..85b145a 100644
--- a/src/roms/rom_fp256bn_32.rs
+++ b/src/roms/rom_fp256bn_32.rs
@@ -17,10 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use fp256bn::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
-
+use fp256bn::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 28
pub const MODULUS: [Chunk; NLEN] = [
diff --git a/src/roms/rom_fp256bn_64.rs b/src/roms/rom_fp256bn_64.rs
index bde7639..77ffc40 100644
--- a/src/roms/rom_fp256bn_64.rs
+++ b/src/roms/rom_fp256bn_64.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use fp256bn::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use fp256bn::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// fp256bn Modulus
// Base Bits= 56
diff --git a/src/roms/rom_fp512bn_32.rs b/src/roms/rom_fp512bn_32.rs
index cdc44af..18fefed 100644
--- a/src/roms/rom_fp512bn_32.rs
+++ b/src/roms/rom_fp512bn_32.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use fp512bn::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use fp512bn::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 29
pub const MODULUS: [Chunk; NLEN] = [
diff --git a/src/roms/rom_fp512bn_64.rs b/src/roms/rom_fp512bn_64.rs
index 54d85c4..65779f7 100644
--- a/src/roms/rom_fp512bn_64.rs
+++ b/src/roms/rom_fp512bn_64.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use fp512bn::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use fp512bn::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 60
pub const MODULUS: [Chunk; NLEN] = [
diff --git a/src/roms/rom_goldilocks_32.rs b/src/roms/rom_goldilocks_32.rs
index 5d5f8bb..791423c 100644
--- a/src/roms/rom_goldilocks_32.rs
+++ b/src/roms/rom_goldilocks_32.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use goldilocks::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use goldilocks::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 29
// Goldilocks modulus
diff --git a/src/roms/rom_goldilocks_64.rs b/src/roms/rom_goldilocks_64.rs
index d6cadf1..15e48b3 100644
--- a/src/roms/rom_goldilocks_64.rs
+++ b/src/roms/rom_goldilocks_64.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use goldilocks::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use goldilocks::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 58
// Goldilocks modulus
diff --git a/src/roms/rom_hifive_32.rs b/src/roms/rom_hifive_32.rs
index cfa9f59..19ef026 100644
--- a/src/roms/rom_hifive_32.rs
+++ b/src/roms/rom_hifive_32.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use hifive::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use hifive::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 29
diff --git a/src/roms/rom_hifive_64.rs b/src/roms/rom_hifive_64.rs
index b2eebb9..b59e423 100644
--- a/src/roms/rom_hifive_64.rs
+++ b/src/roms/rom_hifive_64.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use hifive::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use hifive::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 60
diff --git a/src/roms/rom_nist256_32.rs b/src/roms/rom_nist256_32.rs
index 6859da5..bed195e 100644
--- a/src/roms/rom_nist256_32.rs
+++ b/src/roms/rom_nist256_32.rs
@@ -19,9 +19,9 @@ under the License.
/* Fixed Data in ROM - Field and Curve parameters */
-use nist256::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use nist256::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 28
@@ -45,8 +45,7 @@ pub const CURVE_B: [Chunk; NLEN] = [
0xAC635D8, 0x5,
];
pub const CURVE_ORDER: [Chunk; NLEN] = [
- 0xC632551, 0xB9CAC2F, 0x79E84F3, 0xFAADA71, 0xFFFBCE6, 0xFFFFFFF, 0xFFFFFF, 0x0, 0xFFFFFFF,
- 0xF,
+ 0xC632551, 0xB9CAC2F, 0x79E84F3, 0xFAADA71, 0xFFFBCE6, 0xFFFFFFF, 0xFFFFFF, 0x0, 0xFFFFFFF, 0xF,
];
pub const CURVE_GX: [Chunk; NLEN] = [
0x898C296, 0xA13945D, 0xB33A0F4, 0x7D812DE, 0xF27703, 0xE563A44, 0x7F8BCE6, 0xE12C424,
diff --git a/src/roms/rom_nist256_64.rs b/src/roms/rom_nist256_64.rs
index 015bbb3..fa4fd8b 100644
--- a/src/roms/rom_nist256_64.rs
+++ b/src/roms/rom_nist256_64.rs
@@ -19,9 +19,9 @@ under the License.
/* Fixed Data in ROM - Field and Curve parameters */
-use nist256::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use nist256::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 56
// nist256 modulus
diff --git a/src/roms/rom_nist384_32.rs b/src/roms/rom_nist384_32.rs
index 48d7826..b025645 100644
--- a/src/roms/rom_nist384_32.rs
+++ b/src/roms/rom_nist384_32.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use nist384::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use nist384::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 29
diff --git a/src/roms/rom_nist384_64.rs b/src/roms/rom_nist384_64.rs
index f0f5c69..0c8b75c 100644
--- a/src/roms/rom_nist384_64.rs
+++ b/src/roms/rom_nist384_64.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use nist384::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use nist384::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 56
@@ -44,7 +44,6 @@ pub const R2MODP: [Chunk; NLEN] = [
];
pub const MCONST: Chunk = 0x100000001;
-
// nist384 Curve
pub const CURVE_COF_I: isize = 1;
pub const CURVE_A: isize = -3;
diff --git a/src/roms/rom_nist521_32.rs b/src/roms/rom_nist521_32.rs
index 55cbf30..11d8c51 100644
--- a/src/roms/rom_nist521_32.rs
+++ b/src/roms/rom_nist521_32.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use nist521::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use nist521::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 28
// nist521 Modulus
diff --git a/src/roms/rom_nist521_64.rs b/src/roms/rom_nist521_64.rs
index bf241b2..11bb5f2 100644
--- a/src/roms/rom_nist521_64.rs
+++ b/src/roms/rom_nist521_64.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use nist521::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use nist521::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 60
// nist521 Modulus
diff --git a/src/roms/rom_nums256e_32.rs b/src/roms/rom_nums256e_32.rs
index 45506bd..1f3b5c1 100644
--- a/src/roms/rom_nums256e_32.rs
+++ b/src/roms/rom_nums256e_32.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use nums256e::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use nums256e::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 29
@@ -68,4 +68,3 @@ pub const ATE_BITS: usize = 0;
pub const SIGN_OF_X: SignOfX = SignOfX::NOT;
pub const HASH_TYPE: usize = 32;
pub const AESKEY: usize = 16;
-
diff --git a/src/roms/rom_nums256e_64.rs b/src/roms/rom_nums256e_64.rs
index 4382924..bae331c 100644
--- a/src/roms/rom_nums256e_64.rs
+++ b/src/roms/rom_nums256e_64.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use nums256e::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use nums256e::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 56
// nums256 Modulus
@@ -77,4 +77,3 @@ pub const ATE_BITS: usize = 0;
pub const SIGN_OF_X: SignOfX = SignOfX::NOT;
pub const HASH_TYPE: usize = 32;
pub const AESKEY: usize = 16;
-
diff --git a/src/roms/rom_nums256w_32.rs b/src/roms/rom_nums256w_32.rs
index b768380..2e56c41 100644
--- a/src/roms/rom_nums256w_32.rs
+++ b/src/roms/rom_nums256w_32.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use nums256w::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use nums256w::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 28
// nums256 modulus
diff --git a/src/roms/rom_nums256w_64.rs b/src/roms/rom_nums256w_64.rs
index 5b5d491..711d7ec 100644
--- a/src/roms/rom_nums256w_64.rs
+++ b/src/roms/rom_nums256w_64.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use nums256w::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use nums256w::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 56
// nums256 Modulus
diff --git a/src/roms/rom_nums384e_32.rs b/src/roms/rom_nums384e_32.rs
index eaad1c8..888eff6 100644
--- a/src/roms/rom_nums384e_32.rs
+++ b/src/roms/rom_nums384e_32.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use nums384e::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use nums384e::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 29
// nums384 Modulus
@@ -71,4 +71,3 @@ pub const ATE_BITS: usize = 0;
pub const SIGN_OF_X: SignOfX = SignOfX::NOT;
pub const HASH_TYPE: usize = 48;
pub const AESKEY: usize = 24;
-
diff --git a/src/roms/rom_nums384e_64.rs b/src/roms/rom_nums384e_64.rs
index 08d83c2..20ee825 100644
--- a/src/roms/rom_nums384e_64.rs
+++ b/src/roms/rom_nums384e_64.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use nums384e::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use nums384e::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 56
// nums384 Modulus
@@ -92,4 +92,3 @@ pub const ATE_BITS: usize = 0;
pub const SIGN_OF_X: SignOfX = SignOfX::NOT;
pub const HASH_TYPE: usize = 48;
pub const AESKEY: usize = 24;
-
diff --git a/src/roms/rom_nums384w_32.rs b/src/roms/rom_nums384w_32.rs
index 92181a6..f49379e 100644
--- a/src/roms/rom_nums384w_32.rs
+++ b/src/roms/rom_nums384w_32.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use nums384w::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use nums384w::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 29
// nums384 Modulus
@@ -71,4 +71,3 @@ pub const ATE_BITS: usize = 0;
pub const SIGN_OF_X: SignOfX = SignOfX::NOT;
pub const HASH_TYPE: usize = 48;
pub const AESKEY: usize = 24;
-
diff --git a/src/roms/rom_nums384w_64.rs b/src/roms/rom_nums384w_64.rs
index 3f51d94..f9e134b 100644
--- a/src/roms/rom_nums384w_64.rs
+++ b/src/roms/rom_nums384w_64.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use nums384w::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use nums384w::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 58
// nums384 Modulus
@@ -91,4 +91,3 @@ pub const ATE_BITS: usize = 0;
pub const SIGN_OF_X: SignOfX = SignOfX::NOT;
pub const HASH_TYPE: usize = 48;
pub const AESKEY: usize = 24;
-
diff --git a/src/roms/rom_nums512e_32.rs b/src/roms/rom_nums512e_32.rs
index 8d53f9f..b14a0a1 100644
--- a/src/roms/rom_nums512e_32.rs
+++ b/src/roms/rom_nums512e_32.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use nums512e::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use nums512e::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 29
// nums512 Modulus
diff --git a/src/roms/rom_nums512e_64.rs b/src/roms/rom_nums512e_64.rs
index 298f3cc..7e3fd98 100644
--- a/src/roms/rom_nums512e_64.rs
+++ b/src/roms/rom_nums512e_64.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use nums512e::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use nums512e::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 60
// nums512 Modulus
diff --git a/src/roms/rom_nums512w_32.rs b/src/roms/rom_nums512w_32.rs
index 785070c..c3e07c5 100644
--- a/src/roms/rom_nums512w_32.rs
+++ b/src/roms/rom_nums512w_32.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use nums512w::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use nums512w::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 29
// nums512 Modulus
diff --git a/src/roms/rom_nums512w_64.rs b/src/roms/rom_nums512w_64.rs
index 6868c87..52ee250 100644
--- a/src/roms/rom_nums512w_64.rs
+++ b/src/roms/rom_nums512w_64.rs
@@ -17,9 +17,9 @@ specific language governing permissions and limitations
under the License.
*/
-use nums512w::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use nums512w::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 60
// nums512 Modulus
diff --git a/src/roms/rom_rsa2048_32.rs b/src/roms/rom_rsa2048_32.rs
index 6dd06a6..29b5a60 100644
--- a/src/roms/rom_rsa2048_32.rs
+++ b/src/roms/rom_rsa2048_32.rs
@@ -1,3 +1,3 @@
pub const MODBYTES: usize = 128;
pub const BASEBITS: usize = 28;
-pub const FFLEN: usize = 2;
\ No newline at end of file
+pub const FFLEN: usize = 2;
diff --git a/src/roms/rom_rsa2048_64.rs b/src/roms/rom_rsa2048_64.rs
index be3ba0d..4caac22 100644
--- a/src/roms/rom_rsa2048_64.rs
+++ b/src/roms/rom_rsa2048_64.rs
@@ -1,3 +1,3 @@
pub const MODBYTES: usize = 128;
pub const BASEBITS: usize = 58;
-pub const FFLEN: usize = 2;
\ No newline at end of file
+pub const FFLEN: usize = 2;
diff --git a/src/roms/rom_rsa3072_32.rs b/src/roms/rom_rsa3072_32.rs
index d5622e2..62b929e 100644
--- a/src/roms/rom_rsa3072_32.rs
+++ b/src/roms/rom_rsa3072_32.rs
@@ -1,3 +1,3 @@
pub const MODBYTES: usize = 48;
pub const BASEBITS: usize = 28;
-pub const FFLEN: usize = 8;
\ No newline at end of file
+pub const FFLEN: usize = 8;
diff --git a/src/roms/rom_rsa3072_64.rs b/src/roms/rom_rsa3072_64.rs
index 4d1ed2b..ef66da7 100644
--- a/src/roms/rom_rsa3072_64.rs
+++ b/src/roms/rom_rsa3072_64.rs
@@ -1,3 +1,3 @@
pub const MODBYTES: usize = 48;
pub const BASEBITS: usize = 58;
-pub const FFLEN: usize = 8;
\ No newline at end of file
+pub const FFLEN: usize = 8;
diff --git a/src/roms/rom_rsa4096_32.rs b/src/roms/rom_rsa4096_32.rs
index 223cb7d..16ade15 100644
--- a/src/roms/rom_rsa4096_32.rs
+++ b/src/roms/rom_rsa4096_32.rs
@@ -1,3 +1,3 @@
pub const MODBYTES: usize = 64;
pub const BASEBITS: usize = 29;
-pub const FFLEN: usize = 8;
\ No newline at end of file
+pub const FFLEN: usize = 8;
diff --git a/src/roms/rom_rsa4096_64.rs b/src/roms/rom_rsa4096_64.rs
index 77d3eb6..e8ebfc6 100644
--- a/src/roms/rom_rsa4096_64.rs
+++ b/src/roms/rom_rsa4096_64.rs
@@ -1,3 +1,3 @@
pub const MODBYTES: usize = 64;
pub const BASEBITS: usize = 60;
-pub const FFLEN: usize = 8;
\ No newline at end of file
+pub const FFLEN: usize = 8;
diff --git a/src/roms/rom_secp256k1_32.rs b/src/roms/rom_secp256k1_32.rs
index 94bbbaa..cb28327 100644
--- a/src/roms/rom_secp256k1_32.rs
+++ b/src/roms/rom_secp256k1_32.rs
@@ -19,9 +19,9 @@ under the License.
/* Fixed Data in ROM - Field and Curve parameters */
-use secp256k1::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use secp256k1::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 28
// secp256k1 modulus
diff --git a/src/roms/rom_secp256k1_64.rs b/src/roms/rom_secp256k1_64.rs
index b22d875..43a3b91 100644
--- a/src/roms/rom_secp256k1_64.rs
+++ b/src/roms/rom_secp256k1_64.rs
@@ -19,9 +19,9 @@ under the License.
/* Fixed Data in ROM - Field and Curve parameters */
-use secp256k1::big::NLEN;
use super::super::arch::Chunk;
-use types::{ModType, CurveType, CurvePairingType, SexticTwist, SignOfX};
+use secp256k1::big::NLEN;
+use types::{CurvePairingType, CurveType, ModType, SexticTwist, SignOfX};
// Base Bits= 56
diff --git a/src/types.rs b/src/types.rs
index ea310d7..19b43d0 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -42,4 +42,3 @@ pub enum SignOfX {
POSITIVEX,
NEGATIVEX,
}
-