pub(crate) mod field;
pub(crate) mod scalar;
#[cfg(feature = "hash2curve")]
mod hash2curve;
#[cfg(feature = "precomputed-tables")]
mod tables;
use self::{field::FieldElement, scalar::Scalar};
use crate::NistP256;
use elliptic_curve::{CurveArithmetic, PrimeCurveArithmetic, hazmat::FieldArithmetic};
use primeorder::{PrimeCurveParams, point_arithmetic};
pub type AffinePoint = primeorder::AffinePoint<NistP256>;
pub type ProjectivePoint = primeorder::ProjectivePoint<NistP256>;
impl CurveArithmetic for NistP256 {
type AffinePoint = AffinePoint;
type ProjectivePoint = ProjectivePoint;
type Scalar = Scalar;
}
impl FieldArithmetic for NistP256 {
type FieldElement = FieldElement;
}
impl PrimeCurveArithmetic for NistP256 {
type CurveGroup = ProjectivePoint;
}
impl PrimeCurveParams for NistP256 {
type PointArithmetic = point_arithmetic::EquationAIsMinusThree;
#[cfg(not(feature = "precomputed-tables"))]
type Backend = primeorder::mul_backend::VariableOnly;
#[cfg(feature = "precomputed-tables")]
type Backend = tables::backend::PrecomputedTables;
const EQUATION_A: FieldElement = FieldElement::from_u64(3).neg();
const EQUATION_B: FieldElement = FieldElement::from_hex_vartime(
"5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b",
);
const GENERATOR: (FieldElement, FieldElement) = (
FieldElement::from_hex_vartime(
"6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296",
),
FieldElement::from_hex_vartime(
"4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5",
),
);
}