You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.4 KiB

4 years ago
  1. use ark_ec::{AffineCurve, ProjectiveCurve};
  2. use ark_ff::test_rng;
  3. use rand::Rng;
  4. use crate::*;
  5. use ark_curve_tests::{curves::*, groups::*};
  6. #[test]
  7. fn test_projective_curve() {
  8. curve_tests::<EdwardsProjective>();
  9. edwards_tests::<EdwardsParameters>();
  10. }
  11. #[test]
  12. fn test_projective_group() {
  13. let mut rng = test_rng();
  14. let a = rng.gen();
  15. let b = rng.gen();
  16. for _i in 0..100 {
  17. group_test::<EdwardsProjective>(a, b);
  18. }
  19. }
  20. #[test]
  21. fn test_affine_group() {
  22. let mut rng = test_rng();
  23. let a: EdwardsAffine = rng.gen();
  24. let b: EdwardsAffine = rng.gen();
  25. for _i in 0..100 {
  26. group_test::<EdwardsAffine>(a, b);
  27. }
  28. }
  29. #[test]
  30. fn test_generator() {
  31. let generator = EdwardsAffine::prime_subgroup_generator();
  32. assert!(generator.is_on_curve());
  33. assert!(generator.is_in_correct_subgroup_assuming_on_curve());
  34. }
  35. #[test]
  36. fn test_conversion() {
  37. let mut rng = test_rng();
  38. let a: EdwardsAffine = rng.gen();
  39. let b: EdwardsAffine = rng.gen();
  40. let a_b = {
  41. use ark_ec::group::Group;
  42. (a + &b).double().double()
  43. };
  44. let a_b2 = (a.into_projective() + &b.into_projective())
  45. .double()
  46. .double();
  47. assert_eq!(a_b, a_b2.into_affine());
  48. assert_eq!(a_b.into_projective(), a_b2);
  49. }
  50. #[test]
  51. fn test_montgomery_conversion() {
  52. montgomery_conversion_test::<EdwardsParameters>();
  53. }