-}
-
-impl {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "{}({})", P::name(), self.value)
- }
-}
-
-impl {
- fn zero() -> Self {
- use num::Zero;
-
- Fp {
- value: BigUint::zero(),
- _marker: PhantomData
- }
- }
- fn one() -> Self {
- use num::One;
-
- Fp {
- value: BigUint::one(),
- _marker: PhantomData
- }
- }
- fn random {
- pub fn test_bit(&self, bit: usize) -> bool {
- // TODO: This is a naive approach.
- use num::{One, Zero};
-
- let mut b = BigUint::one();
- let two = &b + &b;
- for _ in 0..bit {
- b = &b + &b;
- }
-
- (&self.value / b) % two != BigUint::zero()
- }
-}
-
-impl<'a, P: PrimeFieldParams> From<&'a str> for Fp {
- fn from(s: &'a str) -> Self {
- Fp {
- value: BigUint::from_str_radix(s, 10).unwrap() % P::modulus(),
- _marker: PhantomData
- }
- }
-}
-
-impl {
- fn clone(&self) -> Self {
- Fp {
- value: self.value.clone(),
- _marker: PhantomData
- }
- }
-}
-
-forward_ops_to_field_ops!(impl(P: PrimeFieldParams) Fp );
diff --git a/oldsrc/fields/fp12.rs b/oldsrc/fields/fp12.rs
deleted file mode 100644
index ffd7d88..0000000
--- a/oldsrc/fields/fp12.rs
+++ /dev/null
@@ -1,294 +0,0 @@
-use ::Fr;
-use ::Fq2;
-use ::Fq6;
-use ::Fq12;
-use fields::fp::PrimeFieldParams;
-use fields::fp6::Fp6Params;
-use params::{FrParams,Fq6Params};
-use rand::Rng;
-use fields::Field;
-use std::ops::{Mul,Add,Sub,Neg};
-use std::cmp::{PartialEq, Eq};
-use std::marker::PhantomData;
-use std::fmt;
-
-pub trait Fp12Params {
- fn non_residue() -> Fq2;
- fn name() -> &'static str;
- fn frobenius_coeffs_c1(n: usize) -> Fq2;
-}
-
-pub struct Fp12
-}
-
-impl {
- pub fn new(a: Fq6, b: Fq6) -> Self {
- Fp12 {
- a: a,
- b: b,
- _marker: PhantomData
- }
- }
-
- pub fn frobenius_map(&self, power: usize) -> Self {
- Fp12 {
- a: self.a.frobenius_map(power),
- b: &self.b.frobenius_map(power) * &P::frobenius_coeffs_c1(power % 12),
- _marker: PhantomData
- }
- }
-}
-
-impl Fq12 {
- pub fn unitary_inverse(&self) -> Fq12 {
- Fp12 {
- a: self.a.clone(),
- b: -&self.b,
- _marker: PhantomData
- }
- }
-
- pub fn cyclotomic_exp(&self, exp: &Fr) -> Self {
- let mut res = Self::one();
-
- let mut found_one = false;
-
- for i in (0..FrParams::bits()).rev() {
- if found_one {
- res = res.cyclotomic_squared();
- }
-
- if exp.test_bit(i) {
- found_one = true;
- res = self * &res;
- }
- }
-
- res
- }
-
- pub fn cyclotomic_squared(&self) -> Self {
- let z0 = &self.a.a;
- let z4 = &self.a.b;
- let z3 = &self.a.c;
- let z2 = &self.b.a;
- let z1 = &self.b.b;
- let z5 = &self.b.c;
-
- let tmp = z0 * z1;
- let t0 = (z0 + z1) * (z1 * Fq6Params::non_residue() + z0) - &tmp - &tmp * Fq6Params::non_residue();
- let t1 = &tmp + &tmp;
-
- let tmp = z2 * z3;
- let t2 = (z2 + z3) * (z3 * Fq6Params::non_residue() + z2) - &tmp - &tmp * Fq6Params::non_residue();
- let t3 = &tmp + &tmp;
-
- let tmp = z4 * z5;
- let t4 = (z4 + z5) * (z5 * Fq6Params::non_residue() + z4) - &tmp - &tmp * Fq6Params::non_residue();
- let t5 = &tmp + &tmp;
-
- let z0 = &t0 - z0;
- let z0 = &z0 + &z0;
- let z0 = &z0 + &t0;
-
- let z1 = &t1 + z1;
- let z1 = &z1 + &z1;
- let z1 = &z1 + &t1;
-
- let tmp = &t5 * Fq6Params::non_residue();
- let z2 = &tmp + z2;
- let z2 = &z2 + &z2;
- let z2 = &z2 + &tmp;
-
- let z3 = &t4 - z3;
- let z3 = &z3 + &z3;
- let z3 = &z3 + &t4;
-
- let z4 = &t2 - z4;
- let z4 = &z4 + &z4;
- let z4 = &z4 + &t2;
-
- let z5 = &t3 + z5;
- let z5 = &z5 + &z5;
- let z5 = &z5 + &t3;
-
- Fp12 {
- a: Fq6::new(z0, z4, z3),
- b: Fq6::new(z2, z1, z5),
- _marker: PhantomData
- }
- }
-
- pub fn mul_by_024(&self,
- ell_0: &Fq2,
- ell_vw: Fq2,
- ell_vv: Fq2) -> Fq12 {
- let z0 = &self.a.a;
- let z1 = &self.a.b;
- let z2 = &self.a.c;
- let z3 = &self.b.a;
- let z4 = &self.b.b;
- let z5 = &self.b.c;
-
- let x0 = ell_0;
- let x2 = &ell_vv;
- let x4 = &ell_vw;
-
- let d0 = z0 * x0;
- let d2 = z2 * x2;
- let d4 = z4 * x4;
- let t2 = z0 + z4;
- let t1 = z0 + z2;
- let s0 = z1 + z3 + z5;
-
- let s1 = z1 * x2;
- let t3 = &s1 + &d4;
- let t4 = &t3 * Fq6Params::non_residue() + &d0;
- let z0 = t4;
-
- let t3 = z5 * x4;
- let s1 = &s1 + &t3;
- let t3 = &t3 + &d2;
- let t4 = &t3 * Fq6Params::non_residue();
- let t3 = z1 * x0;
- let s1 = &s1 + &t3;
- let t4 = &t4 + &t3;
- let z1 = t4;
-
- let t0 = x0 + x2;
- let t3 = &t1 * &t0 - &d0 - &d2;
- let t4 = z3 * x4;
- let s1 = &s1 + &t4;
- let t3 = &t3 + &t4;
-
- let t0 = z2 + z4;
- let z2 = t3;
-
- let t1 = x2 + x4;
- let t3 = &t0 * &t1 - &d2 - &d4;
- let t4 = &t3 * Fq6Params::non_residue();
- let t3 = z3 * x0;
- let s1 = &s1 + &t3;
- let t4 = &t4 + &t3;
- let z3 = t4;
-
- let t3 = z5 * x2;
- let s1 = &s1 + &t3;
- let t4 = &t3 * Fq6Params::non_residue();
- let t0 = x0 + x4;
- let t3 = &t2 * &t0 - &d0 - &d4;
- let t4 = &t4 + &t3;
- let z4 = t4;
-
- let t0 = x0 + x2 + x4;
- let t3 = &s0 * &t0 - &s1;
- let z5 = t3;
-
- Fq12 {
- a: Fq6::new(z0, z1, z2),
- b: Fq6::new(z3, z4, z5),
- _marker: PhantomData
- }
- }
-}
-
-impl {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "{}({:?}, {:?})", P::name(), self.a, self.b)
- }
-}
-
-impl {
- fn clone(&self) -> Self {
- Fp12 {
- a: self.a.clone(),
- b: self.b.clone(),
- _marker: PhantomData
- }
- }
-}
-
-impl {
- fn zero() -> Self {
- Fp12 {
- a: Fq6::zero(),
- b: Fq6::zero(),
- _marker: PhantomData
- }
- }
- fn one() -> Self {
- Fp12 {
- a: Fq6::one(),
- b: Fq6::zero(),
- _marker: PhantomData
- }
- }
- fn random );
diff --git a/oldsrc/fields/fp2.rs b/oldsrc/fields/fp2.rs
deleted file mode 100644
index 7c9523b..0000000
--- a/oldsrc/fields/fp2.rs
+++ /dev/null
@@ -1,146 +0,0 @@
-use ::Fq;
-use rand::Rng;
-use fields::Field;
-use std::ops::{Mul,Add,Sub,Neg};
-use std::cmp::{PartialEq, Eq};
-use std::marker::PhantomData;
-use std::fmt;
-
-pub trait Fp2Params {
- fn non_residue() -> Fq;
- fn name() -> &'static str;
- fn frobenius_coeffs_c1(usize) -> Fq;
-}
-
-pub struct Fp2
-}
-
-impl {
- pub fn new(a: Fq, b: Fq) -> Self {
- Fp2 {
- a: a,
- b: b,
- _marker: PhantomData
- }
- }
-
- pub fn frobenius_map(&self, power: usize) -> Self {
- Fp2 {
- a: self.a.clone(),
- b: &self.b * P::frobenius_coeffs_c1(power % 2),
- _marker: PhantomData
- }
- }
-}
-
-impl {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "{}({:?}, {:?})", P::name(), self.a, self.b)
- }
-}
-
-impl {
- fn clone(&self) -> Self {
- Fp2 {
- a: self.a.clone(),
- b: self.b.clone(),
- _marker: PhantomData
- }
- }
-}
-
-impl {
- fn zero() -> Self {
- Fp2 {
- a: Fq::zero(),
- b: Fq::zero(),
- _marker: PhantomData
- }
- }
- fn one() -> Self {
- Fp2 {
- a: Fq::one(),
- b: Fq::zero(),
- _marker: PhantomData
- }
- }
- fn random {
- type Output = Fp2 ;
-
- fn mul(self, other: &Fq) -> Fp2 {
- Fp2 {
- a: &self.a * other,
- b: &self.b * other,
- _marker: PhantomData
- }
- }
-}
-
-forward_ops_to_field_ops!(impl(P: Fp2Params) Fp2 );
diff --git a/oldsrc/fields/fp6.rs b/oldsrc/fields/fp6.rs
deleted file mode 100644
index 2fe4bd4..0000000
--- a/oldsrc/fields/fp6.rs
+++ /dev/null
@@ -1,192 +0,0 @@
-use ::Fq2;
-use rand::Rng;
-use fields::Field;
-use std::ops::{Mul,Add,Sub,Neg};
-use std::cmp::{PartialEq, Eq};
-use std::marker::PhantomData;
-use std::fmt;
-
-pub trait Fp6Params {
- fn non_residue() -> Fq2;
- fn name() -> &'static str;
- fn frobenius_coeffs_c1(usize) -> Fq2;
- fn frobenius_coeffs_c2(usize) -> Fq2;
-}
-
-pub struct Fp6
-}
-
-impl {
- pub fn new(a: Fq2, b: Fq2, c: Fq2) -> Self {
- Fp6 {
- a: a,
- b: b,
- c: c,
- _marker: PhantomData
- }
- }
-
- pub fn frobenius_map(&self, power: usize) -> Self {
- Fp6 {
- a: self.a.frobenius_map(power),
- b: self.b.frobenius_map(power) * P::frobenius_coeffs_c1(power % 6),
- c: self.c.frobenius_map(power) * P::frobenius_coeffs_c2(power % 6),
- _marker: PhantomData
- }
- }
-}
-
-impl {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "{}({:?}, {:?}, {:?})", P::name(), self.a, self.b, self.c)
- }
-}
-
-impl {
- fn clone(&self) -> Self {
- Fp6 {
- a: self.a.clone(),
- b: self.b.clone(),
- c: self.c.clone(),
- _marker: PhantomData
- }
- }
-}
-
-impl {
- fn zero() -> Self {
- Fp6 {
- a: Fq2::zero(),
- b: Fq2::zero(),
- c: Fq2::zero(),
- _marker: PhantomData
- }
- }
-
- fn one() -> Self {
- Fp6 {
- a: Fq2::one(),
- b: Fq2::zero(),
- c: Fq2::zero(),
- _marker: PhantomData
- }
- }
-
- fn random {
- pub fn mul_by_nonresidue(&self, other: &Fq2) -> Fp6 {
- Fp6 {
- a: &self.c * other,
- b: self.a.clone(),
- c: self.b.clone(),
- _marker: PhantomData
- }
- }
-}
-
-impl<'a, 'b, P: Fp6Params> Mul<&'a Fq2> for &'b Fp6 {
- type Output = Fp6 ;
-
- fn mul(self, other: &Fq2) -> Fp6 {
- Fp6 {
- a: &self.a * other,
- b: &self.b * other,
- c: &self.c * other,
- _marker: PhantomData
- }
- }
-}
-
-forward_ops_to_field_ops!(impl(P: Fp6Params) Fp6 );
diff --git a/oldsrc/fields/macros.rs b/oldsrc/fields/macros.rs
deleted file mode 100644
index 00cc91f..0000000
--- a/oldsrc/fields/macros.rs
+++ /dev/null
@@ -1,107 +0,0 @@
-macro_rules! forward_val_val_binop {
- (impl($($t:ident: $p:ident),*) $imp:ident for $res:ty, $method:ident) => {
- impl<$($t: $p),*> $imp<$res> for $res {
- type Output = $res;
-
- #[inline]
- fn $method(self, other: $res) -> $res {
- $imp::$method(&self, &other)
- }
- }
- }
-}
-
-macro_rules! forward_ref_val_binop {
- (impl($($t:ident: $p:ident),*) $imp:ident for $res:ty, $method:ident) => {
- impl<'a, $($t: $p),*> $imp<$res> for &'a $res {
- type Output = $res;
-
- #[inline]
- fn $method(self, other: $res) -> $res {
- $imp::$method(self, &other)
- }
- }
- }
-}
-
-macro_rules! forward_val_ref_binop {
- (impl($($t:ident: $p:ident),*) $imp:ident for $res:ty, $method:ident) => {
- impl<'a, $($t: $p),*> $imp<&'a $res> for $res {
- type Output = $res;
-
- #[inline]
- fn $method(self, other: &$res) -> $res {
- $imp::$method(&self, other)
- }
- }
- }
-}
-
-macro_rules! forward_all_binop_to_ref_ref {
- (impl($($t:ident: $p:ident),*) $imp:ident for $res:ty, $method:ident) => {
- forward_val_val_binop!(impl($($t: $p),*) $imp for $res, $method);
- forward_ref_val_binop!(impl($($t: $p),*) $imp for $res, $method);
- forward_val_ref_binop!(impl($($t: $p),*) $imp for $res, $method);
- };
-}
-
-macro_rules! forward_ops_to_field_ops {
- (impl($($t:ident: $p:ident),*) $res:ty) => {
- impl<'a, 'b, $($t: $p),*> Add<&'a $res> for &'b $res {
- type Output = $res;
-
- #[inline]
- fn add(self, other: &'a $res) -> $res {
- Field::add(self, other)
- }
- }
-
- impl<'a, 'b, $($t: $p),*> Sub<&'a $res> for &'b $res {
- type Output = $res;
-
- #[inline]
- fn sub(self, other: &'a $res) -> $res {
- Field::sub(self, other)
- }
- }
-
- impl<'a, 'b, $($t: $p),*> Mul<&'a $res> for &'b $res {
- type Output = $res;
-
- #[inline]
- fn mul(self, other: &'a $res) -> $res {
- Field::mul(self, other)
- }
- }
-
- impl<'a, $($t: $p),*> Neg for &'a $res {
- type Output = $res;
-
- #[inline]
- fn neg(self) -> $res {
- Field::neg(self)
- }
- }
-
- impl<$($t: $p),*> Neg for $res {
- type Output = $res;
-
- #[inline]
- fn neg(self) -> $res {
- Field::neg(&self)
- }
- }
-
- impl<$($t: $p),*> PartialEq for $res {
- fn eq(&self, other: &Self) -> bool {
- Field::eq(self, other)
- }
- }
-
- impl<$($t: $p),*> Eq for $res {}
-
- forward_all_binop_to_ref_ref!(impl($($t: $p),*) Add for $res, add);
- forward_all_binop_to_ref_ref!(impl($($t: $p),*) Sub for $res, sub);
- forward_all_binop_to_ref_ref!(impl($($t: $p),*) Mul for $res, mul);
- }
-}
diff --git a/oldsrc/fields/mod.rs b/oldsrc/fields/mod.rs
deleted file mode 100644
index 0c24f0e..0000000
--- a/oldsrc/fields/mod.rs
+++ /dev/null
@@ -1,54 +0,0 @@
-#[macro_use]
-mod macros;
-
-pub mod fp;
-pub mod fp2;
-pub mod fp6;
-pub mod fp12;
-
-#[cfg(test)]
-pub mod tests;
-
-use rand::Rng;
-use self::fp::{Fp, PrimeFieldParams};
-use std::fmt::Debug;
-
-pub trait Field: Sized + Clone + Debug {
- fn zero() -> Self;
- fn one() -> Self;
- fn random ) -> Self {
- let mut res = Self::one();
-
- let mut found_one = false;
-
- for i in (0..P::bits()).rev() {
- if found_one {
- res = res.squared();
- }
-
- if exp.test_bit(i) {
- found_one = true;
- res = self.mul(&res);
- }
- }
-
- res
- }
- fn eq(&self, other: &Self) -> bool;
- fn ne(&self, other: &Self) -> bool {
- !self.eq(other)
- }
-
- fn neg(&self) -> Self;
- fn mul(&self, other: &Self) -> Self;
- fn sub(&self, other: &Self) -> Self;
- fn add(&self, other: &Self) -> Self;
-}
diff --git a/oldsrc/fields/tests.rs b/oldsrc/fields/tests.rs
deleted file mode 100644
index 82f48ea..0000000
--- a/oldsrc/fields/tests.rs
+++ /dev/null
@@ -1,203 +0,0 @@
-use rand::{Rng,SeedableRng,StdRng};
-use fields::Field;
-
-mod large_field {
- use fields::fp::*;
- use num::{BigUint, Num};
-
- struct Large;
-
- impl PrimeFieldParams for Large {
- fn modulus() -> BigUint {
- BigUint::from_str_radix("21888242871839275222246405745257275088696311157297823662689037894645226208583", 10).unwrap()
- }
-
- fn bits() -> usize { 254 }
- fn name() -> &'static str { "Large" }
- }
-
- type Ft = Fp {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "{}({:?}, {:?}, {:?})", P::name(), self.x, self.y, self.z)
- }
-}
-
-impl {
- fn clone(&self) -> Self {
- Jacobian {
- x: self.x.clone(),
- y: self.y.clone(),
- z: self.z.clone()
- }
- }
-}
-pub enum Affine {
- fn clone(&self) -> Self {
- match *self {
- Affine::Zero => Affine::Zero,
- Affine::Point{ref x, ref y} => Affine::Point{x: x.clone(), y: y.clone()}
- }
- }
-}
-
-#[derive(PartialEq, Eq)]
-pub struct EllCoeffs {
- pub ell_0: Fq2,
- pub ell_vw: Fq2,
- pub ell_vv: Fq2
-}
-
-impl {
- pub fn get_x(&self) -> P::Base {
- match *self {
- Affine::Zero => P::Base::zero(),
- Affine::Point{ref x, ref y} => x.clone()
- }
- }
-
- pub fn get_y(&self) -> P::Base {
- match *self {
- Affine::Zero => P::Base::one(),
- Affine::Point{ref x, ref y} => y.clone()
- }
- }
-
- pub fn to_jacobian(&self) -> Jacobian {
- match *self {
- Affine::Zero => P::zero(),
- Affine::Point{ref x, ref y} => Jacobian {
- x: x.clone(),
- y: y.clone(),
- z: P::Base::one()
- }
- }
- }
-
- pub fn neg(&self) -> Self {
- match *self {
- Affine::Zero => Affine::Zero,
- Affine::Point{ref x, ref y} => Affine::Point{x: x.clone(), y: y.neg()}
- }
- }
-}
-
-impl Jacobian {
- pub fn new(x: P::Base, y: P::Base, z: P::Base) -> Option {
- if self.is_zero() {
- Affine::Zero
- } else {
- let z_inv = self.z.inverse();
- let z2_inv = z_inv.squared();
- let z3_inv = z2_inv.mul(&z_inv);
-
- Affine::Point {
- x: self.x.mul(&z2_inv),
- y: self.y.mul(&z3_inv)
- }
- }
- }
-
- pub fn zero() -> Self {
- P::zero()
- }
-
- pub fn one() -> Self {
- P::one()
- }
-
- pub fn add(&self, other: &Self) -> Self {
- if self.is_zero() {
- return other.clone()
- }
-
- if other.is_zero() {
- return self.clone()
- }
-
- let z1_squared = self.z.squared();
- let z2_squared = other.z.squared();
- let u1 = self.x.mul(&z2_squared);
- let u2 = other.x.mul(&z1_squared);
- let z1_cubed = self.z.mul(&z1_squared);
- let z2_cubed = other.z.mul(&z2_squared);
- let s1 = self.y.mul(&z2_cubed);
- let s2 = other.y.mul(&z1_cubed);
-
- if u1.eq(&u2) && s1.eq(&s2) {
- self.double()
- } else {
- let h = u2.sub(&u1);
- let s2_minus_s1 = s2.sub(&s1);
- let i = h.add(&h).squared();
- let j = h.mul(&i);
- let r = s2_minus_s1.add(&s2_minus_s1);
- let v = u1.mul(&i);
- let s1_j = s1.mul(&j);
- let x3 = r.squared().sub(&j).sub(&v.add(&v));
- let y3 = r.mul(&v.sub(&x3)).sub(&s1_j.add(&s1_j));
-
- Jacobian {
- x: x3,
- y: y3,
- z: self.z.add(&other.z).squared().sub(&z1_squared).sub(&z2_squared).mul(&h)
- }
- }
- }
-
- pub fn double(&self) -> Self {
- let a = self.x.squared();
- let b = self.y.squared();
- let c = b.squared();
- let mut d = self.x.add(&b).squared().sub(&a).sub(&c);
- d = d.add(&d);
- let e = a.add(&a).add(&a);
- let f = e.squared();
- let x3 = f.sub(&d.add(&d));
- let mut eight_c = c.add(&c);
- eight_c = eight_c.add(&eight_c);
- eight_c = eight_c.add(&eight_c);
- let y3 = e.mul(&d.sub(&x3)).sub(&eight_c);
- let y1z1 = self.y.mul(&self.z);
- let z3 = y1z1.add(&y1z1);
-
- Jacobian {
- x: x3,
- y: y3,
- z: z3
- }
- }
-
- pub fn eq(&self, other: &Self) -> bool {
- if self.is_zero() {
- return other.is_zero()
- }
-
- if other.is_zero() {
- return false;
- }
-
- let z1_squared = self.z.squared();
- let z2_squared = other.z.squared();
-
- if self.x.mul(&z2_squared).ne(&other.x.mul(&z1_squared)) {
- return false;
- }
-
- let z1_cubed = self.z.mul(&z1_squared);
- let z2_cubed = other.z.mul(&z2_squared);
-
- if self.y.mul(&z2_cubed).ne(&other.y.mul(&z1_cubed)) {
- return false;
- }
-
- return true;
- }
-
- pub fn neg(&self) -> Self {
- Jacobian {
- x: self.x.clone(),
- y: self.y.neg(),
- z: self.z.clone()
- }
- }
-
- #[inline]
- pub fn is_zero(&self) -> bool {
- self.z.is_zero()
- }
-
- pub fn mul {
- let mut result = Jacobian:: ::zero();
- let mut found_one = false;
- for i in (0..S::bits()).rev() {
- if found_one {
- result = result.double();
- }
-
- if other.test_bit(i) {
- found_one = true;
- result = &result + self;
- }
- }
-
- result
- }
-
- #[inline]
- pub fn sub(&self, other: &Self) -> Jacobian {
- self.add(&other.neg())
- }
-}
-
-impl Jacobian );
-
-impl {
- fn eq(&self, other: &Self) -> bool {
- self.to_jacobian() == other.to_jacobian()
- }
-}
-
-impl { }
diff --git a/oldsrc/groups/tests.rs b/oldsrc/groups/tests.rs
deleted file mode 100644
index 1f3d267..0000000
--- a/oldsrc/groups/tests.rs
+++ /dev/null
@@ -1,76 +0,0 @@
-use super::*;
-use ::Fr;
-use fields::Field;
-
-use rand::Rng;
-
-pub fn group_trials = Jacobian ;
-
- let one = G:: ::one();
- let two = one.add(&one);
- let three = two.add(&one);
- let four = three.add(&one);
-
- assert_eq!(one.double(), two);
- assert_eq!(two.double(), four);
- }
-
- fn random_test_addition = Jacobian ;
-
- for _ in 0..50 {
- let r1 = &G:: ::random(rng);
- let r2 = &G:: ::random(rng);
- let r3 = &G:: ::random(rng);
-
- let s1 = (r1 + r2) + r3;
- let s2 = (r2 + r3) + r1;
-
- assert_eq!(s1, s2);
- }
- }
-
- fn random_test_doubling = Jacobian ;
-
- for _ in 0..50 {
- let r1 = &G:: ::random(rng);
- let r2 = &G:: ::random(rng);
-
- let a = (r1 + r2) + r1;
- let b = r1.double() + r2;
-
- assert!(a.eq(&b));
- }
- }
-
- fn random_test_dh = Jacobian ;
-
- for _ in 0..50 {
- let alice_sk = Fr::random(rng);
- let bob_sk = Fr::random(rng);
-
- let alice_pk = G:: ::one() * &alice_sk;
- let bob_pk = G:: ::one() * &bob_sk;
-
- let alice_shared = &bob_pk * &alice_sk;
- let bob_shared = &alice_pk * &bob_sk;
-
- assert_eq!(alice_shared, bob_shared);
- }
- }
-
- test_doubling:: ();
-
- use rand::{SeedableRng,StdRng};
- let seed: [usize; 4] = [103245, 191922, 1293, 192103];
- let mut rng = StdRng::from_seed(&seed);
-
- random_test_addition:: (&mut rng);
- random_test_doubling:: (&mut rng);
- random_test_dh:: (&mut rng);
-}
-
diff --git a/oldsrc/lib.rs b/oldsrc/lib.rs
deleted file mode 100644
index 9512482..0000000
--- a/oldsrc/lib.rs
+++ /dev/null
@@ -1,406 +0,0 @@
-extern crate num;
-extern crate rand;
-
-mod fields;
-mod params;
-
-mod groups;
-
-pub use groups::Gt;
-pub use fields::fp::Fp;
-pub use fields::fp2::Fp2;
-pub use fields::fp6::Fp6;
-pub use fields::fp12::Fp12;
-pub use params::{FrParams,FqParams,Fq2Params,G1Params,G2Params,Fq6Params,Fq12Params,ate_loop_count,final_exponent_z};
-pub use fields::Field;
-pub use groups::{Jacobian};
-use groups::{EllCoeffs,Affine};
-use fields::fp::PrimeFieldParams;
-
-pub type Fr = Fp) -> Jacobian