Generate, enumerate, and delete MLS KeyPackages. Key packages are single-use credentials used to add a new member to a group.
In MLS, a KeyPackage is a signed object that binds a client’s identity credential to its HPKE public key. Another group member fetches a target client’s key package from the Delivery Service and includes it in an Add proposal or commit, which delivers the Welcome message encrypted to that key.Key packages are inherently single-use: once consumed in a Welcome, the private key material is deleted. CoreCrypto manages the generation, storage, and cleanup lifecycle automatically.
// re-export of openmls::prelude::KeyPackagepub use openmls::prelude::KeyPackage as Keypackage;
The full key package object including the leaf node, extensions, signature, and HPKE init key. Implements the KeypackageExt trait for CoreCrypto-specific helpers.
Generates a new KeyPackage from the referenced credential. The key package is persisted to the keystore along with its HPKE private key and encryption keypair. No pruning of existing key packages is performed.
Deletes a single key package and its associated private key material from the keystore. Succeeds silently if the key package no longer exists. Removes from three tables: the key package, the HPKE private key, and the leaf encryption keypair.
let tx = cc.new_transaction().await?;for kp_ref in tx.get_keypackage_refs().await? { if !kp_ref.is_valid() { tx.remove_keypackage(&kp_ref).await?; }}tx.finish().await?;
Removes all key packages that were generated from the given credential. This is an expensive operation as it loads all key packages to find matches. Called automatically by remove_credential.
generate_keypackage() → uploaded to DS ↓ another member fetches it ↓ included in Add commit → Welcome sent ↓ CoreCrypto deletes key package on merge
Manually delete stale key packages (expired lifetime) with remove_keypackage. Replace a credential by generating new key packages and removing the old ones with remove_keypackages_for.