Page MenuHomePhabricator

[keyserver] Store `primaryIdentityPublicKey` in `public_key` column of `cookies` table
ClosedPublic

Authored by atul on Dec 31 2022, 4:26 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 11, 1:56 PM
Unknown Object (File)
Sun, Nov 10, 7:51 AM
Unknown Object (File)
Tue, Oct 22, 5:15 PM
Unknown Object (File)
Tue, Oct 22, 12:22 PM
Unknown Object (File)
Tue, Oct 22, 12:21 PM
Unknown Object (File)
Tue, Oct 22, 12:21 PM
Unknown Object (File)
Tue, Oct 22, 12:21 PM
Unknown Object (File)
Tue, Oct 22, 12:21 PM
Subscribers
None

Details

Summary

Context: https://linear.app/comm/issue/ENG-1967/update-clients-to-generate-a-publicprivate-keypair-when-authing

Basically pass the primaryIdentityPublicKey contained in the SIWE message statement to the cookie creation step in processSIWEAccountCreation(...).


Depends on D6133

Test Plan
  1. public key included in message signing request:

IMG_2687.PNG (2×1 px, 791 KB)

  1. public key stored in public_key column of cookies table (look at last row):

be60cd.png (504×2 px, 247 KB)

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

atul edited the test plan for this revision. (Show Details)
Harbormaster returned this revision to the author for changes because remote builds failed.Dec 31 2022, 4:30 AM
Harbormaster failed remote builds in B15007: Diff 20484!
atul edited the test plan for this revision. (Show Details)

rebase after resolving flow issue

atul published this revision for review.Dec 31 2022, 4:31 AM
This revision is now accepted and ready to land.Jan 1 2023, 8:02 PM
keyserver/src/session/cookies.js
683

Just realized we're allowing the same public key with different cases here – can we lowercase this before storing to make sure we only have one version with it?

keyserver/src/session/cookies.js
683

The public key is base64 encoded... lowercase and uppercase characters are different.

This is different than the ethereum address which is encoded as hexadecimal (with optional capitalization to compute some sort of checksum)

keyserver/src/session/cookies.js
683

I wonder if we should also make sure we don't have multiple cookies with the same public_key. Our whitepaper talks about restoring an existing public_key onto a new device (in "3.1 Backup" and "4.1.7 Primary Device Switch").

That necessitates some sort of hand-off between devices. We generally want to avoid a scenario where two devices are represented simultaneously by the same cookie... we've seen this before after an iOS backup is restored. So you could imagine us excluding the cookie from the backup, as discussed in point 1 of ENG-2628.

I could imagine some sort of problem behavior that would result here of the new device then trying to initiate a new cookie with the same public_key. The protocol in the whitepaper requires the handing-off device to initiate a new session, but if it fails to do this for whatever reason it could be a problem.

Created ENG-2628 to track adding a UNIQUE constraint here.

keyserver/src/session/cookies.js
683

Created ENG-2628 to track adding a UNIQUE constraint here.

Oops, I meant ENG-2629

The public key is base64 encoded... lowercase and uppercase characters are different.

Got it

This is different than the ethereum address which is encoded as hexadecimal (with optional capitalization to compute some sort of checksum)

Uhhh interesting, is that something where we should be normalizing?

keyserver/src/session/cookies.js
683

Uhhh interesting, is that something where we should be normalizing?

Thought about that, but figured it made sense to keep things symmetrical with the interfaces we're using. EG base64 encoding for the public key since that's what OLM uses, and hexadecimal for ethereum address (since that's what rainbowkit... and pretty much everyone uses)

keyserver/src/session/cookies.js
683

We could prefix some sort of base64_ to variable names + column names to make it clearer maybe? (https://en.wikipedia.org/wiki/Hungarian_notation)

keyserver/src/session/cookies.js
683

I think we should normalize the ETH addresses so we only have one way to represent an ETH address in the database. We could keep the checksumming behavior with a package like ethereum-checksum-address (NPM link), or we could just lowercase them. What do you think? Can you create a task to track before landing?

This revision was landed with ongoing or failed builds.Jan 3 2023, 3:55 PM
This revision was automatically updated to reflect the committed changes.