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

Clean up sqrt logic in pcurves #4171

Merged
merged 1 commit into from
Jul 12, 2024
Merged

Clean up sqrt logic in pcurves #4171

merged 1 commit into from
Jul 12, 2024

Conversation

randombit
Copy link
Owner

The sqrt function returned zero to indicate a lack of a square root but this leads to uncertain situations since zero does itself have a square root.

Fix point decompression to verify that the x value is a quadratic root; previously we'd accept invalid x coordinates.

Remove is_square; it was only needed for SSWU and it's faster to just attempt to square root and then use the returned Choice to decide which square root to use. This improves the performance of hash to curve by almost 30%.

@randombit randombit mentioned this pull request Jul 2, 2024
@coveralls
Copy link

Coverage Status

coverage: 91.731% (-0.2%) from 91.932%
when pulling 2113369 on jack/fix-pcurves-sqrt
into 3657a72 on master.

@coveralls
Copy link

Coverage Status

coverage: 91.732% (-0.2%) from 91.932%
when pulling 77b64a6 on jack/fix-pcurves-sqrt
into 3657a72 on master.

@randombit randombit added this to the Botan 3.6.0 milestone Jul 8, 2024
The sqrt function returned zero to indicate a lack of a square root
but this leads to uncertain situations since zero does itself have a
square root.

Fix point decompression to verify that the x value is a quadratic
root; previously we'd accept invalid x coordinates.

Remove is_square; it was only needed for SSWU and it's faster to just
attempt to square root and then use the returned Choice to decide
which square root to use. This improves the performance of hash to
curve by almost 30%.
@coveralls
Copy link

Coverage Status

coverage: 91.706% (+0.001%) from 91.705%
when pulling 6d1172c on jack/fix-pcurves-sqrt
into bb9c069 on master.

@randombit randombit merged commit b2ff8e3 into master Jul 12, 2024
39 checks passed
@randombit randombit deleted the jack/fix-pcurves-sqrt branch July 12, 2024 01:39
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.

None yet

2 participants