mirror of https://github.com/nucypher/pyUmbral.git
parent
f1211478a8
commit
17467431ca
|
@ -32,13 +32,11 @@ def test_capsule_serialization(alices_keys):
|
|||
assert new_capsule._bn_sig == capsule._bn_sig
|
||||
|
||||
|
||||
def test_activated_capsule_serialization(alices_keys):
|
||||
def test_activated_capsule_serialization(alices_keys, bobs_keys):
|
||||
priv_key_alice, pub_key_alice = alices_keys
|
||||
priv_key_bob, pub_key_bob = bobs_keys
|
||||
|
||||
priv_key_bob = pre.gen_priv()
|
||||
pub_key_bob = pre.priv2pub(priv_key_bob)
|
||||
|
||||
_unused_key, capsule = pre._encapsulate(pub_key_bob)
|
||||
_unused_key, capsule = pre._encapsulate(pub_key_bob.point_key)
|
||||
kfrags = pre.split_rekey(priv_key_alice, pub_key_bob, 1, 2)
|
||||
|
||||
cfrag = pre.reencrypt(kfrags[0], capsule)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from umbral import pre, keys
|
||||
|
||||
from umbral.config import default_params
|
||||
|
||||
def test_gen_key():
|
||||
# Pass in the parameters to test that manual param selection works
|
||||
|
@ -10,8 +10,8 @@ def test_gen_key():
|
|||
assert type(umbral_pub_key) == keys.UmbralPublicKey
|
||||
|
||||
|
||||
def test_private_key_serialization():
|
||||
priv_key = pre.gen_priv()
|
||||
def test_private_key_serialization(random_ec_bignum1):
|
||||
priv_key = random_ec_bignum1
|
||||
umbral_key = keys.UmbralPrivateKey(priv_key)
|
||||
|
||||
encoded_key = umbral_key.to_bytes()
|
||||
|
@ -20,8 +20,8 @@ def test_private_key_serialization():
|
|||
assert priv_key == decoded_key.bn_key
|
||||
|
||||
|
||||
def test_private_key_serialization_with_encryption():
|
||||
priv_key = pre.gen_priv()
|
||||
def test_private_key_serialization_with_encryption(random_ec_bignum1):
|
||||
priv_key = random_ec_bignum1
|
||||
umbral_key = keys.UmbralPrivateKey(priv_key)
|
||||
|
||||
encoded_key = umbral_key.to_bytes(password=b'test')
|
||||
|
@ -30,9 +30,11 @@ def test_private_key_serialization_with_encryption():
|
|||
assert priv_key == decoded_key.bn_key
|
||||
|
||||
|
||||
def test_public_key_serialization():
|
||||
priv_key = pre.gen_priv()
|
||||
pub_key = pre.priv2pub(priv_key)
|
||||
def test_public_key_serialization(random_ec_bignum1):
|
||||
priv_key = random_ec_bignum1
|
||||
|
||||
params = default_params()
|
||||
pub_key = priv_key * params.g
|
||||
|
||||
umbral_key = keys.UmbralPublicKey(pub_key)
|
||||
|
||||
|
@ -42,9 +44,11 @@ def test_public_key_serialization():
|
|||
assert pub_key == decoded_key.point_key
|
||||
|
||||
|
||||
def test_public_key_to_bytes():
|
||||
priv_key = pre.gen_priv()
|
||||
pub_key = pre.priv2pub(priv_key)
|
||||
def test_public_key_to_bytes(random_ec_bignum1):
|
||||
priv_key = random_ec_bignum1
|
||||
|
||||
params = default_params()
|
||||
pub_key = priv_key * params.g
|
||||
|
||||
umbral_key = keys.UmbralPublicKey(pub_key)
|
||||
key_bytes = bytes(umbral_key)
|
||||
|
|
|
@ -255,16 +255,6 @@ class ChallengeResponse(object):
|
|||
return self.to_bytes()
|
||||
|
||||
|
||||
def gen_priv(curve: ec.EllipticCurve=None) -> BigNum:
|
||||
curve = curve if curve is not None else default_curve()
|
||||
return BigNum.gen_rand(curve)
|
||||
|
||||
|
||||
def priv2pub(priv: BigNum, params: UmbralParameters=None) -> Point:
|
||||
params = params if params is not None else default_params()
|
||||
return priv * params.g
|
||||
|
||||
|
||||
def split_rekey(priv_a: Union[UmbralPrivateKey, BigNum],
|
||||
pub_b: Union[UmbralPublicKey, Point],
|
||||
threshold: int, N: int,
|
||||
|
|
Loading…
Reference in New Issue