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

ML-DSA: Optimize implementation #205

Open
3 tasks
marsella opened this issue Dec 10, 2024 · 0 comments
Open
3 tasks

ML-DSA: Optimize implementation #205

marsella opened this issue Dec 10, 2024 · 0 comments
Labels
CNSA 2.0 improvement Addresses fixes or changes to existing specs

Comments

@marsella
Copy link
Contributor

marsella commented Dec 10, 2024

The version of ML-DSA that is currently being developed is very closely adherent to the spec. However, the spec is not written in a way that lends itself to fast Cryptol code. There are two particular types of slow-code that I've noticed:

  • direct indexing while operating over arrays; and
  • iterating + rebuilding arrays instead of using sequence-level operations (e.g. join, reverse, etc.)

In general, we don't want to delete the spec-adherent code, because spec adherence is a high-level goal of this repository. We can either make separate functions inline (e.g. BitsToBytes_fast) or make a separate module with the fast versions -- this might depend a little on the architecture decision we make in #198. In either case we need to prove equivalence between the spec version and the fast version.

Here are a few notes about things I've seen that could probably be faster:

  • IntegerToBits: we could use the built-in function fromInteger, with a reverse call to get the endianness right. Similarly with BitsToInteger and probably IntegerToBytes
  • BitsToBytes and BytesToBits: these should just be split and join calls.
  • All the BitPack functions (Alg 16 - 19) index into an array, but they could iterate directly over it instead.

  • Audit or benchmark the spec to identify areas for improvement (either based on Cryptol aesthetics or on some actual timing measurements). Put a list in this issue for future reference.
  • Decide where to put the "fast" versions.
  • Implement the optimized versions.
@marsella marsella added CNSA 2.0 improvement Addresses fixes or changes to existing specs labels Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CNSA 2.0 improvement Addresses fixes or changes to existing specs
Projects
None yet
Development

No branches or pull requests

1 participant