Skip to content

refactor(mimefactory): add Encryption enum - #8573

Merged
link2xt merged 2 commits into
mainfrom
link2xt/encryption-enum
Aug 14, 2026
Merged

refactor(mimefactory): add Encryption enum#8573
link2xt merged 2 commits into
mainfrom
link2xt/encryption-enum

Conversation

@link2xt

@link2xt link2xt commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

This replaces independent data structures
which allowed invalid state of having both the public keys and the shared secret, or having a shared secret
but not encrypting the message because encryption_pubkeys was None instead of Some(Vec::new()).

@link2xt
link2xt force-pushed the link2xt/encryption-enum branch 2 times, most recently from f0f1d06 to d0a6268 Compare August 12, 2026 19:51
@link2xt
link2xt marked this pull request as ready for review August 12, 2026 19:57

@hpk42 hpk42 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A good refactoring although it's a bit hard to know if it fully preserves behaviour especially around symmetric encryption -- it seems that should_encrypt_with_broadcast_secret is not actually used anymore.

Comment thread src/mimefactory.rs Outdated
// created before we had symmetric encryption,
// we show an error message.
let text = BROADCAST_INCOMPATIBILITY_MSG;
chat::add_info_msg(context, chat.id, text).await?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this adds a message to the DB which is a bit unexpected for the from_msg loader function returning a MimeFactory.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Maybe the message can be removed completely, it was for the old broadcast lists. Users should have migrated to channels by now.

Comment thread src/mimefactory.rs Outdated
Comment thread src/mimefactory.rs Outdated
@link2xt
link2xt force-pushed the link2xt/encryption-enum branch 4 times, most recently from 5799581 to d1c9112 Compare August 14, 2026 07:15
@link2xt

link2xt commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator Author

it seems that should_encrypt_with_broadcast_secret is not actually used anymore.

It is used via should_encrypt_symmetrically which just directly calls should_encrypt_with_broadcast_secret.

@link2xt
link2xt force-pushed the link2xt/encryption-enum branch 2 times, most recently from 27ef86d to 229da34 Compare August 14, 2026 08:14
Comment thread src/mimefactory.rs Outdated
Comment thread src/securejoin.rs Outdated
@hpk42

hpk42 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

should_encrypt_with_broadcast_secret is now orphaned.

still not convinced about renaming is_encrypted -> will_be_encrypted. In Chat::is_encrypted, RenderedEmail::is_encrypted and other places we use is_encrypted. Whether encryption is done immediately or lazily is a separate detail that might even change later under the hood.

Creating QR code or sending a message will still fail
with a shorter error, but no info message will be created anymore.
Most users should have migrated the channels by recreating them by now.

This change is needed for moving loading of the shared secret
to earlier stages of message preparation,
otherwise mimefactory will have to create these info messages
when loading the message into memory.
This replaces independent data structures
which allowed invalid state of having both the public keys
and the shared secret, or having a shared secret
but not encrypting the message because encryption_pubkeys
was None instead of Some(Vec::new()).
@link2xt
link2xt force-pushed the link2xt/encryption-enum branch from 229da34 to aa02cd3 Compare August 14, 2026 10:27
@link2xt

link2xt commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator Author

should_encrypt_with_broadcast_secret is used by two functions (should_hide_recipients and should_encrypt_symmetrically), all three functions are just aliases but it was like this since they were introduced in 5034449

@hpk42

hpk42 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

right, the bodies were aliases from the start. Before this PR, should_encrypt_with_broadcast_secret had its own real-world call, now it doesn't and only the wrappers are called. but it's a minor detail, fine.

still my will-be-encrypted rename-comment is open.

@hpk42

hpk42 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

i like the new Encryption enum variants better btw :)

@link2xt

link2xt commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator Author

still my will-be-encrypted rename-comment is open.

I already removed local variable renames.

@hpk42

hpk42 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

ah great, github-refresh shows it now.

@link2xt
link2xt merged commit 3dce06b into main Aug 14, 2026
30 checks passed
@link2xt
link2xt deleted the link2xt/encryption-enum branch August 14, 2026 11:32
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.

3 participants