Skip to content

Optimize SRP6's server step2 - #5781

Merged
randombit merged 1 commit into
masterfrom
jack/srp6-opt
Aug 1, 2026
Merged

Optimize SRP6's server step2#5781
randombit merged 1 commit into
masterfrom
jack/srp6-opt

Conversation

@randombit

Copy link
Copy Markdown
Owner

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 computing v^u (mod p).
  • Use the bit-length of b as the exponent upper bound when computing S = (A * v^u)^b (mod p).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lib/misc/srp6/srp6.cpp Outdated
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
randombit merged commit d422f91 into master Aug 1, 2026
47 checks passed
@randombit
randombit deleted the jack/srp6-opt branch August 1, 2026 14:42
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