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

A toy implementation of ML-KEM algorithm? #95

Open
tomato42 opened this issue Mar 4, 2025 · 7 comments
Open

A toy implementation of ML-KEM algorithm? #95

tomato42 opened this issue Mar 4, 2025 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@tomato42
Copy link
Collaborator

tomato42 commented Mar 4, 2025

So, to continue my insistence that this library is a very good learning resource I was thinking of including a complete toy example variant of ML-KEM: one that uses and encrypts only 1 byte values at a time (i.e. one that uses just 8-th degree polynomials).

Would you be ok accepting such code?

Alfred Menezes has published a series of lectures where he uses an implementation like that (the nice thing about 8-th degree polynomials is that NTT works for them too).

@tomato42 tomato42 added the enhancement New feature or request label Mar 4, 2025
@GiacomoPope
Copy link
Owner

yeah this sounds great and if the maths code I designed was abstract enough it should be fairly easy to implement on top of what we have :)

@tomato42
Copy link
Collaborator Author

tomato42 commented Mar 4, 2025

the downside is that we would have to parametrise more of the ml-kem code; so that outputs of stuff like hash functions is also defined by parameters...

@GiacomoPope
Copy link
Owner

we could make a ml_kem_toy directory with the code which then calls a specific class make in polynomials etc? Hard to know what's best here

@tomato42
Copy link
Collaborator Author

tomato42 commented Mar 4, 2025

that would lead to a lot of code duplication, that's why I was trying to avoid it...

but maybe a base ml_kem class that has the stuff common between the regular ml-kem and the ml-kem-toy, and have stuff like hash functions in the concrete instantiations...

@GiacomoPope
Copy link
Owner

ideally it would be nice for ML-KEM to "work" with any supplied polynomial ring and module providing the available API is correct

@tomato42
Copy link
Collaborator Author

tomato42 commented Mar 4, 2025

yes, but that requires the parameters to also include polynomial ring and module definitions; if you're ok moving them to those parameters:

"ML512": {"k": 2, "eta_1": 3, "eta_2": 2, "du": 10, "dv": 4},

then it should be doable

@GiacomoPope
Copy link
Owner

yeah i think we can do it, it's a little redundant in the sense that all "serious" implementations will have the same n but we can still put it in there to allow for the n value?

@tomato42 tomato42 self-assigned this Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants