Exemplo n.º 1
0
def test_Alice_message_overlong():
    """
    Test overlong address or message
    """

    from os import urandom

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

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

    with raises(Exception) as excinfo:
        mix_client_one_hop(public_key, urandom(1000), b"Dear Alice,\nHello!\nBob")

    with raises(Exception) as excinfo:
        mix_client_one_hop(public_key, b"Alice", urandom(10000))
Exemplo n.º 2
0
def test_Alice_message_overlong():
    """
    Test overlong address or message
    """

    from os import urandom

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

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

    with raises(Exception) as excinfo:
        mix_client_one_hop(public_key, urandom(1000),
                           b"Dear Alice,\nHello!\nBob")

    with raises(Exception) as excinfo:
        mix_client_one_hop(public_key, b"Alice", urandom(10000))
Exemplo n.º 3
0
def encode_Alice_message():
    """
    Encode a single message
    """

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

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

    m1 = mix_client_one_hop(public_key, b"Alice", b"Dear Alice,\nHello!\nBob")
    return private_key, m1
Exemplo n.º 4
0
def encode_Alice_message():
    """
    Encode a single message
    """

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

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

    m1 = mix_client_one_hop(public_key, b"Alice", b"Dear Alice,\nHello!\nBob")
    return private_key, m1
Exemplo n.º 5
0
def test_simple_client_decode_many():
    from os import urandom

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

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

    messages = []
    for _ in range(100):
        m = mix_client_one_hop(public_key, urandom(256), urandom(1000))
        messages += [m]

    # Ensure the mix can decode the message correctly    
    res1 = mix_server_one_hop(private_key, messages)

    assert len(res1) == 100
Exemplo n.º 6
0
def test_simple_client_decode_many():

    from os import urandom

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

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

    messages = []
    for _ in range(100):
        m = mix_client_one_hop(public_key, urandom(256), urandom(1000))
        messages += [m]

    # Ensure the mix can decode the message correctly
    res1 = mix_server_one_hop(private_key, messages)

    assert len(res1) == 100