-
Notifications
You must be signed in to change notification settings - Fork 10
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
Remove n^2 algorithm from signature/key aggregation #60
Conversation
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're trying to optimize as much as possible these bits, I'd say above it could be also a single loop on lines 36-55 in hashPointToR
:
and the XOF could be read 16 bytes at a time in the same loop as well.
Instead of having
The only thing I really don't like here is that it seems we're testing the compatibility of both functions with each other but we don't have any explicit KAT in there, so while it does look functionally identical this might potentially break retro-compatibility with past aggregated signatures as far as our tests are concerned.
Any chance you'd have a few such signatures and set of public keys and mask handy to add as KAT vectors in a new test?
I'm mostly just trying to avoid the
Hm. Yeah, that's a very fair point. I'll grab and/or generate some test signatures. |
Co-authored-by: AnomalRoil <AnomalRoil@users.noreply.github.com>
@AnomalRoil Can you give this a second review? |
Nah, it's not quite ready. I still need to add the test. |
I believe I've addressed the feedback except:
As far as I can tell, I have to finish hashing first and separate loops aren't going to cost much in terms of performance. I guess we could read in 16-byte chunks, but looking at the blake2s code, that actually looks a bit slower (more setup/teardown). |
@Stebalien you're right I misread the code initially when I said we could do the XOF extraction in the same loop. We need to write all peers to it before starting extraction anyway. I'll take a look in the coming days, but I'm traveling right now. |
Np. When you get a chance, could you also look at #61? That's going to have a much bigger impact. |
Closing in favor of dedis#546. |
CountEnabled
andIndexOfNthEnabled
are bothO(n)
in the size of the mask, making this loopn^2
. The BLS operations still tend to be the slow part, but then^2
factor will start to show up with thousands of keys.