Skip to content

Comments

Use separate MlKemPrivateKey/MlKemPublicKey instead of exposing slices#462

Merged
kornelski merged 1 commit intomasterfrom
mlkem-structs
Feb 3, 2026
Merged

Use separate MlKemPrivateKey/MlKemPublicKey instead of exposing slices#462
kornelski merged 1 commit intomasterfrom
mlkem-structs

Conversation

@kornelski
Copy link
Collaborator

On top of #460.

Having all functions attached to one type forces the implementation take keys as arguments. Since there were no types for the keys, the key material had to be handled as bare byte slices.

I've changed it to a more conventional split between private and public key types. They still contain an enum inside to handle both algorithms at run time.

These keys are relatively big (7KB), so I've boxed them internally to avoid returning unusually large stack objects to the user.

I've looked into using MlKem<Private>/MlKem<Public> for similarity with Rsa type, but the underlying implementation is quite different, so there isn't anything obvious to reuse. Having a type like MlKem<768, Public> would be neat, but functionally isn't necessary, I didn't want to overcomplicate this. More specific or flexible types can be added later if needed, and they can be backwards compatible by making type aliases for them.

@kornelski kornelski merged commit 9b098e6 into master Feb 3, 2026
24 checks passed
@kornelski kornelski deleted the mlkem-structs branch February 3, 2026 14:43
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.

3 participants