Available on crate feature
std only.Expand description
Phantom Protocol - Types
Core types for the Phantom Protocol:
- SessionId (256-bit, salt for encryption)
- StreamId, SequenceNumber
- PacketHeader, PacketFlags
- PhantomPacket (the single on-wire data packet)
Structs§
- Packet
Flags - Packet flags bitfield (16-bit).
- Packet
Header - Packet header — 15 bytes on the wire (
PacketHeader::SIZE); the AEAD AAD is the separate, larger 47-byte image (PacketHeader::AAD_SIZE). - Phantom
Packet - Full packet with header and payload — the single on-wire data packet.
- RawPacket
- A partially-decoded v6 packet: the cleartext envelope with the entire
15-byte header-protected region (version included) left opaque, plus the
payload(the message remainder). The recv path produces this from the raw wire bytes before it has the per-session HP key — it locates the ciphertext sample (payload, at the fixed offset 15) and callsRawPacket::unmask_headerwith the mask computed frompayloadto recover thePacketHeader(including itsversionbyte; the off-wiresession_idis then set bySession::parse_protected). This is the codec half of header protection; the mask itself is computed by the session’sHeaderProtector(this module stays crypto-free). Routing is by the outer (rotating) ConnId. - Session
Id - 256-bit Session Identifier
Enums§
- Control
Message - Legacy control-message enum for session management. NOTE: this is not the
live handshake / control wire format — the real handshake uses the borsh structs
in
transport::handshake(ClientHello/ServerHello/ …) and post-handshake control rides inPacketFlags(REKEY/PATH_VALIDATION/KEEPALIVE/ …). This enum is currently unreferenced; retained as a definitional placeholder. - LegType
- Transport-leg discriminant, retained as the metric/telemetry label axis in
crate::observability(the cardinality contract). - Scheduler
Mode - Scheduling strategy for the
Scheduler. NOTE: the scheduler is vestigial — the project does single-path connection migration, not multipath aggregation, soselect_pathsis never called on the live data path. This enum is constructed (defaulting toLowLatency) and threaded throughSession/config but does not steer production traffic. - Wire
Error - Error decoding a packet header / packet from its on-wire bytes.
Constants§
- HP_
PROTECTED_ LEN - Length of the header-protected region (
PacketHeader::SIZE - HP_PROTECTED_OFFSET= 15 bytes in v6:version ‖ packet_number ‖ flags ‖ stream_id ‖ epoch ‖ path_id). TheHeaderProtectorproduces a full 16-byte mask block; the firstHP_PROTECTED_LENbytes are used. - HP_
PROTECTED_ OFFSET - Wire offset where the header-protected region begins. WIRE v6
(anti-fingerprint):
0— the masked region now covers the WHOLE 15-byte header, INCLUDING theversion(1)byte, so the data-plane wire has no constant cleartext byte to fingerprint. (Was1in v5, after the cleartext version byte;33in v4, afterversion ‖ session_id.) Everything at[HP_PROTECTED_OFFSET..PacketHeader::SIZE]is XOR-masked on the wire. - WIRE_
VERSION - The sole on-wire packet-header version byte. Pinned — the wire format is not
negotiated (pre-1.0, no users); a decoder rejects anything else.
6is the anti-fingerprint diet: the version byte is now itself HP-masked (the WHOLE 15-byte header[0..15]is masked — no constant cleartext byte), and the two cleartextu32length prefixes are dropped (payloadis the message remainder —recv_bytesis message-framed — andextensionsleave the wire), saving 8 bytes/packet.5(ε) collapsed the two connection identifiers into one rotating CID: the 32-byte innersession_idleft the data-plane wire (it stays in the AEAD AAD, reconstructed from session context), shrinking the header to 15 bytes.4(T4.6) added QUIC-style header protection (RFC 9001 §5.4) over a 47-byte header;3(Phase 4) widened the packet number tou64. See PROTOCOL.md § 4.2.
Type Aliases§
- Packet
Number - Per-direction monotonic AEAD packet number (① — Phase 4). Feeds the AEAD
nonce and the per-direction replay window.
u64so it never wraps within a session — this is what retires the C1 forced-rekey watermark. - Sequence
Number - Per-stream gap-free reliable-data offset (A.5). Stays
u32. - Stream
Id - Stream identifier within a session