Skip to content

Commit

Permalink
Remove use_ratchet_tree_extension storage (openmls#1643)
Browse files Browse the repository at this point in the history
  • Loading branch information
kkohbrok authored Aug 13, 2024
1 parent 7d3cb92 commit 8c4671d
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 74 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- [#1637](https://github.com/openmls/openmls/pull/1637): Remove `serde` from `MlsGroup`.
- [#1638](https://github.com/openmls/openmls/pull/1638): Remove `serde` from `PublicGroup`. `PublicGroup::load()` becomes public to load a group from the storage provider.
- [#1640](https://github.com/openmls/openmls/pull/1640): The storage provider function `treesync()` was renamed to `tree()` so that it is consistent with other treesync functions.
- [#1642](https://github.com/openmls/openmls/pull/1642): `OpenMlsProvider` is no longer required for the `PublicGroup` API. The `PublicGroup` API now uses the `PublicStorageProvider` trait directly. `ProcessMessageError::InvalidSignature` was removed and replaced with `ValidationError::InvalidSignature`.

### Removed


### Fixed

- [#1641](https://github.com/openmls/openmls/pull/1641): Fixed missing storage of queued proposals & clearing of the queued proposals.
Expand Down
27 changes: 0 additions & 27 deletions memory_storage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ const OWN_LEAF_NODE_INDEX_LABEL: &[u8] = b"OwnLeafNodeIndex";
const EPOCH_SECRETS_LABEL: &[u8] = b"EpochSecrets";
const RESUMPTION_PSK_STORE_LABEL: &[u8] = b"ResumptionPsk";
const MESSAGE_SECRETS_LABEL: &[u8] = b"MessageSecrets";
const USE_RATCHET_TREE_LABEL: &[u8] = b"UseRatchetTree";

// related to MlsGroup
const JOIN_CONFIG_LABEL: &[u8] = b"MlsGroupJoinConfig";
Expand Down Expand Up @@ -741,32 +740,6 @@ impl StorageProvider<CURRENT_VERSION> for MemoryStorage {
self.delete::<CURRENT_VERSION>(OWN_LEAF_NODE_INDEX_LABEL, &serde_json::to_vec(group_id)?)
}

fn use_ratchet_tree_extension<GroupId: traits::GroupId<CURRENT_VERSION>>(
&self,
group_id: &GroupId,
) -> Result<Option<bool>, Self::Error> {
self.read(USE_RATCHET_TREE_LABEL, &serde_json::to_vec(group_id)?)
}

fn set_use_ratchet_tree_extension<GroupId: traits::GroupId<CURRENT_VERSION>>(
&self,
group_id: &GroupId,
value: bool,
) -> Result<(), Self::Error> {
self.write::<CURRENT_VERSION>(
USE_RATCHET_TREE_LABEL,
&serde_json::to_vec(group_id)?,
serde_json::to_vec(&value)?,
)
}

fn delete_use_ratchet_tree_extension<GroupId: traits::GroupId<CURRENT_VERSION>>(
&self,
group_id: &GroupId,
) -> Result<(), Self::Error> {
self.delete::<CURRENT_VERSION>(USE_RATCHET_TREE_LABEL, &serde_json::to_vec(group_id)?)
}

fn group_epoch_secrets<
GroupId: traits::GroupId<CURRENT_VERSION>,
GroupEpochSecrets: traits::GroupEpochSecrets<CURRENT_VERSION>,
Expand Down
22 changes: 0 additions & 22 deletions memory_storage/src/test_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,28 +388,6 @@ impl StorageProvider<V_TEST> for MemoryStorage {
todo!()
}

fn use_ratchet_tree_extension<GroupId: traits::GroupId<V_TEST>>(
&self,
_group_id: &GroupId,
) -> Result<Option<bool>, Self::Error> {
todo!()
}

fn set_use_ratchet_tree_extension<GroupId: traits::GroupId<V_TEST>>(
&self,
_group_id: &GroupId,
_value: bool,
) -> Result<(), Self::Error> {
todo!()
}

fn delete_use_ratchet_tree_extension<GroupId: traits::GroupId<V_TEST>>(
&self,
_group_id: &GroupId,
) -> Result<(), Self::Error> {
todo!()
}

fn group_epoch_secrets<
GroupId: traits::GroupId<V_TEST>,
GroupEpochSecrets: traits::GroupEpochSecrets<V_TEST>,
Expand Down
4 changes: 1 addition & 3 deletions openmls/src/group/core_group/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,6 @@ impl CoreGroup {
self.public_group.store(storage)?;
storage.write_own_leaf_index(group_id, &self.own_leaf_index())?;
storage.write_group_epoch_secrets(group_id, &self.group_epoch_secrets)?;
storage.set_use_ratchet_tree_extension(group_id, self.use_ratchet_tree_extension)?;
storage.write_message_secrets(group_id, &self.message_secrets_store)?;
storage.write_resumption_psk_store(group_id, &self.resumption_psk_store)?;

Expand All @@ -733,11 +732,11 @@ impl CoreGroup {
pub(super) fn load<Storage: StorageProvider>(
storage: &Storage,
group_id: &GroupId,
use_ratchet_tree_extension: Option<bool>,
) -> Result<Option<Self>, Storage::Error> {
let public_group = PublicGroup::load(storage, group_id)?;
let group_epoch_secrets = storage.group_epoch_secrets(group_id)?;
let own_leaf_index = storage.own_leaf_index(group_id)?;
let use_ratchet_tree_extension = storage.use_ratchet_tree_extension(group_id)?;
let message_secrets_store = storage.message_secrets(group_id)?;
let resumption_psk_store = storage.resumption_psk_store(group_id)?;

Expand All @@ -762,7 +761,6 @@ impl CoreGroup {
self.public_group.delete(storage)?;
storage.delete_own_leaf_index(self.group_id())?;
storage.delete_group_epoch_secrets(self.group_id())?;
storage.delete_use_ratchet_tree_extension(self.group_id())?;
storage.delete_message_secrets(self.group_id())?;
storage.delete_all_resumption_psk_secrets(self.group_id())?;

Expand Down
8 changes: 7 additions & 1 deletion openmls/src/group/mls_group/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,13 @@ impl MlsGroup {
group_id: &GroupId,
) -> Result<Option<MlsGroup>, Storage::Error> {
let group_config = storage.mls_group_join_config(group_id)?;
let core_group = CoreGroup::load(storage, group_id)?;
let core_group = CoreGroup::load(
storage,
group_id,
group_config
.as_ref()
.map(|config: &MlsGroupJoinConfig| config.use_ratchet_tree_extension),
)?;
let own_leaf_nodes = storage.own_leaf_nodes(group_id)?;
let aad = Vec::new();
let group_state = storage.group_state(group_id)?;
Expand Down
20 changes: 0 additions & 20 deletions traits/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,6 @@ pub trait StorageProvider<const VERSION: u16> {
own_leaf_index: &LeafNodeIndex,
) -> Result<(), Self::Error>;

/// Returns the MlsGroupState for group with given id.
/// Sets whether to use the RatchetTreeExtension for the group with the given id.
fn set_use_ratchet_tree_extension<GroupId: traits::GroupId<VERSION>>(
&self,
group_id: &GroupId,
value: bool,
) -> Result<(), Self::Error>;

/// Writes the GroupEpochSecrets for the group with the given id.
fn write_group_epoch_secrets<
GroupId: traits::GroupId<VERSION>,
Expand Down Expand Up @@ -355,12 +347,6 @@ pub trait StorageProvider<const VERSION: u16> {
group_id: &GroupId,
) -> Result<Option<LeafNodeIndex>, Self::Error>;

/// Returns whether to use the RatchetTreeExtension for the group with the given id.
fn use_ratchet_tree_extension<GroupId: traits::GroupId<VERSION>>(
&self,
group_id: &GroupId,
) -> Result<Option<bool>, Self::Error>;

/// Returns the GroupEpochSecrets for the group with the given id.
fn group_epoch_secrets<
GroupId: traits::GroupId<VERSION>,
Expand Down Expand Up @@ -501,12 +487,6 @@ pub trait StorageProvider<const VERSION: u16> {
group_id: &GroupId,
) -> Result<(), Self::Error>;

/// Deletes any preference about whether to use the RatchetTreeExtension for the group with the given id.
fn delete_use_ratchet_tree_extension<GroupId: traits::GroupId<VERSION>>(
&self,
group_id: &GroupId,
) -> Result<(), Self::Error>;

/// Deletes the GroupEpochSecrets for the group with the given id.
fn delete_group_epoch_secrets<GroupId: traits::GroupId<VERSION>>(
&self,
Expand Down

0 comments on commit 8c4671d

Please sign in to comment.