Optimize SRP6's server step2 - #5781
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR optimizes SRP6 server-side step2 by reducing the advertised exponent bit-length passed into modular exponentiation, avoiding unnecessary work when the exponent’s maximum size is smaller than the group modulus size.
Changes:
- Use the hash output size (
output_length() * 8) as the exponent upper bound when computingv^u (mod p). - Use the bit-length of
bas the exponent upper bound when computingS = (A * v^u)^b (mod p).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
These used the full width of the group as the advertised exponent size, but that isn't necessary for either `u` or `b`; `u` is a hash so the maximum length is small and public, and the length of `b` is chosen by either a public formula or from an application provided setting. Improves step2 by 10x to 25x depending on group size.
randombit
force-pushed
the
jack/srp6-opt
branch
from
August 1, 2026 13:27
1cfce99 to
bf799f3
Compare
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
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.
These used the full width of the group as the advertised exponent size, but that isn't necessary for either
uorb;uis a hash so the maximum length is small and public, and the length ofbis chosen by either a public formula or from an application provided setting. Improves step2 by 10x to 25x depending on group size.