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::{ModelParameters, SWModelParameters},
4 short_weierstrass_jacobian::{GroupAffine, GroupProjective},
5};
6use ark_ff::{MontFp, Zero};
7
8#[cfg(test)]
9mod tests;
10
11#[derive(Copy, Clone, Default, PartialEq, Eq)]
12pub struct VestaParameters;
13
14impl ModelParameters 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 = MontFp!(Fr, "1");
23}
24
25pub type Affine = GroupAffine<VestaParameters>;
26pub type Projective = GroupProjective<VestaParameters>;
27
28impl SWModelParameters for VestaParameters {
29 /// COEFF_A = 0
30 const COEFF_A: Fq = MontFp!(Fq, "0");
31
32 /// COEFF_B = 5
33 const COEFF_B: Fq = MontFp!(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
46/// Encoded in Montgomery form, so the value here is -R mod p.
47pub const G_GENERATOR_X: Fq = MontFp!(Fq, "-1");
48
49/// G_GENERATOR_Y = 2
50/// Encoded in Montgomery form, so the value here is 2R mod p.
51pub const G_GENERATOR_Y: Fq = MontFp!(Fq, "2");