Skip to main content

Module message

Module message 

Source
Expand description

Wire message payload types for deCDN ALPN protocols.

Every ALPN defines a top-level enum (e.g. ProbeMessage) whose variants wrap the per-message structs. The enum is serialized as the outermost postcard value inside a length-prefixed frame (see crate::framing).

§Signed-field freezing (ADR 013 §Signed Field Freezing)

ProbeResponse is exactly a signed ProbeResponseBody plus its slash_sig; every unsigned field trails in ProbeResponseExt, encoded separately and decoded two-phase (ADR 013 §Tier 1). Unlike an Ed25519 signature over postcard bytes, slash_sig is not computed over a postcard serialization: it is an EIP-712 secp256k1 signature over the typed-data hash of the body fields {hash, has_blob, rate_per_mb, timestamp_us}, exactly as defined in ADR 014 §EIP-712 Type Definitions and implemented in decdn_incentive::ProbeSlashData. There is intentionally no signing_bytes() helper here — postcard bytes are not the signing input, and exposing one would invite incompatible verifier implementations. The #[serde(deserialize_with)] validation on rate_per_mb lives on the body field so the protocol-boundary bound on MAX_RATE_PER_MB continues to apply (issue #378).

This establishes the cdn/probe/v1 signed baseline — it is not an ALPN bump. ADR 013 freezes a signed field set at the protocol version that introduces it; cdn/probe/v1 had no prior signed ProbeResponse, so the set {hash, has_blob, rate_per_mb, timestamp_us} is the v1 baseline (ADR 005 §cdn/probe/v1, ADR 014 §1). total_bytes rides in ProbeResponseExt as the ADR 013 Tier-1 unsigned-evolution exemplar (ADR 005 §cdn/probe/v1) and is deliberately NOT covered by slash_sig. The ProbeMessage variant order is unchanged.

This crate deliberately does not depend on any crypto library. The caller (decdn_incentive::ProbeSlashData and the probe handler/CLI) computes and verifies the EIP-712 slash_sig.

Structs§

ProbeRequest
Client → node request on cdn/probe/v1 (ADR 005 §cdn/probe/v1).
ProbeResponse
Node → client response on cdn/probe/v1 (ADR 005 §cdn/probe/v1).
ProbeResponseBody
Signed fields of a ProbeResponse. Layout is frozen per ADR 013 — future additions go on ProbeResponse as optional unsigned fields, not here.
ProbeResponseExt
Optional ProbeResponse extension fields, carried as trailing bytes after the ProbeResponse message via the two-phase pattern (ADR 013 §Tier 1; see encode_probe_response / parse_probe_response_ext).

Enums§

MessageValidationError
Errors produced when validating wire-decoded protocol messages.
ProbeMessage
Top-level protocol enum for cdn/probe/v1. Variant order is frozen per ADR 013 — new variants MUST be appended at the end.

Constants§

MAX_RATE_PER_MB
Maximum permitted value for ProbeResponseBody::rate_per_mb (issue #378).
SLASH_SIG_LEN
Length in bytes of an EOA secp256k1 EIP-712 signature (r‖s‖v, 32+32+1).

Functions§

encode_probe_response
Encode a ProbeResponse with its optional trailing ProbeResponseExt (ADR 013 §Tier 1, two-phase).
parse_probe_response_ext
Parse the trailing ProbeResponseExt bytes returned as the remainder by crate::decode_message after a ProbeMessage::Response.