arnaucube
arnaucube/ark-curves-cherry-pickedPublic Self-hosted repository
ark-curves-cherry-picked/pallas/src/curves/mod.rs
pallas/src/curves/mod.rsRaw
 1use ark_ec::{
 2    models::{ModelParameters, SWModelParameters},
 3    short_weierstrass_jacobian::{GroupAffine, GroupProjective},
 4};
 5use ark_ff::{MontFp, Zero};
 6
 7use crate::{fq::Fq, fr::Fr};
 8
 9#[cfg(test)]
10mod tests;
11
12#[derive(Copy, Clone, Default, PartialEq, Eq)]
13pub struct PallasParameters;
14
15impl ModelParameters for PallasParameters {
16    type BaseField = Fq;
17    type ScalarField = Fr;
18
19    /// COFACTOR = 1
20    const COFACTOR: &'static [u64] = &[0x1];
21
22    /// COFACTOR_INV = 1
23    const COFACTOR_INV: Fr = MontFp!(Fr, "1");
24}
25
26pub type Affine = GroupAffine<PallasParameters>;
27pub type Projective = GroupProjective<PallasParameters>;
28
29impl SWModelParameters for PallasParameters {
30    /// COEFF_A = 0
31    const COEFF_A: Fq = MontFp!(Fq, "0");
32
33    /// COEFF_B = 5
34    const COEFF_B: Fq = MontFp!(Fq, "5");
35
36    /// AFFINE_GENERATOR_COEFFS = (G1_GENERATOR_X, G1_GENERATOR_Y)
37    const AFFINE_GENERATOR_COEFFS: (Self::BaseField, Self::BaseField) =
38        (G_GENERATOR_X, G_GENERATOR_Y);
39
40    #[inline(always)]
41    fn mul_by_a(_: &Self::BaseField) -> Self::BaseField {
42        Self::BaseField::zero()
43    }
44}
45
46/// G_GENERATOR_X = -1
47pub const G_GENERATOR_X: Fq = MontFp!(Fq, "-1");
48
49/// G_GENERATOR_Y = 2
50pub const G_GENERATOR_Y: Fq = MontFp!(Fq, "2");