Skip to content

Commit c91c502

Browse files
committed
Add finalized Sections 5.4, 8-8.2
1 parent 74e016d commit c91c502

File tree

1 file changed

+111
-0
lines changed

1 file changed

+111
-0
lines changed

vac/raw/mix.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,29 @@ areas such as node discovery, delay strategy, spam resistance, cover traffic gen
303303
and incentivization. Some are REQUIRED for interoperability; others are OPTIONAL or deployment-specific.
304304
The next section describes each component.
305305

306+
### 5.5 Stream Management and Multiplexing
307+
308+
Each Mix Protocol message is routed independently, and forwarding it to the next hop requires
309+
opening a new libp2p stream using the Mix Protocol. This applies to both the initial Sphinx packet
310+
transmission and each hop along the mix path.
311+
312+
In high-throughput environments (_e.g._, messaging systems with continuous anonymous traffic),
313+
mix nodes may frequently communicate with a subset of mix nodes. Opening a new stream for each
314+
Sphinx packet in such scenarios can incur performance costs, as each stream setup requires a
315+
multistream handshake for protocol negotiation.
316+
317+
While libp2p supports multiplexing multiple streams over a single transport connection using
318+
stream muxers such as mplex and yamux, it does not natively support reusing a stream over multiple
319+
message transmissions. However, stream reuse may be desirable in the mixnet setting to reduce overhead
320+
and avoid hitting per protocol stream limits between peers.
321+
322+
The lifecycle of streams, including their reuse, eviction, or pooling strategy, is outside the
323+
scope of this specification. It SHOULD be handled by the libp2p host, connection manager, or
324+
transport stack.
325+
326+
Mix Protocol implementations MUST NOT assume persistent stream availability and SHOULD gracefully
327+
fall back to opening a new stream when reuse is not possible.
328+
306329
## 6. Pluggable Components
307330

308331
Pluggable components define functionality that extends or configures the behavior of the Mix Protocol
@@ -460,6 +483,12 @@ These roles and their required behaviors are defined in the following subsection
460483

461484
The Mix Protocol is identified by the protocol string `"/mix/1.0.0"`.
462485

