Page MenuHomePhabricator

[keyserver] Encode the device id into the QR code

Authored by rohan on Sep 18 2023, 10:01 AM.
Referenced Files
Unknown Object (File)
Sun, Feb 18, 5:00 AM
Unknown Object (File)
Sun, Feb 18, 4:42 AM
Unknown Object (File)
Sun, Feb 18, 4:10 AM
Unknown Object (File)
Sun, Feb 18, 3:35 AM
Unknown Object (File)
Sat, Feb 17, 11:40 PM
Unknown Object (File)
Sat, Feb 17, 11:37 PM
Unknown Object (File)
Dec 17 2023, 4:57 AM
Unknown Object (File)
Dec 17 2023, 4:08 AM



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


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

Diff Detail

rCOMM Comm
Lint Not Applicable
Tests Not Applicable

Event Timeline

rohan edited the test plan for this revision. (Show Details)
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:

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.
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:

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

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

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