Refactor/blsag simplify api#8
Open
RyderFreeman4Logos wants to merge 8 commits intoedwinhere:masterfrom
Open
Conversation
This commit introduces significant API improvements to the BLSAG module to enhance performance and ergonomics, especially for large rings. BREAKING CHANGE: The `BLSAG` signature struct no longer stores the ring. The `verify` function now requires the ring to be passed as an argument. - `sign` and `verify` now accept ring data via slice reference (`&[RistrettoPoint]`), eliminating clones and increasing flexibility. - `sign` no longer takes `secret_index`. - `verify` and `link` now operate on signature references (`&BLSAG`). - New traits (`SignRef`, `VerifyRef`) were introduced to facilitate these changes without affecting other schemes.
This commit introduces significant API improvements to the BLSAG module and addresses several code quality issues for better performance and ergonomics. BREAKING CHANGE: The `BLSAG` signature struct no longer stores the ring. The `verify` function now requires the ring to be passed as an argument. - `sign` and `verify` now accept ring data via slice reference (`&[RistrettoPoint]`), eliminating clones and increasing flexibility. - `sign` no longer takes `secret_index`. - `verify` and `link` now operate on signature references (`&BLSAG`). - Removed unnecessary `.clone()` calls on `Copy` types in tests. - Fixed lints reported by Clippy for more idiomatic code.
This commit completes the full refactoring of the BLSAG module, introducing significant API improvements, better performance, and robust error handling. BREAKING CHANGE: The `sign` function now returns a `Result<BLSAG, SignatureError>` instead of panicking. The `BLSAG` signature struct no longer stores the ring, and the `verify` function now requires the ring to be passed as an argument. - `sign` and `verify` now accept ring data via slice reference (`&[RistrettoPoint]`). - `sign` no longer takes `secret_index`. - `verify` and `link` now operate on signature references (`&BLSAG`). - Added a comprehensive test suite verifying core security properties. - Fixed all lints reported by Clippy for more idiomatic code.
Contributor
Author
|
By the way, I’m currently working on performance testing and trying to optimize the performance of blsag through precomputation. This is because in some scenarios, the size of the public key ring can be as large as a hundred thousand or even millions. On a typical smartphone, signing a ring of size 10_000 takes about 6 to 12 seconds, while for a ring of 1_000_000, the time increases linearly to 10-20 minutes (with slight variations depending on the phone’s CPU). |
Owner
|
Thanks for this. Give me some time to merge it. I'm busy with work. I use this repository for my resume that's why I keep it updated |
eded651 to
e87644e
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.
Title:
refactor(blsag): Comprehensive API and implementation overhaulHi @edwinhere ,
First and foremost, thank you for creating and maintaining this excellent library,
nazgul!While studying and using the library, I identified several opportunities for optimization based on modern Rust design philosophies. With the assistance Gemini 2.5 Pro, I've undertaken a series of in-depth refactors focused on the
blsagmodule.My core strategy was to first focus on polishing the
blsagmodule to perfection, establishing a rock-solid test suite before considering applying these successful patterns to the other modules.This Pull Request contains the following logical steps (corresponding to the branch/commit history):
test/blsag-suite:blsag, covering happy paths, failure paths, and core security properties (unforgeability, anonymity, and linkability).refactor/blsag-info-hiding:BLSAGstruct by making its fields private, enhancing the module's robustness.refactor(blsag)!: Optimize API and improve idiomatic Rust(fromrefactor/blsag-simplify-api&refactor/blsag-dry-up-impl):signfunction now returns aResultinstead of panicking on failure (e.g., if the signer is not in the ring).BLSAGsignature struct no longer stores the entire ring, making it significantly more lightweight.signandverifyfunctions now accept the ring via a slice reference (&[RistrettoPoint]), which completely eliminates the need forring.clone()on the caller's side.secret_indexparameter was removed fromsignto pull complexity downwards.verifyandlinknow operate on references to signatures, avoiding unnecessary clones.signandverifyhas been extracted into a shared private helper function (DRY).A Discussion on Next Steps
I would love to get your feedback on this direction for the
blsagmodule first. As I'm not a cryptographer, your expert review of these API changes for cryptographic soundness would be invaluable.If you approve of this direction, I'd be happy to discuss how we could best proceed with
mlsagandclsag:mlsagandclsag.Either way, I'm very happy to continue contributing to the project.
Thank you again for your time and effort! Looking forward to your feedback.