Simplify the field and curve tests using macros (#90)

* Simplify the field and curve tests using macros

* minor

* remove redundant code

Co-authored-by: weikeng <w.k@berkeley.edu>
This commit is contained in:
Yuncong Hu
2021-12-06 00:03:29 -08:00
committed by GitHub
parent c5547905d0
commit 677b4ae751
18 changed files with 128 additions and 2064 deletions

View File

@@ -1,46 +1,9 @@
use ark_ff::Field;
use ark_std::rand::Rng;
use ark_ff::{Field, One, SquareRootField, UniformRand, Zero};
use ark_std::test_rng;
use crate::*;
use ark_algebra_test_templates::{fields::*, generate_field_test};
use ark_algebra_test_templates::fields::*;
use core::ops::{AddAssign, MulAssign, SubAssign};
#[test]
fn test_fr() {
let mut rng = test_rng();
let a: Fr = rng.gen();
let b: Fr = rng.gen();
field_test(a, b);
sqrt_field_test(a);
primefield_test::<Fr>();
}
#[test]
fn test_fq() {
let mut rng = test_rng();
let a: Fq = rng.gen();
let b: Fq = rng.gen();
field_test(a, b);
sqrt_field_test(a);
primefield_test::<Fq>();
}
#[test]
fn test_fq2() {
let mut rng = test_rng();
let a: Fq2 = rng.gen();
let b: Fq2 = rng.gen();
field_test(a, b);
sqrt_field_test(a);
frobenius_test::<Fq2, _>(Fq::characteristic(), 13);
}
#[test]
fn test_fq4() {
let mut rng = test_rng();
let a: Fq4 = rng.gen();
let b: Fq4 = rng.gen();
field_test(a, b);
frobenius_test::<Fq4, _>(Fq::characteristic(), 13);
}
generate_field_test!(mnt4_753; fq2; fq4;);