Skip to main content

Module canonical

Module canonical 

Source
Expand description

Canonical JSON and the event signing payload.

A provenance signature covers signing_payload: the event exactly as it is sent, with provenance.signature removed (and the block itself if nothing else is in it) and null object members dropped, rendered as canonical JSON. Signing the transmitted JSON (rather than a hand-picked field list) means every field is covered, including the rest of the provenance block (key id, algorithm, signing time, device attestation), and any receiver can verify without knowing this SDK’s types.

The canonical form is byte-identical to Python’s json.dumps(value, sort_keys=True, separators=(",", ":"), ensure_ascii=True) and to PhyCloud’s canonical_json, so the Python SDK, the Rust SDK and PhyCloud all derive the same bytes from the same JSON. The shared test vectors in PhyTrace/test-vectors/provenance-signing.json pin this down.

Functions§

canonical_json
Render value as canonical JSON: keys sorted, no whitespace, non-ASCII escaped as \uXXXX.
leaf_payload_from_value
The payload a batch-signed event’s Merkle leaf is computed over: signing_payload_from_value with provenance.batch also removed (issue #392).
signing_payload
The text an event’s provenance signature is computed over.
signing_payload_from_value
signing_payload for an event already in JSON form, e.g. as received over the wire.
strip_nulls
Recursively drop object members whose value is null. Array elements are kept as-is, matching PhyCloud’s ingest normalisation.