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
valueas 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_valuewithprovenance.batchalso removed (issue #392). - signing_
payload - The text an event’s provenance signature is computed over.
- signing_
payload_ from_ value signing_payloadfor 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.