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