Skip to main content

Crate dig_message

Crate dig_message 

Source
Expand description

§dig-message — the DIG Network generic base message protocol

ONE structured, typed, streamable, e2e-sealed envelope that every DIRECTED (1:1 / group) peer-to- peer message rides (chat, email, video signaling, presence, directed data requests, peer-RPC, and authenticated local IPC). Consensus BROADCAST (blocks/transactions/attestations) is the SPEC §5.4 exemption and stays mTLS-authenticated + signed, not dig-message-sealed.

§What WU1 (this milestone) provides — the crypto-free foundation

§What later WUs add (the FIELDS are already final here)

  • WU2 fills the seal (SealedPayload::kem_enc + ciphertext, DHKEM-over-G1) and the BLS G2 sender signature (InnerMessage::sender_sig), and enforces the SPEC §5.6/§5.6b replay/expiry checks.
  • WU4 drives the SPEC §3 streaming state machine over StreamHeader.
  • WU5 adds the wasm/JS surface + the Rust↔wasm byte-agreement KAT.

§What WU3 (this milestone) adds — the extensible type registry (crypto-free, SPEC §4)

  • MessageBand + MessageType::band — the reserved id-band allocation + classification.
  • MessageKind — the compile-time seam a downstream type declares (id + typed payload).
  • MessageRegistry — the runtime register/lookup/route table, additive-only, with the SPEC §4 unknown-type rule (UNSUPPORTED_TYPE for request/stream, silent Dispatch::Dropped otherwise; never a panic).

Re-exports§

pub use compression::compress_payload;
pub use compression::decompress_payload;
pub use compression::CompressedPayload;
pub use compression::COMPRESSION_NONE;
pub use compression::COMPRESSION_ZSTD;
pub use envelope::decode_envelope;
pub use envelope::encode_envelope;
pub use envelope::DigMessageEnvelope;
pub use envelope::InnerMessage;
pub use envelope::InteractionShape;
pub use envelope::MessageType;
pub use envelope::SealedPayload;
pub use envelope::StreamFrame;
pub use envelope::StreamHeader;
pub use envelope::FLAG_SEALED;
pub use envelope::FLAG_SHAPE_MASK;
pub use error::MessageError;
pub use error::Result;
pub use registry::Dispatch;
pub use registry::MessageBand;
pub use registry::MessageKind;
pub use registry::MessageRegistry;
pub use registry::BAND_CORE;
pub use registry::BAND_DIG_CHAT;
pub use registry::BAND_DIG_EMAIL;
pub use registry::BAND_DIG_VIDEO;
pub use registry::BAND_EXPERIMENTAL;
pub use registry::BAND_IPC;
pub use registry::BAND_PEER_RPC;
pub use registry::BAND_PRESENCE;
pub use constants::*;

Modules§

compression
The compression layer (SPEC §1.1) — the crypto-free codec that runs BEFORE the seal (WU2). A payload is compressed in its OWN fresh context (never a shared running context — the §5.5 CRIME/ BREACH boundary), then WU2 seals the compressed bytes.
constants
Protocol constants — the pinned, normative values every conforming implementation shares (SPEC §1, §1.1, §2, §5.6, §5.6b). These are the byte-level contract; a second implementation MUST match them.
envelope
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).
error
The dig-message error taxonomy — stable, catalogued variants a scripted client can key off (§6.2). WU1 owns the encoding/framing/compression failures; the seal/signature/replay variants arrive with WU2/WU4.
registry
The extensible message-type registry (SPEC §4) — the runtime seam through which every downstream subsystem (dig-chat, dig-email, dig-video, peer-RPC, IPC) plugs its own message types into the one base protocol WITHOUT dig-message depending on any of them.