-
Notifications
You must be signed in to change notification settings - Fork 84
Radix-2^51 support #4
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This probably isn't constant time because of the Z1==Z2 check. If it should be, we can drop that first part (and there is still a speed increase from removing the two FieldElement.invert() calls).
Sign/verify tests fail, but all other tests pass. The problem is probably in ScalarOps somewhere.
…with long The test fails (likely because all longs are signed in Java)
The only BigInteger operations used are and(), or() and shift[Left|Right]() (but it is possible that these are not constant time?)
Before: 0.534 each sign, 2.3272 each verify, 2.8612 s+v After: 0.5888 each sign, 2.3566 each verify, 2.9454 s+v Sign uses reduce() twice, verify uses it once. Therefore the ref10 version is about 28us slower than the BigInteger version. Basically negligible, so the important factor to determine is whether the BigInteger operations used are constant time. If we can't get the ref10 version to be constant time, we may as well use the BigInteger version.
Most FieldElement implementations (in particular, the ref10 implementation) don't have a generic pow() method, and instead will have I hard-coded.
Before black magic: 0.5548 each sign, 2.4118 each verify, 2.9666 s+v After black magic: 0.1572 each sign, 0.2798 each verify, 0.437 s+v
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request refactors the existing BigInteger implementation so all BigInteger-specific code is in a single subpackage. The Ed25519-specific radix-2^51 implementation from ref10 is then implemented, resulting in a considerable speed boost (signing is about 3.5x faster, verifying is about 8.5x faster).