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.

74 lines
2.9 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. use ark_ec::models::{ModelParameters, SWModelParameters};
  2. use ark_ff::{field_new, Zero};
  3. use crate::{Fq, Fq2, Fr};
  4. #[derive(Clone, Default, PartialEq, Eq)]
  5. pub struct Parameters;
  6. impl ModelParameters for Parameters {
  7. type BaseField = Fq2;
  8. type ScalarField = Fr;
  9. }
  10. impl SWModelParameters for Parameters {
  11. /// COEFF_A = [0, 0]
  12. #[rustfmt::skip]
  13. const COEFF_A: Fq2 = field_new!(Fq2, field_new!(Fq, "0"), field_new!(Fq, "0"));
  14. /// COEFF_B = 3/(u+9)
  15. /// = (19485874751759354771024239261021720505790618469301721065564631296452457478373, 266929791119991161246907387137283842545076965332900288569378510910307636690)
  16. #[rustfmt::skip]
  17. const COEFF_B: Fq2 = field_new!(Fq2,
  18. field_new!(Fq, "19485874751759354771024239261021720505790618469301721065564631296452457478373"),
  19. field_new!(Fq, "266929791119991161246907387137283842545076965332900288569378510910307636690"),
  20. );
  21. /// COFACTOR = (36 * X^4) + (36 * X^3) + (30 * X^2) + 6*X + 1
  22. /// = 21888242871839275222246405745257275088844257914179612981679871602714643921549
  23. #[rustfmt::skip]
  24. const COFACTOR: &'static [u64] = &[
  25. 0x345f2299c0f9fa8d,
  26. 0x06ceecda572a2489,
  27. 0xb85045b68181585e,
  28. 0x30644e72e131a029,
  29. ];
  30. /// COFACTOR_INV = COFACTOR^{-1} mod r
  31. #[rustfmt::skip]
  32. const COFACTOR_INV: Fr = field_new!(Fr, "10944121435919637613327163357776759465618812564592884533313067514031822496649");
  33. /// AFFINE_GENERATOR_COEFFS = (G2_GENERATOR_X, G2_GENERATOR_Y)
  34. const AFFINE_GENERATOR_COEFFS: (Self::BaseField, Self::BaseField) =
  35. (G2_GENERATOR_X, G2_GENERATOR_Y);
  36. #[inline(always)]
  37. fn mul_by_a(_: &Self::BaseField) -> Self::BaseField {
  38. Self::BaseField::zero()
  39. }
  40. }
  41. #[rustfmt::skip]
  42. pub const G2_GENERATOR_X: Fq2 = field_new!(Fq2, G2_GENERATOR_X_C0, G2_GENERATOR_X_C1);
  43. #[rustfmt::skip]
  44. pub const G2_GENERATOR_Y: Fq2 = field_new!(Fq2, G2_GENERATOR_Y_C0, G2_GENERATOR_Y_C1);
  45. /// G2_GENERATOR_X_C0 =
  46. /// 10857046999023057135944570762232829481370756359578518086990519993285655852781
  47. #[rustfmt::skip]
  48. pub const G2_GENERATOR_X_C0: Fq = field_new!(Fq, "10857046999023057135944570762232829481370756359578518086990519993285655852781");
  49. /// G2_GENERATOR_X_C1 =
  50. /// 11559732032986387107991004021392285783925812861821192530917403151452391805634
  51. #[rustfmt::skip]
  52. pub const G2_GENERATOR_X_C1: Fq = field_new!(Fq, "11559732032986387107991004021392285783925812861821192530917403151452391805634");
  53. /// G2_GENERATOR_Y_C0 =
  54. /// 8495653923123431417604973247489272438418190587263600148770280649306958101930
  55. #[rustfmt::skip]
  56. pub const G2_GENERATOR_Y_C0: Fq = field_new!(Fq, "8495653923123431417604973247489272438418190587263600148770280649306958101930");
  57. /// G2_GENERATOR_Y_C1 =
  58. /// 4082367875863433681332203403145435568316851327593401208105741076214120093531
  59. #[rustfmt::skip]
  60. pub const G2_GENERATOR_Y_C1: Fq = field_new!(Fq, "4082367875863433681332203403145435568316851327593401208105741076214120093531");