Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions common/client-core/config-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,9 @@ pub struct Traffic {
/// will be routed as usual, to the entry gateway, through three mix nodes, egressing
/// through the exit gateway. If mix hops are disabled, traffic will be routed directly
/// from the entry gateway to the exit gateway, bypassing the mix nodes.
///
/// This overrides the `use_legacy_sphinx_format` setting as reduced mix hops
/// requires use of the updated SURB packet format.
pub disable_mix_hops: bool,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ pub(crate) struct Config {
/// will be routed as usual, to the entry gateway, through three mix nodes, egressing
/// through the exit gateway. If mix hops are disabled, traffic will be routed directly
/// from the entry gateway to the exit gateway, bypassing the mix nodes.
///
/// This overrides the `use_legacy_sphinx_format` setting as reduced mix hops
/// requires use of the updated SURB packet format.
disable_mix_hops: bool,

/// Average delay a data packet is going to get delay at a single mixnode.
Expand Down Expand Up @@ -159,8 +162,12 @@ impl Config {
}

/// Configure whether messages senders using this config should use mix hops or not when sending messages.
///
/// This overrides the `use_legacy_sphinx_format` setting as disabled mix hops
/// requires use of the updated SURB packet format.
pub fn disable_mix_hops(mut self, disable_mix_hops: bool) -> Self {
self.disable_mix_hops = disable_mix_hops;
self.use_legacy_sphinx_format = false;
self
}
}
Expand Down
17 changes: 14 additions & 3 deletions common/nymsphinx/anonymous-replies/src/reply_surb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ impl ReplySurb {
packet_size.plaintext_size() - ack_overhead - ReplySurbKeyDigestAlgorithm::output_size() - 1
}

/// Construct a ResplySurb object. Selects mix hops for the surb unique to this
/// individual construction.
///
/// If mix hops are disabled, the route will consistency of the recipient
/// (i.e. the ingress hop) only. When `disable_mix_hops` is enabled
/// `use_legacy_surb_format` is ignored as disabled mix hops requires use of
/// the updated SURB format.
// TODO: should this return `ReplySURBError` for consistency sake
// or keep `NymTopologyError` because it's the only error it can actually return?
pub fn construct<R>(
Expand All @@ -64,17 +71,21 @@ impl ReplySurb {
average_delay: Duration,
use_legacy_surb_format: bool,
topology: &NymRouteProvider,
_disable_mix_hops: bool, // TODO: support SURBs with no mix hops after changes to surb format / construction
disable_mix_hops: bool,
) -> Result<Self, NymTopologyError>
where
R: RngCore + CryptoRng,
{
let route = topology.random_route_to_egress(rng, recipient.gateway())?;
let route = if disable_mix_hops {
topology.empty_route_to_egress(recipient.gateway())?
} else {
topology.random_route_to_egress(rng, recipient.gateway())?
};
let delays = nym_sphinx_routing::generate_hop_delays(average_delay, route.len());
let destination = recipient.as_sphinx_destination();

let mut surb_material = SURBMaterial::new(route, delays, destination);
if use_legacy_surb_format {
if use_legacy_surb_format && !disable_mix_hops {
surb_material = surb_material.with_version(X25519_WITH_EXPLICIT_PAYLOAD_KEYS_VERSION)
}

Expand Down
5 changes: 4 additions & 1 deletion common/nymsphinx/src/preparer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,9 @@ pub struct MessagePreparer<R> {
/// will be routed as usual, to the entry gateway, through three mix nodes, egressing
/// through the exit gateway. If mix hops are disabled, traffic will be routed directly
/// from the entry gateway to the exit gateway, bypassing the mix nodes.
///
/// This overrides the `use_legacy_sphinx_format` setting as reduced/disabled mix hops
/// requires use of the updated SURB packet format.
pub disable_mix_hops: bool,
}

Expand Down Expand Up @@ -388,7 +391,7 @@ where
self.average_packet_delay,
use_legacy_reply_surb_format,
topology,
disabled_mix_hops, // TODO: support SURBs with no mix hops after changes to surb format / construction
disabled_mix_hops,
)?
.with_key_rotation(key_rotation);
reply_surbs.push(reply_surb)
Expand Down
3 changes: 3 additions & 0 deletions common/wasm/client-core/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ pub struct TrafficWasm {
/// will be routed as usual, to the entry gateway, through three mix nodes, egressing
/// through the exit gateway. If mix hops are disabled, traffic will be routed directly
/// from the entry gateway to the exit gateway, bypassing the mix nodes.
///
/// This overrides the `use_legacy_sphinx_format` setting as reduced/disabeld mix hops
/// requires use of the updated SURB packet format.
pub disable_mix_hops: bool,
}

Expand Down
Loading