CharterAgreementProtocol.Canonicalization (Charter Agreement Protocol v0.2.1)

Copy Markdown View Source

CAP never authorizes.

RFC 8785 JSON Canonicalization Scheme over the protocol's tagged JSON algebra.

Object names sort by unsigned UTF-16 code units, strings use the exact JSON control-byte escape grammar, numbers use ECMAScript shortest-round-trip spelling, and output is UTF-8 without inter-token whitespace. verify/1 accepts received bytes only when decode→re-encode is byte-identical.

Summary

Functions

Encode a tagged JSON value as canonical UTF-8 JSON.

Serialize a float using ECMAScript shortest-round-trip spelling.

Verify that received JSON bytes are already canonical.

Functions

encode(value)

@spec encode(term()) :: {:ok, binary()} | {:error, CharterAgreementProtocol.Error.t()}

Encode a tagged JSON value as canonical UTF-8 JSON.

number(float)

@spec number(term()) :: {:ok, binary()} | {:error, CharterAgreementProtocol.Error.t()}

Serialize a float using ECMAScript shortest-round-trip spelling.

verify(input)

Verify that received JSON bytes are already canonical.