Browse Source

Format

fq2_neg_nonresidue
Pratyush Mishra 4 years ago
parent
commit
7f1fcd6696
13 changed files with 56 additions and 88 deletions
  1. +2
    -4
      curve-benches/benches/bls12_377.rs
  2. +2
    -4
      curve-benches/benches/bls12_381.rs
  3. +3
    -5
      curve-benches/benches/bn254.rs
  4. +2
    -4
      curve-benches/benches/bw6_761.rs
  5. +1
    -1
      curve-benches/benches/cp6_782.rs
  6. +1
    -1
      curve-benches/benches/ed_on_bls12_381.rs
  7. +2
    -4
      curve-benches/benches/mnt4_298.rs
  8. +2
    -4
      curve-benches/benches/mnt4_753.rs
  9. +2
    -4
      curve-benches/benches/mnt6_298.rs
  10. +2
    -4
      curve-benches/benches/mnt6_753.rs
  11. +0
    -8
      curve-benches/src/macros/ec.rs
  12. +29
    -34
      curve-benches/src/macros/field.rs
  13. +8
    -11
      curve-benches/src/macros/pairing.rs

+ 2
- 4
curve-benches/benches/bls12_377.rs

@ -1,15 +1,13 @@
use ark_curve_benches::*;
use rand::SeedableRng;
use rand_xorshift::XorShiftRng;
use std::ops::{AddAssign, MulAssign, SubAssign};
use ark_curve_benches::*;
use ark_bls12_377::{
fq::Fq, fq2::Fq2, fr::Fr, Bls12_377, Fq12, G1Affine, G1Projective as G1, G2Affine,
G2Projective as G2,
};
use ark_ec::{
PairingEngine, ProjectiveCurve,
};
use ark_ec::{PairingEngine, ProjectiveCurve};
use ark_ff::{
biginteger::{BigInteger256 as FrRepr, BigInteger384 as FqRepr},
BigInteger, Field, PrimeField, SquareRootField, UniformRand,

+ 2
- 4
curve-benches/benches/bls12_381.rs

@ -1,15 +1,13 @@
use ark_curve_benches::*;
use rand::SeedableRng;
use rand_xorshift::XorShiftRng;
use std::ops::{AddAssign, MulAssign, SubAssign};
use ark_curve_benches::*;
use ark_bls12_381::{
fq::Fq, fq2::Fq2, fr::Fr, Bls12_381, Fq12, G1Affine, G1Projective as G1, G2Affine,
G2Projective as G2,
};
use ark_ec::{
PairingEngine, ProjectiveCurve,
};
use ark_ec::{PairingEngine, ProjectiveCurve};
use ark_ff::{
biginteger::{BigInteger256 as FrRepr, BigInteger384 as FqRepr},
BigInteger, Field, PrimeField, SquareRootField, UniformRand,

+ 3
- 5
curve-benches/benches/bn254.rs

@ -1,15 +1,13 @@
use ark_curve_benches::*;
use rand::SeedableRng;
use rand_xorshift::XorShiftRng;
use std::ops::{AddAssign, MulAssign, SubAssign};
use ark_curve_benches::*;
use ark_bn254::{
fq::Fq, fq2::Fq2, fr::Fr, Bn254, Fq12, G1Affine, G1Projective as G1, G2Affine,
G2Projective as G2,
};
use ark_ec::{
PairingEngine, ProjectiveCurve,
G2Projective as G2,
};
use ark_ec::{PairingEngine, ProjectiveCurve};
use ark_ff::{
biginteger::{BigInteger256 as FrRepr, BigInteger256 as FqRepr},
BigInteger, Field, PrimeField, SquareRootField, UniformRand,

+ 2
- 4
curve-benches/benches/bw6_761.rs

@ -1,15 +1,13 @@
use ark_curve_benches::*;
use rand::SeedableRng;
use rand_xorshift::XorShiftRng;
use std::ops::{AddAssign, MulAssign, SubAssign};
use ark_curve_benches::*;
use ark_bw6_761::{
fq::Fq, fq3::Fq3, fr::Fr, Fq6, G1Affine, G1Projective as G1, G2Affine, G2Projective as G2,
BW6_761,
};
use ark_ec::{
PairingEngine, ProjectiveCurve,
};
use ark_ec::{PairingEngine, ProjectiveCurve};
use ark_ff::{
biginteger::{BigInteger384 as FrRepr, BigInteger768 as FqRepr},
BigInteger, Field, PrimeField, SquareRootField, UniformRand,

+ 1
- 1
curve-benches/benches/cp6_782.rs

@ -1,7 +1,7 @@
use ark_curve_benches::*;
use rand::SeedableRng;
use rand_xorshift::XorShiftRng;
use std::ops::{AddAssign, MulAssign, SubAssign};
use ark_curve_benches::*;
use ark_cp6_782::{
fq::Fq, fq3::Fq3, fr::Fr, Fq6, G1Affine, G1Projective as G1, G2Affine, G2Projective as G2,

+ 1
- 1
curve-benches/benches/ed_on_bls12_381.rs

@ -1,7 +1,7 @@
use ark_curve_benches::*;
use rand::SeedableRng;
use rand_xorshift::XorShiftRng;
use std::ops::{AddAssign, MulAssign, SubAssign};
use ark_curve_benches::*;
use ark_ec::ProjectiveCurve;
use ark_ed_on_bls12_381::{fq::Fq, fr::Fr, EdwardsAffine as GAffine, EdwardsProjective as G};

+ 2
- 4
curve-benches/benches/mnt4_298.rs

@ -1,11 +1,9 @@
use ark_curve_benches::*;
use rand::SeedableRng;
use rand_xorshift::XorShiftRng;
use std::ops::{AddAssign, MulAssign, SubAssign};
use ark_curve_benches::*;
use ark_ec::{
PairingEngine, ProjectiveCurve,
};
use ark_ec::{PairingEngine, ProjectiveCurve};
use ark_ff::{
biginteger::BigInteger320 as FqRepr, BigInteger, Field, PrimeField, SquareRootField,
UniformRand,

+ 2
- 4
curve-benches/benches/mnt4_753.rs

@ -1,11 +1,9 @@
use ark_curve_benches::*;
use rand::SeedableRng;
use rand_xorshift::XorShiftRng;
use std::ops::{AddAssign, MulAssign, SubAssign};
use ark_curve_benches::*;
use ark_ec::{
PairingEngine, ProjectiveCurve,
};
use ark_ec::{PairingEngine, ProjectiveCurve};
use ark_ff::{
biginteger::BigInteger768 as FqRepr, BigInteger, Field, PrimeField, SquareRootField,
UniformRand,

+ 2
- 4
curve-benches/benches/mnt6_298.rs

@ -1,11 +1,9 @@
use ark_curve_benches::*;
use rand::SeedableRng;
use rand_xorshift::XorShiftRng;
use std::ops::{AddAssign, MulAssign, SubAssign};
use ark_curve_benches::*;
use ark_ec::{
PairingEngine, ProjectiveCurve,
};
use ark_ec::{PairingEngine, ProjectiveCurve};
use ark_ff::{
biginteger::BigInteger320 as FqRepr, BigInteger, Field, PrimeField, SquareRootField,
UniformRand,

+ 2
- 4
curve-benches/benches/mnt6_753.rs

@ -1,11 +1,9 @@
use ark_curve_benches::*;
use rand::SeedableRng;
use rand_xorshift::XorShiftRng;
use std::ops::{AddAssign, MulAssign, SubAssign};
use ark_curve_benches::*;
use ark_ec::{
PairingEngine, ProjectiveCurve,
};
use ark_ec::{PairingEngine, ProjectiveCurve};
use ark_ff::{
biginteger::BigInteger768 as FqRepr, BigInteger, Field, PrimeField, SquareRootField,
UniformRand,

+ 0
- 8
curve-benches/src/macros/ec.rs

@ -6,7 +6,6 @@ macro_rules! ec_bench {
b.iter(|| <$projective>::rand(&mut rng));
}
fn mul_assign(b: &mut $crate::bencher::Bencher) {
const SAMPLES: usize = 1000;
@ -25,7 +24,6 @@ macro_rules! ec_bench {
});
}
fn add_assign(b: &mut $crate::bencher::Bencher) {
const SAMPLES: usize = 1000;
@ -44,7 +42,6 @@ macro_rules! ec_bench {
});
}
fn add_assign_mixed(b: &mut $crate::bencher::Bencher) {
const SAMPLES: usize = 1000;
@ -68,7 +65,6 @@ macro_rules! ec_bench {
});
}
fn double(b: &mut $crate::bencher::Bencher) {
const SAMPLES: usize = 1000;
@ -87,7 +83,6 @@ macro_rules! ec_bench {
});
}
fn deser(b: &mut $crate::bencher::Bencher) {
use ark_ec::ProjectiveCurve;
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
@ -114,7 +109,6 @@ macro_rules! ec_bench {
});
}
fn ser(b: &mut $crate::bencher::Bencher) {
use ark_ec::ProjectiveCurve;
use ark_serialize::CanonicalSerialize;
@ -137,7 +131,6 @@ macro_rules! ec_bench {
});
}
fn deser_unchecked(b: &mut $crate::bencher::Bencher) {
use ark_ec::ProjectiveCurve;
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
@ -164,7 +157,6 @@ macro_rules! ec_bench {
});
}
fn ser_unchecked(b: &mut $crate::bencher::Bencher) {
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
const SAMPLES: usize = 1000;

+ 29
- 34
curve-benches/src/macros/field.rs

@ -31,7 +31,7 @@ macro_rules! f_bench {
repr_div2,
into_repr,
from_repr,
);
);
}
use $modname::$modname;
};
@ -57,7 +57,7 @@ macro_rules! f_bench {
deser_unchecked,
// sqrt field stuff
sqrt,
);
);
}
use $modname::$modname;
};
@ -80,7 +80,7 @@ macro_rules! f_bench {
deser,
ser_unchecked,
deser_unchecked,
);
);
}
use $modname::$modname;
};
@ -107,7 +107,6 @@ macro_rules! field_common {
});
}
fn sub_assign(b: &mut $crate::bencher::Bencher) {
const SAMPLES: usize = 1000;
@ -142,7 +141,6 @@ macro_rules! field_common {
});
}
fn negate(b: &mut $crate::bencher::Bencher) {
const SAMPLES: usize = 1000;
@ -193,7 +191,6 @@ macro_rules! field_common {
});
}
fn inverse(b: &mut $crate::bencher::Bencher) {
const SAMPLES: usize = 1000;
@ -209,21 +206,22 @@ macro_rules! field_common {
});
}
fn deser(b: &mut $crate::bencher::Bencher) {
use ark_serialize::{CanonicalSerialize, CanonicalDeserialize};
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
const SAMPLES: usize = 1000;
let mut rng = XorShiftRng::seed_from_u64(1231275789u64);
let mut num_bytes = 0;
let v: Vec<_> = (0..SAMPLES).flat_map(|_| {
let mut bytes = Vec::with_capacity(1000);
let tmp = $f::rand(&mut rng);
tmp.serialize(&mut bytes).unwrap();
num_bytes = bytes.len();
bytes
}).collect();
let v: Vec<_> = (0..SAMPLES)
.flat_map(|_| {
let mut bytes = Vec::with_capacity(1000);
let tmp = $f::rand(&mut rng);
tmp.serialize(&mut bytes).unwrap();
num_bytes = bytes.len();
bytes
})
.collect();
let mut count = 0;
b.iter(|| {
@ -233,7 +231,6 @@ macro_rules! field_common {
});
}
fn ser(b: &mut $crate::bencher::Bencher) {
use ark_serialize::CanonicalSerialize;
const SAMPLES: usize = 1000;
@ -249,25 +246,25 @@ macro_rules! field_common {
count = (count + 1) % SAMPLES;
bytes.clear();
tmp.serialize(&mut bytes)
});
}
fn deser_unchecked(b: &mut $crate::bencher::Bencher) {
use ark_serialize::{CanonicalSerialize, CanonicalDeserialize};
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
const SAMPLES: usize = 1000;
let mut rng = XorShiftRng::seed_from_u64(1231275789u64);
let mut num_bytes = 0;
let v: Vec<_> = (0..SAMPLES).flat_map(|_| {
let mut bytes = Vec::with_capacity(1000);
let tmp = $f::rand(&mut rng);
tmp.serialize_unchecked(&mut bytes).unwrap();
num_bytes = bytes.len();
bytes
}).collect();
let v: Vec<_> = (0..SAMPLES)
.flat_map(|_| {
let mut bytes = Vec::with_capacity(1000);
let tmp = $f::rand(&mut rng);
tmp.serialize_unchecked(&mut bytes).unwrap();
num_bytes = bytes.len();
bytes
})
.collect();
let mut count = 0;
b.iter(|| {
@ -277,7 +274,6 @@ macro_rules! field_common {
});
}
fn ser_unchecked(b: &mut $crate::bencher::Bencher) {
use ark_serialize::CanonicalSerialize;
const SAMPLES: usize = 1000;
@ -293,10 +289,9 @@ macro_rules! field_common {
count = (count + 1) % SAMPLES;
bytes.clear();
tmp.serialize_unchecked(&mut bytes)
});
}
}
};
}
#[macro_export]
@ -313,7 +308,7 @@ macro_rules! sqrt {
tmp.square_in_place();
tmp
})
.collect();
.collect();
let mut count = 0;
b.iter(|| {
@ -321,7 +316,7 @@ macro_rules! sqrt {
v[count].sqrt()
});
}
}
};
}
#[macro_export]
@ -343,7 +338,7 @@ macro_rules! prime_field {
}
(tmp1, tmp2)
})
.collect();
.collect();
let mut count = 0;
b.iter(|| {
@ -369,7 +364,7 @@ macro_rules! prime_field {
}
(tmp1, tmp2)
})
.collect();
.collect();
let mut count = 0;
b.iter(|| {
@ -456,5 +451,5 @@ macro_rules! prime_field {
$f::from(v[count]);
});
}
}
};
}

