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    /// COFACTOR = 1
19    const COFACTOR: &'static [u64] = &[0x1];
20
21    /// COFACTOR_INV = 1
22    const COFACTOR_INV: Fr = field_new!(Fr, "1");
23}
24
25pub type Affine = GroupAffine<PallasParameters>;
26pub type Projective = GroupProjective<PallasParameters>;
27
28impl SWModelParameters for PallasParameters {
29    /// COEFF_A = 0
30    const COEFF_A: Fq = field_new!(Fq, "0");
31
32    /// COEFF_B = 5
33    const COEFF_B: Fq = field_new!(Fq, "5");
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");