def build_mixnet_nodes(pki, params, rand_reader):
"""
i am a helper function used to build a testing mix network.
given the sphinx params and a node_factory i will return
a dictionary of NodeDescriptors, a dictionary of node protocols
and a dictionary of addr -> node protocol
"""
mix_size = 5
nodes = {}
addr_to_nodes = {}
for i in range(mix_size):
addr = i
public_key, private_key = generate_node_keypair(rand_reader)
replay_cache = PacketReplayCacheDict()
key_state = MixKeyState(public_key, private_key)
params = SphinxParams(5, 1024) # 5 hops max and payload 1024 bytes
transport = DummyTransport(i)
node_id = generate_node_id(rand_reader)
threshold_count = 100
mix = ThresholdMixNode(threshold_count, node_id, replay_cache, key_state, params, pki, transport)
yield mix.start()
nodes[node_id] = mix
addr_to_nodes[addr] = mix
defer.returnValue((nodes, addr_to_nodes))
评论列表
文章目录