matrix-rust-sdk
matrix-rust-sdk copied to clipboard
Allow inbound megolm sessions to be merged when two copies are received from different sources
We may receive a room key with an incomplete ratchet (first known message index of 1) but ideal SenderData, only to later find another room key with a complete ratchet (first known message index of 0) but less optimal SenderData.
PR #4040 addressed a special case of this issue, where the ratchets are identical (i.e., the first known message index is the same) but the SenderData differs.
However, we should also be able to merge two room keys with different ratchet states and SenderData, ensuring that the resulting key retains the best properties from both.
The InboundGroupSession::merge() method can be used to determine if two InboundGroupSession instances share the same ratchet.
This issue supersedes #3703, which had become cluttered with some loosely related discussions.
Causes app layer issue: https://github.com/element-hq/element-x-ios/issues/3352