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//! - **WU3** adds the runtime `MessageRegistry` that dispatches on [`MessageType`].
21//! - **WU4** drives the SPEC §3 streaming state machine over [`StreamHeader`].
22//! - **WU5** adds the wasm/JS surface + the Rust↔wasm byte-agreement KAT.
23
24pub mod compression;
25pub mod constants;
26pub mod envelope;
27pub mod error;
28
29pub use compression::{
30    compress_payload, decompress_payload, CompressedPayload, COMPRESSION_NONE, COMPRESSION_ZSTD,
31};
32pub use constants::*;
33pub use envelope::{
34    decode_envelope, encode_envelope, DigMessageEnvelope, InnerMessage, InteractionShape,
35    MessageType, SealedPayload, StreamFrame, StreamHeader, FLAG_SEALED, FLAG_SHAPE_MASK,
36};
37pub use error::{MessageError, Result};