arnaucube
arnaucube/ark-curves-cherry-pickedPublic Self-hosted repository
ark-curves-cherry-picked/vesta/src/curves/mod.rs
vesta/src/curves/mod.rsRaw
 1use crate::{fq::Fq, fr::Fr};
 2use ark_ec::{
 3    models::CurveConfig,
 4    short_weierstrass::{self as sw, SWCurveConfig},
 5};
 6use ark_ff::{Field, MontFp, Zero};
 7
 8#[cfg(test)]
 9mod tests;
10
11#[derive(Copy, Clone, Default, PartialEq, Eq)]
12pub struct VestaParameters;
13
14impl CurveConfig for VestaParameters {
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 = Fr::ONE;
23}
24
25pub type Affine = sw::Affine<VestaParameters>;
26pub type Projective = sw::Projective<VestaParameters>;
27
28impl SWCurveConfig for VestaParameters {
29    /// COEFF_A = 0
30    const COEFF_A: Fq = Fq::ZERO;
31
32    /// COEFF_B = 5
33    const COEFF_B: Fq = MontFp!("5");
34
35    /// AFFINE_GENERATOR_COEFFS = (G1_GENERATOR_X, G1_GENERATOR_Y)
36    const GENERATOR: Affine = Affine::new_unchecked(G_GENERATOR_X, G_GENERATOR_Y);
37
38    #[inline(always)]
39    fn mul_by_a(_: &Self::BaseField) -> Self::BaseField {
40        Self::BaseField::zero()
41    }
42}
43
44/// G_GENERATOR_X = -1
45/// Encoded in Montgomery form, so the value here is -R mod p.
46pub const G_GENERATOR_X: Fq = MontFp!("-1");
47
48/// G_GENERATOR_Y = 2
49/// Encoded in Montgomery form, so the value here is 2R mod p.
50pub const G_GENERATOR_Y: Fq = MontFp!("2");