1pub(crate) mod field;
8pub(crate) mod scalar;
9
10#[cfg(feature = "hash2curve")]
11mod hash2curve;
12#[cfg(feature = "precomputed-tables")]
13mod tables;
14
15use self::{field::FieldElement, scalar::Scalar};
16use crate::NistP256;
17use elliptic_curve::{CurveArithmetic, PrimeCurveArithmetic, hazmat::FieldArithmetic};
18use primeorder::{PrimeCurveParams, point_arithmetic};
19
20pub type AffinePoint = primeorder::AffinePoint<NistP256>;
22
23pub type ProjectivePoint = primeorder::ProjectivePoint<NistP256>;
25
26impl CurveArithmetic for NistP256 {
27 type AffinePoint = AffinePoint;
28 type ProjectivePoint = ProjectivePoint;
29 type Scalar = Scalar;
30}
31
32impl FieldArithmetic for NistP256 {
33 type FieldElement = FieldElement;
34}
35
36impl PrimeCurveArithmetic for NistP256 {
37 type CurveGroup = ProjectivePoint;
38}
39
40impl PrimeCurveParams for NistP256 {
44 type PointArithmetic = point_arithmetic::EquationAIsMinusThree;
45
46 #[cfg(not(feature = "precomputed-tables"))]
47 type Backend = primeorder::mul_backend::VariableOnly;
48 #[cfg(feature = "precomputed-tables")]
50 type Backend = tables::backend::PrecomputedTables;
51
52 const EQUATION_A: FieldElement = FieldElement::from_u64(3).neg();
54
55 const EQUATION_B: FieldElement = FieldElement::from_hex_vartime(
56 "5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b",
57 );
58
59 const GENERATOR: (FieldElement, FieldElement) = (
68 FieldElement::from_hex_vartime(
69 "6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296",
70 ),
71 FieldElement::from_hex_vartime(
72 "4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5",
73 ),
74 );
75}