示例#1
0
def test_dlne_interactive(group):
    g = group.generator()
    x = Secret()
    y = 3 * g
    y2 = 397474 * g
    g2 = 1397 * g

    p1 = DLNotEqual([y, g], [y2, g2], x, bind=True)
    p2 = DLNotEqual([y, g], [y2, g2], x, bind=True)
    secret_dict = {x: 3}
    prover = p1.get_prover(secret_dict)
    verifier = p2.get_verifier()
    verifier.process_precommitment(prover.precommit())
    commitment = prover.commit()
    challenge = verifier.send_challenge(commitment)
    responses = prover.compute_response(challenge)

    verifier.stmt.full_validate()
    assert verifier.verify(responses)
示例#2
0
def test_dlne_fails_when_non_binding(group):
    """
    TODO: Describe what is being tested here.
    """
    g = group.generator()
    x = Secret()
    y = 3 * g
    g2 = 1397 * g
    y2 = 3 * g2

    p1 = DLNotEqual([y, g], [y2, g2], x)
    p2 = DLNotEqual([y, g], [y2, g2], x)
    secret_dict = {x: 3}
    prover = p1.get_prover(secret_dict)
    verifier = p2.get_verifier()
    verifier.process_precommitment(prover.precommit())
    commitment = prover.commit()
    challenge = verifier.send_challenge(commitment)
    responses = prover.compute_response(challenge)

    with pytest.raises(ValidationError):
        verifier.verify(responses)