Browse Source

Fix the remaining curve and field tests (#118)

* push

* push

* cargo ready

Co-authored-by: onewayfunc <onewayfunc@gmail.com>
cherry-pick
Weikeng Chen 2 years ago
committed by GitHub
parent
commit
dc555882cd
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 148 additions and 548 deletions
  1. +6
    -18
      bls12_377/src/curves/tests.rs
  2. +14
    -20
      bls12_377/src/fields/tests.rs
  3. +18
    -17
      curve-constraint-tests/src/lib.rs
  4. +2
    -21
      ed_on_bls12_377/src/curves/tests.rs
  5. +4
    -14
      ed_on_bls12_377/src/fields/tests.rs
  6. +3
    -61
      ed_on_bls12_381/src/curves/tests.rs
  7. +7
    -12
      ed_on_bls12_381/src/fields/tests.rs
  8. +2
    -61
      ed_on_bls12_381_bandersnatch/src/curves/tests.rs
  9. +7
    -12
      ed_on_bls12_381_bandersnatch/src/fields/tests.rs
  10. +2
    -53
      ed_on_bn254/src/curves/tests.rs
  11. +7
    -11
      ed_on_bn254/src/fields/tests.rs
  12. +2
    -21
      ed_on_cp6_782/src/curves/tests.rs
  13. +4
    -11
      ed_on_cp6_782/src/fields/tests.rs
  14. +2
    -14
      ed_on_mnt4_298/src/curves/tests.rs
  15. +4
    -11
      ed_on_mnt4_298/src/fields/tests.rs
  16. +2
    -21
      ed_on_mnt4_753/src/curves/tests.rs
  17. +4
    -11
      ed_on_mnt4_753/src/fields/tests.rs
  18. +5
    -13
      mnt4_298/src/curves/tests.rs
  19. +5
    -10
      mnt4_298/src/fields/tests.rs
  20. +5
    -13
      mnt4_753/src/curves/tests.rs
  21. +5
    -10
      mnt4_753/src/fields/tests.rs
  22. +5
    -13
      mnt6_298/src/curves/tests.rs
  23. +7
    -16
      mnt6_298/src/fields/tests.rs
  24. +5
    -13
      mnt6_753/src/curves/tests.rs
  25. +7
    -17
      mnt6_753/src/fields/tests.rs
  26. +3
    -16
      pallas/src/curves/tests.rs
  27. +4
    -11
      pallas/src/fields/tests.rs
  28. +3
    -16
      vesta/src/curves/tests.rs
  29. +4
    -11
      vesta/src/fields/tests.rs

+ 6
- 18
bls12_377/src/curves/tests.rs

@ -1,19 +1,7 @@
use ark_algebra_test_templates::{
curves::{curve_tests, edwards_tests, sw_tests},
generate_bilinearity_test, generate_g1_generator_raw_test, generate_g1_test, generate_g2_test,
msm::test_var_base_msm,
};
use ark_ec::{models::short_weierstrass::SWCurveConfig, AffineRepr, PairingEngine};
use ark_ff::{
fields::{Field, PrimeField},
One, Zero,
};
use ark_std::{rand::Rng, test_rng};
use core::ops::{AddAssign, MulAssign};
use crate::{Bls12_377, G1Projective, G2Projective};
use ark_algebra_test_templates::*;
use crate::{g1, g2, Bls12_377, Fq, Fq12, Fr, G1Affine, G1Projective, G2Affine, G2Projective};
generate_g1_test!(bls12_377; curve_tests; sw_tests; edwards_tests;);
generate_g2_test!(bls12_377; curve_tests; sw_tests;);
generate_bilinearity_test!(Bls12_377, Fq12);
generate_g1_generator_raw_test!(bls12_377, 1);
test_group!(g1; G1Projective; sw);
test_group!(g2; G2Projective; sw);
test_group!(pairing_output; ark_ec::pairing::PairingOutput<Bls12_377>; msm);
test_pairing!(pairing; crate::Bls12_377);

+ 14
- 20
bls12_377/src/fields/tests.rs

@ -1,22 +1,22 @@
use ark_algebra_test_templates::{
fields::*, generate_field_serialization_test, generate_field_test,
};
use ark_algebra_test_templates::*;
use ark_ff::{ use ark_ff::{
biginteger::{BigInt, BigInteger, BigInteger384}, biginteger::{BigInt, BigInteger, BigInteger384},
fields::{FftField, Field, Fp6Config, PrimeField}, fields::{FftField, Field, Fp6Config, PrimeField},
One, UniformRand, Zero,
Fp384, One, UniformRand, Zero,
}; };
use ark_serialize::{buffer_bit_byte_size, CanonicalSerialize};
use ark_std::{rand::Rng, test_rng};
use core::{
use ark_std::{
cmp::Ordering, cmp::Ordering,
ops::{AddAssign, MulAssign, SubAssign},
ops::{AddAssign, MulAssign},
test_rng,
}; };
use crate::{Fq, Fq12, Fq2, Fq6, Fq6Config, FqConfig, Fr, FrConfig};
use crate::{Fq, Fq12, Fq2, Fq6, Fq6Config, Fr};
generate_field_test!(bls12_377; fq2; fq6; fq12; mont(6, 4); );
generate_field_serialization_test!(bls12_377; fq2; fq6; fq12;);
test_field!(fr; Fr; mont_prime_field);
test_field!(fq; Fq; mont_prime_field);
test_field!(fq2; Fq2);
test_field!(fq6; Fq6);
test_field!(fq12; Fq12);
#[test] #[test]
fn test_fq_repr_from() { fn test_fq_repr_from() {
@ -85,7 +85,7 @@ fn test_fq_ordering() {
// BigInteger384's ordering is well-tested, but we still need to make sure the // BigInteger384's ordering is well-tested, but we still need to make sure the
// Fq elements aren't being compared in Montgomery form. // Fq elements aren't being compared in Montgomery form.
for i in 0..100u64 { for i in 0..100u64 {
assert!(Fq::from(BigInteger384::from(i + 1)) > Fq::from(BigInteger384::from(i)));
assert!(Fq::from(Fp384::from(i + 1)) > Fq::from(Fp384::from(i)));
} }
} }
@ -95,14 +95,8 @@ fn test_fq_legendre() {
assert_eq!(QuadraticResidue, Fq::one().legendre()); assert_eq!(QuadraticResidue, Fq::one().legendre());
assert_eq!(Zero, Fq::zero().legendre()); assert_eq!(Zero, Fq::zero().legendre());
assert_eq!(
QuadraticResidue,
Fq::from(BigInteger384::from(4u64)).legendre()
);
assert_eq!(
QuadraticNonResidue,
Fq::from(BigInteger384::from(5u64)).legendre()
);
assert_eq!(QuadraticResidue, Fq::from(Fp384::from(4u64)).legendre());
assert_eq!(QuadraticNonResidue, Fq::from(Fp384::from(5u64)).legendre());
} }
#[test] #[test]

+ 18
- 17
curve-constraint-tests/src/lib.rs

@ -225,7 +225,7 @@ pub mod fields {
pub mod curves { pub mod curves {
use ark_ec::{ use ark_ec::{
short_weierstrass::Projective as SWProjective, twisted_edwards::Projective as TEProjective, short_weierstrass::Projective as SWProjective, twisted_edwards::Projective as TEProjective,
ProjectiveCurve,
CurveGroup, Group,
}; };
use ark_ff::{BitIteratorLE, Field, One, PrimeField}; use ark_ff::{BitIteratorLE, Field, One, PrimeField};
use ark_relations::r1cs::{ConstraintSystem, SynthesisError}; use ark_relations::r1cs::{ConstraintSystem, SynthesisError};
@ -235,7 +235,7 @@ pub mod curves {
pub fn group_test<C, ConstraintF, GG>() -> Result<(), SynthesisError> pub fn group_test<C, ConstraintF, GG>() -> Result<(), SynthesisError>
where where
C: ProjectiveCurve,
C: CurveGroup,
ConstraintF: Field, ConstraintF: Field,
GG: CurveVar<C, ConstraintF>, GG: CurveVar<C, ConstraintF>,
for<'a> &'a GG: GroupOpsBounds<'a, C, GG>, for<'a> &'a GG: GroupOpsBounds<'a, C, GG>,
@ -512,18 +512,19 @@ pub mod curves {
} }
pub mod pairing { pub mod pairing {
use ark_ec::{PairingEngine, ProjectiveCurve};
use ark_ec::pairing::PairingOutput;
use ark_ec::{pairing::Pairing, CurveGroup};
use ark_ff::{BitIteratorLE, Field, PrimeField}; use ark_ff::{BitIteratorLE, Field, PrimeField};
use ark_r1cs_std::prelude::*; use ark_r1cs_std::prelude::*;
use ark_relations::r1cs::{ConstraintSystem, SynthesisError}; use ark_relations::r1cs::{ConstraintSystem, SynthesisError};
use ark_std::{test_rng, vec::Vec, UniformRand}; use ark_std::{test_rng, vec::Vec, UniformRand};
#[allow(dead_code)] #[allow(dead_code)]
pub fn bilinearity_test<E: PairingEngine, P: PairingVar<E>>() -> Result<(), SynthesisError>
pub fn bilinearity_test<E: Pairing, P: PairingVar<E>>() -> Result<(), SynthesisError>
where where
for<'a> &'a P::G1Var: GroupOpsBounds<'a, E::G1Projective, P::G1Var>,
for<'a> &'a P::G2Var: GroupOpsBounds<'a, E::G2Projective, P::G2Var>,
for<'a> &'a P::GTVar: FieldOpsBounds<'a, E::Fqk, P::GTVar>,
for<'a> &'a P::G1Var: GroupOpsBounds<'a, E::G1, P::G1Var>,
for<'a> &'a P::G2Var: GroupOpsBounds<'a, E::G2, P::G2Var>,
for<'a> &'a P::GTVar: FieldOpsBounds<'a, E::TargetField, P::GTVar>,
{ {
let modes = [ let modes = [
AllocationMode::Input, AllocationMode::Input,
@ -531,12 +532,12 @@ pub mod pairing {
AllocationMode::Constant, AllocationMode::Constant,
]; ];
for &mode in &modes { for &mode in &modes {
let cs = ConstraintSystem::<E::Fq>::new_ref();
let cs = ConstraintSystem::<<E::G1 as CurveGroup>::BaseField>::new_ref();
let mut rng = test_rng(); let mut rng = test_rng();
let a = E::G1Projective::rand(&mut rng);
let b = E::G2Projective::rand(&mut rng);
let s = E::Fr::rand(&mut rng);
let a = E::G1::rand(&mut rng);
let b = E::G2::rand(&mut rng);
let s = E::ScalarField::rand(&mut rng);
let mut sa = a; let mut sa = a;
sa *= s; sa *= s;
@ -578,7 +579,7 @@ pub mod pairing {
let mut ans_g = P::pairing(a_prep_g, b_prep_g)?; let mut ans_g = P::pairing(a_prep_g, b_prep_g)?;
let mut ans_n = E::pairing(a, b); let mut ans_n = E::pairing(a, b);
ans_n = ans_n.pow(s.into_bigint());
ans_n = PairingOutput(ans_n.0.pow(s.into_bigint()));
ans_g = ans_g.pow_le(&s_iter)?; ans_g = ans_g.pow_le(&s_iter)?;
(ans_g, ans_n) (ans_g, ans_n)
@ -587,12 +588,12 @@ pub mod pairing {
ans1_g.enforce_equal(&ans2_g)?; ans1_g.enforce_equal(&ans2_g)?;
ans2_g.enforce_equal(&ans3_g)?; ans2_g.enforce_equal(&ans3_g)?;
assert_eq!(ans1_g.value()?, ans1_n, "Failed native test 1");
assert_eq!(ans2_g.value()?, ans2_n, "Failed native test 2");
assert_eq!(ans3_g.value()?, ans3_n, "Failed native test 3");
assert_eq!(ans1_g.value()?, ans1_n.0, "Failed native test 1");
assert_eq!(ans2_g.value()?, ans2_n.0, "Failed native test 2");
assert_eq!(ans3_g.value()?, ans3_n.0, "Failed native test 3");
assert_eq!(ans1_n, ans2_n, "Failed ans1_native == ans2_native");
assert_eq!(ans2_n, ans3_n, "Failed ans2_native == ans3_native");
assert_eq!(ans1_n.0, ans2_n.0, "Failed ans1_native == ans2_native");
assert_eq!(ans2_n.0, ans3_n.0, "Failed ans2_native == ans3_native");
assert_eq!(ans1_g.value()?, ans3_g.value()?, "Failed ans1 == ans3"); assert_eq!(ans1_g.value()?, ans3_g.value()?, "Failed ans1 == ans3");
assert_eq!(ans1_g.value()?, ans2_g.value()?, "Failed ans1 == ans2"); assert_eq!(ans1_g.value()?, ans2_g.value()?, "Failed ans1 == ans2");
assert_eq!(ans2_g.value()?, ans3_g.value()?, "Failed ans2 == ans3"); assert_eq!(ans2_g.value()?, ans3_g.value()?, "Failed ans2 == ans3");

+ 2
- 21
ed_on_bls12_377/src/curves/tests.rs

@ -1,23 +1,4 @@
use ark_algebra_test_templates::curves::*;
use ark_ec::AffineRepr;
use crate::*; use crate::*;
use ark_algebra_test_templates::*;
#[test]
fn test_projective_curve() {
curve_tests::<EdwardsProjective>();
edwards_tests::<EdwardsParameters>();
}
#[test]
fn test_generator() {
let generator = EdwardsAffine::prime_subgroup_generator();
assert!(generator.is_on_curve());
assert!(generator.is_in_correct_subgroup_assuming_on_curve());
}
#[test]
fn test_montgomery_conversion() {
montgomery_conversion_test::<EdwardsParameters>();
}
test_group!(te; EdwardsProjective; te);

+ 4
- 14
ed_on_bls12_377/src/fields/tests.rs

@ -1,15 +1,5 @@
use ark_algebra_test_templates::{
fields::*, generate_field_serialization_test, generate_field_test,
};
use ark_ff::{
fields::{Field, PrimeField},
One, UniformRand, Zero,
};
use ark_serialize::{buffer_bit_byte_size, CanonicalSerialize};
use ark_std::{rand::Rng, test_rng};
use core::ops::{AddAssign, MulAssign, SubAssign};
use crate::{Fq, Fr};
use ark_algebra_test_templates::*;
use crate::{Fq, FqConfig, Fr, FrConfig};
generate_field_test!(ed_on_bls12_377; mont(4, 4); );
generate_field_serialization_test!(ed_on_bls12_377;);
test_field!(fr; Fr; mont_prime_field);
test_field!(fq; Fq; mont_prime_field);

+ 3
- 61
ed_on_bls12_381/src/curves/tests.rs

@ -1,63 +1,5 @@
use ark_algebra_test_templates::curves::*;
use ark_ec::{AffineRepr, ProjectiveCurve};
use ark_ff::Zero;
use ark_std::{ops::Mul, str::FromStr};
use crate::*; use crate::*;
use ark_algebra_test_templates::*;
#[test]
fn test_projective_curve() {
curve_tests::<EdwardsProjective>();
edwards_tests::<JubjubParameters>();
montgomery_conversion_test::<JubjubParameters>();
sw_tests::<JubjubParameters>();
}
#[test]
fn test_generator() {
// edward curve
let generator = EdwardsAffine::prime_subgroup_generator();
assert!(generator.is_on_curve());
assert!(generator.is_in_correct_subgroup_assuming_on_curve());
// weierstrass curve
let generator = SWAffine::prime_subgroup_generator();
assert!(generator.is_on_curve());
assert!(generator.is_in_correct_subgroup_assuming_on_curve());
}
#[test]
fn test_scalar_multiplication() {
let f1 = Fr::from_str(
"4691331900926794624732159288782398864809513177368446695323460897088210774597",
)
.unwrap();
let f2 = Fr::from_str(
"1305028103380024953477151132159456965337646722479526711736847301646466538045",
)
.unwrap();
let g = EdwardsAffine::from_str(
"(1158870117176967269192899343636553522971009777237254192973081388797299308391, \
36933624999642413792569726058244472742169727126562409632889593958355839948294)",
)
.unwrap();
let f1f2g = EdwardsAffine::from_str(
"(12638652891150111215300246576936483137884466359309882317048163368620501191944, \
38385045634663742820428406709832518145724237919360177362175527604556651918148)",
)
.unwrap();
assert!(!g.is_zero());
assert!(!f1f2g.is_zero());
let f1g = g.mul(f1).into_affine();
assert_eq!(g.mul(f1 * &f2).into_affine(), f1f2g);
assert_eq!(f1g.mul(f2).into_affine(), f1f2g);
}
#[test]
fn test_montgomery_conversion() {
montgomery_conversion_test::<JubjubParameters>();
}
test_group!(sw; SWProjective; sw);
test_group!(te; EdwardsProjective; te);

+ 7
- 12
ed_on_bls12_381/src/fields/tests.rs

@ -1,19 +1,14 @@
use ark_algebra_test_templates::{
fields::*, generate_field_serialization_test, generate_field_test,
};
use crate::{Fq, Fr};
use ark_algebra_test_templates::*;
use ark_ff::{ use ark_ff::{
biginteger::BigInteger256 as BigInteger, biginteger::BigInteger256 as BigInteger,
fields::{Field, LegendreSymbol::*, PrimeField},
One, UniformRand, Zero,
fields::{Field, LegendreSymbol::*},
One, Zero,
}; };
use ark_serialize::{buffer_bit_byte_size, CanonicalSerialize};
use ark_std::{rand::Rng, str::FromStr, test_rng};
use core::ops::{AddAssign, MulAssign, SubAssign};
use crate::{Fq, FqConfig, Fr, FrConfig};
use ark_std::str::FromStr;
generate_field_test!(ed_on_bls12_381; mont(4, 4); );
generate_field_serialization_test!(ed_on_bls12_381;);
test_field!(fr; Fr; mont_prime_field);
test_field!(fq; Fq; mont_prime_field);
#[test] #[test]
fn test_fq_add() { fn test_fq_add() {

+ 2
- 61
ed_on_bls12_381_bandersnatch/src/curves/tests.rs

@ -1,63 +1,4 @@
use ark_algebra_test_templates::curves::*;
use ark_ec::{AffineRepr, ProjectiveCurve};
use ark_ff::Zero;
use ark_std::{ops::Mul, str::FromStr};
use crate::*; use crate::*;
use ark_algebra_test_templates::*;
#[test]
fn test_projective_curve() {
curve_tests::<EdwardsProjective>();
edwards_tests::<BandersnatchParameters>();
montgomery_conversion_test::<BandersnatchParameters>();
sw_tests::<BandersnatchParameters>();
}
#[test]
fn test_generator() {
// edward curve
let generator = EdwardsAffine::prime_subgroup_generator();
assert!(generator.is_on_curve());
assert!(generator.is_in_correct_subgroup_assuming_on_curve());
// weierstrass curve
let generator = SWAffine::prime_subgroup_generator();
assert!(generator.is_on_curve());
assert!(generator.is_in_correct_subgroup_assuming_on_curve());
}
#[test]
fn test_scalar_multiplication() {
let f1 = Fr::from_str(
"4257185345094557079734489188109952172285839137338142340240392707284963971010",
)
.unwrap();
let f2 = Fr::from_str(
"1617998875791656082457755819308421023664764572929977389209373068350490665160",
)
.unwrap();
let g = EdwardsAffine::from_str(
"(29627151942733444043031429156003786749302466371339015363120350521834195802525, \
27488387519748396681411951718153463804682561779047093991696427532072116857978)",
)
.unwrap();
let f1f2g = EdwardsAffine::from_str(
"(16530491029447613915334753043669938793793987372416328257719459807614119987301, \
42481140308370805476764840229335460092474682686441442216596889726548353970772)",
)
.unwrap();
assert!(!g.is_zero());
assert!(!f1f2g.is_zero());
let f1g = g.mul(f1).into_affine();
assert_eq!(g.mul(f1 * &f2).into_affine(), f1f2g);
assert_eq!(f1g.mul(f2).into_affine(), f1f2g);
}
#[test]
fn test_montgomery_conversion() {
montgomery_conversion_test::<BandersnatchParameters>();
}
test_group!(te; EdwardsProjective; te);

+ 7
- 12
ed_on_bls12_381_bandersnatch/src/fields/tests.rs

@ -1,19 +1,14 @@
use ark_algebra_test_templates::{
fields::*, generate_field_serialization_test, generate_field_test,
};
use crate::{Fq, Fr};
use ark_algebra_test_templates::*;
use ark_ff::{ use ark_ff::{
biginteger::BigInteger256 as BigInteger, biginteger::BigInteger256 as BigInteger,
fields::{Field, LegendreSymbol::*, PrimeField},
One, UniformRand, Zero,
fields::{Field, LegendreSymbol::*},
One, Zero,
}; };
use ark_serialize::{buffer_bit_byte_size, CanonicalSerialize};
use ark_std::{rand::Rng, str::FromStr, test_rng};
use core::ops::{AddAssign, MulAssign, SubAssign};
use crate::{Fq, FqConfig, Fr, FrConfig};
use ark_std::str::FromStr;
generate_field_test!(ed_on_bls12_381_bandersnatch; mont(4, 4); );
generate_field_serialization_test!(ed_on_bls12_381_bandersnatch;);
test_field!(fr; Fr; mont_prime_field);
test_field!(fq; Fq; mont_prime_field);
#[test] #[test]
fn test_fq_add() { fn test_fq_add() {

+ 2
- 53
ed_on_bn254/src/curves/tests.rs

@ -1,55 +1,4 @@
use ark_algebra_test_templates::curves::*;
use ark_ec::{AffineRepr, ProjectiveCurve};
use ark_ff::Zero;
use ark_std::{ops::Mul, str::FromStr};
use crate::*; use crate::*;
use ark_algebra_test_templates::*;
#[test]
fn test_projective_curve() {
curve_tests::<EdwardsProjective>();
edwards_tests::<EdwardsParameters>();
}
#[test]
fn test_generator() {
let generator = EdwardsAffine::prime_subgroup_generator();
assert!(generator.is_on_curve());
assert!(generator.is_in_correct_subgroup_assuming_on_curve());
}
#[test]
fn test_scalar_multiplication() {
let f1 = Fr::from_str(
"4691331900926794624732159288782398864809513177368446695323460897088210774597",
)
.unwrap();
let f2 = Fr::from_str(
"1305028103380024953477151132159456965337646722479526711736847301646466538045",
)
.unwrap();
let g = EdwardsAffine::from_str(
"(15863623088992515880085393097393553694825975317405843389771115419751650972659, \
16950150798460657717958625567821834550301663161624707787222815936182638968203)",
)
.unwrap();
let f1f2g = EdwardsAffine::from_str(
"(20773645713088336957786354488799297695596635653208610804806657050882264237947, \
19987327827845206670850937090314462639017692512983955920885166014935289314257)",
)
.unwrap();
assert!(!g.is_zero());
assert!(!f1f2g.is_zero());
let f1g = g.mul(f1).into_affine();
assert_eq!(g.mul(f1 * &f2).into_affine(), f1f2g);
assert_eq!(f1g.mul(f2).into_affine(), f1f2g);
}
#[test]
fn test_montgomery_conversion() {
montgomery_conversion_test::<EdwardsParameters>();
}
test_group!(te; EdwardsProjective; te);

+ 7
- 11
ed_on_bn254/src/fields/tests.rs

@ -1,19 +1,15 @@
use ark_algebra_test_templates::{
fields::*, generate_field_serialization_test, generate_field_test,
};
use ark_algebra_test_templates::*;
use ark_ff::{ use ark_ff::{
biginteger::BigInteger256 as BigInteger, biginteger::BigInteger256 as BigInteger,
fields::{Field, LegendreSymbol::*, PrimeField},
One, UniformRand, Zero,
fields::{Field, LegendreSymbol::*},
One, Zero,
}; };
use ark_serialize::{buffer_bit_byte_size, CanonicalSerialize};
use ark_std::{rand::Rng, str::FromStr, test_rng};
use core::ops::{AddAssign, MulAssign, SubAssign};
use ark_std::str::FromStr;
use crate::{Fq, FqConfig, Fr, FrConfig};
use crate::{Fq, Fr};
generate_field_test!(ed_on_bn254; mont(4, 4); );
generate_field_serialization_test!(ed_on_bn254;);
test_field!(fr; Fr; mont_prime_field);
test_field!(fq; Fq; mont_prime_field);
#[test] #[test]
fn test_fq_add() { fn test_fq_add() {

+ 2
- 21
ed_on_cp6_782/src/curves/tests.rs

@ -1,23 +1,4 @@
use ark_algebra_test_templates::curves::*;
use ark_ec::AffineRepr;
use crate::*; use crate::*;
use ark_algebra_test_templates::*;
#[test]
fn test_projective_curve() {
curve_tests::<EdwardsProjective>();
edwards_tests::<EdwardsParameters>();
}
#[test]
fn test_generator() {
let generator = EdwardsAffine::prime_subgroup_generator();
assert!(generator.is_on_curve());
assert!(generator.is_in_correct_subgroup_assuming_on_curve());
}
#[test]
fn test_montgomery_conversion() {
montgomery_conversion_test::<EdwardsParameters>();
}
test_group!(te; EdwardsProjective; te);

+ 4
- 11
ed_on_cp6_782/src/fields/tests.rs

@ -1,12 +1,5 @@
use ark_algebra_test_templates::{
fields::*, generate_field_serialization_test, generate_field_test,
};
use ark_ff::{Field, One, PrimeField, UniformRand, Zero};
use ark_serialize::{buffer_bit_byte_size, CanonicalSerialize};
use ark_std::{rand::Rng, test_rng};
use core::ops::{AddAssign, MulAssign, SubAssign};
use crate::{Fq, Fr};
use ark_algebra_test_templates::*;
use crate::{Fq, FqConfig, Fr, FrConfig};
generate_field_test!(ed_on_cp6_782; mont(6, 6); );
generate_field_serialization_test!(ed_on_cp6_782;);
test_field!(fr; Fr; mont_prime_field);
test_field!(fq; Fq; mont_prime_field);

+ 2
- 14
ed_on_mnt4_298/src/curves/tests.rs

@ -1,16 +1,4 @@
use ark_algebra_test_templates::curves::*;
use ark_ec::AffineRepr;
use crate::*; use crate::*;
use ark_algebra_test_templates::*;
#[test]
fn test_generator() {
let generator = EdwardsAffine::prime_subgroup_generator();
assert!(generator.is_on_curve());
assert!(generator.is_in_correct_subgroup_assuming_on_curve());
}
#[test]
fn test_montgomery_conversion() {
montgomery_conversion_test::<EdwardsParameters>();
}
test_group!(te; EdwardsProjective; te);

+ 4
- 11
ed_on_mnt4_298/src/fields/tests.rs

@ -1,12 +1,5 @@
use ark_algebra_test_templates::{
fields::*, generate_field_serialization_test, generate_field_test,
};
use ark_ff::{Field, One, PrimeField, UniformRand, Zero};
use ark_serialize::{buffer_bit_byte_size, CanonicalSerialize};
use ark_std::{rand::Rng, test_rng};
use core::ops::{AddAssign, MulAssign, SubAssign};
use crate::{Fq, Fr};
use ark_algebra_test_templates::*;
use crate::{Fq, FqConfig, Fr, FrConfig};
generate_field_test!(ed_on_mnt4_298; mont(5, 5); );
generate_field_serialization_test!(ed_on_mnt4_298;);
test_field!(fr; Fr; mont_prime_field);
test_field!(fq; Fq; mont_prime_field);

+ 2
- 21
ed_on_mnt4_753/src/curves/tests.rs

@ -1,23 +1,4 @@
use ark_algebra_test_templates::curves::*;
use ark_ec::AffineRepr;
use crate::*; use crate::*;
use ark_algebra_test_templates::*;
#[test]
fn test_projective_curve() {
curve_tests::<EdwardsProjective>();
edwards_tests::<EdwardsParameters>();
}
#[test]
fn test_generator() {
let generator = EdwardsAffine::prime_subgroup_generator();
assert!(generator.is_on_curve());
assert!(generator.is_in_correct_subgroup_assuming_on_curve());
}
#[test]
fn test_montgomery_conversion() {
montgomery_conversion_test::<EdwardsParameters>();
}
test_group!(te; EdwardsProjective; te);

+ 4
- 11
ed_on_mnt4_753/src/fields/tests.rs

@ -1,12 +1,5 @@
use ark_algebra_test_templates::{
fields::*, generate_field_serialization_test, generate_field_test,
};
use ark_ff::{Field, One, PrimeField, UniformRand, Zero};
use ark_serialize::{buffer_bit_byte_size, CanonicalSerialize};
use ark_std::{rand::Rng, test_rng};
use core::ops::{AddAssign, MulAssign, SubAssign};
use crate::{Fq, Fr};
use ark_algebra_test_templates::*;
use crate::{Fq, FqConfig, Fr, FrConfig};
generate_field_test!(ed_on_mnt4_753; mont(12, 12); );
generate_field_serialization_test!(ed_on_mnt4_753;);
test_field!(fr; Fr; mont_prime_field);
test_field!(fq; Fq; mont_prime_field);

+ 5
- 13
mnt4_298/src/curves/tests.rs

@ -1,15 +1,7 @@
use ark_algebra_test_templates::{
curves::*, generate_bilinearity_test, generate_g1_test, generate_g2_test,
generate_product_of_pairings_test, msm::*,
};
use ark_ec::{AffineRepr, PairingEngine, ProjectiveCurve};
use ark_ff::{Field, One, PrimeField, UniformRand};
use ark_std::{rand::Rng, test_rng};
use core::ops::MulAssign;
use crate::*; use crate::*;
use ark_algebra_test_templates::*;
generate_g1_test!(mnt4_298; curve_tests; sw_tests;);
generate_g2_test!(mnt4_298; curve_tests; sw_tests;);
generate_bilinearity_test!(MNT4_298, Fq4);
generate_product_of_pairings_test!(MNT4_298);
test_group!(g1; G1Projective; sw);
test_group!(g2; G2Projective; sw);
test_group!(pairing_output; ark_ec::pairing::PairingOutput<MNT4_298>; msm);
test_pairing!(pairing; crate::MNT4_298);

+ 5
- 10
mnt4_298/src/fields/tests.rs

@ -1,12 +1,7 @@
use ark_algebra_test_templates::{
fields::*, generate_field_serialization_test, generate_field_test,
};
use ark_ff::{Field, One, PrimeField, UniformRand, Zero};
use ark_serialize::{buffer_bit_byte_size, CanonicalSerialize};
use ark_std::{rand::Rng, test_rng};
use core::ops::{AddAssign, MulAssign, SubAssign};
use crate::*; use crate::*;
use ark_algebra_test_templates::*;
generate_field_test!(mnt4_298; fq2; fq4; mont(5, 5); );
generate_field_serialization_test!(mnt4_298;);
test_field!(fr; Fr; mont_prime_field);
test_field!(fq; Fq; mont_prime_field);
test_field!(fq2; Fq2);
test_field!(fq4; Fq4);

+ 5
- 13
mnt4_753/src/curves/tests.rs

@ -1,15 +1,7 @@
use ark_algebra_test_templates::{
curves::*, generate_bilinearity_test, generate_g1_test, generate_g2_test,
generate_product_of_pairings_test, msm::*,
};
use ark_ec::{AffineRepr, PairingEngine, ProjectiveCurve};
use ark_ff::{Field, One, PrimeField, UniformRand};
use ark_std::{rand::Rng, test_rng};
use core::ops::MulAssign;
use crate::*; use crate::*;
use ark_algebra_test_templates::*;
generate_g1_test!(mnt4_753; curve_tests; sw_tests;);
generate_g2_test!(mnt4_753; curve_tests; sw_tests;);
generate_bilinearity_test!(MNT4_753, Fq4);
generate_product_of_pairings_test!(MNT4_753);
test_group!(g1; G1Projective; sw);
test_group!(g2; G2Projective; sw);
test_group!(pairing_output; ark_ec::pairing::PairingOutput<MNT4_753>; msm);
test_pairing!(pairing; crate::MNT4_753);

+ 5
- 10
mnt4_753/src/fields/tests.rs

@ -1,12 +1,7 @@
use ark_algebra_test_templates::{
fields::*, generate_field_serialization_test, generate_field_test,
};
use ark_ff::{Field, One, PrimeField, UniformRand, Zero};
use ark_serialize::{buffer_bit_byte_size, CanonicalSerialize};
use ark_std::{rand::Rng, test_rng};
use core::ops::{AddAssign, MulAssign, SubAssign};
use crate::*; use crate::*;
use ark_algebra_test_templates::*;
generate_field_test!(mnt4_753; fq2; fq4; mont(12, 12); );
generate_field_serialization_test!(mnt4_753;);
test_field!(fr; Fr; mont_prime_field);
test_field!(fq; Fq; mont_prime_field);
test_field!(fq2; Fq2);
test_field!(fq4; Fq4);

+ 5
- 13
mnt6_298/src/curves/tests.rs

@ -1,15 +1,7 @@
use ark_algebra_test_templates::{
curves::*, generate_bilinearity_test, generate_g1_test, generate_g2_test,
generate_product_of_pairings_test, msm::*,
};
use ark_ec::{AffineRepr, PairingEngine, ProjectiveCurve};
use ark_ff::{Field, One, PrimeField, UniformRand};
use ark_std::{rand::Rng, test_rng};
use core::ops::MulAssign;
use crate::*; use crate::*;
use ark_algebra_test_templates::*;
generate_g1_test!(mnt6_298; curve_tests; sw_tests;);
generate_g2_test!(mnt6_298; curve_tests; sw_tests;);
generate_bilinearity_test!(MNT6_298, Fq6);
generate_product_of_pairings_test!(MNT6_298);
test_group!(g1; G1Projective; sw);
test_group!(g2; G2Projective; sw);
test_group!(pairing_output; ark_ec::pairing::PairingOutput<MNT6_298>; msm);
test_pairing!(pairing; crate::MNT6_298);

+ 7
- 16
mnt6_298/src/fields/tests.rs

@ -1,27 +1,18 @@
use ark_algebra_test_templates::{
fields::*, generate_field_serialization_test, generate_field_test,
};
use ark_ff::{
fields::{models::fp6_2over3::*, quadratic_extension::QuadExtConfig},
Field, PrimeField,
};
use ark_serialize::{buffer_bit_byte_size, CanonicalSerialize};
use ark_std::{rand::Rng, test_rng, One, UniformRand, Zero};
use core::ops::{AddAssign, MulAssign, SubAssign};
use ark_algebra_test_templates::*;
use ark_ff::fields::{models::fp6_2over3::*, quadratic_extension::QuadExtConfig};
use ark_std::{rand::Rng, test_rng};
use crate::*; use crate::*;
generate_field_test!(mnt6_298; fq3; fq6_2_on_3; mont(5, 5); );
generate_field_serialization_test!(mnt6_298;);
test_field!(fr; Fr; mont_prime_field);
test_field!(fq; Fq; mont_prime_field);
test_field!(fq3; Fq3);
test_field!(fq6; Fq6);
#[test] #[test]
fn test_fq3_more() { fn test_fq3_more() {
let mut rng = test_rng(); let mut rng = test_rng();
let a: Fq3 = rng.gen(); let a: Fq3 = rng.gen();
let b: Fq3 = rng.gen();
field_test(a, b);
sqrt_field_test(a);
frobenius_test::<Fq3, _>(Fq::characteristic(), 13);
assert_eq!( assert_eq!(
a * Fq6Config::NONRESIDUE, a * Fq6Config::NONRESIDUE,
<Fp6ConfigWrapper<Fq6Config>>::mul_base_field_by_nonresidue(&a) <Fp6ConfigWrapper<Fq6Config>>::mul_base_field_by_nonresidue(&a)

+ 5
- 13
mnt6_753/src/curves/tests.rs

@ -1,15 +1,7 @@
use ark_algebra_test_templates::{
curves::*, generate_bilinearity_test, generate_g1_test, generate_g2_test,
generate_product_of_pairings_test, msm::*,
};
use ark_ec::{AffineRepr, PairingEngine, ProjectiveCurve};
use ark_ff::{Field, One, PrimeField, UniformRand};
use ark_std::{rand::Rng, test_rng};
use core::ops::MulAssign;
use crate::*; use crate::*;
use ark_algebra_test_templates::*;
generate_g1_test!(mnt6_753; curve_tests; sw_tests;);
generate_g2_test!(mnt6_753; curve_tests; sw_tests;);
generate_bilinearity_test!(MNT6_753, Fq6);
generate_product_of_pairings_test!(MNT6_753);
test_group!(g1; G1Projective; sw);
test_group!(g2; G2Projective; sw);
test_group!(pairing_output; ark_ec::pairing::PairingOutput<MNT6_753>; msm);
test_pairing!(pairing; crate::MNT6_753);

+ 7
- 17
mnt6_753/src/fields/tests.rs

@ -1,27 +1,17 @@
use ark_algebra_test_templates::{
fields::*, generate_field_serialization_test, generate_field_test,
};
use ark_ff::{
fields::{models::fp6_2over3::*, quadratic_extension::QuadExtConfig},
Field, PrimeField,
};
use ark_serialize::{buffer_bit_byte_size, CanonicalSerialize};
use ark_std::{rand::Rng, test_rng, One, UniformRand, Zero};
use core::ops::{AddAssign, MulAssign, SubAssign};
use crate::*; use crate::*;
use ark_algebra_test_templates::*;
use ark_ff::fields::{models::fp6_2over3::*, quadratic_extension::QuadExtConfig};
use ark_std::{rand::Rng, test_rng};
generate_field_test!(mnt6_753; fq3; fq6_2_on_3; mont(12, 12); );
generate_field_serialization_test!(mnt6_753;);
test_field!(fr; Fr; mont_prime_field);
test_field!(fq; Fq; mont_prime_field);
test_field!(fq3; Fq3);
test_field!(fq6; Fq6);
#[test] #[test]
fn test_fq3_more() { fn test_fq3_more() {
let mut rng = test_rng(); let mut rng = test_rng();
let a: Fq3 = rng.gen(); let a: Fq3 = rng.gen();
let b: Fq3 = rng.gen();
field_test(a, b);
sqrt_field_test(a);
frobenius_test::<Fq3, _>(Fq::characteristic(), 13);
assert_eq!( assert_eq!(
a * Fq6Config::NONRESIDUE, a * Fq6Config::NONRESIDUE,
<Fp6ConfigWrapper<Fq6Config>>::mul_base_field_by_nonresidue(&a) <Fp6ConfigWrapper<Fq6Config>>::mul_base_field_by_nonresidue(&a)

+ 3
- 16
pallas/src/curves/tests.rs

@ -1,17 +1,4 @@
use ark_algebra_test_templates::curves::{curve_tests, sw_tests};
use ark_ec::AffineRepr;
use crate::Projective;
use ark_algebra_test_templates::*;
use crate::{Affine, PallasParameters, Projective};
#[test]
fn test_projective_curve() {
curve_tests::<Projective>();
sw_tests::<PallasParameters>();
}
#[test]
fn test_generator() {
let generator = Affine::prime_subgroup_generator();
assert!(generator.is_on_curve());
assert!(generator.is_in_correct_subgroup_assuming_on_curve());
}
test_group!(g1; Projective; sw);

+ 4
- 11
pallas/src/fields/tests.rs

@ -1,12 +1,5 @@
use ark_algebra_test_templates::{
fields::*, generate_field_serialization_test, generate_field_test,
};
use ark_ff::{Field, One, PrimeField, UniformRand, Zero};
use ark_serialize::{buffer_bit_byte_size, CanonicalSerialize};
use ark_std::{rand::Rng, test_rng};
use core::ops::{AddAssign, MulAssign, SubAssign};
use crate::{Fq, Fr};
use ark_algebra_test_templates::*;
use crate::{Fq, FqConfig, Fr, FrConfig};
generate_field_test!(pallas; mont(4, 4); );
generate_field_serialization_test!(pallas;);
test_field!(fr; Fr; mont_prime_field);
test_field!(fq; Fq; mont_prime_field);

+ 3
- 16
vesta/src/curves/tests.rs

@ -1,17 +1,4 @@
use ark_algebra_test_templates::curves::{curve_tests, sw_tests};
use ark_ec::AffineRepr;
use crate::Projective;
use ark_algebra_test_templates::*;
use crate::{Affine, Projective, VestaParameters};
#[test]
fn test_projective_curve() {
curve_tests::<Projective>();
sw_tests::<VestaParameters>();
}
#[test]
fn test_generator() {
let generator = Affine::prime_subgroup_generator();
assert!(generator.is_on_curve());
assert!(generator.is_in_correct_subgroup_assuming_on_curve());
}
test_group!(g1; Projective; sw);

+ 4
- 11
vesta/src/fields/tests.rs

@ -1,12 +1,5 @@
use ark_algebra_test_templates::{
fields::*, generate_field_serialization_test, generate_field_test,
};
use ark_ff::{Field, One, PrimeField, UniformRand, Zero};
use ark_serialize::{buffer_bit_byte_size, CanonicalSerialize};
use ark_std::{rand::Rng, test_rng};
use core::ops::{AddAssign, MulAssign, SubAssign};
use crate::{Fq, Fr};
use ark_algebra_test_templates::*;
use crate::{Fq, FqConfig, Fr, FrConfig};
generate_field_test!(vesta; mont(4, 4); );
generate_field_serialization_test!(vesta;);
test_field!(fr; Fr; mont_prime_field);
test_field!(fq; Fq; mont_prime_field);

Loading…
Cancel
Save