mirror of
https://github.com/arnaucube/ark-curves-cherry-picked.git
synced 2026-01-09 07:21:30 +01:00
Fix the remaining curve and field tests (#118)
* push * push * cargo ready Co-authored-by: onewayfunc <onewayfunc@gmail.com>
This commit is contained in:
@@ -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 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);
|
||||
|
||||
@@ -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::{
|
||||
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};
|
||||
|
||||
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]
|
||||
fn test_fq_add() {
|
||||
|
||||
Reference in New Issue
Block a user