Exemplo n.º 1
0
    def __init__(self, sec_params, name, port, host, privk=None, pubk=None):
        LoopixMixNode.__init__(self, sec_params, name, port, host, privk, pubk)

        self.privk = privk or sec_params.group.G.order().random()
        self.pubk = pubk or (self.privk * sec_params.group.G.generator())
        self.crypto_node = ProviderCore((sec_params, self.config_params), self.name,
                                        self.port, self.host, self.privk, self.pubk)
Exemplo n.º 2
0
def loopix_mixes():
    sec_params = SphinxParams(header_len=1024)

    dbManager.create_mixnodes_table('Mixnodes')
    mixes = []
    pubs_mixes = []
    for i in range(3):
        mix = LoopixMixNode(sec_params, 'Mix%d' % (i + 1), 9999 - i,
                            '1.2.3.%d' % i, i)
        mix.transport = proto_helpers.FakeDatagramTransport()
        mix.config_params = mix.config_params._replace(DATABASE_NAME='test.db')
        mixes.append(mix)
        dbManager.insert_row_into_table('Mixnodes', [
            None, mix.name, mix.port, mix.host,
            sqlite3.Binary(petlib.pack.encode(mix.pubk)), mix.group
        ])
    pubs_mixes = [Mix(m.name, m.port, m.host, m.pubk, m.group) for m in mixes]
    return mixes, pubs_mixes
Exemplo n.º 3
0
import os.path
from sphinxmix.SphinxParams import SphinxParams

if not (os.path.exists("secretMixnode.prv")
        and os.path.exists("publicMixnode.bin")):
    raise Exception("Key parameter files not found")

secret = petlib.pack.decode(file("secretMixnode.prv", "rb").read())
sec_params = SphinxParams(header_len=1024, body_len=57800)
try:
    data = file("publicMixnode.bin", "rb").read()
    _, name, port, host, group, _ = petlib.pack.decode(data)

    mix = LoopixMixNode(sec_params,
                        name,
                        port,
                        host,
                        group,
                        privk=secret,
                        pubk=None)
    reactor.listenUDP(port, mix)
    reactor.run()
    udp_server = internet.UDPServer(port, mix)
    application = service.Application("Mixnode")
    udp_server.setServiceParent(application)

except Exception, e:
    exc_type, exc_value, exc_traceback = sys.exc_info()
    traceback.print_tb(exc_traceback)
    print str(e)