mina_curves/pasta/curves/
pallas.rs

1use crate::pasta::*;
2use ark_ec::{
3    models::short_weierstrass::{Affine, Projective, SWCurveConfig},
4    CurveConfig,
5};
6use ark_ff::{MontFp, Zero};
7
8/// G_GENERATOR_X =
9/// 1
10pub const G_GENERATOR_X: Fp = MontFp!("1");
11
12/// G1_GENERATOR_Y =
13/// 12418654782883325593414442427049395787963493412651469444558597405572177144507
14pub const G_GENERATOR_Y: Fp =
15    MontFp!("12418654782883325593414442427049395787963493412651469444558597405572177144507");
16
17#[derive(Debug, Clone, Default, PartialEq, Eq)]
18pub struct PallasParameters;
19
20impl CurveConfig for PallasParameters {
21    type BaseField = Fp;
22
23    type ScalarField = Fq;
24
25    /// COFACTOR = 1
26    const COFACTOR: &'static [u64] = &[0x1];
27
28    /// COFACTOR_INV = 1
29    const COFACTOR_INV: Fq = MontFp!("1");
30}
31
32pub type Pallas = Affine<PallasParameters>;
33
34pub type ProjectivePallas = Projective<PallasParameters>;
35
36impl SWCurveConfig for PallasParameters {
37    const COEFF_A: Self::BaseField = MontFp!("0");
38
39    const COEFF_B: Self::BaseField = MontFp!("5");
40
41    const GENERATOR: Affine<Self> = Affine::new_unchecked(G_GENERATOR_X, G_GENERATOR_Y);
42}
43
44impl PallasParameters {
45    #[inline(always)]
46    pub fn mul_by_a(
47        _: &<PallasParameters as CurveConfig>::BaseField,
48    ) -> <PallasParameters as CurveConfig>::BaseField {
49        <PallasParameters as CurveConfig>::BaseField::zero()
50    }
51}
52
53/// legacy curve, a copy of the normal curve to support legacy sponge params
54#[derive(Copy, Clone, Default, PartialEq, Eq)]
55pub struct LegacyPallasParameters;
56
57impl CurveConfig for LegacyPallasParameters {
58    type BaseField = <PallasParameters as CurveConfig>::BaseField;
59
60    type ScalarField = <PallasParameters as CurveConfig>::ScalarField;
61
62    const COFACTOR: &'static [u64] = <PallasParameters as CurveConfig>::COFACTOR;
63
64    const COFACTOR_INV: Self::ScalarField = <PallasParameters as CurveConfig>::COFACTOR_INV;
65}
66
67impl SWCurveConfig for LegacyPallasParameters {
68    const COEFF_A: Self::BaseField = <PallasParameters as SWCurveConfig>::COEFF_A;
69
70    const COEFF_B: Self::BaseField = <PallasParameters as SWCurveConfig>::COEFF_B;
71
72    const GENERATOR: Affine<Self> = Affine::new_unchecked(G_GENERATOR_X, G_GENERATOR_Y);
73}
74
75pub type LegacyPallas = Affine<LegacyPallasParameters>;