From 8a631e7c29d2ee795376ff5b4fb4953793483b5f Mon Sep 17 00:00:00 2001 From: Dakota Brink <779390+codabrink@users.noreply.github.com> Date: Tue, 17 Dec 2024 10:43:18 -0500 Subject: [PATCH] Cycle the HMAC key on installation revoke (#1427) * cycle the hmac key on revoke and test * use the wasm trait --- xmtp_mls/src/groups/device_sync/preference_sync.rs | 9 +++++++++ xmtp_mls/src/identity_updates.rs | 8 +++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/xmtp_mls/src/groups/device_sync/preference_sync.rs b/xmtp_mls/src/groups/device_sync/preference_sync.rs index 9f23374b1..f6028d64d 100644 --- a/xmtp_mls/src/groups/device_sync/preference_sync.rs +++ b/xmtp_mls/src/groups/device_sync/preference_sync.rs @@ -93,6 +93,7 @@ mod tests { use super::*; use crate::{ builder::ClientBuilder, + groups::scoped_client::ScopedGroupClient, storage::consent_record::{ConsentState, ConsentType}, }; use crypto_utils::generate_local_wallet; @@ -158,5 +159,13 @@ mod tests { let pref_b = StoredUserPreferences::load(amal_b_conn).unwrap(); assert_eq!(pref_a.hmac_key, pref_b.hmac_key); + + amal_a + .revoke_installations(vec![amal_b.installation_id().to_vec()]) + .await + .unwrap(); + + let new_pref_a = StoredUserPreferences::load(amal_a_conn).unwrap(); + assert_ne!(pref_a.hmac_key, new_pref_a.hmac_key); } } diff --git a/xmtp_mls/src/identity_updates.rs b/xmtp_mls/src/identity_updates.rs index 822c00bac..cb68afe1e 100644 --- a/xmtp_mls/src/identity_updates.rs +++ b/xmtp_mls/src/identity_updates.rs @@ -1,4 +1,6 @@ -use crate::storage::association_state::StoredAssociationState; +use crate::storage::{ + association_state::StoredAssociationState, user_preferences::StoredUserPreferences, +}; use futures::future::try_join_all; use std::collections::{HashMap, HashSet}; use thiserror::Error; @@ -350,6 +352,10 @@ where ) } + // Cycle the HMAC key + let conn = self.store().conn()?; + StoredUserPreferences::new_hmac_key(&conn, &self.local_events)?; + Ok(builder.build()) }