-
Notifications
You must be signed in to change notification settings - Fork 251
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
Update QuadExtField::sqrt
for better performance
#352
Conversation
31b2a96
to
5f16308
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! I believe you can skip <P as QuadExtsParameters>
since it's already dictated by the trait bounds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Untested ACK.
Better rebase on top of #354 before merging so the performance difference will be clear and documented |
Currently, the QuadExtField uses an expensive runtime inverse of two calculation defined as `P::BaseField::one().double().inverse()`. With the proposed change, we compute the BigInt `(p+1)/2` that is ~15% cheaper than the previous method, by avoiding `inverse`. Alternatively, we could require a compile-time constant provided by the user that represents `1/2`. However, having a constant requirement to satisfy a single use-case isn't ideal. `PrimeField::modulus` was introduced to facilitate the available constants usage. Closes #210
d465245
to
e55606d
Compare
Description
Currently, the QuadExtField uses an expensive runtime inverse of two
calculation defined as
P::BaseField::one().double().inverse()
.With the proposed change, we compute the BigInt
(p+1)/2
that is ~15%cheaper than the previous method.
Alternatively, we could require a compile-time constant provided by the
user that represents
1/2
. However, having a constant requirement tosatisfy a single use-case isn't ideal.
closes: #210
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
Targeted PR against correct branch (master)
Linked to GitHub issue with discussion and accepted design OR have an explanation in the PR that describes this work.
Updated relevant documentation in the code
Added a relevant changelog entry to the
Pending
section inCHANGELOG.md
Re-reviewed
Files changed
in the GitHub PR explorerWrote unit tests (tests are already covering this section:
bls12_381::tests::test_fq2
)