urbit / bridge

An application for interacting with Azimuth.
MIT License
96 stars 25 forks source link

auth: use keccak256 to derive token #1012

Closed tomholford closed 2 years ago

tomholford commented 2 years ago

Context

This PR re-opens #984. After the initial review, we decided to explore an alternative solution (see: #1000). Unfortunately, that approach ended up not being feasible. So, here we are again :) Although the UX is not ideal, it stops the bleeding and provides a suitable fix for now. Eventually, we plan to split Bridge into separate apps, and can rethink this design when the time comes.

See the recent comments in #549 for details, but in short:

This commit introduced a discrepancy between how auth tokens are generated between custodial and non-custodial wallets. Specifically, per the docs for personal_sign, keccak256 is used by Ethereum Providers to sign a message.

When I first joined the Bridge project and had little insight into how things worked, I instead used the subtly different sha256 for the default auth token case (i.e, for master tickets and mnemonics). As such, for roughly the past 6 months, any actions performed in Bridge (generating invites, setting keys, etc) using these login methods were with a logically incorrect auth token.

Changes

This resolves #549 by:

Preview

Legacy Toggle

image

When Keyfile is Unavailable

image

Info Modal

image

Testing

Confirmed using the dev mnemonic on Ropsten.

  1. Log in with Recovery Phrase
  2. Select ~winnet
  3. Navigate to Home > OS, verify that Keyfile is unavailable
  4. Logout
  5. Log in with Recovery Phrase again, this time with Use Legacy Token enabled
  6. Select ~winnet
  7. Navigate to Home > OS, verify that Keyfile can be downloaded