Skip to main content

Module envelope

Module envelope 

Source
Expand description

The base envelope + inner message — the byte-deterministic Chia-Streamable wire shapes (SPEC §2, §5.2) and the length-framed, size-bounded codec (SPEC §1).

The envelope header (fields 1-8) is cleartext so a relay can route on recipient and multiplex on correlation_id/stream; ALL content lives in the sealed region (field 9). WU1 defines the shapes and the framing; the seal (SealedPayload.kem_enc + ciphertext) and the signature (InnerMessage.sender_sig) are populated by WU2 — their FIELDS are final here.

Structs§

DigMessageEnvelope
The base envelope (SPEC §2, field order normative). Fields 1-8 are the cleartext routing header; field 9 is the sealed region.
InnerMessage
The sealed inner message (SPEC §5.2, FINAL field list — order is normative). Every field lives inside the AEAD-authenticated + signed region so a relay cannot tamper with any of it.
MessageType
Extensible message-type id (SPEC §4). Additive-only: an id, once assigned, is never renumbered or repurposed. The runtime registry that dispatches on it is WU3; the wire newtype is defined here.
SealedPayload
The e2e-sealed region (SPEC §5.2). WU1 defines the shape; WU2 fills kem_enc (the G1 ephemeral encapsulation) and ciphertext (AEAD.Seal of the InnerMessage).
StreamHeader
A stream frame’s control header (SPEC §3), present iff the shape is StreamFrame. The state machine that drives these frames is WU4; the wire shape is final here.

Enums§

InteractionShape
The interaction shape carried in flags bits 0-1 (SPEC §2 field 3 / §3).
StreamFrame
Stream frame kinds (SPEC §3). The wire field StreamHeader::frame is a u8; this enum names the values for WU4’s state machine.

Constants§

FLAG_SEALED
flags bit 2: the sealed bit — MUST be 1 for directed messages (SPEC §2 field 3).
FLAG_SHAPE_MASK
flags bitmask: bits 0-1 are the InteractionShape (SPEC §2 field 3).

Functions§

decode_envelope
Decode an envelope from on-wire bytes, rejecting an over-cap frame BEFORE decoding and an unknown version after (SPEC §1, §2).
encode_envelope
Serialize an envelope to its on-wire bytes, enforcing the MAX_ENVELOPE_BYTES cap (SPEC §1).