add an option to turn off mixing

This commit is contained in:
Youngjoon Lee 2024-05-20 16:54:32 +09:00
parent 84ec0b06ff
commit a46dbfe826
No known key found for this signature in database
GPG Key ID: 09B750B5BD6F08A2
3 changed files with 6 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -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