-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
perf(crypto): optimize secp256k1 field element comparison #23495
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughThe pull request introduces a modification to the Changes
The changes are minimal and focused on the loop iteration order within the field element comparison function, with no other significant modifications to the implementation. 📜 Recent review detailsConfiguration used: .coderabbit.yml 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
🔇 Additional comments (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
would you be able to provide benchmarks on this change? |
Hey Marco! Sorry, but I can't provide Go benchmarks for this change because this is C code in libsecp256k1, and Go benchmarks wouldn't show the real performance difference here. The main reason for changing the loop from backward to forward is that modern CPUs are better optimized for forward iteration (i = 0; i < n; i++). It's a common optimization pattern that most developers use. If you really need benchmarks, I can try to add them using C code in the libsecp256k1 testing framework. Let me know if you want me to do that! |
Optimizes the field element comparison function in secp256k1 implementation
by changing the comparison order from most significant to least significant
digits to least significant to most significant. This change can improve
performance in common cases where numbers differ in lower digits, avoiding
unnecessary comparisons of higher digits.
The semantic behavior of the function remains unchanged while potentially
providing better performance characteristics for typical use cases in
cryptographic operations.
Summary by CodeRabbit
This update involves a subtle change in how field elements are compared, which may improve performance or address a specific implementation detail in the cryptographic key generation process.