arnaucube
arnaucube/ark-curves-cherry-pickedPublic Self-hosted repository
ark-curves-cherry-picked/mnt4_298/src/fields/fq.rs
mnt4_298/src/fields/fq.rsRaw
  1use ark_ff::{
  2    biginteger::BigInteger320 as BigInteger,
  3    fields::{FftParameters, Fp320, Fp320Parameters, FpParameters},
  4};
  5
  6pub type Fq = Fp320<FqParameters>;
  7
  8pub struct FqParameters;
  9
 10impl Fp320Parameters for FqParameters {}
 11impl FftParameters for FqParameters {
 12    type BigInt = BigInteger;
 13
 14    const TWO_ADICITY: u32 = 17;
 15
 16    #[rustfmt::skip]
 17    const TWO_ADIC_ROOT_OF_UNITY: BigInteger = BigInteger([
 18        9821480371597472441u64,
 19        9468346035609379175u64,
 20        9963748368231707135u64,
 21        14865337659602750405u64,
 22        3984815592673u64,
 23    ]);
 24
 25    const SMALL_SUBGROUP_BASE: Option<u32> = Some(7);
 26    const SMALL_SUBGROUP_BASE_ADICITY: Option<u32> = Some(2);
 27
 28    /// LARGE_SUBGROUP_ROOT_OF_UNITY = x * g
 29    /// where x = (n - 1) / 2^17 / 7^2
 30    /// and represent this value in the Montgomery residue form.
 31    /// I.e., write
 32    /// 381811485921190977554243339163030148371175054922689353173385941180422489253833691237722982
 33    /// * R
 34    /// = 260534023778902228073198316993669317435810479439368306496187170459125001342456918103569322
 35    const LARGE_SUBGROUP_ROOT_OF_UNITY: Option<BigInteger> = Some(BigInteger([
 36        7711798843682337706u64,
 37        16456007754393011187u64,
 38        7470854640069402569u64,
 39        10767969225751706229u64,
 40        2250015743691u64,
 41    ]));
 42}
 43impl FpParameters for FqParameters {
 44    /// MODULUS = 475922286169261325753349249653048451545124879242694725395555128576210262817955800483758081
 45    #[rustfmt::skip]
 46    const MODULUS: BigInteger = BigInteger([
 47        14487189785281953793u64,
 48        4731562877756902930u64,
 49        14622846468719063274u64,
 50        11702080941310629006u64,
 51        4110145082483u64,
 52    ]);
 53
 54    const MODULUS_BITS: u32 = 298;
 55
 56    const CAPACITY: u32 = Self::MODULUS_BITS - 1;
 57
 58    const REPR_SHAVE_BITS: u32 = 22;
 59
 60    #[rustfmt::skip]
 61    const R: BigInteger = BigInteger([
 62        1784298994435064924u64,
 63        16852041090100268533u64,
 64        14258261760832875328u64,
 65        2961187778261111191u64,
 66        1929014752195u64,
 67    ]);
 68
 69    #[rustfmt::skip]
 70    const R2: BigInteger = BigInteger([
 71        28619103704175136u64,
 72        11702218449377544339u64,
 73        7403203599591297249u64,
 74        2248105543421449339u64,
 75        2357678148148u64,
 76    ]);
 77
 78    const INV: u64 = 12714121028002250751u64;
 79
 80    #[rustfmt::skip]
 81    const GENERATOR: BigInteger = BigInteger([
 82        2709730703260633621u64,
 83        13556085429182073539u64,
 84        10903316137158576359u64,
 85        5319113788683590444u64,
 86        4022235209932u64,
 87    ]);
 88
 89    #[rustfmt::skip]
 90    const T: BigInteger = BigInteger([
 91        0x70964866b2d38b3,
 92        0x987520d4f1af2890,
 93        0x2a47657764b1ae89,
 94        0x6a39d133124ed3d8,
 95        0x1de7bde,
 96    ]);
 97
 98    #[rustfmt::skip]
 99    const T_MINUS_ONE_DIV_TWO: BigInteger = BigInteger([
100        0x384b24335969c59,
101        0xcc3a906a78d79448,
102        0x1523b2bbb258d744,
103        0x351ce899892769ec,
104        0xef3def,
105    ]);
106
107    #[rustfmt::skip]
108    const MODULUS_MINUS_ONE_DIV_TWO: BigInteger = BigInteger([
109        0x64866b2d38b30000,
110        0x20d4f1af28900709,
111        0x657764b1ae899875,
112        0xd133124ed3d82a47,
113        0x1de7bde6a39,
114    ]);
115}