From c47c884649b2403a180407632470a42b768ce2a4 Mon Sep 17 00:00:00 2001 From: Peter Goodspeed-Niklaus Date: Mon, 5 May 2025 13:09:10 +0200 Subject: [PATCH] feat(ephemeral): `KeyPackageSecretEncapsulation` can be treated as `KeyPackage` i.e we can dereference or cheaply as_ref it into a KeyPackage. --- openmls/src/key_packages/mod.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/openmls/src/key_packages/mod.rs b/openmls/src/key_packages/mod.rs index dfce1ecbf1..e860b49638 100644 --- a/openmls/src/key_packages/mod.rs +++ b/openmls/src/key_packages/mod.rs @@ -261,6 +261,20 @@ impl KeyPackageSecretEncapsulation { } } +impl AsRef for KeyPackageSecretEncapsulation { + fn as_ref(&self) -> &KeyPackage { + &self.key_package + } +} + +impl std::ops::Deref for KeyPackageSecretEncapsulation { + type Target = KeyPackage; + + fn deref(&self) -> &Self::Target { + &self.key_package + } +} + // Public `KeyPackage` functions. impl KeyPackage { /// Create a key package builder.