Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Add some comments on the last use of checkDeviceTrust
Browse files Browse the repository at this point in the history
  • Loading branch information
richvdh committed Apr 20, 2023
1 parent 3ef6f58 commit 943a0a7
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/stores/SetupEncryptionStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,20 @@ export class SetupEncryptionStore extends EventEmitter {
const dehydratedDevice = await cli.getDehydratedDevice();
const ownUserId = cli.getUserId()!;
const crossSigningInfo = cli.getStoredCrossSigningForUser(ownUserId);
this.hasDevicesToVerifyAgainst = cli
.getStoredDevicesForUser(ownUserId)
.some(
(device) =>
device.getIdentityKey() &&
(!dehydratedDevice || device.deviceId != dehydratedDevice.device_id) &&
crossSigningInfo?.checkDeviceTrust(crossSigningInfo, device, false, true).isCrossSigningVerified(),
);
this.hasDevicesToVerifyAgainst = cli.getStoredDevicesForUser(ownUserId).some((device) => {
if (!device.getIdentityKey() || (dehydratedDevice && device.deviceId == dehydratedDevice?.device_id)) {
return false;
}
// check if the device is signed by the cross-signing key stored for our user. Note that this is
// *different* to calling `cryptoApi.getDeviceVerificationStatus`, because even if we have stored
// a cross-signing key for our user, we don't necessarily trust it yet (In legacy Crypto, we have not
// yet imported it into `Crypto.crossSigningInfo`, which for maximal confusion is a different object to
// `Crypto.getStoredCrossSigningForUser(ownUserId)`).
//
// TODO: figure out wtf to to here for rust-crypto
const verificationStatus = crossSigningInfo?.checkDeviceTrust(crossSigningInfo, device, false, true);
return !!verificationStatus?.isCrossSigningVerified();
});

this.phase = Phase.Intro;
this.emit("update");
Expand Down

0 comments on commit 943a0a7

Please sign in to comment.