mina_curves/pasta/curves/
vesta.rs

1use crate::pasta::*;
2use ark_ec::{
3    models::short_weierstrass::{Affine, Projective, SWCurveConfig},
4    CurveConfig,
5};
6use ark_ff::{MontFp, Zero};
7
8/// G_GENERATOR_X =
9/// 1
10pub const G_GENERATOR_X: Fq = MontFp!("1");
11
12/// G1_GENERATOR_Y =
13/// 11426906929455361843568202299992114520848200991084027513389447476559454104162
14pub const G_GENERATOR_Y: Fq =
15    MontFp!("11426906929455361843568202299992114520848200991084027513389447476559454104162");
16
17#[derive(Debug, Clone, Default, PartialEq, Eq)]
18pub struct VestaParameters;
19
20impl CurveConfig for VestaParameters {
21    type BaseField = Fq;
22    type ScalarField = Fp;
23
24    /// COFACTOR = 1
25    const COFACTOR: &'static [u64] = &[0x1];
26
27    /// COFACTOR_INV = 1
28    const COFACTOR_INV: Fp = MontFp!("1");
29}
30
31pub type Vesta = Affine<VestaParameters>;
32pub type ProjectiveVesta = Projective<VestaParameters>;
33
34impl SWCurveConfig for VestaParameters {
35    /// COEFF_A = 0
36    const COEFF_A: Fq = MontFp!("0");
37
38    /// COEFF_B = 5
39    const COEFF_B: Fq = MontFp!("5");
40
41    /// AFFINE_GENERATOR_COEFFS = (G1_GENERATOR_X, G1_GENERATOR_Y)
42    const GENERATOR: Affine<Self> = Affine::new_unchecked(G_GENERATOR_X, G_GENERATOR_Y);
43}
44
45impl VestaParameters {
46    #[inline(always)]
47    pub fn mul_by_a(
48        _: &<VestaParameters as CurveConfig>::BaseField,
49    ) -> <VestaParameters as CurveConfig>::BaseField {
50        <VestaParameters as CurveConfig>::BaseField::zero()
51    }
52}
53
54/// legacy curve, a copy of the normal curve to support legacy sponge params
55#[derive(Copy, Clone, Default, PartialEq, Eq)]
56pub struct LegacyVestaParameters;
57
58impl CurveConfig for LegacyVestaParameters {
59    type BaseField = <VestaParameters as CurveConfig>::BaseField;
60    type ScalarField = <VestaParameters as CurveConfig>::ScalarField;
61    const COFACTOR: &'static [u64] = <VestaParameters as CurveConfig>::COFACTOR;
62    const COFACTOR_INV: Self::ScalarField = <VestaParameters as CurveConfig>::COFACTOR_INV;
63}
64
65impl SWCurveConfig for LegacyVestaParameters {
66    const COEFF_A: Self::BaseField = <VestaParameters as SWCurveConfig>::COEFF_A;
67    const COEFF_B: Self::BaseField = <VestaParameters as SWCurveConfig>::COEFF_B;
68    const GENERATOR: Affine<Self> = Affine::new_unchecked(G_GENERATOR_X, G_GENERATOR_Y);
69}
70
71pub type LegacyVesta = Affine<LegacyVestaParameters>;