mirror of
https://github.com/saymrwulf/pasta_curves-source.git
synced 2026-09-04 20:03:39 +00:00
Add Coordinates constructor
This commit is contained in:
parent
8a3643682f
commit
8b101d67c4
1 changed files with 5 additions and 0 deletions
|
|
@ -140,6 +140,11 @@ pub struct Coordinates<C: CurveAffine> {
|
||||||
|
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
impl<C: CurveAffine> Coordinates<C> {
|
impl<C: CurveAffine> Coordinates<C> {
|
||||||
|
/// 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<Self> {
|
||||||
|
// We use CurveAffine::from_xy to validate the coordinates.
|
||||||
|
C::from_xy(x, y).map(|_| Coordinates { x, y })
|
||||||
|
}
|
||||||
/// Returns the x-coordinate.
|
/// Returns the x-coordinate.
|
||||||
///
|
///
|
||||||
/// Equivalent to `Coordinates::u`.
|
/// Equivalent to `Coordinates::u`.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue