Simon/feat/decrypt targeted message - #2425
Open
SimonThormeyer wants to merge 25 commits into
Open
Conversation
SimonThormeyer
force-pushed
the
simon/feat/decrypt-targeted-message
branch
3 times, most recently
from
August 3, 2026 15:08
1fb2154 to
3ce3db2
Compare
Base automatically changed from
simon/feat/targeted-message-message-enum
to
main
August 12, 2026 12:45
SimonThormeyer
force-pushed
the
simon/feat/decrypt-targeted-message
branch
4 times, most recently
from
August 19, 2026 11:39
8f64620 to
c12991b
Compare
… or tnt The tnt decrypt function doesn't exist yet, but it's about to be added
…ion and decryption
SimonThormeyer
force-pushed
the
simon/feat/decrypt-targeted-message
branch
from
August 19, 2026 13:31
d96cc23 to
b0dc974
Compare
This tests - basic encryption/decryption roundtrip - decrypting messages as far back as `MAX_PAST_EPOCHS`, and failure beyond - protection from replays via `DuplicateMessageError` - buffering of targeted messages from epochs one step in the future
SimonThormeyer
force-pushed
the
simon/feat/decrypt-targeted-message
branch
from
August 19, 2026 14:02
b0dc974 to
95a4841
Compare
SimonThormeyer
force-pushed
the
simon/feat/decrypt-targeted-message
branch
from
August 19, 2026 14:13
95a4841 to
09eb4dc
Compare
coriolinus
reviewed
Aug 19, 2026
coriolinus
reviewed
Aug 19, 2026
| } | ||
|
|
||
| #[derive(Clone, Debug, PartialEq, Eq, Hash, derive_more::Constructor)] | ||
| pub struct TntSecretPk { |
Contributor
There was a problem hiding this comment.
This seems like a good opportunity to have TntSecretPkRef<'a> containing an &'a ConversationRef, so that you can impl EntityGetBorrowed and EntityDeleteBorrowed.
coriolinus
reviewed
Aug 19, 2026
coriolinus
reviewed
Aug 19, 2026
| let epoch_before_operation = group.epoch(); | ||
|
|
||
| // Save the tnt secret. We need to do this exactly once per epoch. | ||
| let tnt_secret_key = TntSecretPk::new(id.as_ref().to_vec(), epoch_before_operation.as_u64()); |
Contributor
There was a problem hiding this comment.
The needed to_vec() here is why I'm suggesting EntityGetBorrowed for TntSecret.
coriolinus
reviewed
Aug 19, 2026
| group.reset_targeted_message_tx_counters(tx).await; | ||
|
|
||
| let oldest_retained_epoch = group.epoch().as_u64().saturating_sub(MAX_PAST_EPOCHS as u64); | ||
| let conversation_id = DbConversationId::from(id.as_ref().to_vec()); |
Contributor
There was a problem hiding this comment.
I bet we could also invent a borrowed form of ConversationId that we could implement searching for.
coriolinus
reviewed
Aug 19, 2026
Comment on lines
+74
to
+83
| // This is not a lot of data: just `MAX_PAST_EPOCHS` records. In practice, we could in most cases just | ||
| // delete the single one with the oldest epoch. However, to avoid any assumptions about the data, let's just | ||
| // check each of the `MAX_PAST_EPOCHS` records. | ||
| for secret in secrets { | ||
| if secret.epoch < oldest_retained_epoch { | ||
| tx.remove::<TntSecret>(&TntSecretPk::new(secret.conversation_id.clone(), secret.epoch)) | ||
| .await | ||
| .map_err(KeystoreError::wrap("removing old tnt secret"))?; | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
This is acceptable as a first draft but I'd rather see an AnyEpochOlderThan(pub u64) newtype with a DeletableBySearchKey impl which ultimately delegates down to DELETE FROM tnt_secrets WHERE epoch < ?.
coriolinus
reviewed
Aug 19, 2026
| } | ||
|
|
||
| let database = self.database().await?; | ||
| let counter_pk = TargetedMessageRxCounterPk::new(self.id.to_bytes(), message.sender().u32(), group_epoch); |
SimonThormeyer
marked this pull request as ready for review
August 19, 2026 14:52
coriolinus
reviewed
Aug 19, 2026
| } | ||
|
|
||
| let database = self.database().await?; | ||
| let key = TntSecretPk::new(mls_group.group_id().to_vec(), message.epoch.as_u64()); |
…e variants in clients
…orresponding struct
SimonThormeyer
force-pushed
the
simon/feat/decrypt-targeted-message
branch
from
August 19, 2026 15:08
0a3dbb9 to
ffa32fa
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.