elliptic_curve/
arithmetic.rs
1use crate::{
4 ops::LinearCombination, AffineXCoordinate, Curve, FieldBytes, IsHigh, PrimeCurve, ScalarCore,
5};
6use core::fmt::Debug;
7use subtle::{ConditionallySelectable, ConstantTimeEq};
8use zeroize::DefaultIsZeroes;
9
10#[cfg_attr(docsrs, doc(cfg(feature = "arithmetic")))]
12pub trait AffineArithmetic: Curve + ScalarArithmetic {
13 type AffinePoint: 'static
15 + AffineXCoordinate<Self>
16 + Copy
17 + Clone
18 + ConditionallySelectable
19 + ConstantTimeEq
20 + Debug
21 + Default
22 + DefaultIsZeroes
23 + Eq
24 + PartialEq
25 + Sized
26 + Send
27 + Sync;
28}
29
30#[cfg_attr(docsrs, doc(cfg(feature = "arithmetic")))]
32pub trait PrimeCurveArithmetic:
33 PrimeCurve + ProjectiveArithmetic<ProjectivePoint = Self::CurveGroup>
34{
35 type CurveGroup: group::prime::PrimeCurve<Affine = <Self as AffineArithmetic>::AffinePoint>;
37}
38
39#[cfg_attr(docsrs, doc(cfg(feature = "arithmetic")))]
41pub trait ProjectiveArithmetic: Curve + AffineArithmetic {
42 type ProjectivePoint: ConditionallySelectable
54 + ConstantTimeEq
55 + Default
56 + DefaultIsZeroes
57 + From<Self::AffinePoint>
58 + Into<Self::AffinePoint>
59 + LinearCombination
60 + group::Curve<AffineRepr = Self::AffinePoint>
61 + group::Group<Scalar = Self::Scalar>;
62}
63
64#[cfg(feature = "arithmetic")]
66#[cfg_attr(docsrs, doc(cfg(feature = "arithmetic")))]
67pub trait ScalarArithmetic: Curve {
68 type Scalar: DefaultIsZeroes
81 + From<ScalarCore<Self>>
82 + Into<FieldBytes<Self>>
83 + Into<Self::UInt>
84 + IsHigh
85 + ff::Field
86 + ff::PrimeField<Repr = FieldBytes<Self>>;
87}