-
Notifications
You must be signed in to change notification settings - Fork 16
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 Parameter Set Monomorphization with Macros #732
Conversation
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.
This is a big one! Left a few comments, but happy for most of these being follow-ups.
However, let's document the general style guidelines implemented here, so that new code can also follow this pattern. I am adding a comment to the PR noting this.
This PR does a bit more cleanup than just the const generic monomorphization.
|
You're right, there's more here than the monomorphization. Thanks for noting down the style changes! |
Eurydice can't handle associated types right now. So this changes it such that the Operations trait is implemented on top of a wrapper struct for the coefficients again. This requires the implementations of the trait to point into the struct again. But this is more self contained than propagating the generic type for the trait. I couldn't measure an impact on performance or stack size with this change
Co-authored-by: Jonas Schneider-Bensch <[email protected]>
Co-authored-by: Jonas Schneider-Bensch <[email protected]>
ML-DSA: Work around Eurydice limitations
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.
I think we should simplify the plumbing for the variants a little to make it easier to add nice APIs. But that's for follow-ups. Let's get this in.
The motivation for this PR is to mostly get rid of allocations below the level of
ml_dsa_generic
. To this end,const
generics are replaced by a macro-based manual monomorphization to the different parameter sets. In doing this, I've attempted to simplify parameter set specific constants, as well as platform instantiation and multiplexing.Essentially
ml_dsa_generic
,constants
, the instantiations inml_dsa_generic::instantiation::{portable, neon, avx2}
andml_dsa_generic::multiplexing
now have (macro-generated) submodules for each parameter set which should be guarded by their respective feature flag. They contain:constants::ml_dsa_44/65/87
: Parameter set specific constants go here. Theconstants
module also definesconst fn
s for deriving everything but the basic constants in the parameter set specific submodules.ml_dsa_generic::ml_dsa_44/65/87
: A version of theml_dsa_generic::generic
module where the parameter specific constants fromconstants
are pulled in and derived constants are derived using theconst fn
s fromconstants
. The module also defines type aliasesMLDSA{44/65/87}SigningKey, MLDSA{44/65/87}VerificationKey, etc
. This is achieved by theml_dsa_parameter_sets
proc macro.instantiations::{portable, neon, avx2}::ml_dsa_44/65/87: The platform specific instantiations of the versions from
ml_dsa_generic. In the case of
avx2that includes the application of the
target_platform` cfg.multiplexing
::ml_dsa_44/65/87`: Runtime multiplexing, reverting to a portable version if platform-specific version was not compiled in.I've verified that F* extraction still works and laxes. C extraction pending further updates.