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::{fields::FQ_ZERO, Fq};
 2use ark_ff::{
 3    field_new,
 4    fields::fp3::{Fp3, Fp3Parameters},
 5    Field,
 6};
 7
 8pub type Fq3 = Fp3<Fq3Parameters>;
 9
10pub struct Fq3Parameters;
11
12impl Fp3Parameters for Fq3Parameters {
13    type Fp = Fq;
14
15    /// NONRESIDUE = 13
16    #[rustfmt::skip]
17    const NONRESIDUE: Fq = field_new!(Fq, "13");
18
19    const TWO_ADICITY: u32 = 3;
20
21    #[rustfmt::skip]
22    const T_MINUS_ONE_DIV_TWO: &'static [u64] = &[
23        0x62730e2cd2029617,
24        0x660647f735cb88cf,
25        0x274359d60784f69d,
26        0x83067194eb102629,
27        0x54ea4a12a9381160,
28        0xade0b24e398dac25,
29        0xb476ae9f927e81cb,
30        0x220fd4a9178adc3b,
31        0x57e0cb9b0569745b,
32        0xba15024addc8f52e,
33        0x145b9bc116144ab6,
34        0x6bc2260726e88b15,
35        0x51da6bf151066474,
36        0x9fd1b3190f6320cf,
37        0x2097bfb7bf4167b0,
38        0x27c35b1e7e628e09,
39        0x94f80c9d623dd9bb,
40        0x20bfa6d5bf31e7d3,
41        0x19fb862c049d3a8,
42        0xdf4c5efe04c0cec1,
43        0x32c9a8abe9b50297,
44        0x268d5c2076b44f0a,
45        0x76027ec67b23ca21,
46        0x248d61e0c45d270,
47        0x419cd0d1d6be027e,
48        0xbcd8dc3b1986ef18,
49        0x73093d8719c862c2,
50        0x651d60f8f9f6fcd9,
51        0x8dabebe38a09b261,
52        0xfa85b5a9e180cd3f,
53        0x6a97fc618f319fb7,
54        0xce08b93a5652a8e1,
55        0x37525cbc4ba24cf9,
56        0xb104c580df9d2150,
57        0x1407c1bfe240a89d,
58        0x34c96a73372daf9a,
59        0x2b87fda171,
60    ];
61
62    #[rustfmt::skip]
63    const QUADRATIC_NONRESIDUE_TO_T: (Fq, Fq, Fq) = (
64        field_new!(Fq, "5759691735434357221228070840130186543101559976323700017469395641639510585333061695996665166662748527158637897523704071820491869715512532675375604262649010727161924084052120196921150869218319839231115277876207074651754402338718419191428"),
65        FQ_ZERO,
66        FQ_ZERO,
67    );
68
69    #[rustfmt::skip]
70    const FROBENIUS_COEFF_FP3_C1: &'static [Fq] = &[
71        field_new!(Fq, "1"),
72        field_new!(Fq, "2416169158604010336818399199316106389588878314690767988978701685873498866746813334102117883272276610365242925950967572554030909749205624998805208910209389668659757274773858916683688639755413288353778854399286396639505385648830027756861"),
73        field_new!(Fq, "19953705140271686593528343007184948545186721150606416593204794941773275185711211206130361134875604609812811649452874332003866805473427708373329547516091672819022569300184729084448897691707139947053705234905346679611277243843727293068715"),
74    ];
75
76    #[rustfmt::skip]
77    const FROBENIUS_COEFF_FP3_C2: &'static [Fq] = &[
78        field_new!(Fq, "1"),
79        field_new!(Fq, "19953705140271686593528343007184948545186721150606416593204794941773275185711211206130361134875604609812811649452874332003866805473427708373329547516091672819022569300184729084448897691707139947053705234905346679611277243843727293068715"),
80        field_new!(Fq, "2416169158604010336818399199316106389588878314690767988978701685873498866746813334102117883272276610365242925950967572554030909749205624998805208910209389668659757274773858916683688639755413288353778854399286396639505385648830027756861"),
81    ];
82
83    #[inline(always)]
84    fn mul_fp_by_nonresidue(fe: &Self::Fp) -> Self::Fp {
85        let original = *fe;
86        let mut four_fe = fe.double();
87        four_fe.double_in_place();
88        let eight_fe = four_fe.double();
89        eight_fe + &four_fe + &original
90    }
91}