diff --git a/nucypher/crypto/constants.py b/nucypher/crypto/constants.py index c932f39b1..49b14ca84 100644 --- a/nucypher/crypto/constants.py +++ b/nucypher/crypto/constants.py @@ -7,7 +7,5 @@ BLAKE2B_DIGEST_LENGTH = 64 KECCAK_DIGEST_LENGTH = 32 # These lengths are specific to secp256k1 -KFRAG_LENGTH(194) -CFRAG_LENGTH_WITHOUT_PROOF(131) CAPSULE_LENGTH(98) PUBLIC_KEY_LENGTH(33) diff --git a/nucypher/keystore/keystore.py b/nucypher/keystore/keystore.py index 215245fed..83be083ea 100644 --- a/nucypher/keystore/keystore.py +++ b/nucypher/keystore/keystore.py @@ -1,6 +1,5 @@ from typing import Union -from nucypher.crypto.constants import KFRAG_LENGTH from nucypher.crypto.signature import Signature from bytestring_splitter import BytestringSplitter from nucypher.keystore.db.models import Key, PolicyArrangement, Workorder @@ -22,7 +21,7 @@ class KeyStore(object): """ A storage class of cryptographic keys. """ - kfrag_splitter = BytestringSplitter(Signature, (KFrag, KFRAG_LENGTH)) + kfrag_splitter = BytestringSplitter(Signature, (KFrag, KFrag.get_size())) def __init__(self, sqlalchemy_engine=None): """ diff --git a/tests/characters/test_bob_handles_frags.py b/tests/characters/test_bob_handles_frags.py index 8de5f181e..513b477f8 100644 --- a/tests/characters/test_bob_handles_frags.py +++ b/tests/characters/test_bob_handles_frags.py @@ -2,7 +2,7 @@ import pytest from nucypher.crypto.powers import EncryptingPower from umbral import pre -from umbral.fragments import KFrag +from umbral.fragments import KFrag, CapsuleFrag from nucypher.crypto.constants import CFRAG_LENGTH_WITHOUT_PROOF @@ -134,7 +134,7 @@ def test_bob_can_issue_a_work_order_to_a_specific_ursula(enacted_policy, bob, the_correct_cfrag = pre.reencrypt(the_kfrag, capsule) # The first CFRAG_LENGTH_WITHOUT_PROOF bytes (ie, the cfrag proper, not the proof material), are the same: - assert bytes(the_cfrag)[:CFRAG_LENGTH_WITHOUT_PROOF] == bytes(the_correct_cfrag)[:CFRAG_LENGTH_WITHOUT_PROOF] # It's the correct cfrag! + assert bytes(the_cfrag)[:CapsuleFrag.get_size()] == bytes(the_correct_cfrag)[:CapsuleFrag.get_size()] # It's the correct cfrag! assert the_correct_cfrag.verify_correctness(capsule, pubkey_a=enacted_policy.public_key, diff --git a/tests/conftest.py b/tests/conftest.py index 904fe895e..edba4c36d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,10 +1,10 @@ from cryptography.hazmat.primitives.asymmetric import ec from umbral.config import set_default_curve +set_default_curve(ec.SECP256K1()) + from .eth_fixtures import * from .fixtures import * -set_default_curve(ec.SECP256K1()) - import pytest def pytest_addoption(parser):