w3c-ccg / did-spec

Please see README.md for latest version being developed by W3C DID WG.
https://w3c.github.io/did-core/
Other
124 stars 45 forks source link

Why does the `type` property commingle crypto algo with actual type? #30

Closed csuwildcat closed 6 years ago

csuwildcat commented 6 years ago

Why is "type": "RsaCryptographicKey" not split into "algorithm": "rsa" and "type": "cryptographicKey"?

If the answer is "Because there will only ever be cryptographic keys as types", then why do we even have the string 'CryptographicKey' attached to it?

msporny commented 6 years ago

Why is "type": "RsaCryptographicKey" not split into "algorithm": "rsa" and "type": "cryptographicKey"?

A couple of reasons:

We had this split out into two properties a few years ago and someone suggested that we combine them to save the developer from extra typing and the cognitive overhead from having to look for two properties to figure out what type of crypto key it is. Remember, that since it's JSON, there is no guarantee that "type" and "algorithm" are going to be next to each other, having the developer have to hunt for the two properties when debugging so that they'll know about the type of key that it is.

If the answer is "Because there will only ever be cryptographic keys as types", then why do we even have the string 'CryptographicKey' attached to it?

Since it's Linked Data, the namespace for these things tend to be global to the application. As a result, having properties like "RSA" are typically frowned upon as, from a semantics point of view, there isn't much information you can get out of what "RSA" means. Same argument for things like "value", "data", etc. Best practices for design of Linked Data vocabularies tend to point to terminology that can be mixed with other vocabularies without accidentally stomping on the other vocabulary space, which is why things tend to be a bit more verbose (but again, it doesn't matter all that much because these things typically compress down to single bytes when run through just about any modern compression algorithm.

csuwildcat commented 6 years ago

Good reasons, closing.