Skip to content

Commit

Permalink
[uniffi] Rename commit to key_update
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mgeisler committed Apr 3, 2024
1 parent 8f7d38b commit 731c0b5
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions mls-rs-uniffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<CommitOutput, Error> {
// TODO: ensure `path_required` is always set in
// [`MlsRules::commit_options`](`mls_rs::MlsRules::commit_options`).
pub async fn key_update(&self) -> Result<CommitOutput, Error> {
let mut group = self.inner().await;
let commit_output = group.commit(Vec::new()).await?;
commit_output.try_into()
Expand Down Expand Up @@ -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(())
}

Expand All @@ -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());
Expand Down

0 comments on commit 731c0b5

Please sign in to comment.