Files
matrix-rust-sdk/crates
Ivan Enderlin 5d080bdbec feat(sqlite): Event ID are encrypted in the events and event_chunks tables for the Event Cache.
This patch encrypts the `EventId` value in the `events` and
`event_chunks` tables for the Event Cache database.

The `EventId` is transformed as a `String`, and encoded as is.

This patch also adds `Encryption::encode_event_id` and
`Encryption::encode_room_id` to centralise these operations. The _table
name_ for the room ID encoding changes from `keys::LINKED_CHUNKS` to
`keys::EVENTS`. This is not a big change but since we are erasing all
the data for the Event Cache database, we can do this small change.

The biggest change is in `filter_duplicated_events` where we can no
longer use the `event_id` value from the `SELECT` as the returned value
because it is encrypted and cannot be decrypted. To achieve that, we use
the data provided as the parameter of the method to _map_ the encoded
value the other way. Before, the algorithm was:

- `Vec<EventId>` were the event we want to find duplicates,
- run the SQL query selecting all events matching the `event_id`s,
- returning the `event_id` from the SQL query

And now, the algorithm is:

- `Vec<EventId>` were the event we want to find duplicates,
- transform it to `Vec<(EventId, Key)>` where `Key` is the encoded event ID,
- run the SQl query selecting all events matching the encoded flavour of
  the `event_id`s,
- when found, the SQL query returns the encoded flavour, so we look back
  in `Vec<(EventId, Key)>` to find the `EventId` from the `Key`.
2026-07-15 17:42:11 +02:00
..