arnaucube
arnaucube/ark-curves-cherry-pickedPublic Self-hosted repository
ark-curves-cherry-picked/cp6_782/src/fields/fq3.rs
cp6_782/src/fields/fq3.rsRaw
  1use crate::Fq;
  2use ark_ff::{
  3    biginteger::BigInteger832 as BigInteger,
  4    field_new,
  5    fields::fp3::{Fp3, Fp3Parameters},
  6    Field,
  7};
  8
  9pub type Fq3 = Fp3<Fq3Parameters>;
 10
 11pub struct Fq3Parameters;
 12
 13impl Fp3Parameters for Fq3Parameters {
 14    type Fp = Fq;
 15
 16    /// NONRESIDUE = 13
 17    #[rustfmt::skip]
 18    const NONRESIDUE: Fq = field_new!(Fq, BigInteger([
 19        0xe755952f4650755e,
 20        0x16c44ce1331ef791,
 21        0x162f8835b467306f,
 22        0xac1c2b31e1062c4c,
 23        0x20b3dab9a2a935e1,
 24        0xccd2ec5fd01e00c1,
 25        0x4d1d1bf190c8da9b,
 26        0x49cba09fb0e13fbe,
 27        0xe392ed2957c061a3,
 28        0x3159d02b3c93d6e1,
 29        0x71566d160a9f8614,
 30        0xa5840728fc854414,
 31        0x2dc4,
 32    ]));
 33
 34    const TWO_ADICITY: u32 = 3;
 35
 36    #[rustfmt::skip]
 37    const T_MINUS_ONE_DIV_TWO: &'static [u64] = &[
 38        0x62730e2cd2029617,
 39        0x660647f735cb88cf,
 40        0x274359d60784f69d,
 41        0x83067194eb102629,
 42        0x54ea4a12a9381160,
 43        0xade0b24e398dac25,
 44        0xb476ae9f927e81cb,
 45        0x220fd4a9178adc3b,
 46        0x57e0cb9b0569745b,
 47        0xba15024addc8f52e,
 48        0x145b9bc116144ab6,
 49        0x6bc2260726e88b15,
 50        0x51da6bf151066474,
 51        0x9fd1b3190f6320cf,
 52        0x2097bfb7bf4167b0,
 53        0x27c35b1e7e628e09,
 54        0x94f80c9d623dd9bb,
 55        0x20bfa6d5bf31e7d3,
 56        0x19fb862c049d3a8,
 57        0xdf4c5efe04c0cec1,
 58        0x32c9a8abe9b50297,
 59        0x268d5c2076b44f0a,
 60        0x76027ec67b23ca21,
 61        0x248d61e0c45d270,
 62        0x419cd0d1d6be027e,
 63        0xbcd8dc3b1986ef18,
 64        0x73093d8719c862c2,
 65        0x651d60f8f9f6fcd9,
 66        0x8dabebe38a09b261,
 67        0xfa85b5a9e180cd3f,
 68        0x6a97fc618f319fb7,
 69        0xce08b93a5652a8e1,
 70        0x37525cbc4ba24cf9,
 71        0xb104c580df9d2150,
 72        0x1407c1bfe240a89d,
 73        0x34c96a73372daf9a,
 74        0x2b87fda171,
 75    ];
 76
 77    #[rustfmt::skip]
 78    const QUADRATIC_NONRESIDUE_TO_T: (Fq, Fq, Fq) = (
 79        field_new!(Fq, BigInteger([
 80            0x59987c0ef8e31739,
 81            0x59578d750d6f57dd,
 82            0x9672547570dddab8,
 83            0x1a1f630e1d6dbdd5,
 84            0xde15f46e52d7613e,
 85            0x6a1b6e4f80179926,
 86            0x461ad119d93123b,
 87            0x12054e3654907ed9,
 88            0x85ea06b12bf811a0,
 89            0xc01d53d07347f9ec,
 90            0x70c424eb666c3922,
 91            0x1796ce4ed605d49e,
 92            0x68b,
 93        ])),
 94        field_new!(Fq, BigInteger([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])),
 95        field_new!(Fq, BigInteger([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])),
 96    );
 97
 98    #[rustfmt::skip]
 99    const FROBENIUS_COEFF_FP3_C1: &'static [Fq] = &[
100        field_new!(Fq, BigInteger([
101            0x9b4e60b420910c71,
102            0xe068d7c83f284a6e,
103            0x1f708acc7c452c43,
104            0xeb2f6a66cca51856,
105            0x9acf675f886e9fcd,
106            0xb26885e567cc8082,
107            0x75d05357183eb61f,
108            0x24db4a09b5842a32,
109            0x85e64cf9ba4b14ae,
110            0xf311a6784358a588,
111            0xe8d431c061aecb4a,
112            0xd92c8b4aab19f288,
113            0x21d3,
114        ])),
115        field_new!(Fq, BigInteger([
116            0xe793e750fc0c0fdc,
117            0x28cd75f5634a867e,
118            0xde5e9b1261eb3c33,
119            0x68a0fb1c17595903,
120            0x19626d2c9f392e46,
121            0xc4d95794cb378b83,
122            0x54870f1f582d67c9,
123            0xf3f1a0ac4aceb56d,
124            0x811361215ea4fd47,
125            0x32cd6ee17d95bd00,
126            0x725f9881049a9c52,
127            0x5acb70be0613a307,
128            0x11bb,
129        ])),
130        field_new!(Fq, BigInteger([
131            0x57ec31b05ef70e9c,
132            0x4b273803cb8a715d,
133            0xf0443627811cbe40,
134            0x485f10c72ec590f1,
135            0x66a35e7875569c25,
136            0xdb621dfd9498071a,
137            0xe0de3451f11039a8,
138            0x6a3f87d780a6f7eb,
139            0x637875d359122b11,
140            0x967e0211b37c8d9d,
141            0x8e255dfc2908fec6,
142            0x90da2a32facafe8f,
143            0x4b9,
144        ])),
145    ];
146
147    #[rustfmt::skip]
148    const FROBENIUS_COEFF_FP3_C2: &'static [Fq] = &[
149        field_new!(Fq, BigInteger([
150            0x9b4e60b420910c71,
151            0xe068d7c83f284a6e,
152            0x1f708acc7c452c43,
153            0xeb2f6a66cca51856,
154            0x9acf675f886e9fcd,
155            0xb26885e567cc8082,
156            0x75d05357183eb61f,
157            0x24db4a09b5842a32,
158            0x85e64cf9ba4b14ae,
159            0xf311a6784358a588,
160            0xe8d431c061aecb4a,
161            0xd92c8b4aab19f288,
162            0x21d3,
163        ])),
164        field_new!(Fq, BigInteger([
165            0x57ec31b05ef70e9c,
166            0x4b273803cb8a715d,
167            0xf0443627811cbe40,
168            0x485f10c72ec590f1,
169            0x66a35e7875569c25,
170            0xdb621dfd9498071a,
171            0xe0de3451f11039a8,
172            0x6a3f87d780a6f7eb,
173            0x637875d359122b11,
174            0x967e0211b37c8d9d,
175            0x8e255dfc2908fec6,
176            0x90da2a32facafe8f,
177            0x4b9,
178        ])),
179        field_new!(Fq, BigInteger([
180            0xe793e750fc0c0fdc,
181            0x28cd75f5634a867e,
182            0xde5e9b1261eb3c33,
183            0x68a0fb1c17595903,
184            0x19626d2c9f392e46,
185            0xc4d95794cb378b83,
186            0x54870f1f582d67c9,
187            0xf3f1a0ac4aceb56d,
188            0x811361215ea4fd47,
189            0x32cd6ee17d95bd00,
190            0x725f9881049a9c52,
191            0x5acb70be0613a307,
192            0x11bb,
193        ])),
194    ];
195
196    #[inline(always)]
197    fn mul_fp_by_nonresidue(fe: &Self::Fp) -> Self::Fp {
198        let original = *fe;
199        let mut four_fe = fe.double();
200        four_fe.double_in_place();
201        let eight_fe = four_fe.double();
202        eight_fe + &four_fe + &original
203    }
204}