Page MenuHomePhabricator

[keyserver] Encode the device id into the QR code
ClosedPublic

Authored by rohan on Sep 18 2023, 10:01 AM.
Tags
None
Referenced Files
F3370348: D9220.id31368.diff
Tue, Nov 26, 2:12 AM
F3370340: D9220.id31341.diff
Tue, Nov 26, 2:10 AM
F3368362: D9220.id31372.diff
Mon, Nov 25, 7:27 PM
Unknown Object (File)
Fri, Nov 22, 8:42 AM
Unknown Object (File)
Thu, Nov 21, 2:07 AM
Unknown Object (File)
Tue, Nov 19, 5:05 PM
Unknown Object (File)
Tue, Nov 19, 3:42 PM
Unknown Object (File)
Tue, Nov 19, 3:25 PM
Subscribers

Details

Summary

The second key we need to encode into the QR code for the terminal output is the ed25519 key / the device id. The way we seem to currently do this is to fetch the content OLM account and parse out the identity keys (here we want the ed25519, not the curve25519 key). Going to set @varun as blocking since I used his initial script as a starting point here

Depends on D9202

Addresses ENG-4798

Test Plan

Screenshot 2023-09-18 at 11.16.27 AM.png (1×3 px, 1 MB)

Logged out the url encoded and parsed out the keys to confirm they were correctly set:

const url = 'comm://qr-code/%7B%22aes256%22%3A%2267f88084dcf741c747f07d83e053444b4ed08c74f0930b86c0b59de04a90a725%22%2C%22ed25519%22%3A%22zLtHliYkjRAfwJxIGp%2FGXDjfu2BsifodMQfJteML6%2Fg%22%7D';

// This is the regex we use to parse the QR code link in `links.js`
const qrCodeKeysRegex = /qr-code\/(\S+)$/;
const qrCodeKeysMatch = qrCodeKeysRegex.exec(url)[1];

// Decode and parse the keys from the URL
const keys = JSON.parse(decodeURIComponent(qrCodeKeysMatch));

// Log the keys to verify
console.log(keys);

Output:

{
  aes256: '67f88084dcf741c747f07d83e053444b4ed08c74f0930b86c0b59de04a90a725',
  ed25519: 'zLtHliYkjRAfwJxIGp/GXDjfu2BsifodMQfJteML6/g'
}

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

rohan edited the test plan for this revision. (Show Details)
keyserver/src/keyserver.js
95–101 ↗(On Diff #31207)

This isn't strictly necessary, just figured it'll be easy for now to bring over the same instructions from both native and web on how to scan the QR code via the Comm app (external camera scanning is still supported).

The \x1b[1m is used to begin bolded font, and the x1b[0m is used to end bolded font (see here: https://gist.github.com/raghav4/48716264a0f426cf95e4342c21ada8e7#features).

This 1. matches the bolded font on web and native on the QR code screen and 2. makes it a bit easier to separate normal instructions vs. components the user needs to interact with, but happy to just make it all normal text if need be

varun requested changes to this revision.Sep 20 2023, 10:56 PM
varun added inline comments.
keyserver/src/keyserver.js
90–93 ↗(On Diff #31207)

i realize i probably should've done this, but can you please dedup this? we have the same logic in

  • keyserver/src/scripts/get-keyserver-public-key.js
  • keyserver/src/socket/tunnelbroker.js

(- we should be using it in keyserver/src/utils/olm-utils.js but there's a bug: https://linear.app/comm/issue/ENG-4993/use-correct-key-content-ed25519-public-key-as-device-id)

This revision now requires changes to proceed.Sep 20 2023, 10:56 PM

Consolidate retrieving device id logic into a helper function & use that in:

  • keyserver/src/scripts/get-keyserver-public-key.js
  • keyserver/src/socket/tunnelbroker.js
  • keyserver/src/keyserver.js

To test this, I logged the ed25519 key in keyserver.js when generating the QR code and ran yarn script dist/scripts/get-keyserver-public-key.js to verify it still worked

keyserver/src/utils/olm-utils.js
150–153 ↗(On Diff #31341)

Not 100% if this is actually the right name for this function, happy to change it

thank you! one comment inline

keyserver/src/utils/olm-utils.js
150–153 ↗(On Diff #31341)

getContentSigningKey to keep it consistent with native. would also change the variable names appropriately from contentPublicKey to contentSigningKey

This revision is now accepted and ready to land.Sep 21 2023, 11:57 AM

Rename getContentPublicKey -> getContentSigningKey and
contentPublicKey -> contentSigningKey