Skip to content

Commit eb30ab6

Browse files
feat!: add field to MlsCommitBundle [WPB-17106]
We need this field to enable advancing the epoch and sharing an application message with all members immediately when a new epoch is started.
1 parent ff13613 commit eb30ab6

File tree

5 files changed

+19
-0
lines changed

5 files changed

+19
-0
lines changed

crypto-ffi/bindings/js/src/CoreCryptoMLS.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ export interface CommitBundle {
7373
* @readonly
7474
*/
7575
groupInfo: GroupInfoBundle;
76+
77+
/**
78+
* An encrypted message to fan out to all other conversation members in the new epoch
79+
* @readonly
80+
*/
81+
encryptedMessage?: Uint8Array;
7682
}
7783

7884
function commitBundleFromFfi(commitBundle: CommitBundleFfi): CommitBundle {
@@ -84,6 +90,7 @@ function commitBundleFromFfi(commitBundle: CommitBundleFfi): CommitBundle {
8490
ratchetTreeType: commitBundle.group_info.ratchet_tree_type,
8591
payload: commitBundle.group_info.payload,
8692
},
93+
encryptedMessage: commitBundle.encryptedMessage,
8794
};
8895
}
8996

crypto-ffi/src/bundles/commit.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,23 @@ pub struct CommitBundle {
1515
pub welcome: Option<Vec<u8>>,
1616
pub commit: Vec<u8>,
1717
pub group_info: GroupInfoBundle,
18+
#[cfg_attr(target_family = "wasm", wasm_bindgen(js_name = "encryptedMessage", readonly))]
19+
/// An encrypted message to fan out to all other conversation members in the new epoch
20+
pub encrypted_message: Option<Vec<u8>>,
1821
}
1922

2023
impl TryFrom<MlsCommitBundle> for CommitBundle {
2124
type Error = CoreCryptoError;
2225

2326
fn try_from(msg: MlsCommitBundle) -> Result<Self, Self::Error> {
27+
let encrypted_message = msg.encrypted_message.clone();
2428
let (welcome, commit, group_info) = msg.to_bytes_triple()?;
2529
let group_info = group_info.into();
2630
Ok(Self {
2731
welcome,
2832
commit,
2933
group_info,
34+
encrypted_message,
3035
})
3136
}
3237
}

crypto/src/mls/conversation/commit.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ impl MlsConversation {
4141
welcome,
4242
commit,
4343
group_info,
44+
encrypted_message: None,
4445
}))
4546
}
4647
}
@@ -54,6 +55,8 @@ pub struct MlsCommitBundle {
5455
pub commit: MlsMessageOut,
5556
/// `GroupInfo` if the commit is merged
5657
pub group_info: MlsGroupInfoBundle,
58+
/// An encrypted message to fan out to all other conversation members in the new epoch
59+
pub encrypted_message: Option<Vec<u8>>,
5760
}
5861

5962
impl MlsCommitBundle {

crypto/src/mls/conversation/conversation_guard/commit.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ impl ConversationGuard {
138138
commit,
139139
welcome,
140140
group_info,
141+
encrypted_message: None,
141142
};
142143

143144
self.send_and_merge_commit(commit).await?;
@@ -187,6 +188,7 @@ impl ConversationGuard {
187188
commit,
188189
welcome,
189190
group_info,
191+
encrypted_message: None,
190192
})
191193
.await
192194
}
@@ -263,6 +265,7 @@ impl ConversationGuard {
263265
welcome,
264266
commit,
265267
group_info,
268+
encrypted_message: None,
266269
})
267270
}
268271

crypto/src/transaction_context/conversation/external_commit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ impl TransactionContext {
129129
welcome: None,
130130
commit,
131131
group_info,
132+
encrypted_message: None,
132133
};
133134

134135
let welcome_bundle = WelcomeBundle {

0 commit comments

Comments
 (0)