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