Skip to content

Conversation

@tarcieri
Copy link
Member

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.

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 merged commit b35f40c into master Nov 18, 2021
@tarcieri tarcieri deleted the ecdsa/default-sign-primitive-impl branch November 18, 2021 00:32
tarcieri added a commit that referenced this pull request Nov 18, 2021
Similar to #396, this adds a generic implementation of ECDSA signature
verification by providing a default implementation of the
`VerifyPrimitive::verify_prehashed` method.

Downstream crates can choose to override this implementation if they so
desire, allowing them to potentially leverage more efficient arithmetic
such as Shamir's trick / linear combinations (at least, until such a
time as there are traits for these in the `group` crate).

This approach does have a disadvantage that it necessarily adds a
`AffineArithmetic<AffinePoint = Self>` bound on the curve, meaning that
`VerifyPrimitive` can only be impl'd for a particular curve's affine
point 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 changed the title Add default impl of SignPrimitive::try_sign_prehashed ecdsa: add default impl of SignPrimitive::try_sign_prehashed Nov 18, 2021
tarcieri added a commit that referenced this pull request Nov 18, 2021
Similar to #396, this adds a generic implementation of ECDSA signature
verification by providing a default implementation of the
`VerifyPrimitive::verify_prehashed` method.

Downstream crates can choose to override this implementation if they so
desire, allowing them to potentially leverage more efficient arithmetic
such as Shamir's trick / linear combinations (at least, until such a
time as there are traits for these in the `group` crate).

This approach does have a disadvantage that it necessarily adds a
`AffineArithmetic<AffinePoint = Self>` bound on the curve, meaning that
`VerifyPrimitive` can only be impl'd for a particular curve's affine
point 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 that referenced this pull request Nov 18, 2021
#397)

Similar to #396, this adds a generic implementation of ECDSA signature
verification by providing a default implementation of the
`VerifyPrimitive::verify_prehashed` method.

Downstream crates can choose to override this implementation if they so
desire, allowing them to potentially leverage more efficient arithmetic
such as Shamir's trick / linear combinations (at least, until such a
time as there are traits for these in the `group` crate).

This approach does have a disadvantage that it necessarily adds a
`AffineArithmetic<AffinePoint = Self>` bound on the curve, meaning that
`VerifyPrimitive` can only be impl'd for a particular curve's affine
point 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 that referenced this pull request Nov 18, 2021
Updates test macros with the changes from #396 and #397
@tarcieri tarcieri mentioned this pull request Nov 18, 2021
tarcieri added a commit that referenced this pull request Nov 18, 2021
Updates test macros with the changes from #396 and #397
tarcieri added a commit to RustCrypto/elliptic-curves that referenced this pull request Nov 18, 2021
This updates the crates in this repo to leverage the following generic
implementations recently added to the `ecdsa` crate:

- Sign: RustCrypto/signatures#396
- Verify: RustCrypto/signatures#397

The `p256` crate is able to directly utilize the generic implementation
from the `ecdsa` crate.

The `k256` crate retains its previous custom implementation, which
provides a secp256k1-specific take on public key recovery, but can also
directly leverage optimizations for computing linear combinations, which
there are not presently traits in `elliptic-curve` or `group` to
express.
tarcieri added a commit to RustCrypto/elliptic-curves that referenced this pull request Nov 18, 2021
This updates the crates in this repo to leverage the following generic
implementations recently added to the `ecdsa` crate:

- Sign: RustCrypto/signatures#396
- Verify: RustCrypto/signatures#397

The `p256` crate is able to directly utilize the generic implementation
from the `ecdsa` crate.

The `k256` crate retains its previous custom implementation, which
provides a secp256k1-specific take on public key recovery, but can also
directly leverage optimizations for computing linear combinations, which
there are not presently traits in `elliptic-curve` or `group` to
express.
tarcieri added a commit to RustCrypto/elliptic-curves that referenced this pull request Nov 18, 2021
This updates the crates in this repo to leverage the following generic
implementations recently added to the `ecdsa` crate:

- Sign: RustCrypto/signatures#396
- Verify: RustCrypto/signatures#397

The `p256` crate is able to directly utilize the generic implementation
from the `ecdsa` crate.

The `k256` crate retains its previous custom implementation, which
provides a secp256k1-specific take on public key recovery, but can also
directly leverage optimizations for computing linear combinations, which
there are not presently traits in `elliptic-curve` or `group` to
express.
tarcieri added a commit to RustCrypto/elliptic-curves that referenced this pull request Nov 18, 2021
This updates the crates in this repo to leverage the following generic
implementations recently added to the `ecdsa` crate:

- Sign: RustCrypto/signatures#396
- Verify: RustCrypto/signatures#397

The `p256` crate is able to directly utilize the generic implementation
from the `ecdsa` crate.

The `k256` crate retains its previous custom implementation, which
provides a secp256k1-specific take on public key recovery, but can also
directly leverage optimizations for computing linear combinations, which
there are not presently traits in `elliptic-curve` or `group` to
express.
tarcieri added a commit to RustCrypto/elliptic-curves that referenced this pull request Nov 18, 2021
This updates the crates in this repo to leverage the following generic
implementations recently added to the `ecdsa` crate:

- Sign: RustCrypto/signatures#396
- Verify: RustCrypto/signatures#397

The `p256` crate is able to directly utilize the generic implementation
from the `ecdsa` crate.

The `k256` crate retains its previous custom implementation, which
provides a secp256k1-specific take on public key recovery, but can also
directly leverage optimizations for computing linear combinations, which
there are not presently traits in `elliptic-curve` or `group` to
express.
@tarcieri tarcieri mentioned this pull request Nov 21, 2021
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