Make Mix hops optional for Mixnet Client SURBs (#5861)
* allow SURBs to be configured without mix hops * gateways require consistency in surb format so if disabling mixnhops - use updated format
This commit is contained in:
@@ -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,
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>(
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user