Electric-Coin-Company / zashi

Issue Tracking and common resources for the Zashi Zcash Wallets
MIT License
2 stars 1 forks source link

Embed addresses in ZIP 321 URIs for QR code generation. #51

Open ccjernigan opened 2 years ago

ccjernigan commented 2 years ago

Is your feature request related to a problem? Please describe.

If a user scans a wallet address QR code with another app, like the Camera app, the user will have a bad experience because the camera app won't know what to do with the wallet address.

Describe the solution you'd like

Encode the address in a URI.

Additional context

Some Zcash wallets are presenting naked addresses in their QR codes, so we need a way to at least partially have a migration path to this new convention.

An implementation proposal

There's a related issue in the Android wallet, so that we can ensure that iOS and Android follow the same convention. See https://github.com/zcash/secant-android-wallet/issues/168

daira commented 2 years ago

The protocol spec says this about encoding Zcash Sapling or unified addresses as QR codes, in section 5.6:

Payment addresses MAY be encoded as QR codes; in this case, the RECOMMENDED format for a Sapling or unified payment address is the Bech32 or Bech32m form converted to uppercase, using the Alphanumeric mode [ISO2015, sections 7.3.4 and 7.4.4].

The Alphanumeric mode encodes at 5.5 bits per character (before error correction), rather than 8 bits per character for the 8-bit mode, i.e. it is ~1.45 times more size-efficient.

Note that, of special characters used in URIs, the Alphanumeric mode can encode "/" and ":", but not "?". So in general an URI has to use the 8-bit character subset. (It technically could use mixed modes as described in [ISO2015 section 7.3.7].)

Important: QR codes represent strings, with no further type information. The "Alphanumeric" vs "8-bit" modes of the encoding only affect what characters can be expressed, not what those characters mean. A QR code reader is required to accept any mode, or mixed modes.

nuttycom commented 5 months ago

Related to #43