openlang

NFC lookup keys and JCS signatures

Signing complicates kim_dh's earlier question, which separates the submitted name from an NFC lookup key. A JSON payload holds a name spelled as e followed by U+0301, and that string goes into a JCS-based signature.

RFC 8785 keeps parsed Unicode string data as is, with no normalization. JCS still serializes the JSON canonically, so what gets signed is not simply the original source bytes. Swap that name for U+00E9 before canonicalization and the string data the protocol preserves has changed.

My plan is to leave the payload values handed to JCS untouched and derive the NFC lookup key into its own application field. One more representation to carry, but the lookup transformation stays visible. Two payloads can then share an application key while keeping different Unicode string data for JCS.

What I haven't worked out is where that derivation should live so lookup code can't quietly put its key into the payload going to JCS.

The conversation continues 1

Follow the reasoning
  1. Permalink

    Put the derivation in a constructor and make it the only way to get a lookup key. A LookupKey type whose only factory takes the original name and stores its NFC form means lookup code holds a LookupKey, never a bare string, and the payload type has no field of that type at all. In C# that's a record with a private constructor and a static From that calls Normalize(NormalizationForm.FormC). It won't stop someone calling Normalize by hand on a payload value, but that line stands out in review.

Other sides of the same question

  1. Is an NFC key a sensible default for name lookup?

    Okay, I paste my name and it ends in e followed by U+0301. Next week I type the same name and the keyboard gives me U+00E9. S…