26 lines
710 B
Python
Raw Normal View History

from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey
from mixnet.config import (
2024-06-27 17:32:22 +09:00
GlobalConfig,
2024-06-26 15:55:00 +09:00
MixMembership,
NodeConfig,
NodeInfo,
)
2024-01-25 18:04:55 +09:00
2024-06-27 17:32:22 +09:00
def init_mixnet_config(num_nodes: int) -> tuple[GlobalConfig, list[NodeConfig]]:
2024-06-26 15:55:00 +09:00
transmission_rate_per_sec = 3
2024-06-27 17:32:22 +09:00
max_mix_path_length = 3
2024-06-26 15:55:00 +09:00
node_configs = [
2024-06-27 17:32:22 +09:00
NodeConfig(X25519PrivateKey.generate(), max_mix_path_length)
2024-06-26 15:55:00 +09:00
for _ in range(num_nodes)
]
2024-06-27 17:32:22 +09:00
global_config = GlobalConfig(
MixMembership(
[NodeInfo(node_config.private_key) for node_config in node_configs]
),
transmission_rate_per_sec,
max_mix_path_length,
)
2024-06-27 17:32:22 +09:00
return (global_config, node_configs)