{
+ /// Obtains a `TwistedEdwardsCoordinates` value given $(x, y)$, failing if it is not
+ /// on the curve.
+ pub fn from_coordinates(x: P::Base, y: P::Base) -> CtOption {
+ fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self {
+ TwistedEdwardsCoordinates {
+ x: P::Base::conditional_select(&a.x, &b.x, choice),
+ y: P::Base::conditional_select(&a.y, &b.y, choice),
+ }
+ }
+}
+
+//
+// Montgomery curve
+//
+
+/// An affine elliptic curve point on a Montgomery curve
+/// $B \cdot v^2 = u^3 + A \cdot u^2 + u$.
+///
+/// For these curves, it is required that $B \cdot (A^2 - 4) ≠ 0$, which implies that
+/// $A ≠ ±2$ and $B ≠ 0$.
+pub trait MontgomeryPoint: CurveAffine + Default + ConditionallySelectable {
+ /// Field element type used in the curve equation.
+ type Base: Copy + ConditionallySelectable;
+
+ /// The parameter $A$ in the Montgomery curve equation.
+ const A: Self::Base;
+
+ /// The parameter $B$ in the Montgomery curve equation.
+ const B: Self::Base;
+
+ /// Obtains a point given $(u, v)$, failing if it is not on the curve.
+ fn from_bare_coordinates(u: Self::Base, v: Self::Base) -> CtOption {
+ /// Obtains a `MontgomeryCoordinates` value given $(u, v)$, failing if it is not on
+ /// the curve.
+ pub fn from_coordinates(u: P::Base, v: P::Base) -> CtOption {
+ fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self {
+ MontgomeryCoordinates {
+ u: P::Base::conditional_select(&a.u, &b.u, choice),
+ v: P::Base::conditional_select(&a.v, &b.v, choice),
+ }
+ }
+}
+
+//
+// Short Weierstrass curve
+//
+
+/// An affine elliptic curve point on a short Weierstrass curve
+/// $y^2 = x^3 + a \cdot x + b$.
+pub trait ShortWeierstrassPoint: CurveAffine + Default + ConditionallySelectable {
+ /// Field element type used in the curve equation.
+ type Base: Copy + ConditionallySelectable;
+
+ /// The parameter $a$ in the short Weierstrass curve equation.
+ const A: Self::Base;
+
+ /// The parameter $b$ in the short Weierstrass curve equation.
+ const B: Self::Base;
+
+ /// Obtains a point given $(x, y)$, failing if it is not on the curve.
+ fn from_bare_coordinates(x: Self::Base, y: Self::Base) -> CtOption {
+ /// Obtains a `ShortWeierstrassCoordinates` value given $(x, y)$, failing if it is not
+ /// on the curve.
+ pub fn from_coordinates(x: P::Base, y: P::Base) -> CtOption {
+ fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self {
+ ShortWeierstrassCoordinates {
+ x: P::Base::conditional_select(&a.x, &b.x, choice),
+ y: P::Base::conditional_select(&a.y, &b.y, choice),
+ }
+ }
+}
diff --git a/src/lib.rs b/src/lib.rs
index 4d84743..9ec208d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -21,6 +21,8 @@ pub mod prime;
#[cfg(feature = "tests")]
pub mod tests;
+pub mod coordinates;
+
#[cfg(feature = "alloc")]
mod wnaf;
#[cfg(feature = "alloc")]