Skip to content

Conversation

@coriolinus
Copy link
Contributor

What's new in this PR


PR Submission Checklist for internal contributors
  • The PR Title
    • conforms to the style of semantic commits messages¹ supported in Wire's Github Workflow²
    • contains a reference JIRA issue number like SQPIT-764
    • answers the question: If merged, this PR will: ... ³
  1. https://sparkbox.com/foundry/semantic_commit_messages
  2. https://github.com/wireapp/.github#usage
  3. E.g. feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764.

}

// About WASM Encryption:
// The store key (i.e. passphrase) is hashed using SHA256 to obtain 32 bytes
Copy link
Member

Choose a reason for hiding this comment

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

This is not the case anymore, since the database key type change clients have to provide the key directly .

Disable the `derive(Entity)` macro to a noop.
I'm going to be doing some major refactoring of the `Entity` trait,
and the noise of compiler errors due to implementations not matching
the new definitions would absolutely drown out the signal
of real problems, except for this.

Obviously, we need to retain a real entity derive macro before this PR
is over, but this should simplify things temporarily.
These traits should be both easier to use and more performant.

One `set` method can't cover all desired cases: there may be some times
when you want set-and-replace, and other times when you want set-if-absent.
Since we're providing these with a blanket impl, there's no chance to
just implement the desired semantics on your own type, particularly as
there may be circumstances where you want both semantics for different
occasions on the same entity.
These functions handle the boilerplate of a "standard" sql table.
@coriolinus coriolinus force-pushed the prgn/refactor/20839-new-entity-trait branch from d493f98 to 207b857 Compare December 3, 2025 14:38
The existing `trait EntityEncryptionExt` was confusing: it depended
on mutating the internal state, and never calling the appropriate
methods too many or too few times. It wasn't obvious when or whether
it was ever appropriate for an implementing item to override one of
the default trait methods.

In fairness, it's a complicated problem.

This commit contains my approach, which breaks it up substantially.
Entities no longer implement `Serialize` or `Deserialize`, and in fact
must not implement either of those. (If it were possible, I'd have
added negative trait bounds to that effect.) Doing this with separate
types gives us some static type safety, which is always nice!

Instead, entities which want to serialize must implement `Encrypting`,
which requires them to copy all non-sensitive data and encrypt all sensitive data
into an associated type. This associated type implements `Serialize`.

Likewise, entities which want to deserialize must implement `Decrypting`,
which requires them to copy all non-sensitive data and decrypt all sensitive data
from an associated type. This associated type implements `Deserialize`.

The benefit is that required methods have no defaults, and it is
impossible to improperly override default methods. There are now
helper traits `EncryptData` and `DecryptData`, which are automatically
implemented for all entities, and handle all the details of the
symmetrical encryption and decryption.
@coriolinus coriolinus force-pushed the prgn/refactor/20839-new-entity-trait branch from 207b857 to e7a3c21 Compare December 3, 2025 14:40
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