Use separate MlKemPrivateKey/MlKemPublicKey instead of exposing slices
#462
+205
−259
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
enuminside 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 withRsatype, but the underlying implementation is quite different, so there isn't anything obvious to reuse. Having a type likeMlKem<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.