ark-curves-cherry-picked/mnt6_298/src/curves/g2.rs
mnt6_298/src/curves/g2.rsRaw
1use ark_ec::{
2 mnt6,
3 mnt6::MNT6Parameters,
4 models::{ModelParameters, SWModelParameters},
5};
6use ark_ff::{biginteger::BigInteger320, field_new};
7
8use crate::{g1, Fq, Fq3, Fr};
9
10pub type G2Affine = mnt6::G2Affine<crate::Parameters>;
11pub type G2Projective = mnt6::G2Projective<crate::Parameters>;
12pub type G2Prepared = mnt6::G2Prepared<crate::Parameters>;
13
14#[derive(Clone, Default, PartialEq, Eq)]
15pub struct Parameters;
16
17impl ModelParameters for Parameters {
18 type BaseField = Fq3;
19 type ScalarField = Fr;
20}
21
22/// MUL_BY_A_C0 = NONRESIDUE * COEFF_A
23 #[rustfmt::skip]
24pub const MUL_BY_A_C0: Fq = field_new!(Fq, BigInteger320([
25 0xa07b458bf1496fab,
26 0xde8254e6541f9fb4,
27 0xb1b5cc7bf859c3ea,
28 0xf83c4d58364645a9,
29 0x30a29b55fa2,
30]));
31
32/// MUL_BY_A_C1 = NONRESIDUE * COEFF_A
33 #[rustfmt::skip]
34pub const MUL_BY_A_C1: Fq = field_new!(Fq, BigInteger320([
35 0xa07b458bf1496fab,
36 0xde8254e6541f9fb4,
37 0xb1b5cc7bf859c3ea,
38 0xf83c4d58364645a9,
39 0x30a29b55fa2,
40]));
41
42/// MUL_BY_A_C2 = COEFF_A
43pub const MUL_BY_A_C2: Fq = g1::Parameters::COEFF_A;
44
45impl SWModelParameters for Parameters {
46 const COEFF_A: Fq3 = crate::Parameters::TWIST_COEFF_A;
47 #[rustfmt::skip]
48 const COEFF_B: Fq3 = field_new!(Fq3,
49 field_new!(Fq, BigInteger320([
50 0x79a4c2cea3c84026,
51 0x4b50cad0f3233baa,
52 0x9ded82770e7a4410,
53 0x5ade8b105838b95d,
54 0xe4036e0a3a,
55 ])),
56 field_new!(Fq, BigInteger320([0, 0, 0, 0, 0])),
57 field_new!(Fq, BigInteger320([0, 0, 0, 0, 0])),
58 );
59
60 /// COFACTOR =
61 /// 226502022472576270196498690498308461791828762732602586162207535351960270082712694977333372361549082214519252261735048131889018501404377856786623430385820659037970876666767495659520
62 #[rustfmt::skip]
63 const COFACTOR: &'static [u64] = &[
64 15308190245346869248,
65 10669098443577192943,
66 4561413759929581409,
67 3680089780298582849,
68 17336300687782721465,
69 10745756320947240891,
70 17479264233688728128,
71 16828697388537672097,
72 4184034152442024798,
73 915787,
74 ];
75
76 /// COFACTOR^(-1) mod r =
77 /// 79320381028210220958891541608841408590854146655427655872973753568875979721417185067925504
78 #[rustfmt::skip]
79 const COFACTOR_INV: Fr = field_new!(Fr, BigInteger320([
80 5837598184463018016,
81 7845868194417674836,
82 12170332588914158076,
83 6950611683754678431,
84 102280178745,
85 ]));
86
87 /// AFFINE_GENERATOR_COEFFS = (G2_GENERATOR_X, G2_GENERATOR_Y)
88 const AFFINE_GENERATOR_COEFFS: (Self::BaseField, Self::BaseField) =
89 (G2_GENERATOR_X, G2_GENERATOR_Y);
90
91 #[inline(always)]
92 fn mul_by_a(elt: &Fq3) -> Fq3 {
93 field_new!(
94 Fq3,
95 MUL_BY_A_C0 * &elt.c1,
96 MUL_BY_A_C1 * &elt.c2,
97 MUL_BY_A_C2 * &elt.c0,
98 )
99 }
100}
101
102const G2_GENERATOR_X: Fq3 =
103 field_new!(Fq3, G2_GENERATOR_X_C0, G2_GENERATOR_X_C1, G2_GENERATOR_X_C2);
104const G2_GENERATOR_Y: Fq3 =
105 field_new!(Fq3, G2_GENERATOR_Y_C0, G2_GENERATOR_Y_C1, G2_GENERATOR_Y_C2);
106
107#[rustfmt::skip]
108pub const G2_GENERATOR_X_C0: Fq = field_new!(Fq, BigInteger320([
109 0x15ca12fc5d551ea7,
110 0x9e0b2b2b2bb8b979,
111 0xe6e66283ad5a786a,
112 0x46ba0aedcc383c07,
113 0x243853463ed,
114]));
115
116#[rustfmt::skip]
117pub const G2_GENERATOR_X_C1: Fq = field_new!(Fq, BigInteger320([
118 0x2c0e3dd7be176130,
119 0x27a15d879495904b,
120 0x6f1f0d2dd1502a82,
121 0x9782ee3c70834da,
122 0x2c28bb71862,
123]));
124
125#[rustfmt::skip]
126pub const G2_GENERATOR_X_C2: Fq = field_new!(Fq, BigInteger320([
127 0xf3e5f4eb9631e1f1,
128 0x657801e80c50778,
129 0x2d2abb128fee90f3,
130 0x72e58e4c3aa3598c,
131 0x100b8026b9d,
132]));
133
134#[rustfmt::skip]
135pub const G2_GENERATOR_Y_C0: Fq = field_new!(Fq, BigInteger320([
136 0xb1cddd6c64a67c5f,
137 0xa01e90d89aa5d2ba,
138 0x39e9a733be49ed1,
139 0x9438f46f63d3264f,
140 0x12cc928ef10,
141]));
142
143#[rustfmt::skip]
144pub const G2_GENERATOR_Y_C1: Fq = field_new!(Fq, BigInteger320([
145 0xa1529b7265ad4be7,
146 0x21c5e827cf309306,
147 0x9b3d647bd8c70b22,
148 0x42835bf373e4b213,
149 0xd3c77c9ff9,
150]));
151
152#[rustfmt::skip]
153pub const G2_GENERATOR_Y_C2: Fq = field_new!(Fq, BigInteger320([
154 0x610557ec4b58b8df,
155 0x51a23865b52045f1,
156 0x9dcfd915a09da608,
157 0x6d65c95f69adb700,
158 0x2d3c3d195a1,
159]));