-
Notifications
You must be signed in to change notification settings - Fork 7
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
ML-KEM: Try to clean up the NTT implementations #156
Conversation
I revisited this today and have not gained any insight in the interim week. The innermost loop of NTT accesses and updates
I keep ending up in the following train of thought:
There might be a somewhat cleaner way to implement the recursive loops than what I did in e742abb and 0b355c3, but I think that's going to have to be the basic structure, which means it's going to be hard to read. Unless we can find a different NIST-standardized NTT description that's stated to be equivalent to this one, and can implement that instead. Anyway, for now I propose we take the clean-up commits through b56844e and I'll spin out a separate issue to implement NTT itself more closely to the spec. |
I |
This doesn't replace all uses of `Z_q_256`, but it gets all the easy ones.
This replaces `'`s with suffixes explictly describing what type of data each NTT function operates over.
This adds some documentation around the NTT module explaining where the spec says it's allowed to choose any version of their algorithms that are the same.
Several properties didn't have correct `repl` commands in the docstrings.
- Adds docs to BitRev and contains its behavior a bit better - Adjust spacing, naming, etc in MultiplyNTTs and BaseCaseMultiply
This doesn't make them spec adherent but it simplifies the section a bit.
FWIW I found the recursive start you had here easier to follow. I was able to see how the list comprehensions you have currently still fit the spec. |
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.
Looks like a good step in the right direction to me!
Does not quite finish #147.
This addresses most of the clean-up issues in the linked issue, except for cleaning up the naive NTT version described in the spec (see Algorithms 9 and 10). That has a dense nested loop structure whose bounds depend on each other's variables and that iteratively updates the state of the
f
variable. We have a version that works but doesn't clearly map onto the spec, and I spent a day failing to find a more obviously-matched way to implement it.Update: I made a recursive version of Algorithm 9 which may or may not be better. I solicit opinions from reviewers on whether they like it or not.
Everything else should be addressed in a reasonable way. Looking for general gold-standard quality review.