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.

99 lines
2.3 KiB

4 years ago
  1. use ark_ff::{
  2. biginteger::BigInteger320 as BigInteger,
  3. fields::{FftParameters, Fp320, Fp320Parameters, FpParameters},
  4. };
  5. pub type Fr = Fp320<FrParameters>;
  6. pub struct FrParameters;
  7. impl Fp320Parameters for FrParameters {}
  8. impl FftParameters for FrParameters {
  9. type BigInt = BigInteger;
  10. const TWO_ADICITY: u32 = 34;
  11. #[rustfmt::skip]
  12. const TWO_ADIC_ROOT_OF_UNITY: BigInteger = BigInteger([
  13. 0x818b361df1af7be4,
  14. 0x2ae2750d46a53957,
  15. 0x5784a8fe792c5f8a,
  16. 0xf9bd39c0cdcf1bb6,
  17. 0x6a24a0f8a8,
  18. ]);
  19. }
  20. impl FpParameters for FrParameters {
  21. /// MODULUS = 475922286169261325753349249653048451545124878552823515553267735739164647307408490559963137
  22. #[rustfmt::skip]
  23. const MODULUS: BigInteger = BigInteger([
  24. 0xbb4334a400000001,
  25. 0xfb494c07925d6ad3,
  26. 0xcaeec9635cf44194,
  27. 0xa266249da7b0548e,
  28. 0x3bcf7bcd473,
  29. ]);
  30. const MODULUS_BITS: u32 = 298;
  31. const CAPACITY: u32 = Self::MODULUS_BITS - 1;
  32. const REPR_SHAVE_BITS: u32 = 22;
  33. #[rustfmt::skip]
  34. const R: BigInteger = BigInteger([
  35. 0xc3177aefffbb845c,
  36. 0x9b80c702f9961788,
  37. 0xc5df8dcdac70a85a,
  38. 0x29184098647b5197,
  39. 0x1c1223d33c3,
  40. ]);
  41. #[rustfmt::skip]
  42. const R2: BigInteger = BigInteger([
  43. 0x465a743c68e0596b,
  44. 0x34f9102adb68371,
  45. 0x4bbd6dcf1e3a8386,
  46. 0x2ff00dced8e4b6d,
  47. 0x149bb44a342,
  48. ]);
  49. const INV: u64 = 0xbb4334a3ffffffff;
  50. #[rustfmt::skip]
  51. const GENERATOR: BigInteger = BigInteger([
  52. 0xb1ddfacffd532b94,
  53. 0x25e295ff76674008,
  54. 0x8f00647b48958d36,
  55. 0x1159f37d4e0fddb2,
  56. 0x2977770b3d1,
  57. ]);
  58. #[rustfmt::skip]
  59. const MODULUS_MINUS_ONE_DIV_TWO: BigInteger = BigInteger([
  60. 0xdda19a5200000000,
  61. 0x7da4a603c92eb569,
  62. 0x657764b1ae7a20ca,
  63. 0xd133124ed3d82a47,
  64. 0x1de7bde6a39,
  65. ]);
  66. // T and T_MINUS_ONE_DIV_TWO, where MODULUS - 1 = 2^S * T
  67. #[rustfmt::skip]
  68. const T: BigInteger = BigInteger([
  69. 0xe4975ab4eed0cd29,
  70. 0xd73d10653ed25301,
  71. 0x69ec1523b2bbb258,
  72. 0x3def351ce8998927,
  73. 0xef,
  74. ]);
  75. #[rustfmt::skip]
  76. const T_MINUS_ONE_DIV_TWO: BigInteger = BigInteger([
  77. 0xf24bad5a77686694,
  78. 0x6b9e88329f692980,
  79. 0xb4f60a91d95dd92c,
  80. 0x9ef79a8e744cc493,
  81. 0x77,
  82. ]);
  83. }