Beispiel #1
0
def test_aggregate_verify(SKs, messages, success):
    PKs = [G2Basic.PrivToPub(SK) for SK in SKs]
    messages = [bytes(msg) for msg in messages]
    signatures = [G2Basic.Sign(SK, msg) for SK, msg in zip(SKs, messages)]
    aggregate_signature = G2Basic.Aggregate(signatures)
    assert G2Basic.AggregateVerify(zip(PKs, messages),
                                   aggregate_signature) == success
Beispiel #2
0
def test_core_aggregate_verify(SKs, messages):
    PKs = [G2Basic.PrivToPub(sk) for sk in SKs]
    messages = [bytes(msg) for msg in messages]
    signatures = [
        G2Basic._CoreSign(sk, msg, G2Basic.DST)
        for sk, msg in zip(SKs, messages)
    ]
    aggregate_signature = G2Basic.Aggregate(signatures)
    assert G2Basic._CoreAggregateVerify(zip(PKs, messages),
                                        aggregate_signature, G2Basic.DST)
Beispiel #3
0
def test_sign_verify(privkey):
    msg = str(privkey).encode('utf-8')
    pub = G2Basic.PrivToPub(privkey)
    sig = G2Basic._CoreSign(privkey, msg, G2Basic.DST)
    assert G2Basic._CoreVerify(pub, msg, sig, G2Basic.DST)
Beispiel #4
0
    (bytes.fromhex(
        '0099FF991111002299DD7744EE3355BBDD8844115566CC55663355668888CC00'),
     45379166311535261329029945990467475187325618028073620882733843918126031931161
     ),
    (bytes.fromhex(
        'd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3'),
     31740500954810567003972734830331791822878290325762596213711963944729383643688
     ),
])
def test_key_gen(ikm, result_sk):
    _, sk = G2Basic.KeyGen(ikm)
    assert sk == result_sk


@pytest.mark.parametrize('pubkey,success', [
    (G2Basic.PrivToPub(42), True),
    (b'11' * 48, False),
])
def test_key_validate(pubkey, success):
    assert G2Basic.KeyValidate(pubkey) == success


@pytest.mark.parametrize('privkey', [
    (1),
    (5),
    (124),
    (735),
    (127409812145),
    (90768492698215092512159),
    (0),
])