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

Update/Revise SDK to implement reference flowchart for key sharing/forwarding + use backup #5559

Merged
merged 29 commits into from
May 11, 2022

Conversation

BillCarsonFr
Copy link
Member

@BillCarsonFr BillCarsonFr commented Mar 16, 2022

Type of change

  • Bugfix

Content

Fixes #5494

A complete revision of the SDK key requesting and forwarding code.
The code has been modified to follow the reference recommandation for key forwarding and requesting.

  1. Key Requesting is now managed by the OutgoingKeyRequestManager. The lifecycle is now based on the sync pulse:

    • Improvement Before sending a key request we first check the megolm backup for that session
    • Improvement Key requests where cancelled too early, now we keep track of the wanted ratchet index and keep the request alive until we have the proper index
    • Improvement We wait for catchup syncs before sending request to avoid unneccessary to_device traffic
    • Improvement using MSC3735 we can now have a track of the replies from a key request (withheld from xxx, forwarded from xxx with index....) That would allow to provide better UI feedback
    • Keys are now reshared to our own unverified device if it was previously shared
    • Most of the code as been refactored, database entities have changed
  2. Secret management has been reworked and separated from key request, as it happens during interactive verification it's not using anymore workers, but it is replying directly and faster.

  3. We don't download the full backup after verification as it can be very long and was causing incomplete session as the megolm backup key was only saved after the full import (for big backups the megolm key might not be saved at all if the app is killed before download complete). With the new system it's much faster as you will query keys on the fly when the timeline is opened (you can still download the complete backup from settings, with proper feedback).

  4. A new SDK configuration to limit key request to the users own device has been added (requested by some forks), see MXCryptoConfig

  5. ** Update ** Remove Woker usage for verification, as it's an interactive process there's no reason to use workers

  6. Resurrected Withheld and verification tests

Motivation and context

Screenshots / GIFs

image

Tests

  • Step 1
  • Step 2
  • Step ...

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

@github-actions
Copy link

github-actions bot commented Mar 17, 2022

Unit Test Results

122 files  ±0  122 suites  ±0   2m 8s ⏱️ -16s
205 tests ±0  205 ✔️ ±0  0 💤 ±0  0 ±0 
690 runs  ±0  690 ✔️ ±0  0 💤 ±0  0 ±0 

Results for commit 3948f26. ± Comparison against base commit 04cadb9.

♻️ This comment has been updated with latest results.

@BillCarsonFr BillCarsonFr force-pushed the feature/bca/crypto_better_key_share branch from 5ce8765 to 569a3fc Compare March 18, 2022 16:12
@BillCarsonFr BillCarsonFr marked this pull request as ready for review March 18, 2022 16:16
@BillCarsonFr BillCarsonFr changed the title Feature/bca/crypto better key share Update/Revise SDK to implement reference flowchart for key sharing/forwarding + use backup Mar 18, 2022
@BillCarsonFr BillCarsonFr force-pushed the feature/bca/crypto_better_key_share branch from 32e5033 to 7e68b1d Compare March 29, 2022 12:10
@bmarty
Copy link
Member

bmarty commented Apr 14, 2022

(Waiting for this PR to be rebased to review it)

@BillCarsonFr BillCarsonFr force-pushed the feature/bca/crypto_better_key_share branch 4 times, most recently from 3d64727 to ba03413 Compare April 20, 2022 16:06
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

Amazing work, thanks! A few remarks after a static review.

@BillCarsonFr BillCarsonFr force-pushed the feature/bca/crypto_better_key_share branch 2 times, most recently from afd905b to a4314c0 Compare April 25, 2022 15:06
@BillCarsonFr BillCarsonFr force-pushed the feature/bca/crypto_better_key_share branch from 70720e9 to 58c4c4e Compare April 26, 2022 07:14
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

Thanks for the update, more remarks.

I have also tested the Realm migration, it is working fine.

Timber.w("## SAS ignored verification ready with methods: ${keyReq.methods}")
}
}
/*
Copy link
Member

Choose a reason for hiding this comment

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

crlf?

@BillCarsonFr BillCarsonFr force-pushed the feature/bca/crypto_better_key_share branch from df8eb40 to 8920ed3 Compare April 27, 2022 07:45
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

One more remark, also there are some un-handled remarks

@ericmigi
Copy link

ericmigi commented May 5, 2022

FYI Beeper is now testing this PR internally, we'll see how it goes!

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

Thanks for the update!

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

Thanks for the update. Let's merge it!

@BillCarsonFr BillCarsonFr merged commit 304cb07 into develop May 11, 2022
@BillCarsonFr BillCarsonFr deleted the feature/bca/crypto_better_key_share branch May 11, 2022 10:05
@github-actions
Copy link

Matrix SDK

Integration Tests Results:

  • [org.matrix.android.sdk.session]
    = passed=15 failures=5 errors=0 skipped=3
  • [org.matrix.android.sdk.account]
    = passed=3 failures=0 errors=0 skipped=2
  • [org.matrix.android.sdk.internal]
    = passed=90 failures=40 errors=0 skipped=31
  • [org.matrix.android.sdk.ordering]
    = passed=16 failures=0 errors=0 skipped=0
  • [org.matrix.android.sdk.PermalinkParserTest]
    = passed=2 failures=0 errors=0 skipped=0

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.

Update/Revise SDK to implement reference flowchart for key sharing/forwarding + use backup
3 participants