Crate json_digest_wasm
source · [−]Expand description
This library provides some algorithms to calculate cryptographically secure digests of JSON documents. Since JSON is an ambiguous serialization format, we also had to define a canonical deterministic subset of all allowed documents. Order of keys in an object and Unicode normalization are well-defined in this subset, making it suitable for hashing.
Traits
An extension trait on Result
that helps easy conversion of Rust errors to JavaScript
error strings usable by wasm_bindgen
Functions
Calculates the digest of a JSON document. Since this digest is calculated by recursively replacing sub-objects with their digest, it is possible to selectively reveal parts of the document using {@link selectiveDigestJson}
Converts any error that can be converted into a string into a JavaScript error string usable by wasm_bindgen
Returns a canonical string representation of a JSON document, in which any sub-objects not explicitly listed in the second argument are collapsed to their digest. The format of the second argument is inspired by JQ basic filters and these are some examples:
This function provides a canonical string for any JSON document. Order of the keys in objects, whitespace and unicode normalization are all taken care of, so document that belongs to a single digest is not malleable.
You should protect scalar values and easy-to-guess lists by replacing them with an object that has an extra “nonce” property, which has enough entropy. List of all countries, cities in a country, streets in a city are all easy to enumerate for a brute-fore attack.