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.

55 lines
2.3 KiB

4 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. use crate::{Fq, Fr, FR_ONE};
  2. use ark_ec::{
  3. mnt4,
  4. models::{ModelParameters, SWModelParameters},
  5. };
  6. use ark_ff::field_new;
  7. pub type G1Affine = mnt4::G1Affine<crate::Parameters>;
  8. pub type G1Projective = mnt4::G1Projective<crate::Parameters>;
  9. pub type G1Prepared = mnt4::G1Prepared<crate::Parameters>;
  10. #[derive(Clone, Default, PartialEq, Eq)]
  11. pub struct Parameters;
  12. impl ModelParameters for Parameters {
  13. type BaseField = Fq;
  14. type ScalarField = Fr;
  15. }
  16. impl SWModelParameters for Parameters {
  17. /// COEFF_A = 2
  18. /// Reference: https://github.com/scipr-lab/libff/blob/c927821ebe02e0a24b5e0f9170cec5e211a35f08/libff/algebra/curves/mnt/mnt4/mnt4_init.cpp#L116
  19. #[rustfmt::skip]
  20. const COEFF_A: Fq = field_new!(Fq, "2");
  21. /// COEFF_B = 423894536526684178289416011533888240029318103673896002803341544124054745019340795360841685
  22. /// Reference: https://github.com/scipr-lab/libff/blob/c927821ebe02e0a24b5e0f9170cec5e211a35f08/libff/algebra/curves/mnt/mnt4/mnt4_init.cpp#L117
  23. #[rustfmt::skip]
  24. const COEFF_B: Fq = field_new!(Fq, "423894536526684178289416011533888240029318103673896002803341544124054745019340795360841685");
  25. /// COFACTOR = 1
  26. const COFACTOR: &'static [u64] = &[1];
  27. /// COFACTOR^(-1) mod r =
  28. /// 1
  29. #[rustfmt::skip]
  30. const COFACTOR_INV: Fr = FR_ONE;
  31. /// AFFINE_GENERATOR_COEFFS = (G1_GENERATOR_X, G1_GENERATOR_Y)
  32. const AFFINE_GENERATOR_COEFFS: (Self::BaseField, Self::BaseField) =
  33. (G1_GENERATOR_X, G1_GENERATOR_Y);
  34. }
  35. // Generator of G1
  36. // X = 60760244141852568949126569781626075788424196370144486719385562369396875346601926534016838,
  37. // Y = 363732850702582978263902770815145784459747722357071843971107674179038674942891694705904306,
  38. /// G1_GENERATOR_X
  39. /// Reference: https://github.com/scipr-lab/libff/blob/c927821ebe02e0a24b5e0f9170cec5e211a35f08/libff/algebra/curves/mnt/mnt4/mnt4_init.cpp#L137
  40. #[rustfmt::skip]
  41. pub const G1_GENERATOR_X: Fq = field_new!(Fq, "60760244141852568949126569781626075788424196370144486719385562369396875346601926534016838");
  42. /// G1_GENERATOR_Y
  43. /// Reference: https://github.com/scipr-lab/libff/blob/c927821ebe02e0a24b5e0f9170cec5e211a35f08/libff/algebra/curves/mnt/mnt4/mnt4_init.cpp#L138
  44. #[rustfmt::skip]
  45. pub const G1_GENERATOR_Y: Fq = field_new!(Fq, "363732850702582978263902770815145784459747722357071843971107674179038674942891694705904306");