486+
All Mix Protocol interactions occur over libp2p streams negotiated using this identifier.
487+
Each Sphinx packet transmission—whether initiated locally or forwarded as part of a
488+
mix path—involves opening a new libp2p stream to the next hop. Implementations MAY optimize
489+
performance by reusing streams where appropriate; see [Section 5.5](#55-stream-management-and-multiplexing)
490+
for more details on stream management.
491+
463492
### 7.2 Initiation
464493

465494
A mix node initiates anonymous routing only when it is explicitly invoked with a message
@@ -509,3 +538,85 @@ To process a Sphinx packet as an exit, a mix node MUST:
509538
- Forward the valid message to the Mix Exit Layer for delivery to the destination origin protocol instance.
510539

511540
The node MUST NOT retain decrypted content after forwarding.
541+
542+
## 8. Sphinx Packet Format
543+
544+
The Mix Protocol uses the Sphinx packet format to enable unlinkable, multi-hop message routing
545+
with per-hop confidentiality and integrity. Each message transmitted through the mix network is
546+
encapsulated in a Sphinx packet constructed by the initiating mix node. The packet is encrypted in
547+
layers such that each hop in the mix path can decrypt exactly one layer and obtain the next-hop
548+
routing information and delay value, without learning the complete path or the message origin.
549+
550+
Sphinx packets are self-contained and indistinguishable on the wire, providing strong metadata
551+
protection. Mix nodes forward packets without retaining state or requiring knowledge of the
552+
source or destination beyond their immediate routing target.
553+
554+
To ensure uniformity, each Sphinx packet consists of a fixed-length header and a payload
555+
that is padded to a fixed maximum size. Although the original message payload may vary in length,
556+
padding ensures that all packets are identical in size on the wire. This ensures unlinkability
557+
and protects against correlation attacks based on message size.
558+
559+
If a message exceeds the maximum supported payload size, it MUST be fragmented before being passed
560+
to the Mix Protocol. Fragmentation and reassembly are the responsibility of the origin protocol
561+
or the top-level application. The Mix Protocol handles only messages that do not require
562+
fragmentation.
563+
564+
The structure, encoding, and size constraints of the Sphinx packet are detailed in the following
565+
subsections.
566+
567+
### 8.1 Packet Structure Overview
568+
569+
Each Sphinx packet consists of three fixed-length header fields — $α$, $β$, and $γ$ —
570+
followed by a fixed-length encrypted payload $δ$. Together, these components enable per-hop message
571+
processing with strong confidentiality and integrity guarantees in a stateless and unlinkable manner.
572+
573+
- **$α$ (Alpha)**: An ephemeral public value. Each mix node uses its private key and $α$ to
574+
derive a shared session key for that hop. This session key is used to decrypt and process
575+
one layer of the packet.
576+
- **$β$ (Beta)**: The nested encrypted routing information. It encodes the next hop address, the forwarding delay,
577+
integrity check $γ$ for the next hop, and the $β$ for subsequent hops.
578+
- **$γ$ (Gamma)**: A message authentication code computed over $β$ using the session key derived
579+
from $α$. It ensures header integrity at each hop.
580+
- **$δ$ (Delta)**: The encrypted payload. It consists of the message padded to a fixed maximum length and
581+
encrypted in layers corresponding to each hop in the mix path.
582+
583+
At each hop, the mix node derives the session key from $α$, verifies the header integrity
584+
using $γ$, decrypts one layer of $β$ to extract the next hop and delay, and decrypts one layer
585+
of $δ$. It then constructs a new packet with updated values of $α$, $β$, $γ$, and $δ$, and
586+
forwards it to the next hop.
587+
588+
All Sphinx packets are fixed in size and indistinguishable on the wire. This uniform format,
589+
combined with layered encryption and per-hop integrity protection, ensures unlinkability,
590+
tamper resistance, and robustness against correlation attacks.
591+
592+
The structure and semantics of these fields, the cryptographic primitives used, and the construction
593+
and processing steps are defined in the following subsections.
594+
595+
### 8.2 Cryptographic Primitives
596+
597+
This section defines the cryptographic primitives used in Sphinx packet construction and processing.
598+
599+
- **Security Parameter**: All cryptographic operations target a minimum of $\kappa = 128$ bits of
600+
security, balancing performance with resistance to modern attacks.
601+
602+
- **Elliptic Curve Group $\mathbb{G}$**:
603+
- **Curve**: Curve25519
604+
- **Purpose**: Used for deriving Diffie–Hellman-style shared key at each hop using $α$.
605+
- **Representation**: Small 32-byte group elements, efficient for both encryption and key exchange.
606+
607+
- **Key Derivation Function (KDF)**:
608+
- **Purpose**: To derive encryption keys, IVs, and MAC key from the shared session key at each hop.
609+
- **Construction**: SHA-256 hash with output truncated to 128 bits.
610+
- **Key Derivation**: The KDF key separation labels (_e.g.,_ `"aes_key"`, `"mac_key"`)
611+
are fixed strings and MUST be agreed upon across implementations.
612+
613+
- **Symmetric Encryption**: AES-128 in Counter Mode (AES-CTR)
614+
- **Purpose**: To encrypt $β$ and $δ$ for each hop.
615+
- **Keys and IVs**: Each derived from the session key for the hop using the KDF.
616+
617+
- **Message Authentication Code (MAC)**:
618+
- **Construction**: HMAC-SHA-256 with output truncated to 128 bits.
619+
- **Purpose**: To compute $γ$ for each hop.
620+
- **Key**: Derived using KDF from the session key for the hop.
621+
622+
These primitives are used consistently throughout packet construction and decryption, as described in the following sections.

0 commit comments

Comments
 (0)