ark-curves-cherry-picked/bn254/src/curves/mod.rs
bn254/src/curves/mod.rsRaw
1use crate::*;
2use ark_ec::{
3 bn,
4 bn::{Bn, BnParameters, TwistType},
5};
6use ark_ff::field_new;
7pub mod g1;
8pub mod g2;
9
10#[cfg(test)]
11mod tests;
12
13pub struct Parameters;
14
15impl BnParameters for Parameters {
16 const X: &'static [u64] = &[4965661367192848881];
17 /// `x` is positive.
18 const X_IS_NEGATIVE: bool = false;
19 const ATE_LOOP_COUNT: &'static [i8] = &[
20 0, 0, 0, 1, 0, 1, 0, -1, 0, 0, 1, -1, 0, 0, 1, 0, 0, 1, 1, 0, -1, 0, 0, 1, 0, -1, 0, 0, 0,
21 0, 1, 1, 1, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 1, 0, 0, -1, 0, 0, 0, 1, 1, 0,
22 -1, 0, 0, 1, 0, 1, 1,
23 ];
24 /// `ate_loop_count` is positive.
25 const ATE_LOOP_COUNT_IS_NEGATIVE: bool = false;
26
27 const TWIST_MUL_BY_Q_X: Fq2 = field_new!(
28 Fq2,
29 field_new!(Fq, "21575463638280843010398324269430826099269044274347216827212613867836435027261"),
30 field_new!(Fq, "10307601595873709700152284273816112264069230130616436755625194854815875713954"),
31 );
32 const TWIST_MUL_BY_Q_Y: Fq2 = field_new!(
33 Fq2,
34 field_new!(Fq, "2821565182194536844548159561693502659359617185244120367078079554186484126554"),
35 field_new!(Fq, "3505843767911556378687030309984248845540243509899259641013678093033130930403"),
36 );
37 const TWIST_TYPE: TwistType = TwistType::D;
38 type Fp = Fq;
39 type Fp2Params = Fq2Parameters;
40 type Fp6Params = Fq6Parameters;
41 type Fp12Params = Fq12Parameters;
42 type G1Parameters = g1::Parameters;
43 type G2Parameters = g2::Parameters;
44}
45
46pub type Bn254 = Bn<Parameters>;
47
48pub type G1Affine = bn::G1Affine<Parameters>;
49pub type G1Projective = bn::G1Projective<Parameters>;
50pub type G2Affine = bn::G2Affine<Parameters>;
51pub type G2Projective = bn::G2Projective<Parameters>;