Skip to main content

ark_tom256/curves/
mod.rs

1use ark_ec::{
2    models::CurveConfig,
3    short_weierstrass::{self as sw, SWCurveConfig},
4};
5use ark_ff::{Field, MontFp};
6
7use crate::{fq::Fq, fr::Fr};
8
9#[cfg(test)]
10mod tests;
11
12pub type Affine = sw::Affine<Config>;
13pub type Projective = sw::Projective<Config>;
14
15#[derive(Copy, Clone, Default, PartialEq, Eq)]
16pub struct Config;
17
18impl CurveConfig for Config {
19    type BaseField = Fq;
20    type ScalarField = Fr;
21
22    /// COFACTOR = 1
23    const COFACTOR: &'static [u64] = &[0x1];
24
25    /// COFACTOR_INV = COFACTOR^{-1} mod r = 1
26    #[rustfmt::skip]
27    const COFACTOR_INV: Fr =  Fr::ONE;
28}
29
30impl SWCurveConfig for Config {
31    /// COEFF_A = 115792089210356248762697446949407573530594504085698471288169790229257723883796
32    const COEFF_A: Fq =
33        MontFp!("115792089210356248762697446949407573530594504085698471288169790229257723883796");
34
35    /// COEFF_B = 81531206846337786915455327229510804132577517753388365729879493166393691077718
36    const COEFF_B: Fq =
37        MontFp!("81531206846337786915455327229510804132577517753388365729879493166393691077718");
38
39    /// GENERATOR = (G_GENERATOR_X, G_GENERATOR_Y)
40    const GENERATOR: Affine = Affine::new_unchecked(G_GENERATOR_X, G_GENERATOR_Y);
41
42    /// Correctness:
43    /// The curve equation is y^2 = x^3 + ax + b
44    /// Substituting (0, 0) gives 0 = b. Since b is not zero,
45    /// the point (0, 0) is not on the curve, so (0, 0) can safely
46    /// flag the zero/identity point.
47    #[cfg(feature = "zero-flag")]
48    type ZeroFlag = ();
49}
50
51/// G_GENERATOR_X =
52/// 3
53pub const G_GENERATOR_X: Fq = MontFp!("3");
54
55/// G_GENERATOR_Y =
56/// 40902200210088653215032584946694356296222563095503428277299570638400093548589
57pub const G_GENERATOR_Y: Fq =
58    MontFp!("40902200210088653215032584946694356296222563095503428277299570638400093548589");