arnaucube
arnaucube/ark-curves-cherry-pickedPublic Self-hosted repository
ark-curves-cherry-picked/cp6_782/src/curves/g2.rs
cp6_782/src/curves/g2.rsRaw
  1use ark_ec::{
  2    models::{ModelParameters, SWModelParameters},
  3    short_weierstrass_jacobian::{GroupAffine, GroupProjective},
  4};
  5use ark_ff::{
  6    biginteger::{BigInteger384, BigInteger832},
  7    field_new,
  8};
  9
 10use crate::{Fq, Fq3, Fr, FQ_ZERO};
 11
 12pub type G2Affine = GroupAffine<Parameters>;
 13pub type G2Projective = GroupProjective<Parameters>;
 14
 15#[derive(Clone, Default, PartialEq, Eq)]
 16pub struct Parameters;
 17
 18impl ModelParameters for Parameters {
 19    type BaseField = Fq3;
 20    type ScalarField = Fr;
 21}
 22
 23impl SWModelParameters for Parameters {
 24    /// COEFF_A = (0, 0, COEFF_A * TWIST^2) = (0, 0, 5)
 25    #[rustfmt::skip]
 26    const COEFF_A: Fq3 = field_new!(Fq3,
 27        FQ_ZERO,
 28        FQ_ZERO,
 29        field_new!(Fq, BigInteger832([
 30            0x781c76643018bd7a,
 31            0x64f3a5a4f1d1ad48,
 32            0xd2f8a1eb4f72692d,
 33            0xc35eb123c6ed72ca,
 34            0xb58d6bcfd32de058,
 35            0x841eab13b02a492c,
 36            0x4b70dc5a54c487e7,
 37            0x2f231a8808a74c59,
 38            0x5e2915154d70b050,
 39            0x8a40fa16f37a6b37,
 40            0xd01980093a72c54b,
 41            0xef6845c25398004c,
 42            0x48,
 43        ])),
 44    );
 45
 46    /// COEFF_B = (G1::COEFF_B * TWIST^3, 0, 0) =
 47    /// (7237353553714858194254855835825640240663090882935418626687402315497764195116318527743248304684159666286416318482685337633828994152723793439622384740540789612754127688659139509552568164770448654259255628317166934203899992395064470477612,
 48    /// 0, 0)
 49    #[rustfmt::skip]
 50    const COEFF_B: Fq3 = field_new!(Fq3,
 51        field_new!(Fq, BigInteger832([
 52            0xc00a9afc5cbce615,
 53            0x0260c2b730644102,
 54            0x9051e955661691ec,
 55            0x15f9af8514839e37,
 56            0xfa62826ca407172b,
 57            0x37043dc868f48874,
 58            0x876b5588d132b025,
 59            0x481952128335562a,
 60            0x4ffa729aeddd7dcd,
 61            0xe181a5dae94a399f,
 62            0x671fb50145b255d8,
 63            0xbc3860730482d728,
 64            0x00000000000023dd,
 65        ])),
 66        FQ_ZERO,
 67        FQ_ZERO,
 68    );
 69
 70    /// COFACTOR =
 71    /// 43276679045916726782882096851503554444292580777869919574700824986947162516693702667493938255647666346010819253090121562084993205202476199057555142869892665220155573207800985012241638987472334344174208389303164492698303448192856551557283997344470334833850065978668184377503856699635686872344035470027430053642178229054516302338812152178131995800255516474185251732445975837621097393375441662426280154371264547168198834382681059556891327702516519955053315674076980350109237328216856859758931256208439575383786363605925879337208599843910819433766160937121108797819223653884174994325142959644019600
 72    #[rustfmt::skip]
 73    const COFACTOR: &'static [u64] = &[
 74        0x4b77fca151d50b90,
 75        0x8c98a12bd486d2fb,
 76        0x1f0c9a51593693f8,
 77        0x1d6f388069c063c1,
 78        0x556e918748f06793,
 79        0x2cea7dc01aae2140,
 80        0x4216f0595cee44d0,
 81        0x7a5e400154f633cf,
 82        0xbb74eb9b6630846b,
 83        0x8eb48c92998f3358,
 84        0xbedd37f629e8e634,
 85        0xc541018fe4d10cc7,
 86        0x574956a099ace2c3,
 87        0xa597504275948226,
 88        0x7ecaaf050acb91f3,
 89        0x0f25b044f4e9c932,
 90        0xf8c39cbf0df97780,
 91        0xd8f9eda95d6abf3e,
 92        0xd1d80da227dd39c1,
 93        0x8b589c61531dbce7,
 94        0xfee4439281455474,
 95        0x9eea59baa2aeb4a1,
 96        0xa3b8a42c4e1e6f5a,
 97        0xc4b99b0d9b077d21,
 98        0xd09033887d09b4d2,
 99        0x4a86d8ebb7fdf52a,
100        0xbe7ce44dd084e05d,
101        0x4ed25f7ebe6c44b3,
102        0xd7f8e3ef00255961,
103        0xa1ad2ad61580ef78,
104        0x19e70d3618ca3,
105    ];
106
107    /// COFACTOR^(-1) mod r =
108    /// 45586359457219724873147353901735745013467692594291916855200979604570630929674383405372210802279573887880950375598
109    #[rustfmt::skip]
110    const COFACTOR_INV: Fr = field_new!(Fr, BigInteger384([
111        7373687189387546408,
112        11284009518041539892,
113        301575489693670883,
114        13203058298476577559,
115        18441611830097862156,
116        4115759498196698,
117    ]));
118
119    /// AFFINE_GENERATOR_COEFFS = (G2_GENERATOR_X, G2_GENERATOR_Y)
120    const AFFINE_GENERATOR_COEFFS: (Self::BaseField, Self::BaseField) =
121        (G2_GENERATOR_X, G2_GENERATOR_Y);
122}
123
124const G2_GENERATOR_X: Fq3 =
125    field_new!(Fq3, G2_GENERATOR_X_C0, G2_GENERATOR_X_C1, G2_GENERATOR_X_C2);
126const G2_GENERATOR_Y: Fq3 =
127    field_new!(Fq3, G2_GENERATOR_Y_C0, G2_GENERATOR_Y_C1, G2_GENERATOR_Y_C2);
128
129/// G2_GENERATOR_X_C0 =
130/// 13426761183630949215425595811885033211332897733228446437546263564078445562454176776915160094418980045665397361295624472103734543457352048745726512354895954850428989867542989474136256025045975283415690491751906307188562464175510373683338
131#[rustfmt::skip]
132pub const G2_GENERATOR_X_C0: Fq = field_new!(Fq, BigInteger832([
133    0x03b3fe4c8d4ecac7,
134    0x9568212677524d1e,
135    0xf5de3f2228d187c1,
136    0x7bac772e31a420ef,
137    0x0255cf59968a612b,
138    0x991d4676f6b5d605,
139    0x02dd2ae4831d29ea,
140    0xbeca7c9a62e392c2,
141    0xfc1d0633d48d2fc5,
142    0x7867813be5f7d2a1,
143    0x6f567b6617030028,
144    0xf08c9fa6ca6809df,
145    0x0000000000000de9,
146]));
147
148/// G2_GENERATOR_X_C1 =
149/// 20471601555918880743198170952645906008198510944268658573129351735028343217532386920456705632337352161031960990613816401042894531220068552819818037605513359562118363589199569321421558696125646867661360498323171027455638052943806292028610
150#[rustfmt::skip]
151pub const G2_GENERATOR_X_C1: Fq = field_new!(Fq, BigInteger832([
152    0xefd1b506e5fbe05f,
153    0xad27d47a4975140c,
154    0xfa11540132dbc27a,
155    0x8dca42b6da7c4717,
156    0x66d30fd7fd76207a,
157    0xb8e4f65c68932b1d,
158    0x3b7f971e93ad14be,
159    0xf860a89f4e582f9f,
160    0x7d438aaa3986f73b,
161    0xa37ec0c18c6e106a,
162    0x9f2dfb98b5185b54,
163    0x19995e421ca939bc,
164    0x0000000000002f4f,
165]));
166
167/// G2_GENERATOR_X_C2 =
168/// 3905053196875761830053608605277158152930144841844497593936739534395003062685449846381431331169369910535935138116320442345524758217411779027270883193856999691582831339845600938304719916501940381093815781408183227875600753651697934495980
169#[rustfmt::skip]
170pub const G2_GENERATOR_X_C2: Fq = field_new!(Fq, BigInteger832([
171    0xc081ed832bdf911e,
172    0xb85ff7aeebdfe7b3,
173    0x96dce6bb307b14eb,
174    0x578f7ded84bd824c,
175    0xb799305a9971d184,
176    0x0116ad33c2874b90,
177    0x862dce68efdca245,
178    0x4190947c70534c1d,
179    0x1b1aa80334248d03,
180    0xb13b07aff63fcf27,
181    0x5727687b73ab4fff,
182    0xf559a7f4eb8d180a,
183    0x0000000000002d37,
184]));
185
186/// G2_GENERATOR_Y_C0 =
187/// 8567517639523571619872938228644013584947463594196306323477160496987712111576624702939472765993995586889532559039169098780892505598589581147768095093536988446010255611523736706017580686335404469207486594272103717837888228343074699140243
188#[rustfmt::skip]
189pub const G2_GENERATOR_Y_C0: Fq = field_new!(Fq, BigInteger832([
190    0x3f680b59e26b33d1,
191    0x720fdf65b9e15b17,
192    0x0f0b56def11247b1,
193    0x5ea05417c8a4a52c,
194    0x4ad59dc4f7c47a09,
195    0xf393e0db62107115,
196    0xde3b16404a53d2bb,
197    0xeaa74961636280e0,
198    0x2d16ccd14cf5a88c,
199    0x5667565a06187d0e,
200    0xb446fdc7565d0261,
201    0xd3ad395d6fd0faab,
202    0x0000000000000655,
203]));
204
205/// G2_GENERATOR_Y_C1 =
206/// 3890537069205870914984502594450293167889863914413852788876350245583932846980126025043974070704295857226211547108005650399870458089721518559480870503159804530091559886149680718531004778697982910253701559194337987238111062202037698927752
207#[rustfmt::skip]
208pub const G2_GENERATOR_Y_C1: Fq = field_new!(Fq, BigInteger832([
209    0x9e86cc63207679dd,
210    0x4e16d9a9d87c3e47,
211    0xdbee3524db80627d,
212    0x137322b87d93befc,
213    0x24a7ca2f9aae90a0,
214    0x44abea538df3e854,
215    0xc01d176c6e042eee,
216    0xf5fcc4caabc75699,
217    0x1f99972699a38960,
218    0x30d4cc8256bf963d,
219    0xa3634826edcfefff,
220    0x34f3bd0c8e5a4b38,
221    0x0000000000001d28,
222]));
223
224/// G2_GENERATOR_Y_C2 =
225/// 10936269922612615564271188303104593362724754284143779051599749016735041389483971486958818324356025479751246744831831158558101688599198721653921723013062333636402617118847009085485166284126970598561393411916461254016145116183331671450721
226#[rustfmt::skip]
227pub const G2_GENERATOR_Y_C2: Fq = field_new!(Fq, BigInteger832([
228    0xfc478105dedf3654,
229    0xa6fcfcfdd2710d6a,
230    0x05a68c283d5d4c65,
231    0x9fab8d94c667a679,
232    0x009b0a616ea54ff9,
233    0xf0df517bc7bc6382,
234    0xdb44338e7491f5b7,
235    0xcd192a7e53453f45,
236    0xa041a7a60982d92c,
237    0x4dd01c62bae4c7ff,
238    0x79a69a54e6b66178,
239    0xd47b0bfe832b05f8,
240    0x00000000000000ef,
241]));