1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::elliptic_curve::traits::IsEllipticCurve;
use crate::field::element::FieldElement;
use core::fmt::Debug;
/// Trait to add elliptic curves behaviour to a struct.
pub trait IsEdwards: IsEllipticCurve + Clone + Debug {
    fn a() -> FieldElement<Self::BaseField>;

    fn d() -> FieldElement<Self::BaseField>;

    fn defining_equation(
        x: &FieldElement<Self::BaseField>,
        y: &FieldElement<Self::BaseField>,
    ) -> FieldElement<Self::BaseField> {
        (Self::a() * x.pow(2_u16) + y.pow(2_u16))
            - FieldElement::<Self::BaseField>::one()
            - Self::d() * x.pow(2_u16) * y.pow(2_u16)
    }
}