Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use the Curve25519 sender key to store room keys #1091

Merged
merged 3 commits into from
Oct 10, 2022

Conversation

poljar
Copy link
Contributor

@poljar poljar commented Oct 7, 2022

This implements MSC 3700, which is nowadays part of the spec.

Now that we're not scoping the room keys by the Curve25519 sender key
we're opening the door of multiple devices trying to insert the same
room key into our store.

This patch changes our logic so we only store room keys from an
m.room_key event if we don't have one already or if the new key is
a better version of the one we already have.

This mostly assumes that the first room key with a given session id
is coming from the creator of the room key.
@poljar poljar force-pushed the poljar/store-group-sessions-without-sender-key branch from 8133aef to c4a019d Compare October 7, 2022 14:48
@codecov
Copy link

codecov bot commented Oct 7, 2022

Codecov Report

Base: 77.96% // Head: 77.91% // Decreases project coverage by -0.05% ⚠️

Coverage data is based on head (c4a019d) compared to base (6a561c2).
Patch coverage: 80.18% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1091      +/-   ##
==========================================
- Coverage   77.96%   77.91%   -0.06%     
==========================================
  Files         109      109              
  Lines       14718    14696      -22     
==========================================
- Hits        11475    11450      -25     
- Misses       3243     3246       +3     
Impacted Files Coverage Δ
...trix-sdk-crypto/src/types/events/room/encrypted.rs 83.33% <ø> (-0.39%) ⬇️
crates/matrix-sdk-crypto/src/gossiping/machine.rs 78.97% <58.82%> (-0.78%) ⬇️
crates/matrix-sdk-crypto/src/machine.rs 82.19% <68.00%> (-0.40%) ⬇️
crates/matrix-sdk-sled/src/crypto_store.rs 88.77% <68.75%> (-0.43%) ⬇️
crates/matrix-sdk-crypto/src/store/caches.rs 97.82% <80.00%> (-0.10%) ⬇️
...atrix-sdk-crypto/src/olm/group_sessions/inbound.rs 90.28% <100.00%> (+1.54%) ⬆️
...s/matrix-sdk-crypto/src/store/integration_tests.rs 100.00% <100.00%> (ø)
crates/matrix-sdk-crypto/src/store/memorystore.rs 89.15% <100.00%> (-0.07%) ⬇️
crates/matrix-sdk-crypto/src/store/mod.rs 58.39% <100.00%> (+1.57%) ⬆️
crates/matrix-sdk-sled/src/lib.rs 90.90% <100.00%> (ø)
... and 5 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@poljar poljar requested a review from a team October 7, 2022 15:35
Copy link
Contributor

@gnunicorn gnunicorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It reveals some oddity in the client-builder, which arguably isn't related to the core aspect of this PR. Aside from that I just have one clarification question.

// be a trippled of `(room_id, sender_key, session_id)` now it's a
// tuple of `(room_id, session_id)`
//
// Let's just drop the whole object store.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is that save? The session will just be recovered during via sync?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, we're just dropping things in the indexeddb store since it's unused as of yet. I guess I could have just made a breaking change instead.

@@ -129,12 +129,12 @@ impl ClientBuilder {
/// This is a shorthand for
/// <code>.[store_config](Self::store_config)([matrix_sdk_sled]::[make_store_config](matrix_sdk_sled::make_store_config)(path, passphrase)?)</code>.
#[cfg(feature = "sled")]
pub fn sled_store(
pub async fn sled_store(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm... this is a bit odd of a pattern ... generally, in the builder-pattern we expect to just set things and can chain them and don't have them do stuff yet but only really become active on build().await? ...

This isn't strictly about this PR, it just became more obvious that this isn't really proper when I noticed the new .await on its setter...

@poljar poljar merged commit 8763a24 into main Oct 10, 2022
@poljar poljar deleted the poljar/store-group-sessions-without-sender-key branch October 10, 2022 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants