Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set creation time of OlmDevices migrated from legacy to zero #128

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# UNRELEASED

- Set "creation time" of `OlmAccount`s which were migrated from legacy libolm data to the unix epoch, instead of "now". Fixes https://github.com/element-hq/element-web/issues/27590.
([#128](https://github.com/matrix-org/matrix-rust-sdk-crypto-wasm/pull/128))

# matrix-sdk-crypto-wasm v6.0.0

**BREAKING CHANGES**
Expand Down
11 changes: 10 additions & 1 deletion src/libolm_migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,16 @@ async fn migrate_base_data_to_store(
dehydrated: false,
// Assume we have 50 keys on the server, until we get a sync that says fewer.
uploaded_signed_key_count: 50,
creation_local_time: MilliSecondsSinceUnixEpoch::now(),

// The legacy crypto stack didn't keep a record of when the device was created, so we
// have to make something up.
//
// The main thing the creation time is used for is determining whether an event was sent
// before the device was created (and hence should not expect to receive the keys).
// To avoid incorrectly marking UTD events sent before migration as "expected UTDs", we
// set the "creation time" to zero.
creation_local_time: MilliSecondsSinceUnixEpoch(UInt::MIN),

fallback_key_creation_timestamp: None,
})?;

Expand Down
1 change: 1 addition & 0 deletions tests/libolm_migration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ describe("Migration", () => {
);
expect(olmMachine.identityKeys.curve25519.toBase64()).toEqual("LKv0bKbc0EC4h0jknbemv3QalEkeYvuNeUXVRgVVTTU");
expect(olmMachine.identityKeys.ed25519.toBase64()).toEqual("qK70DEqIXq7T+UU3v/al47Ab4JkMEBLpNrTBMbS5rrw");
expect(olmMachine.deviceCreationTimeMs).toEqual(0);

const backupKeys: BackupKeys = await olmMachine.getBackupKeys();
expect(backupKeys.backupVersion).toEqual("3");
Expand Down
Loading