Using.get_size() for fragments.

pull/269/head
jMyles 2018-05-08 21:45:00 -07:00
parent 41805d5d06
commit 3e76563c10
4 changed files with 5 additions and 8 deletions

View File

@ -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)

View File

@ -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):
"""

View File

@ -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,

View File

@ -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):