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::CurveConfig,
 3    short_weierstrass::{Affine, Projective, SWCurveConfig},
 4};
 5use ark_ff::{Field, 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 CurveConfig 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 = Fr::ONE;
24}
25
26pub type G1Affine = Affine<PallasParameters>;
27pub type G1Projective = Projective<PallasParameters>;
28
29impl SWCurveConfig for PallasParameters {
30    /// COEFF_A = 0
31    const COEFF_A: Fq = Fq::ZERO;
32
33    /// COEFF_B = 5
34    const COEFF_B: Fq = MontFp!("5");
35
36    /// AFFINE_GENERATOR_COEFFS = (G1_GENERATOR_X, G1_GENERATOR_Y)
37    const GENERATOR: G1Affine = Affine::new_unchecked(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 = MontFp!("-1");
47
48/// G_GENERATOR_Y = 2
49pub const G_GENERATOR_Y: Fq = MontFp!("2");