+ 8
- 11
curve-benches/src/macros/pairing.rs

@ -14,16 +14,19 @@ macro_rules! pairing_bench {
.into_iter()
.zip(g2s)
.map(|(g1, g2)| (g1.into(), g2.into()))
.collect::<Vec<(<$curve as PairingEngine>::G1Prepared, <$curve as PairingEngine>::G2Prepared)>>();
.collect::<Vec<(
<$curve as PairingEngine>::G1Prepared,
<$curve as PairingEngine>::G2Prepared,
)>>();
let mut count = 0;
b.iter(|| {
let tmp = $curve::miller_loop(&[(prepared[count].0.clone(), prepared[count].1.clone())]);
let tmp =
$curve::miller_loop(&[(prepared[count].0.clone(), prepared[count].1.clone())]);
count = (count + 1) % SAMPLES;
tmp
});
}
fn final_exponentiation(b: &mut $crate::bencher::Bencher) {
const SAMPLES: usize = 1000;
@ -47,7 +50,6 @@ macro_rules! pairing_bench {
});
}
fn full_pairing(b: &mut $crate::bencher::Bencher) {
const SAMPLES: usize = 1000;
@ -65,11 +67,6 @@ macro_rules! pairing_bench {
});
}
$crate::benchmark_group!(
pairing,
miller_loop,
final_exponentiation,
full_pairing,
);
}
$crate::benchmark_group!(pairing, miller_loop, final_exponentiation, full_pairing,);
};
}

Loading…
Cancel
Save