diff --git a/src/arithmetic/curves.rs b/src/arithmetic/curves.rs index ca94e58..44eced6 100644 --- a/src/arithmetic/curves.rs +++ b/src/arithmetic/curves.rs @@ -140,6 +140,11 @@ pub struct Coordinates { #[cfg(feature = "alloc")] impl Coordinates { + /// Obtains a `Coordinates` value given $(x, y)$, failing if it is not on the curve. + pub fn from_xy(x: C::Base, y: C::Base) -> CtOption { + // We use CurveAffine::from_xy to validate the coordinates. + C::from_xy(x, y).map(|_| Coordinates { x, y }) + } /// Returns the x-coordinate. /// /// Equivalent to `Coordinates::u`.