Example #1
0
def sign_key2() -> SignKey:
    seed = bytes([
        1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 21, 2,
        3, 4, 5, 6, 7, 8, 9, 10, 31, 32
    ])
    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
 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
Example #4
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
Example #5
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
Example #6
0
def test_as_bytes(sign_key1: SignKey):
    xbytes = sign_key1.as_bytes()
    assert len(xbytes) > 0