From a46dbfe82655eb08072e8123d316b459c7aa4528 Mon Sep 17 00:00:00 2001 From: Youngjoon Lee <5462944+youngjoon-lee@users.noreply.github.com> Date: Mon, 20 May 2024 16:54:32 +0900 Subject: [PATCH] add an option to turn off mixing --- mixnet/v2/sim/config.py | 2 +- mixnet/v2/sim/config.yaml | 2 ++ mixnet/v2/sim/node.py | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/mixnet/v2/sim/config.py b/mixnet/v2/sim/config.py index ddd4c1f..5a58474 100644 --- a/mixnet/v2/sim/config.py +++ b/mixnet/v2/sim/config.py @@ -62,7 +62,7 @@ class MixnetConfig: def validate(self): assert self.num_nodes > 0 - assert 0 < self.num_mix_layers <= self.num_nodes + assert 0 <= self.num_mix_layers <= self.num_nodes assert self.payload_size > 0 assert self.message_interval > 0 assert self.real_message_prob > 0 diff --git a/mixnet/v2/sim/config.yaml b/mixnet/v2/sim/config.yaml index 76d26d8..36a37b2 100644 --- a/mixnet/v2/sim/config.yaml +++ b/mixnet/v2/sim/config.yaml @@ -4,6 +4,8 @@ simulation: mixnet: num_nodes: 100 + # A number of mix nodes selected by a message sender through which the Sphinx message goes through + # If 0, the message is broadcast directly to all nodes without being Sphinx-encoded. num_mix_layers: 3 # A size of a message payload in bytes (e.g. the size of a block proposal) payload_size: 320 diff --git a/mixnet/v2/sim/node.py b/mixnet/v2/sim/node.py index b55a5ba..2d349c2 100644 --- a/mixnet/v2/sim/node.py +++ b/mixnet/v2/sim/node.py @@ -63,6 +63,9 @@ class Node: Creates a real or cover message @return: """ + if self.config.mixnet.num_mix_layers == 0: # if mixing is turned off + return self.build_payload() + mixes = self.p2p.get_nodes(self.config.mixnet.num_mix_layers) public_keys = [mix.public_key for mix in mixes] # TODO: replace with realistic tx