Example #1
0
def test_keypair_with_umbral_keys():
    umbral_privkey = UmbralPrivateKey.gen_key()
    umbral_pubkey = umbral_privkey.get_pubkey()

    new_keypair_from_priv = keypairs.Keypair(umbral_privkey)
    assert new_keypair_from_priv._privkey.bn_key.to_bytes() == umbral_privkey.bn_key.to_bytes()
    assert new_keypair_from_priv.pubkey.to_bytes() == umbral_pubkey.to_bytes()

    new_keypair_from_pub = keypairs.Keypair(public_key=umbral_pubkey)
    assert new_keypair_from_pub.pubkey.to_bytes() == umbral_pubkey.to_bytes()
    assert new_keypair_from_pub._privkey == PUBLIC_ONLY
Example #2
0
def test_keypair_with_umbral_keys():
    umbral_privkey = SecretKey.random()
    umbral_pubkey = umbral_privkey.public_key()

    new_keypair_from_priv = keypairs.Keypair(umbral_privkey)
    assert new_keypair_from_priv._privkey == umbral_privkey
    assert bytes(new_keypair_from_priv.pubkey) == bytes(umbral_pubkey)

    new_keypair_from_pub = keypairs.Keypair(public_key=umbral_pubkey)
    assert bytes(new_keypair_from_pub.pubkey) == bytes(umbral_pubkey)
    assert new_keypair_from_pub._privkey == PUBLIC_ONLY
Example #3
0
def test_keypair_fingerprint():
    umbral_pubkey = UmbralPrivateKey.gen_key().get_pubkey()
    new_keypair = keypairs.Keypair(public_key=umbral_pubkey)

    fingerprint = new_keypair.fingerprint()
    assert fingerprint is not None

    umbral_fingerprint = sha3.keccak_256(bytes(umbral_pubkey)).hexdigest().encode()
    assert fingerprint == umbral_fingerprint
Example #4
0
def test_keypair_serialization():
    umbral_pubkey = UmbralPrivateKey.gen_key().get_pubkey()
    new_keypair = keypairs.Keypair(public_key=umbral_pubkey)

    pubkey_bytes = new_keypair.serialize_pubkey()
    assert pubkey_bytes == bytes(umbral_pubkey)

    pubkey_b64 = new_keypair.serialize_pubkey(as_b64=True)
    assert pubkey_b64 == base64.urlsafe_b64encode(umbral_pubkey.to_bytes())
Example #5
0
def test_keypair_fingerprint():
    umbral_pubkey = SecretKey.random().public_key()
    new_keypair = keypairs.Keypair(public_key=umbral_pubkey)

    fingerprint = new_keypair.fingerprint()
    assert fingerprint is not None

    umbral_fingerprint = sha3.keccak_256(
        bytes(umbral_pubkey)).hexdigest().encode()
    assert fingerprint == umbral_fingerprint
Example #6
0
def test_keypair_serialization():
    umbral_pubkey = SecretKey.random().public_key()
    new_keypair = keypairs.Keypair(public_key=umbral_pubkey)

    pubkey_bytes = bytes(new_keypair.pubkey)
    assert pubkey_bytes == bytes(umbral_pubkey)