Skip to content

Conversation

@tarcieri
Copy link
Member

Ideally we could get rid of the bespoke traits in ml-kem and replace them with traits from the kem crate.

This PR rewrites the usage example to use the KeyInit trait for generating the seed and initializing a DecapsulationKey, as well as retrieving its associated encapsulator.

cc @rozbb

Ideally we could get rid of the bespoke traits in `ml-kem` and replace
them with traits from the `kem` crate.

This PR rewrites the usage example to use the `KeyInit` trait for
generating the seed and initializing a `DecapsulationKey`, as well as
retrieving its associated encapsulator.
@tarcieri tarcieri requested a review from bifurcation October 31, 2025 02:43
@tarcieri
Copy link
Member Author

This is attempting to leverage the changes I've been discussing in RustCrypto/traits#1508

Opened it for discussion on the ergonomics as they're not particularly awesome yet

//! kem::{Decapsulate, Encapsulate, KeyInit}
//! };
//!
//! type DecapsulationKey = ml_kem::kem::DecapsulationKey<MlKem768Params>;
Copy link
Member Author

@tarcieri tarcieri Oct 31, 2025

Choose a reason for hiding this comment

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

Perhaps we could put these type aliases together for people so they don't have to assemble them like this?

Suggested change
//! type DecapsulationKey = ml_kem::kem::DecapsulationKey<MlKem768Params>;
//! use ml_kem::ml_kem_768::DecapsulationKey;

tarcieri added a commit that referenced this pull request Oct 31, 2025
Defines the following modules:

- `ml_kem_512`
- `ml_kem_768`
- `ml_kem_1024`

Each contains the `ParameterSet` definition for the given security level
(re-exported at the toplevel) along with type aliases for
[`DecapsulationKey`] and [`EncapsulationKey`].

The documentation has been updated to use such a type alias for
`DecapsulationKey` as originally proposed in #161
@tarcieri
Copy link
Member Author

Closing in favor of #162

@tarcieri tarcieri closed this Oct 31, 2025
@tarcieri tarcieri deleted the ml-kem/use-kem-traits-in-docs branch October 31, 2025 15:37
tarcieri added a commit that referenced this pull request Nov 2, 2025
Defines the following modules:

- `ml_kem_512`
- `ml_kem_768`
- `ml_kem_1024`

Each contains the `ParameterSet` definition for the given security level
(re-exported at the toplevel) along with type aliases for
`DecapsulationKey` and `EncapsulationKey`.

The documentation has been updated to use such a type alias for
`DecapsulationKey` as originally proposed in #161
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.

2 participants