Skip to main content

dig_message/
lib.rs

1//! # dig-message — the DIG Network generic base message protocol
2//!
3//! ONE structured, typed, streamable, e2e-sealed envelope that every DIRECTED (1:1 / group) peer-to-
4//! peer message rides (chat, email, video signaling, presence, directed data requests, peer-RPC, and
5//! authenticated local IPC). Consensus BROADCAST (blocks/transactions/attestations) is the SPEC §5.4
6//! exemption and stays mTLS-authenticated + signed, not dig-message-sealed.
7//!
8//! ## What WU1 (this milestone) provides — the crypto-free foundation
9//! - [`DigMessageEnvelope`] + [`InnerMessage`] + [`StreamHeader`] + [`SealedPayload`] — the byte-
10//!   deterministic Chia-Streamable wire shapes (SPEC §2, §5.2).
11//! - [`encode_envelope`] / [`decode_envelope`] — the length-framed, size-bounded codec (SPEC §1).
12//! - [`compress_payload`] / [`decompress_payload`] — the additive compression layer (raw + zstd) with
13//!   the decompression-bomb guard (SPEC §1.1).
14//! - The pinned protocol [`constants`] and the [`MessageError`] taxonomy.
15//!
16//! ## What later WUs add (the FIELDS are already final here)
17//! - **WU2** fills the seal ([`SealedPayload::kem_enc`] + `ciphertext`, DHKEM-over-G1) and the BLS G2
18//!   sender signature ([`InnerMessage::sender_sig`]), and enforces the SPEC §5.6/§5.6b replay/expiry
19//!   checks.
20//! - **WU4** drives the SPEC §3 streaming state machine over [`StreamHeader`].
21//! - **WU5** adds the wasm/JS surface + the Rust↔wasm byte-agreement KAT.
22//!
23//! ## What WU3 (this milestone) adds — the extensible type registry (crypto-free, SPEC §4)
24//! - [`MessageBand`] + [`MessageType::band`] — the reserved id-band allocation + classification.
25//! - [`MessageKind`] — the compile-time seam a downstream type declares (id + typed payload).
26//! - [`MessageRegistry`] — the runtime register/lookup/route table, additive-only, with the SPEC §4
27//!   unknown-type rule (UNSUPPORTED_TYPE for request/stream, silent [`Dispatch::Dropped`] otherwise;
28//!   never a panic).
29
30pub mod compression;
31pub mod constants;
32pub mod envelope;
33pub mod error;
34pub mod registry;
35
36pub use compression::{
37    compress_payload, decompress_payload, CompressedPayload, COMPRESSION_NONE, COMPRESSION_ZSTD,
38};
39pub use constants::*;
40pub use envelope::{
41    decode_envelope, encode_envelope, DigMessageEnvelope, InnerMessage, InteractionShape,
42    MessageType, SealedPayload, StreamFrame, StreamHeader, FLAG_SEALED, FLAG_SHAPE_MASK,
43};
44pub use error::{MessageError, Result};
45pub use registry::{
46    Dispatch, MessageBand, MessageKind, MessageRegistry, BAND_CORE, BAND_DIG_CHAT, BAND_DIG_EMAIL,
47    BAND_DIG_VIDEO, BAND_EXPERIMENTAL, BAND_IPC, BAND_PEER_RPC, BAND_PRESENCE,
48};