Beispiel #1
0
def test_verify_multi_sig_works_for_invalid_signature(generator, message):
    sign_key1 = SignKey.new(None)
    ver_key1 = VerKey.new(generator, sign_key1)

    sign_key2 = SignKey.new(None)
    ver_key2 = VerKey.new(generator, SignKey.new(None))

    signature1 = Bls.sign(message, sign_key1)
    signature2 = Bls.sign(message, sign_key2)
    multi_signature_invalid = MultiSignature.new([signature1, signature2])

    valid = Bls.verify_multi_sig(multi_signature_invalid, message, [ver_key1, ver_key2], generator)
    assert not valid
 def generate_keys(params: GroupParams, seed=None) -> (SignKey, VerKey, ProofOfPossession):
     seed = IndyCryptoBlsUtils.prepare_seed(seed)
     gen = IndyCryptoBlsUtils.bls_from_str(params.g, Generator)
     sk = SignKey.new(seed)
     vk = VerKey.new(gen, sk)
     key_proof = ProofOfPossession.new(ver_key=vk, sign_key=sk)
     return sk, vk, key_proof
 def generate_keys(params: GroupParams, seed=None) -> (str, str):
     seed = IndyCryptoBlsUtils.prepare_seed(seed)
     gen = IndyCryptoBlsUtils.bls_from_str(params.g, Generator)
     sk = SignKey.new(seed)
     vk = VerKey.new(gen, sk)
     sk_str = IndyCryptoBlsUtils.bls_to_str(sk)
     vk_str = IndyCryptoBlsUtils.bls_to_str(vk)
     return sk_str, vk_str
Beispiel #4
0
def sign_key2() -> SignKey:
    seed = bytes([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4,
                  5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8,
                  9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8])
    sign_key = SignKey.new(seed)

    assert type(sign_key) is SignKey
    assert sign_key.c_instance is not None
    return sign_key
 def generate_keys(params: GroupParams, seed=None) -> (str, str, str):
     seed = IndyCryptoBlsUtils.prepare_seed(seed)
     gen = IndyCryptoBlsUtils.bls_from_str(params.g, Generator)
     sk = SignKey.new(seed)
     vk = VerKey.new(gen, sk)
     key_proof = ProofOfPossession.new(ver_key=vk, sign_key=sk)
     sk_str = IndyCryptoBlsUtils.bls_to_str(sk)
     vk_str = IndyCryptoBlsUtils.bls_to_str(vk)
     key_proof_str = IndyCryptoBlsUtils.bls_to_str(key_proof)
     return sk_str, vk_str, key_proof_str
Beispiel #6
0
def demo():
    # Create generator
    generator = Generator.new()

    # Create first key pair
    sign_key1 = SignKey.new(None)
    ver_key1 = VerKey.new(generator, sign_key1)

    # Create second keys pair based on seed
    seed = bytes([
        1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3,
        4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6,
        7, 8
    ])
    sign_key2 = SignKey.new(seed)
    ver_key2 = VerKey.new(generator, sign_key2)

    # Sample message
    message = bytes([1, 2, 3, 4, 5])

    # Sign message with first sing key
    signature1 = Bls.sign(message, sign_key1)

    # Verify first signature with first ver key
    valid = Bls.verify(signature1, message, ver_key1, generator)
    assert valid

    # Sign message with second sing key
    signature2 = Bls.sign(message, sign_key2)

    # Verify second signature with second ver key
    valid = Bls.verify(signature2, message, ver_key2, generator)
    assert valid

    # Create multi signature
    multi_sig = MultiSignature.new([signature1, signature2])

    # Verify multi signature
    valid = Bls.verify_multi_sig(multi_sig, message, [ver_key1, ver_key2],
                                 generator)
    assert valid
Beispiel #7
0
def sign_key1() -> SignKey:
    sign_key = SignKey.new(None)

    assert type(sign_key) is SignKey
    assert sign_key.c_instance is not None
    return sign_key