primeorder/
lib.rs

1#![no_std]
2#![cfg_attr(docsrs, feature(doc_auto_cfg))]
3#![doc(
4    html_logo_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg",
5    html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg"
6)]
7#![forbid(unsafe_code)]
8#![warn(missing_docs, rust_2018_idioms, unused_qualifications)]
9#![doc = include_str!("../README.md")]
10
11#[cfg(feature = "alloc")]
12#[macro_use]
13extern crate alloc;
14
15pub mod point_arithmetic;
16
17mod affine;
18#[cfg(feature = "dev")]
19mod dev;
20mod field;
21mod projective;
22
23pub use crate::{affine::AffinePoint, projective::ProjectivePoint};
24pub use elliptic_curve::{
25    self, generic_array, point::Double, Field, FieldBytes, PrimeCurve, PrimeField,
26};
27
28use elliptic_curve::CurveArithmetic;
29
30/// Parameters for elliptic curves of prime order which can be described by the
31/// short Weierstrass equation.
32pub trait PrimeCurveParams:
33    PrimeCurve
34    + CurveArithmetic
35    + CurveArithmetic<AffinePoint = AffinePoint<Self>>
36    + CurveArithmetic<ProjectivePoint = ProjectivePoint<Self>>
37{
38    /// Base field element type.
39    // TODO(tarcieri): add `Invert` bound
40    type FieldElement: PrimeField<Repr = FieldBytes<Self>>;
41
42    /// [Point arithmetic](point_arithmetic) implementation, might be optimized for this specific curve
43    type PointArithmetic: point_arithmetic::PointArithmetic<Self>;
44
45    /// Coefficient `a` in the curve equation.
46    const EQUATION_A: Self::FieldElement;
47
48    /// Coefficient `b` in the curve equation.
49    const EQUATION_B: Self::FieldElement;
50
51    /// Generator point's affine coordinates: (x, y).
52    const GENERATOR: (Self::FieldElement, Self::FieldElement);
53}