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

Add support for ML-DSA #877

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
Draft

Conversation

bifurcation
Copy link

@bifurcation bifurcation commented Nov 14, 2024

This PR is a first step toward ML-DSA support, as discussed in #8. It puts in place enough of the basic algebraic and encoding primitives to get key generation going.

Still TODO:

  • More complete unit test coverage (e.g., on encoding routines)
  • Signing
  • Verification
  • Integration tests against NIST ACVP test vectors
  • Performance benchmarks
  • Pull out things that are common with ML-KEM into a shared module (?)

@tarcieri - This is currently blocked on typenum not having enough integers. Specifically, there is no ArraySize implementation for U4896, which the compiler says is necessary for MlDsa87. Can we get that added?

@cothan, @marija-mijailovic - If you guys are still interested in collaborating, making PRs to this branch would be a good way to help.

On the latter point about overlap with ML-KEM: Thinking about this while I was writing this PR, it seems like the main shared stuff would be:

  • Structs for polynomials, polynomial vectors, NTT vectors, and NTT matrices
  • Fixed-width encoding of unsigned integers

Getting those factored out would be a non-trivial savings, but would require some careful introduction of generics. For example, the algebraic stuff would have to be generic over the field over which the polynomials exist (since there are different q moduli in the two algorithms), as well as the details of multiplication of polynomials and NTT.

@tarcieri
Copy link
Member

@bifurcation sure. Here's an example PR to add more sizes: RustCrypto/hybrid-array#104

Note that the uint! macro uses a little endian bit encoding for the size

@bifurcation
Copy link
Author

Latest push adds signing/verification logic. It can verify its own signatures, but fails the ACVP test vectors.

Note that it will not build against the public version of hybrid-array, since that is missing some ArraySize implementations. I'm planning to submit a PR to that repo once things are in basic working order here, so that we have confidence that we've covered all the necessary integers.

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.

2 participants