SaltDns.Shaker.CanonicalJSON (Salt v1.0.0)

The canonical JSON encoding of contract 3.5: a JSON object with its keys sorted and no whitespace.

A Shaker signs a status report over the SHA-256 of this encoding of the report without its signature member. Salt must reproduce it byte for byte to verify. Jason does not promise an object order, so this encoder sorts keys itself; strings and numbers still go through Jason so escaping and number formatting are JSON-correct.

Only what a status report contains is supported: objects, arrays, strings, numbers, booleans and null. Anything else raises ArgumentError, because silently signing something else would be a false weight.

Summary

Functions

Encodes value canonically: sorted object keys, no whitespace.

Types

json()

@type json() :: map() | [json()] | String.t() | number() | boolean() | nil

Functions

encode(value)

@spec encode(json()) :: String.t()

Encodes value canonically: sorted object keys, no whitespace.