Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
beltram committed Jul 24, 2023
1 parent 317f6dc commit a160be1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
11 changes: 6 additions & 5 deletions crypto/src/mls/conversation/wipe.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::prelude::{ConversationId, CryptoResult, MlsCentral, MlsConversation};
use core_crypto_keystore::{entities::MlsEncryptionKeyPair, CryptoKeystoreMls};
use crate::prelude::{ConversationId, CryptoResult, MlsCentral, MlsConversation, MlsError};
use core_crypto_keystore::CryptoKeystoreMls;
use mls_crypto_provider::MlsCryptoProvider;
use openmls::prelude::Proposal;
use openmls_traits::OpenMlsCryptoProvider;

impl MlsCentral {
Expand Down Expand Up @@ -29,11 +28,13 @@ impl MlsConversation {
// Since it is a terminal operation, ignoring the error is fine here.
let _ = self.group.delete_previous_epoch_keypairs(backend).await;

for proposal in self.group.pending_proposals() {
let pending_proposals = self.group.pending_proposals().cloned().collect::<Vec<_>>();
for proposal in pending_proposals {
// Update proposals rekey the own leaf node. Hence the associated encryption keypair has to be cleared
self.group
.remove_pending_proposal(backend.key_store(), proposal.proposal_reference())
.await?;
.await
.map_err(MlsError::from)?;
}

Ok(())
Expand Down
5 changes: 5 additions & 0 deletions crypto/src/mls/external_commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,8 @@ pub mod tests {
.await
.unwrap();

let initial_count = alice_central.count_entities().await;

// export Alice group info
let group_info = alice_central.get_group_info(&id).await;

Expand All @@ -664,6 +666,9 @@ pub mod tests {
// But for some reason, Bob wants to abort joining the group
bob_central.clear_pending_group_from_external_commit(&id).await.unwrap();

let final_count = alice_central.count_entities().await;
assert_eq!(initial_count, final_count);

// Hence trying to merge the pending should fail
let result = bob_central.merge_pending_group_from_external_commit(&id).await;
assert!(matches!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ impl EntityBase for MlsEpochEncryptionKeyPair {
async fn save(&self, conn: &mut Self::ConnectionType) -> crate::CryptoKeystoreResult<()> {
use rusqlite::OptionalExtension as _;

println!("+ {}", hex::encode(&self.id));

Self::ConnectionType::check_buffer_size(self.id.len())?;
Self::ConnectionType::check_buffer_size(self.keypairs.len())?;

Expand Down Expand Up @@ -202,7 +200,6 @@ impl EntityBase for MlsEpochEncryptionKeyPair {
let len = ids.len();
let mut updated = 0;
for id in ids {
println!("- {}", hex::encode(id.as_slice()));
updated += transaction.execute(
"DELETE FROM mls_epoch_encryption_keypairs WHERE id = ?",
[id.as_slice()],
Expand Down

0 comments on commit a160be1

Please sign in to comment.