joakim / iota-uri-scheme

IOTA URI Scheme (proposal) – Not set in stone, see open issues:
https://git.io/vpWy0
3 stars 0 forks source link

Tag format (UTF-8 chars or trytes?) #3

Open joakim opened 6 years ago

joakim commented 6 years ago

The tag param is currently specified in the grammar as being a regular UTF-8 percent-encoded query parameter of any length.

tag-param = "tag=" *qchar

Yet in IOTA's reference libraries, a tag is a tryte-encoded string of max 27 trytes (eg. iota.lib.js).

The message doesn't have a maximum length (if longer than 2187 trytes, it will be fragmented and stored across multiple transactions in the bundle), so it can safely be a regular UTF-8 string of any length, later to be percent-decoded and tryte-encoded by the wallet.

But the tag's maximum length makes things more complicated, especially with percent-encoded UTF-8 characters. How to specify the max length then, so that it corresponds to 27 trytes?

I see two options…

  1. Require that the tag is represented as UTF-8, but once percent-decoded and tryte-encoded, must be maximum 27 trytes. \ This complicates creating URIs with tags somewhat, as the length of the raw (not percent-encoded) tag should be checked before percent-encoding (16 bytes = 27 trytes) to avoid it being truncated. \ It also complicates using a tag that is intended to be consumed as trytes (eg. FOO is a valid tryte tag, but if provided as FOO in UTF-8, it will get tryte-encoded into PBYBYB when added to the transaction – not what one might expect).

  2. Require that the tag must be specified as 27 trytes. \ This means that one can't write URIs by hand with tags in UTF-8 (eg. This is a tag), it must first be tryte-encoded (into CCWCXCGDEAXCGDEAPCEAHDPCVC), and the tag's plain-text value will be obfuscated.

Any other options? Ideas? Feedback?

joakim commented 6 years ago

I've heard from one wallet dev that UTF-8 is fine, as that's how the app handles the input anyway.