arnaucube
arnaucube/ark-curves-cherry-pickedPublic Self-hosted repository
ark-curves-cherry-picked/cp6_782/src/fields/fq.rs
cp6_782/src/fields/fq.rsRaw
  1use ark_ff::{
  2    biginteger::BigInteger832 as BigInteger,
  3    fields::{FftParameters, Fp832, Fp832Parameters, FpParameters},
  4};
  5
  6pub type Fq = Fp832<FqParameters>;
  7
  8pub struct FqParameters;
  9
 10pub const FQ_ONE: Fq = ark_ff::field_new!(Fq, "1");
 11pub const FQ_ZERO: Fq = ark_ff::field_new!(Fq, "0");
 12
 13impl Fp832Parameters for FqParameters {}
 14impl FftParameters for FqParameters {
 15    type BigInt = BigInteger;
 16
 17    const TWO_ADICITY: u32 = 3;
 18
 19    #[rustfmt::skip]
 20    const TWO_ADIC_ROOT_OF_UNITY: BigInteger = BigInteger([
 21        18044746167194862600u64,
 22        63590321303744709u64,
 23        5009346151370959890u64,
 24        2859114157767503991u64,
 25        8301813204852325413u64,
 26        5629414263664332594u64,
 27        2637340888701394641u64,
 28        17433538052687852753u64,
 29        2230763098934759248u64,
 30        3785382115983092023u64,
 31        8895511354022222370u64,
 32        15792083141709071785u64,
 33        1328u64,
 34    ]);
 35}
 36impl FpParameters for FqParameters {
 37    /// MODULUS = 22369874298875696930346742206501054934775599465297184582183496627646774052458024540232479018147881220178054575403841904557897715222633333372134756426301062487682326574958588001132586331462553235407484089304633076250782629492557320825577
 38    #[rustfmt::skip]
 39    const MODULUS: BigInteger = BigInteger([
 40        0xdace79b57b942ae9,
 41        0x545d85c16dfd424a,
 42        0xee135c065f4d26b7,
 43        0x9c2f764a12c4024b,
 44        0x1ad533049cfe6a39,
 45        0x52a3fb77c79c1320,
 46        0xab3596c8617c5792,
 47        0x830c728d80f9d78b,
 48        0x6a7223ee72023d07,
 49        0xbc5d176b746af026,
 50        0xe959283d8f526663,
 51        0xc4d2263babf8941f,
 52        0x3848,
 53    ]);
 54
 55    const MODULUS_BITS: u32 = 782;
 56
 57    const CAPACITY: u32 = Self::MODULUS_BITS - 1;
 58
 59    const REPR_SHAVE_BITS: u32 = 50;
 60
 61    #[rustfmt::skip]
 62    const R: BigInteger = BigInteger([
 63        11190988450819017841u64,
 64        16170411717126802030u64,
 65        2265463223430229059u64,
 66        16946880912571045974u64,
 67        11155248462028513229u64,
 68        12855672356664541314u64,
 69        8489376931127408159u64,
 70        2655797810825538098u64,
 71        9648483887143916718u64,
 72        17514963461276738952u64,
 73        16777089214204267338u64,
 74        15649035958020076168u64,
 75        8659u64,
 76    ]);
 77
 78    #[rustfmt::skip]
 79    const R2: BigInteger = BigInteger([
 80        13983406830510863714u64,
 81        17863856572171232656u64,
 82        1698388424046564526u64,
 83        1773634430448388392u64,
 84        8684647957094413275u64,
 85        3992637317298078843u64,
 86        18420879196616862245u64,
 87        3238482510270583127u64,
 88        7928200707794018216u64,
 89        10024831010452223910u64,
 90        9613847725664942650u64,
 91        15361265984156787358u64,
 92        7833u64,
 93    ]);
 94
 95    const INV: u64 = 14469047335842394791u64;
 96
 97    /// GENERATOR = 13
 98    #[rustfmt::skip]
 99    const GENERATOR: BigInteger = BigInteger([
100        16669393626057438558u64,
101        1640520694378723217u64,
102        1598646156981121135u64,
103        12401834967100173388u64,
104        2356467520877704673u64,
105        14759118825104212161u64,
106        5556628239575210651u64,
107        5317520392768798654u64,
108        16398429955031064995u64,
109        3556102264904210145u64,
110        8166834915717907988u64,
111        11926665585800594452u64,
112        11716u64,
113    ]);
114
115    #[rustfmt::skip]
116    const MODULUS_MINUS_ONE_DIV_TWO: BigInteger = BigInteger([
117        0x6d673cdabdca1574,
118        0xaa2ec2e0b6fea125,
119        0xf709ae032fa6935b,
120        0xce17bb2509620125,
121        0xd6a99824e7f351c,
122        0x2951fdbbe3ce0990,
123        0xd59acb6430be2bc9,
124        0xc1863946c07cebc5,
125        0x353911f739011e83,
126        0xde2e8bb5ba357813,
127        0xf4ac941ec7a93331,
128        0x6269131dd5fc4a0f,
129        0x1c24,
130    ]);
131
132    // (T - 1)/2 =
133    // 1398117143679731058146671387906315933423474966581074036386468539227923378278626533764529938634242576261128410962740119034868607201414583335758422276643816405480145410934911750070786645716409577212967755581539567265673914343284832551598
134    #[rustfmt::skip]
135    const T_MINUS_ONE_DIV_TWO: BigInteger = BigInteger([
136        0xadace79b57b942ae,
137        0x7545d85c16dfd424,
138        0xbee135c065f4d26b,
139        0x99c2f764a12c4024,
140        0x1ad533049cfe6a3,
141        0x252a3fb77c79c132,
142        0xbab3596c8617c579,
143        0x7830c728d80f9d78,
144        0x66a7223ee72023d0,
145        0x3bc5d176b746af02,
146        0xfe959283d8f52666,
147        0x8c4d2263babf8941,
148        0x384,
149    ]);
150
151    // T =
152    // 2796234287359462116293342775812631866846949933162148072772937078455846756557253067529059877268485152522256821925480238069737214402829166671516844553287632810960290821869823500141573291432819154425935511163079134531347828686569665103197
153    #[rustfmt::skip]
154    const T: BigInteger = BigInteger([
155        0x5b59cf36af72855d,
156        0xea8bb0b82dbfa849,
157        0x7dc26b80cbe9a4d6,
158        0x3385eec942588049,
159        0x35aa660939fcd47,
160        0x4a547f6ef8f38264,
161        0x7566b2d90c2f8af2,
162        0xf0618e51b01f3af1,
163        0xcd4e447dce4047a0,
164        0x778ba2ed6e8d5e04,
165        0xfd2b2507b1ea4ccc,
166        0x189a44c7757f1283,
167        0x709,
168    ]);
169}