Skip to main content

Module jcs

Module jcs 

Source
Expand description

RFC 8785 JSON Canonicalization Scheme (JCS).

Produces the deterministic byte string that all co-signatures and bundle signatures attest: same logical content, same bytes, for any conforming implementation. The rules implemented here:

  • object keys sorted by UTF-16 code unit sequence;
  • no insignificant whitespace;
  • strings serialized with the JSON minimal-escape set (\b \t \n \f \r \" \\ and lowercase \u00xx for other control characters), all other characters emitted verbatim as UTF-8;
  • numbers: integers exactly; floats in shortest round-trip form (ECMAScript number-to-string), negative zero normalized to 0, NaN and infinities rejected;
  • booleans and null as true / false / null.

Functions§

canonical_hash
SHA-256 over the JCS canonicalization — the SIGNATIF canonical payload hash of a JSON object.
canonicalize
Canonicalize a JSON value to its RFC 8785 byte string.