-
Notifications
You must be signed in to change notification settings - Fork 219
elliptic-curve: consolidate AffineCoordinates
trait
#1237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
tarcieri
merged 1 commit into
master
from
elliptic-curve/consolidate-affine-coordinates-trait
Feb 1, 2023
Merged
elliptic-curve: consolidate AffineCoordinates
trait
#1237
tarcieri
merged 1 commit into
master
from
elliptic-curve/consolidate-affine-coordinates-trait
Feb 1, 2023
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
See RustCrypto/elliptic-curves#50 for some historic context. After being able to get by on `AffineXCoordinate` for generic ECDH and ECDSA, #1199 added an `AffineYIsOdd` trait which was needed to enable the generic ECDSA implementation in the `ecdsa` crate to compute the "recovery ID" for signatures (which is effectively point compression for the `R` curve point). This commit consolidates `AffineXCoordinate` and `AffineYIsOdd` into an `AffineCoordinates` trait. Some observations since prior discussion in RustCrypto/elliptic-curves#50: - Access to coordinates is through bytes, namely `FieldBytes`. This is so as to avoid exposing a crate's field element type. This approach isn't type safe (base field elements and scalar field elements share the same serialization) but does make ECDSA's weird reduction of a base field element into the scalar field straightforward in generic code. - Prior to this attempts were made to extract ECDSA-specific bits into a trait to handle these conversions, but it complicates both writing generic code and optimizing performance. While this still might be worth exploring, so far those explorations have largely failed. - Generally there have been a lot of requests for coordinate access specifically for things like point serialization formats. We ended up adding "compaction" support upstream but we have had requests for several other formats (e.g. Elligator Squared) where direct coordinate access would be useful. This trait can hopefully be replaced by a coordinate access API provided by the `group` crate in the future. See zkcrypto/group#30
tarcieri
added a commit
to RustCrypto/signatures
that referenced
this pull request
Feb 1, 2023
Switches to the newly consolidated `AffineCoordinates` trait. See RustCrypto/traits#1237
tarcieri
added a commit
to RustCrypto/signatures
that referenced
this pull request
Feb 1, 2023
Switches to the newly consolidated `AffineCoordinates` trait. See RustCrypto/traits#1237
tarcieri
added a commit
to RustCrypto/elliptic-curves
that referenced
this pull request
Feb 1, 2023
Switches to the newly consolidated `AffineCoordinates` trait. See RustCrypto/traits#1237
tarcieri
added a commit
to RustCrypto/elliptic-curves
that referenced
this pull request
Feb 1, 2023
Switches to the newly consolidated `AffineCoordinates` trait. See RustCrypto/traits#1237
Merged
tarcieri
added a commit
that referenced
this pull request
Jun 5, 2025
Closes #1019 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.
tarcieri
added a commit
that referenced
this pull request
Jun 5, 2025
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
tarcieri
added a commit
that referenced
this pull request
Jun 5, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See RustCrypto/elliptic-curves#50 for some historic context.
After being able to get by on
AffineXCoordinate
for generic ECDH and ECDSA, #1199 added anAffineYIsOdd
trait which was needed to enable the generic ECDSA implementation in theecdsa
crate to compute the "recovery ID" for signatures (which is effectively point compression for theR
curve point).This commit consolidates
AffineXCoordinate
andAffineYIsOdd
into anAffineCoordinates
trait.Some observations since prior discussion in
RustCrypto/elliptic-curves#50:
FieldBytes
. This is so as to avoid exposing a crate's field element type. This approach isn't type safe (base field elements and scalar field elements share the same serialization) but does make ECDSA's weird reduction of a base field element into the scalar field straightforward in generic code.This trait can hopefully be replaced by a coordinate access API provided by the
group
crate in the future. See zkcrypto/group#30