From 731c0b5c85211d8e5982235d24157cea3bd97872 Mon Sep 17 00:00:00 2001 From: Martin Geisler Date: Wed, 3 Apr 2024 15:33:49 +0200 Subject: [PATCH] [uniffi] Rename `commit` to `key_update` When discussing this internally, the feeling was that `commit` would mostly be used to refresh keys. The name `key_update` would thus be more descriptive. Addresses #81. --- mls-rs-uniffi/src/lib.rs | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/mls-rs-uniffi/src/lib.rs b/mls-rs-uniffi/src/lib.rs index f4da9743..3319c61d 100644 --- a/mls-rs-uniffi/src/lib.rs +++ b/mls-rs-uniffi/src/lib.rs @@ -612,14 +612,19 @@ impl Group { group.export_tree().try_into() } - /// Perform a commit of received proposals (or an empty commit). + /// Perform a commit to update encryption keys. /// - /// TODO: ensure `path_required` is always set in - /// [`MlsRules::commit_options`](`mls_rs::MlsRules::commit_options`). + /// This will commit any received proposals (or create an empty + /// commit). Empty commits are important since they let clients + /// refresh their encryption keys. Doing so periodically ensures + /// forward secrecy and post-compromise security the group + /// messages. /// /// Returns the resulting commit message. See /// [`mls_rs::Group::commit`] for details. - pub async fn commit(&self) -> Result { + // TODO: ensure `path_required` is always set in + // [`MlsRules::commit_options`](`mls_rs::MlsRules::commit_options`). + pub async fn key_update(&self) -> Result { let mut group = self.inner().await; let commit_output = group.commit(Vec::new()).await?; commit_output.try_into() @@ -905,7 +910,7 @@ mod tests { let alice = Client::new(b"alice".to_vec(), alice_keypair, alice_config); let group = alice.create_group(None)?; - assert_eq!(group.commit()?.ratchet_tree, None); + assert_eq!(group.key_update()?.ratchet_tree, None); Ok(()) } @@ -921,8 +926,12 @@ mod tests { let alice = Client::new(b"alice".to_vec(), alice_keypair, alice_config); let group = alice.create_group(None)?; - let ratchet_tree: group::ExportedTree = - group.commit()?.ratchet_tree.unwrap().try_into().unwrap(); + let ratchet_tree: group::ExportedTree = group + .key_update()? + .ratchet_tree + .unwrap() + .try_into() + .unwrap(); group.inner().apply_pending_commit()?; assert_eq!(ratchet_tree, group.inner().export_tree());