arnaucube
arnaucube/ark-curves-cherry-pickedPublic Self-hosted repository
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!(
30            Fq,
31            "21575463638280843010398324269430826099269044274347216827212613867836435027261"
32        ),
33        field_new!(
34            Fq,
35            "10307601595873709700152284273816112264069230130616436755625194854815875713954"
36        ),
37    );
38    const TWIST_MUL_BY_Q_Y: Fq2 = field_new!(
39        Fq2,
40        field_new!(
41            Fq,
42            "2821565182194536844548159561693502659359617185244120367078079554186484126554"
43        ),
44        field_new!(
45            Fq,
46            "3505843767911556378687030309984248845540243509899259641013678093033130930403"
47        ),
48    );
49    const TWIST_TYPE: TwistType = TwistType::D;
50    type Fp = Fq;
51    type Fp2Params = Fq2Parameters;
52    type Fp6Params = Fq6Parameters;
53    type Fp12Params = Fq12Parameters;
54    type G1Parameters = g1::Parameters;
55    type G2Parameters = g2::Parameters;
56}
57
58pub type Bn254 = Bn<Parameters>;
59
60pub type G1Affine = bn::G1Affine<Parameters>;
61pub type G1Projective = bn::G1Projective<Parameters>;
62pub type G2Affine = bn::G2Affine<Parameters>;
63pub type G2Projective = bn::G2Projective<Parameters>;