p256/
arithmetic.rs
1pub(crate) mod field;
8#[cfg(feature = "hash2curve")]
9mod hash2curve;
10pub(crate) mod scalar;
11pub(crate) mod util;
12
13use self::{field::FieldElement, scalar::Scalar};
14use crate::NistP256;
15use elliptic_curve::{CurveArithmetic, PrimeCurveArithmetic};
16use primeorder::{point_arithmetic, PrimeCurveParams};
17
18pub type AffinePoint = primeorder::AffinePoint<NistP256>;
20
21pub type ProjectivePoint = primeorder::ProjectivePoint<NistP256>;
23
24impl CurveArithmetic for NistP256 {
25 type AffinePoint = AffinePoint;
26 type ProjectivePoint = ProjectivePoint;
27 type Scalar = Scalar;
28}
29
30impl PrimeCurveArithmetic for NistP256 {
31 type CurveGroup = ProjectivePoint;
32}
33
34impl PrimeCurveParams for NistP256 {
38 type FieldElement = FieldElement;
39 type PointArithmetic = point_arithmetic::EquationAIsMinusThree;
40
41 const EQUATION_A: FieldElement = FieldElement::from_u64(3).neg();
43
44 const EQUATION_B: FieldElement =
45 FieldElement::from_hex("5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b");
46
47 const GENERATOR: (FieldElement, FieldElement) = (
56 FieldElement::from_hex("6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),
57 FieldElement::from_hex("4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),
58 );
59}