ark-curves-cherry-picked/cp6_782/src/curves/g1.rs
cp6_782/src/curves/g1.rsRaw
1use ark_ec::{
2 models::{short_weierstrass::SWCurveConfig, CurveConfig},
3 short_weierstrass::{Affine, Projective},
4 AffineRepr, CurveGroup,
5};
6use ark_ff::MontFp;
7
8use crate::{Fq, Fr};
9
10pub type G1Affine = Affine<Parameters>;
11pub type G1Projective = Projective<Parameters>;
12
13#[derive(Clone, Debug, PartialEq, Eq)]
14pub struct G1Prepared(pub G1Affine);
15
16impl From<G1Affine> for G1Prepared {
17 fn from(other: G1Affine) -> Self {
18 G1Prepared(other)
19 }
20}
21
22impl From<G1Projective> for G1Prepared {
23 fn from(q: G1Projective) -> Self {
24 q.into_affine().into()
25 }
26}
27
28impl<'a> From<&'a G1Affine> for G1Prepared {
29 fn from(other: &'a G1Affine) -> Self {
30 G1Prepared(*other)
31 }
32}
33
34impl<'a> From<&'a G1Projective> for G1Prepared {
35 fn from(q: &'a G1Projective) -> Self {
36 q.into_affine().into()
37 }
38}
39
40impl G1Prepared {
41 pub fn is_zero(&self) -> bool {
42 self.0.is_identity()
43 }
44}
45
46impl Default for G1Prepared {
47 fn default() -> Self {
48 G1Prepared(G1Affine::generator())
49 }
50}
51
52#[derive(Clone, Default, PartialEq, Eq)]
53pub struct Parameters;
54
55impl CurveConfig for Parameters {
56 type BaseField = Fq;
57 type ScalarField = Fr;
58
59 /// COFACTOR =
60 /// 86482221941698704497288378992285180119495364068003923046442785886272123124361700722982503222189455144364945735564951561028
61 #[rustfmt::skip]
62 const COFACTOR: &'static [u64] = &[
63 0x5657b9b57b942344,
64 0x84f9a65f3bd54eaf,
65 0x5ea4214e35cd127,
66 0xe3cbcbc14ec1501d,
67 0xf196cb845a3092ab,
68 0x7e14627ad0e19017,
69 0x217db4,
70 ];
71
72 /// COFACTOR^(-1) mod r =
73 /// 163276846538158998893990986356139314746223949404500031940624325017036397274793417940375498603127780919653358641788
74 const COFACTOR_INV: Fr = MontFp!("163276846538158998893990986356139314746223949404500031940624325017036397274793417940375498603127780919653358641788");
75}
76
77impl SWCurveConfig for Parameters {
78 /// COEFF_A = 5
79 const COEFF_A: Fq = MontFp!("5");
80
81 /// COEFF_B = 17764315118651679038286329069295091506801468118146712649886336045535808055361274148466772191243305528312843236347777260247138934336850548243151534538734724191505953341403463040067571652261229308333392040104884438208594329793895206056414
82 const COEFF_B: Fq = MontFp!("17764315118651679038286329069295091506801468118146712649886336045535808055361274148466772191243305528312843236347777260247138934336850548243151534538734724191505953341403463040067571652261229308333392040104884438208594329793895206056414");
83
84 /// AFFINE_GENERATOR_COEFFS = (G1_GENERATOR_X, G1_GENERATOR_Y)
85 const GENERATOR: G1Affine = G1Affine::new_unchecked(G1_GENERATOR_X, G1_GENERATOR_Y);
86}
87
88/// G1_GENERATOR_X =
89/// 5511163824921585887915590525772884263960974614921003940645351443740084257508990841338974915037175497689287870585840954231884082785026301437744745393958283053278991955159266640440849940136976927372133743626748847559939620888818486853646
90pub const G1_GENERATOR_X: Fq = MontFp!("5511163824921585887915590525772884263960974614921003940645351443740084257508990841338974915037175497689287870585840954231884082785026301437744745393958283053278991955159266640440849940136976927372133743626748847559939620888818486853646");
91
92/// G1_GENERATOR_Y =
93/// 7913123550914612057135582061699117755797758113868200992327595317370485234417808273674357776714522052694559358668442301647906991623400754234679697332299689255516547752391831738454121261248793568285885897998257357202903170202349380518443
94pub const G1_GENERATOR_Y: Fq = MontFp!("7913123550914612057135582061699117755797758113868200992327595317370485234417808273674357776714522052694559358668442301647906991623400754234679697332299689255516547752391831738454121261248793568285885897998257357202903170202349380518443");