pub enum Message {
MessageV0(MessageV0),
}Expand description
Top-level message format with versioning support.
§Message Versioning Strategy
The Message enum provides the primary versioning mechanism for the wire protocol.
Each variant (e.g., MessageV0) represents a specific version of the message format
with hard-wired cryptographic choices and content types.
§Version-Specific Design Philosophy
Unlike other protocols where features are negotiated dynamically, this protocol hard-wires cryptographic algorithms and content types into each message version. This design provides several benefits:
- Security: No downgrade attacks through feature negotiation
- Simplicity: Clear, unambiguous message format per version
- Performance: No runtime algorithm selection overhead
- Evolution: Clean migration path to new cryptographic standards
§Content Type Binding
Each message version has a fixed set of supported Content variants:
MessageV0supports:Raw,ChaCha20Poly1305,Ed25519Encrypted- Future versions (e.g.,
MessageV1) may support different encryption schemes
This binding ensures that cryptographic choices are made explicitly during protocol design rather than being negotiated at runtime.
§Serialization and Wire Compatibility
Messages are serialized using postcard, which handles enum versioning through compact binary tags:
MessageV0(data)→ serialized as[0, ...message data...]MessageV1(data)→ would serialize as[1, ...message data...](future)
This allows clients to:
- Quickly identify the message version from the first byte
- Skip unknown message versions gracefully
- Maintain backwards compatibility with supported versions
§Evolution Path
When cryptographic standards change or new features are needed, the protocol evolves by adding new message versions:
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
pub enum Message {
MessageV0(MessageV0), // Legacy: ChaCha20-Poly1305, Ed25519
MessageV1(MessageV1), // Future: Post-quantum crypto, new content types
}This ensures that:
- Older clients continue working with
MessageV0 - Newer clients can handle both versions
- Migration happens gradually and safely
§Example: Version-Specific Handling
use zoe_wire_protocol::{Message, MessageV0, Content};
fn handle_message(msg: Message) {
match msg {
Message::MessageV0(v0_msg) => {
// Handle v0-specific features
match v0_msg.content {
Content::Raw(data) => { /* process raw data */ },
Content::ChaCha20Poly1305(_) => { /* decrypt with ChaCha20 */ },
Content::Ed25519SelfEncrypted(_) => { /* decrypt with Ed25519 */ },
}
}
// Future: MessageV1 would be handled here with its own content types
}
}Variants§
MessageV0(MessageV0)
Message format version 0.
Supports the following cryptographic primitives:
- Signing: Ed25519 digital signatures
- Encryption: ChaCha20-Poly1305 AEAD
- Key Derivation: Ed25519-based and context-based schemes
- Content Types:
Content::Raw,Content::ChaCha20Poly1305,Content::Ed25519SelfEncrypted,Content::EphemeralEcdh
This version is designed for high-performance messaging with modern cryptographic standards as of 2025.