Skip to content

elliptic-curve: impl BatchInvert for NonZeroScalar #1890

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

Conversation

daxpedda
Copy link
Contributor

@daxpedda daxpedda commented Jun 3, 2025

This implements BatchInvert for NonZeroScalar.

To accomplish this, I did the following notable things:

  • Remove all trait bounds on BatchInvert itself.
  • Remove CtOption from BatchInvert::batch_inverts return type.
  • Expose invert_batch_internal() internally, which now takes an invert function instead of requiring trait Invert.
  • Implement MulAssign for NonZeroScalar.

Things that could still be added:

  • Mirror all BatchInvert implementations on Scalar, I left the ones taking a reference to a slice out.
  • Implement MulAssign for NonZeroScalar on more combinations.

It might be a tiny bit simpler if I implemented Default on NonZeroScalar, but that seemed like a footgun to me.

@tarcieri tarcieri changed the title Implement BatchInvert for NonZeroScalar elliptic-curve: impl BatchInvert for NonZeroScalar Jun 6, 2025
@tarcieri tarcieri merged commit f8663d3 into RustCrypto:master Jun 6, 2025
12 checks passed
@tarcieri
Copy link
Member

tarcieri commented Jun 6, 2025

@daxpedda hmm, probably should've asked for a companion PR for this to https://github.com/RustCrypto/elliptic-curves for this, having a little trouble updating primeorder

tarcieri added a commit to RustCrypto/elliptic-curves that referenced this pull request Jun 6, 2025
@tarcieri
Copy link
Member

tarcieri commented Jun 6, 2025

Never mind, got it: RustCrypto/elliptic-curves#1234

tarcieri added a commit to RustCrypto/elliptic-curves that referenced this pull request Jun 6, 2025
tarcieri added a commit to RustCrypto/elliptic-curves that referenced this pull request Jun 6, 2025
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