matrix-org / matrix-org/matrix-rust-sdk

Crypto: Improve logging around OTKs

Open
#3,388 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-Encryption
Dominant language
Rust
Stars
2.3k
Forks
500
Avg merge
1d 16h
Merged PRs (30d)
106

Description

I've seen some bug reports which report `Failed to create a new Olm session from a pre-key message:
InboundCreation(MissingOneTimeKey(....))`. There are [many reasons](https://github.com/element-hq/element-meta/issues/2406) this can happen, but I need more logging to debug this further. In particular:
- Log whenever an OTK is deleted from the database. They are deleted when they get used (which we probably log already?) but they also get deleted when we reach the max OTK count (which we probably don't log).
- Log the number of stored OTKs / the max number of OTKs we will store e.g `504/1000` when we add new OTKs.

This serves two purposes:
- Logging when an OTK is deleted allows us to confirm if the OTK _did exist in the first place_ because it will be present in the bug report logs.
- Logging the number of stored OTKs allows us to know if we are hitting the max and if the bug could be caused by this.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named. Start by locating the code that deletes one-time keys from the database and the code that adds new OTKs; trace both the used-key and maximum-count paths. Done means logging each deletion and reporting stored versus maximum OTK counts when new keys are added.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cryptography
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.