Skip to content

Conversation

@tarcieri
Copy link
Member

Protocols like ECDH and ECDSA rely on x-coordinate access.

We've tried various ways of trying to keep affine coordinate access out of the public API, but it complicates generic implementations of these protocols.

Most recently RustCrypto/signatures#395 attempted to add a trait which encapsulated ECDSA signing, but a similar (or expanded version of the same) trait is needed for verification.

All of these problems go away, and can be expressed with simple trait bounds, if there is some way to access the x-coordinate of an AffinePoint as serialized FieldBytes.

This commit adds such a trait: AffineXCoordinate, which is a mandatory bound of AffineArithmetic::AffinePoint.

Protocols like ECDH and ECDSA rely on x-coordinate access.

We've tried various ways of trying to keep affine coordinate access out
of the public API, but it complicates generic implementations of these
protocols.

Most recently RustCrypto/signatures#395 attempted to add a trait which
encapsulated ECDSA signing, but a similar (or expaned version of the
same) trait is needed for verification.

All of these problems go away, and can be expressed with simple trait
bounds, if there is some way to access the x-coordinate of an
`AffinePoint` as serialized `FieldBytes`.

This commit adds such a trait: `AffineXCoordinate`, which is a mandatory
bound of `AffineArithmetic::AffinePoint`.
@tarcieri tarcieri merged commit 7d81302 into master Nov 17, 2021
@tarcieri tarcieri deleted the elliptic-curve/affine-x-coordinate branch November 17, 2021 23:59
tarcieri added a commit to RustCrypto/signatures that referenced this pull request Nov 18, 2021
Leverages the newly added `AffineXCoordinate` trait from
RustCrypto/traits#817 to provide a default generic implementation of
the ECDSA signature algorithm.

Downstream crates can choose to override this implementation if they so
desire, allowing them to potentially leverage more efficient arithmetic.

This approach does have a disadvantage that it necessarily adds a
`ScalarArithmetic<Scalar = Self>` bound on the curve, meaning that
`SignPrimitive` can only be impl'd for a particular curve's scalar type,
as opposed to the original design goal of allowing it to be impl'd for a
hardware ECDSA accelerator that stores a private scalar.

Either the default impl needs to be replaced with a blanket impl with
more restrictive bounds, or a separate trait needs to be added to
support hardware accelerators. The latter may indeed make the most
sense.
tarcieri added a commit to RustCrypto/signatures that referenced this pull request Nov 18, 2021
Leverages the newly added `AffineXCoordinate` trait from
RustCrypto/traits#817 to provide a default generic implementation of
the ECDSA signature algorithm.

Downstream crates can choose to override this implementation if they so
desire, allowing them to potentially leverage more efficient arithmetic.

This approach does have a disadvantage that it necessarily adds a
`ScalarArithmetic<Scalar = Self>` bound on the curve, meaning that
`SignPrimitive` can only be impl'd for a particular curve's scalar type,
as opposed to the original design goal of allowing it to be impl'd for a
hardware ECDSA accelerator that stores a private scalar.

Either the default impl needs to be replaced with a blanket impl with
more restrictive bounds, or a separate trait needs to be added to
support hardware accelerators. The latter may indeed make the most
sense.
@tarcieri tarcieri mentioned this pull request Nov 20, 2021
scv35 added a commit to scv35/Signature-algorithms that referenced this pull request Jul 4, 2025
Leverages the newly added `AffineXCoordinate` trait from
RustCrypto/traits#817 to provide a default generic implementation of
the ECDSA signature algorithm.

Downstream crates can choose to override this implementation if they so
desire, allowing them to potentially leverage more efficient arithmetic.

This approach does have a disadvantage that it necessarily adds a
`ScalarArithmetic<Scalar = Self>` bound on the curve, meaning that
`SignPrimitive` can only be impl'd for a particular curve's scalar type,
as opposed to the original design goal of allowing it to be impl'd for a
hardware ECDSA accelerator that stores a private scalar.

Either the default impl needs to be replaced with a blanket impl with
more restrictive bounds, or a separate trait needs to be added to
support hardware accelerators. The latter may indeed make the most
sense.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants