Skip to main content

Module wire

Module wire 

Source
Expand description

Wire decoders and the VerificationReceipt codec pair (SPEC §17.5, §5.1).

Decoders are strict: unknown fields are rejected (serde deny_unknown_fields on the wire types), the wire-integer domain and canonical base64 are enforced by the field (de)serializers, and the input bounds of SPEC §5.1 are enforced here — decode_proof_bundle rejects an oversized payload BEFORE parsing, and JSON container nesting beyond MAX_JSON_NESTING_DEPTH is rejected up front. Violations are structural failures — callers surface them as the existing invalid status.

JSON parsing (and therefore the decode_* functions) requires serde_json and is only available with the std feature. encode_verification_receipt and check_json_nesting_depth are no_std-compatible.

Functions§

check_cert_bounds
Enforce the per-cert count and length limits of SPEC §5.1 during decode. Does NOT enforce issuance hygiene (validate_resource_constraints) — decoders accept what issuance rejects; verification fails unsatisfiable sets closed.
check_json_nesting_depth
Reject JSON whose container nesting exceeds MAX_JSON_NESTING_DEPTH, scanning the raw bytes with string-literal awareness so brackets inside strings do not count. Mirrors the depth rule of Go’s CheckWireJSON.
check_receipt_structure
Enforce the structural invariants of a wire VerificationReceipt (SPEC §17.5) — shared by the encoder and decoder so the codec pair never emits a document its counterpart rejects.
decode_delegation_cert
Parse canonical wire JSON into a DelegationCert under strict wire acceptance and the SPEC §5.1 input bounds.
decode_proof_bundle
Parse canonical wire JSON into a crate::types::ProofBundle under strict wire acceptance and the SPEC §5.1 input bounds. The [MAX_PROOF_BUNDLE_BYTES] check runs BEFORE any parsing: an oversized payload is rejected without being parsed at all.
decode_verification_receipt
Parse canonical wire JSON into a VerificationReceipt under strict wire acceptance and the same structural invariants the encoder enforces (hash and key-component lengths, known decision, protocol version). Signature verification is the caller’s job via verify_verification_receipt.
encode_verification_receipt
Marshal a VerificationReceipt into its canonical wire JSON (SPEC §17.5): lex-sorted keys, byte fields as base64-standard strings, optional fields omitted when empty. A structurally invalid receipt is an error, never emitted: the codec pair never produces a document its own decoder rejects.