mirror of
https://github.com/saymrwulf/pasta_curves-source.git
synced 2026-09-04 20:03:39 +00:00
Merge pull request #34 from davidnevadoc/coordinates-pub
Add constructor for `Coordinates`
This commit is contained in:
commit
cc57a3b75b
1 changed files with 5 additions and 0 deletions
|
|
@ -140,6 +140,11 @@ pub struct Coordinates<C: CurveAffine> {
|
|||
|
||||
#[cfg(feature = "alloc")]
|
||||
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.
|
||||
///
|
||||
/// Equivalent to `Coordinates::u`.
|
||||
|
|
|
|||
Loading…
Reference in a new issue