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

Speedup sqrt on PrimeField when a square root exists. #131

Merged
merged 1 commit into from
Dec 14, 2020

Conversation

ValarDragon
Copy link
Member

@ValarDragon ValarDragon commented Dec 14, 2020

Description

Applies daira's suggestion from #40 to make the square root algorithm skip computing the legendre symbol. This speeds up the square root when the element is actually a square root, in exchange for slowing down the square root when its not actually a square root.

I think this makes sense as a trade-off, as getting faster point decompression in the honest case is quite useful. And in cases I'm aware of, with an adversary who want to delay another node, you would have made your curve point pass deserialization and fail in other logic later on

cref #40


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 (main)
  • Linked to Github issue with discussion and accepted design OR have an explanation in the PR that describes this work.
  • Wrote unit tests
  • Updated relevant documentation in the code
  • Added a relevant changelog entry to the Pending section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer

This comes at the expense of slowing sqrt down when it does not exist.
This came from no longer computing the legendre symbol before the
square root.
Copy link
Member

@Pratyush Pratyush left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, thanks!

@ValarDragon ValarDragon merged commit 4cbe462 into master Dec 14, 2020
@ValarDragon ValarDragon deleted the speedup_sqrt branch December 14, 2020 16:30
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