Skip to content

Commit c190381

Browse files
authored
elliptic-curve: expose AffineCoordinates::y (#1891)
In the past we've deliberately avoided exposing the y-coordinate to prevent the possibility of things like invalid curve attacks, although with time we have exposed more and more to support things like alternative point compression formats. See #1237 for some history. We're now trying to use these traits with Edwards curves like Curve25519 (in `curve25519-dalek`) and Ed448-Goldilocks, which use compressed Edwards y-coordinates as their compressed point format. That requires y-coordinate access. As such, this changes the previous `y_is_odd` method, which was used to implement SEC1-like compressed points, to a full `fn y` which returns a serialized field element for the y-coordinate. Closes #1019
1 parent faf3f65 commit c190381

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

elliptic-curve/src/dev.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,14 @@ impl AffineCoordinates for AffinePoint {
473473
unimplemented!();
474474
}
475475

476+
fn y(&self) -> FieldBytes {
477+
unimplemented!();
478+
}
479+
480+
fn x_is_odd(&self) -> Choice {
481+
unimplemented!();
482+
}
483+
476484
fn y_is_odd(&self) -> Choice {
477485
unimplemented!();
478486
}

elliptic-curve/src/point.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,18 @@ pub type ProjectivePoint<C> = <C as CurveArithmetic>::ProjectivePoint;
2222
/// Access to the affine coordinates of an elliptic curve point.
2323
// TODO: use zkcrypto/group#30 coordinate API when available
2424
pub trait AffineCoordinates {
25-
/// Field element representation.
25+
/// Field element representation with curve-specific serialization/endianness.
2626
type FieldRepr: AsRef<[u8]>;
2727

2828
/// Get the affine x-coordinate as a serialized field element.
2929
fn x(&self) -> Self::FieldRepr;
3030

31+
/// Get the affine y-coordinate as a serialized field element.
32+
fn y(&self) -> Self::FieldRepr;
33+
34+
/// Is the affine x-coordinate odd?
35+
fn x_is_odd(&self) -> Choice;
36+
3137
/// Is the affine y-coordinate odd?
3238
fn y_is_odd(&self) -> Choice;
3339
}

0 commit comments

Comments
 (0)