Skip to content
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

Avoid a square root computation in EllipticCurve_field.quadratic_twist #35294

Merged
merged 1 commit into from
Apr 1, 2023

Conversation

remyoudompheng
Copy link
Contributor

📚 Description

The current implementation of quadratic_twist computes (possibly several times) unnecessary finite field square roots, but the only requirement is to select D which has no such square roots, which can be tested efficiently using PARI (by checking that the norm is not a quadratic residue).

This solves slowness over large finite field extensions:

sage: p = 2**255 - 19
....: K.<a> = GF(p**64)
# Sage 9.8
sage: %timeit EllipticCurve(K, [0, K.random_element()]).quadratic_twist()
17.8 s ± 8.5 s per loop (mean ± std. dev. of 7 runs, 1 loop each)
# This patch
sage: %timeit EllipticCurve(K, [0, K.random_element()]).quadratic_twist()
9.69 ms ± 388 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)

📝 Checklist

  • I have made sure that the title is self-explanatory and the description concisely explains the PR.
  • I have linked an issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation accordingly.

⌛ Dependencies

@vbraun vbraun merged commit 29b99c9 into sagemath:develop Apr 1, 2023
@remyoudompheng remyoudompheng deleted the faster-quadratic-twist branch April 3, 2023 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants