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::{biginteger::BigInteger256, 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 const TWIST_MUL_BY_Q_X: Fq2 = field_new!(
27 Fq2,
28 field_new!(
29 Fq,
30 BigInteger256([
31 0xb5773b104563ab30,
32 0x347f91c8a9aa6454,
33 0x7a007127242e0991,
34 0x1956bcd8118214ec,
35 ])
36 ),
37 field_new!(
38 Fq,
39 BigInteger256([
40 0x6e849f1ea0aa4757,
41 0xaa1c7b6d89f89141,
42 0xb6e713cdfae0ca3a,
43 0x26694fbb4e82ebc3,
44 ])
45 ),
46 );
47 const TWIST_MUL_BY_Q_Y: Fq2 = field_new!(
48 Fq2,
49 field_new!(
50 Fq,
51 BigInteger256([
52 0xe4bbdd0c2936b629,
53 0xbb30f162e133bacb,
54 0x31a9d1b6f9645366,
55 0x253570bea500f8dd,
56 ])
57 ),
58 field_new!(
59 Fq,
60 BigInteger256([
61 0xa1d77ce45ffe77c7,
62 0x07affd117826d1db,
63 0x6d16bd27bb7edc6b,
64 0x2c87200285defecc,
65 ])
66 ),
67 );
68 const TWIST_TYPE: TwistType = TwistType::D;
69 type Fp = Fq;
70 type Fp2Params = Fq2Parameters;
71 type Fp6Params = Fq6Parameters;
72 type Fp12Params = Fq12Parameters;
73 type G1Parameters = g1::Parameters;
74 type G2Parameters = g2::Parameters;
75}
76
77pub type Bn254 = Bn<Parameters>;
78
79pub type G1Affine = bn::G1Affine<Parameters>;
80pub type G1Projective = bn::G1Projective<Parameters>;
81pub type G2Affine = bn::G2Affine<Parameters>;
82pub type G2Projective = bn::G2Projective<Parameters>;