Skip to Content
New: a threat-model-first guide to choosing your network defence, plus the nym-smoldvpn dVPN package and nym-swizzle sender hygiene.
Developersnym-sdkMixnet Module

Mixnet Module

The mixnet module provides MixnetClient for connecting to the Nym Mixnet, sending messages through Sphinx packet encryption and 5-hop routing, and receiving reconstructed messages on the other side.

Messages are individually routed through the Mixnet with no guaranteed ordering or persistent connections. If you want familiar socket-like I/O (read/write), use the Stream module instead. See the Tour for how the two approaches compare.

Two operating modes

The client operates in one of two mutually exclusive modes:

Message mode (default): send and receive raw message payloads:

use nym_sdk::mixnet::{self, MixnetMessageSender}; let mut client = mixnet::MixnetClient::connect_new().await.unwrap(); // Send a message client.send_plain_message(*client.nym_address(), "hello").await.unwrap(); // Receive messages if let Some(msgs) = client.wait_for_messages().await { for msg in msgs { println!("Got: {}", String::from_utf8_lossy(&msg.message)); } } client.disconnect().await;

Stream mode: persistent AsyncRead + AsyncWrite channels. See the Stream module for details.

Stream mode is activated by calling open_stream() or listener(). Once active, message-mode methods return Error::StreamModeActive. This is a one-way transition.

API reference

  • API reference on docs.rs : full architecture documentation, all types, builder methods, traits, and configuration options
  • Examples on GitHub : runnable examples covering simple send/receive, builder patterns, custom topologies, SOCKS proxy, anonymous replies, and more

Run any example with:

cargo run --example <example_name>

Next steps

Last updated on