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

Optimize ML-DSA Implementation #232

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

mariosge
Copy link
Contributor

Closes #205

@mariosge mariosge linked an issue Jan 28, 2025 that may be closed by this pull request
3 tasks
…Specification.cry

We also edit ML_DSA.cry to point to the optimized file.

We avoid importing private functions or properties as these have already been tested. Looking forward, we will optimize some of these functions and will define equivalence properties.
@mariosge mariosge force-pushed the 205-ml-dsa-optimize-implementation branch from e45267a to 60b2c83 Compare January 28, 2025 23:04
In particular, we optimize `IntegerToBits`, `BitsToInteger`, `IntegerToBytes`, `BitsToBytes` and `BytesToBits`.

We also add equivalence properties. The updated functions are around 10x faster.
The functions we optimize are:
`SimpleBitPack`, `BitPack`, `SimpleBitUnpack` and `BitUnpack`. These functions are now 10x faster than in the specs.

We also implement and check equivalence properties.
@mariosge mariosge marked this pull request as ready for review January 29, 2025 00:06
@mariosge mariosge requested a review from marsella January 29, 2025 00:06
@marsella marsella mentioned this pull request Jan 30, 2025
3 tasks
Copy link
Contributor

@marsella marsella left a comment

Choose a reason for hiding this comment

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

Thank you, this looks great! I'd be very interested to see what kind of runtime improvement we get on the top-level functions (_internal). It probably won't be 10x because NTT and other operations are slow right now, but that's the big one we're interested in.

I have a couple docs requests and one bug.

These definitions are copied and pasted directly from the Specification.cry file. Only tiny edits in the some type parameters are made and are explicitly mentioned in the doc comments.

The edited functions are: `KeyGen_internal`, `pkEncode`, `pkDecode`, `skEncode`, `skDecode`, `sigEncode`, `sigDecode`, `w1Encode`, `SampleInBall`, `ExpandA`, `ExpandS` and `ExpandMask`
…rove in a reasonable amount of time or if checking is better
@mariosge mariosge force-pushed the 205-ml-dsa-optimize-implementation branch from 5949fb4 to fd3c350 Compare January 31, 2025 23:18
@mariosge mariosge requested a review from marsella February 3, 2025 16:02
Copy link
Contributor

@marsella marsella left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks for updating.

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.

ML-DSA: Optimize implementation
2 participants