-
Notifications
You must be signed in to change notification settings - Fork 3
Refactor/blsag simplify api #8
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
base: master
Are you sure you want to change the base?
Refactor/blsag simplify api #8
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 introduces significant API improvements to the BLSAG module and addresses several code quality issues for better performance and ergonomics. It also adds a new suite of tests to verify core security properties. 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]`). - `sign` no longer takes `secret_index`. - `verify` and `link` now operate on signature references (`&BLSAG`). - Added tests for unforgeability, anonymity, and linkability properties. - Fixed lints reported by Clippy for more idiomatic code.
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). |
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 |
Title:
refactor(blsag): Comprehensive API and implementation overhaul
Hi @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
blsag
module.My core strategy was to first focus on polishing the
blsag
module 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
:BLSAG
struct 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
):sign
function now returns aResult
instead of panicking on failure (e.g., if the signer is not in the ring).BLSAG
signature struct no longer stores the entire ring, making it significantly more lightweight.sign
andverify
functions now accept the ring via a slice reference (&[RistrettoPoint]
), which completely eliminates the need forring.clone()
on the caller's side.secret_index
parameter was removed fromsign
to pull complexity downwards.verify
andlink
now operate on references to signatures, avoiding unnecessary clones.sign
andverify
has 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
blsag
module 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
mlsag
andclsag
:mlsag
andclsag
.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.