Esempio n. 1
0
def execute_Alice_encode_hop(hops, use_blinding_factor=False):
    """
    Test sending a multi-hop message through 1-hop
    """

    from os import urandom

    G = EcGroup()
    g = G.generator()
    o = G.order()

    private_keys = [o.random() for _ in range(hops)]
    public_keys = [pk * g for pk in private_keys]

    address = b"Alice"
    message = b"Dear Alice,\nHello!\nBob"

    # Execute the encoding with the client implementation
    m1 = mix_client_n_hop(public_keys, address, message, use_blinding_factor)

    # Walk through the hops with the server implementation
    out = [m1]
    for hop in range(0, hops - 1):
        out = mix_server_n_hop(private_keys[hop], out, use_blinding_factor)
    out = mix_server_n_hop(private_keys[hops - 1],
                           out,
                           use_blinding_factor,
                           final=True)

    # Check the result
    assert len(out) == 1
    assert out[0][0] == address
    assert out[0][1] == message
Esempio n. 2
0
def execute_Alice_encode_hop(hops, use_blinding_factor=False):
    """
    Test sending a multi-hop message through 1-hop
    """

    from os import urandom

    G = EcGroup()
    g = G.generator()
    o = G.order()

    private_keys = [o.random() for _ in range(hops)]
    public_keys = [pk * g for pk in private_keys]

    address = b"Alice"
    message = b"Dear Alice,\nHello!\nBob"

    # Execute the encoding with the client implementation
    m1 = mix_client_n_hop(public_keys, address, message, use_blinding_factor)

    # Walk through the hops with the server implementation
    out = [m1]
    for hop in range(0, hops - 1):
        out = mix_server_n_hop(private_keys[hop], out, use_blinding_factor)
    out = mix_server_n_hop(private_keys[hops - 1], out, use_blinding_factor, final=True)

    # Check the result
    assert len(out) == 1
    assert out[0][0] == address
    assert out[0][1] == message
def test_Alice_encode_3_hop():
    """
    Test sending a multi-hop message through 1-hop
    """

    from os import urandom

    G = EcGroup()
    g = G.generator()
    o = G.order()

    private_keys = [o.random() for _ in range(3)]
    public_keys = [pk * g for pk in private_keys]

    address = b"Alice"
    message = b"Dear Alice,\nHello!\nBob"

    m1 = mix_client_n_hop(public_keys, address, message)
    out = mix_server_n_hop(private_keys[0], [m1])
    out = mix_server_n_hop(private_keys[1], out)
    out = mix_server_n_hop(private_keys[2], out, final=True)

    assert len(out) == 1
    assert out[0][0] == address
    assert out[0][1] == message
Esempio n. 4
0
def test_Alice_encode_3_hop():
    """
    Test sending a multi-hop message through 1-hop
    """

    from os import urandom

    G = EcGroup()
    g = G.generator()
    o = G.order()

    private_keys = [o.random() for _ in range(3)]
    public_keys  = [pk * g for pk in private_keys]

    address = b"Alice"
    message = b"Dear Alice,\nHello!\nBob"

    m1 = mix_client_n_hop(public_keys, address, message)
    out = mix_server_n_hop(private_keys[0], [m1])
    out = mix_server_n_hop(private_keys[1], out)
    out = mix_server_n_hop(private_keys[2], out, final=True)

    assert len(out) == 1
    assert out[0][0] == address
    assert out[0][1] == message
Esempio n. 5
0
def test_Alice_encode_1_hop():
    """
    Test sending a multi-hop message through 1-hop
    """

    from os import urandom

    G = EcGroup()
    g = G.generator()
    o = G.order()

    private_key = o.random()
    public_key = private_key * g

    address = b"Alice"
    message = b"Dear Alice,\nHello!\nBob"

    m1 = mix_client_n_hop([public_key], address, message)
    out = mix_server_n_hop(private_key, [m1], final=True)

    assert len(out) == 1
    assert out[0][0] == address
    assert out[0][1] == message
Esempio n. 6
0
def test_Alice_encode_1_hop():
    """
    Test sending a multi-hop message through 1-hop
    """

    from os import urandom

    G = EcGroup()
    g = G.generator()
    o = G.order()

    private_key = o.random()
    public_key = private_key * g

    address = b"Alice"
    message = b"Dear Alice,\nHello!\nBob"

    m1 = mix_client_n_hop([public_key], address, message)
    out = mix_server_n_hop(private_key, [m1], final=True)

    assert len(out) == 1
    assert out[0][0] == address
    assert out[0][1] == message