Skip to content
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

Introduce a new CachedMask for BDN #61

Closed
wants to merge 6 commits into from

Conversation

Stebalien
Copy link

@Stebalien Stebalien commented Aug 27, 2024

This new mask will pre-compute reusable values, speeding up repeated verification and aggregation of aggregate signatures (mostly the former).

Importantly, we noticed that F3 spends a lot of time multiplying public keys and coefficients:

pubC := pub.Clone().Mul(coefs[peerIndex], pub)

But, when we have a stable set of keys to draw from (which, IMO, is the usual case), we can pre-compute that product and save a bunch of time.

This PR is stacked on #60. Unfortunately, I can't change the base to that PR without making this PR against my fork, which kind of defeats the point. Only look at the top commit.

This is an early PR to get some quick feedback before I start writing tests.

Stebalien and others added 5 commits August 9, 2024 14:51
CountEnabled and IndexOfNthEnabled are both O(n) in the size of the
mask, making this loop n^2. The BLS operations still tend to be the slow
part, but the n^2 factor will start to show up with thousands of keys.
Co-authored-by: AnomalRoil <[email protected]>
@Stebalien
Copy link
Author

Benchmark: For 3000 keys (our use-case), this is 88x faster assuming the mask is cached.

@Stebalien
Copy link
Author

Well, that's 88x faster purely for aggregating public keys. For validating an aggregate signature with 3000 signers, it's 58x faster.

This new mask will pre-compute reusable values, speeding up repeated
verification and aggregation of aggregate signatures (mostly the former).
// 2. Pre-computes the terms for public key aggregation. Once the CachedMask has been instantiated,
// distinct sets of public keys can be aggregated by simply summing the cached terms, ~2 orders
// of magnitude faster than aggregating from scratch.
func NewCachedMask(mask Mask) (*CachedMask, error) {
Copy link
Author

Choose a reason for hiding this comment

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

Happy to bikeshed on the name. Maybe just callit BDNMask?

@@ -165,25 +162,23 @@ func (scheme *Scheme) AggregateSignatures(sigs [][]byte, mask *sign.Mask) (kyber
// AggregatePublicKeys aggregates a set of public keys (similarly to
// AggregateSignatures for signatures) using the hash function
// H: keyGroup -> R with R = {1, ..., 2^128}.
func (scheme *Scheme) AggregatePublicKeys(mask *sign.Mask) (kyber.Point, error) {
coefs, err := hashPointToR(mask.Publics())
func (scheme *Scheme) AggregatePublicKeys(mask Mask) (kyber.Point, error) {
Copy link
Author

Choose a reason for hiding this comment

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

This is a breaking change for anyone abstracting over Scheme using an interface (e.g., for testing). If that's going to be an issue, I can look into alternative APIs (e.g., adding additional methods, putting the methods on the CachedMask, etc.

@Stebalien
Copy link
Author

dedis#546

@Stebalien Stebalien closed this Sep 5, 2024
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.

1 participant