-
Notifications
You must be signed in to change notification settings - Fork 107
Open
Description
This is a subtle point, but if we're going to use hashing for verifying the asset definition file, then it's probably best that we define a strict ordering and formatting of the JSON so that idiosyncrasies in JSON serialization and/or rendering don't affect the value of the hash.
Given that the asset definition file is JSON, it's likely to be stored as such, and possibly deserialized and re-serialized before being rendered, or after being fetched for verification. JSON as a format doesn't care about indentation, newlines, or field ordering, but the hash operation does care about those things.
Off the top of my head, there are a couple of options:
- Treat the asset definition file as a raw string. Encourage providers (issuers) to avoid deserializing the string after extracting it from the data store and encourage verifiers to read the raw HTTP body for hash generation.
- Extend the standard to specify pre-processing before calculating the hash. For example, to verify an asset definition file, the verifier would deserialize the contents, re-render them as a string with sorted keys (or some ordering defined in the standard), strip out unnecessary whitespace (most JSON serializers will do this by default), maybe treat blank strings or
nullvalues as if the key was removed, and then take the hash.
Metadata
Metadata
Assignees
Labels
No labels