1 //! Elliptic curve arithmetic traits.
4 ops
::LinearCombination
, AffineXCoordinate
, Curve
, FieldBytes
, IsHigh
, PrimeCurve
, ScalarCore
,
7 use subtle
::{ConditionallySelectable, ConstantTimeEq}
;
8 use zeroize
::DefaultIsZeroes
;
10 /// Elliptic curve with affine arithmetic implementation.
11 #[cfg_attr(docsrs, doc(cfg(feature = "arithmetic")))]
12 pub trait AffineArithmetic
: Curve
+ ScalarArithmetic
{
13 /// Elliptic curve point in affine coordinates.
14 type AffinePoint
: '
static
15 + AffineXCoordinate
<Self>
18 + ConditionallySelectable
30 /// Prime order elliptic curve with projective arithmetic implementation.
31 #[cfg_attr(docsrs, doc(cfg(feature = "arithmetic")))]
32 pub trait PrimeCurveArithmetic
:
33 PrimeCurve
+ ProjectiveArithmetic
<ProjectivePoint
= Self::CurveGroup
>
35 /// Prime order elliptic curve group.
36 type CurveGroup
: group
::prime
::PrimeCurve
<Affine
= <Self as AffineArithmetic
>::AffinePoint
>;
39 /// Elliptic curve with projective arithmetic implementation.
40 #[cfg_attr(docsrs, doc(cfg(feature = "arithmetic")))]
41 pub trait ProjectiveArithmetic
: Curve
+ AffineArithmetic
{
42 /// Elliptic curve point in projective coordinates.
44 /// Note: the following bounds are provided by [`group::Group`]:
53 type ProjectivePoint
: ConditionallySelectable
57 + From
<Self::AffinePoint
>
58 + Into
<Self::AffinePoint
>
60 + group
::Curve
<AffineRepr
= Self::AffinePoint
>
61 + group
::Group
<Scalar
= Self::Scalar
>;
64 /// Scalar arithmetic.
65 #[cfg(feature = "arithmetic")]
66 #[cfg_attr(docsrs, doc(cfg(feature = "arithmetic")))]
67 pub trait ScalarArithmetic
: Curve
{
68 /// Scalar field type.
70 /// Note: the following bounds are provided by [`ff::Field`]:
74 /// - [`ConditionallySelectable`]
75 /// - [`ConstantTimeEq`]
80 type Scalar
: DefaultIsZeroes
81 + From
<ScalarCore
<Self>>
82 + Into
<FieldBytes
<Self>>
86 + ff
::PrimeField
<Repr
= FieldBytes
<Self>>;