Page MenuHomePhabricator

[web/native] Retrieve and encode the ed25519 key in the QR code

Authored by rohan on Thu, Sep 7, 7:18 AM.
Referenced Files
F788362: D9096.id30833.diff
Tue, Oct 3, 4:20 PM
Tue, Oct 3, 12:27 PM
F787798: D9096.id31060.diff
Tue, Oct 3, 7:49 AM
Unknown Object (File)
Fri, Sep 29, 7:57 AM
Unknown Object (File)
Fri, Sep 8, 7:38 AM



The second key we need to encode into the QR code during secondary device login is the ed25519 key, identified as the device id.

After speaking with @marcin and @kamil (and office hours yesterday), accessing this via the commCoreModule on native is done by making a commCoreModule.getUserPublicKey() call, returning both a ed25519 and curve25519 keypair - the first is the one we need.

On web, it's a little different. @kamil pointed out the way we currently do it is by accessing it through Redux, and it seems like the only way to access the keys for now. I won't need to worry about running the key generation protocol since key generation occurs when the login form is rendered. Since the QR code login screen is accessed by clicking a button on the login form, we know the keys should exist.

Depends on D9093

Addresses ENG-4800

Test Plan

On native and web:

  • Opened the QR code login screen and console.log(url)
  • Copied the string
  • Used the same RegEx in links.js to parse out the keys
  • Confirmed that the ed25519 key was encoded correctly
const url = 

const qrCodeKeysRegex = /qr-code\/(\S+)$/;
const qrCodeKeysMatch = qrCodeKeysRegex.exec(url)[1];

const keys = JSON.parse(decodeURIComponent(qrCodeKeysMatch));



  aes256: {
    '0': 213,
    '1': 43,
    '2': 225,
    '3': 116,
    '4': 29,
    '5': 212,
    '6': 144,
    '7': 175,
    '8': 227,
    '9': 166,
    '10': 225,
    '11': 42,
    '12': 77,
    '13': 29,
    '14': 189,
    '15': 156,
    '16': 93,
    '17': 204,
    '18': 38,
    '19': 3,
    '20': 246,
    '21': 18,
    '22': 139,
    '23': 50,
    '24': 220,
    '25': 238,
    '26': 64,
    '27': 24,
    '28': 149,
    '29': 191,
    '30': 7,
    '31': 229
  ed25519: '8dKa0Z7j4P4cs1FRGj+HvXDzwiaylxqa90PgLM0Muzg'

Two additional testing plans:

  • I deleted Comm on the simulator then reinstalled and opened it up to confirm that the keys would be generated before the QR code screen is shown
  • Opened Comm on a separate browser to confirm that the key generation occurred before reaching the QR code page on web

Diff Detail

rCOMM Comm
Lint Not Applicable
Tests Not Applicable

Event Timeline

rohan requested review of this revision.Thu, Sep 7, 7:37 AM

LGTM, but letting other reviewers to take a look

28–31 ↗(On Diff #30833)
20–22 ↗(On Diff #30833)

probably in the future, this check will not be needed, because will need this key to log into identity anyway, so at this point should be present, but for now seems okay

marcin added inline comments.
28–31 ↗(On Diff #30833)

I agree. We should try to reuse code implemented by others.

This revision is now accepted and ready to land.Fri, Sep 8, 2:18 AM
28–31 ↗(On Diff #30833)

Thanks for mentioning getContentSigningKey, I didn't realize we already had a method!

Use getContentSigningKey

This revision was landed with ongoing or failed builds.Wed, Sep 13, 8:41 AM
This revision was automatically updated to reflect the committed changes.