mirror of https://github.com/nucypher/nucypher.git
Remove UmbralMessageKit alias
parent
17353ddf55
commit
3b43eac717
|
@ -27,7 +27,7 @@ import sys
|
|||
from nucypher.characters.lawful import Bob, Enrico, Ursula
|
||||
from nucypher.config.constants import TEMPORARY_DOMAIN
|
||||
from nucypher.crypto.keypairs import DecryptingKeypair, SigningKeypair
|
||||
from nucypher.crypto.kits import UmbralMessageKit
|
||||
from nucypher.crypto.kits import PolicyMessageKit
|
||||
from nucypher.crypto.powers import DecryptingPower, SigningPower
|
||||
from nucypher.crypto.umbral_adapter import PublicKey
|
||||
from nucypher.network.middleware import RestMiddleware
|
||||
|
@ -95,7 +95,7 @@ treasure_map = EncryptedTreasureMap.from_bytes(base64.b64decode(policy_data["tre
|
|||
# Let's read the file produced by the heart monitor and unpack the MessageKits,
|
||||
# which are the individual ciphertexts.
|
||||
data = msgpack.load(open("heart_data.msgpack", "rb"), raw=False)
|
||||
message_kits = (UmbralMessageKit.from_bytes(k) for k in data['kits'])
|
||||
message_kits = (PolicyMessageKit.from_bytes(k) for k in data['kits'])
|
||||
|
||||
# The doctor also needs to create a view of the Data Source from its public keys
|
||||
data_source = Enrico.from_public_keys(
|
||||
|
|
|
@ -43,7 +43,7 @@ from nucypher.blockchain.eth.signers.base import Signer
|
|||
from nucypher.characters.control.controllers import CharacterCLIController
|
||||
from nucypher.control.controllers import JSONRPCController
|
||||
from nucypher.crypto.keystore import Keystore
|
||||
from nucypher.crypto.kits import UmbralMessageKit
|
||||
from nucypher.crypto.kits import PolicyMessageKit
|
||||
from nucypher.crypto.powers import (
|
||||
CryptoPower,
|
||||
CryptoPowerUp,
|
||||
|
@ -384,7 +384,7 @@ class Character(Learner):
|
|||
|
||||
def verify_from(self,
|
||||
stranger: 'Character',
|
||||
message_kit: Union[UmbralMessageKit, bytes],
|
||||
message_kit: Union[PolicyMessageKit, bytes],
|
||||
signature: Signature = None,
|
||||
decrypt=False,
|
||||
label=None,
|
||||
|
@ -470,7 +470,7 @@ class Character(Learner):
|
|||
return cleartext
|
||||
|
||||
def decrypt(self,
|
||||
message_kit: UmbralMessageKit,
|
||||
message_kit: PolicyMessageKit,
|
||||
label: Optional[bytes] = None) -> bytes:
|
||||
if label and DelegatingPower in self._default_crypto_powerups:
|
||||
delegating_power = self._crypto_power.power_ups(DelegatingPower)
|
||||
|
|
|
@ -23,7 +23,7 @@ import maya
|
|||
from nucypher.characters.base import Character
|
||||
from nucypher.characters.control.specifications import alice, bob, enrico
|
||||
from nucypher.control.interfaces import attach_schema, ControlInterface
|
||||
from nucypher.crypto.kits import UmbralMessageKit
|
||||
from nucypher.crypto.kits import PolicyMessageKit
|
||||
from nucypher.crypto.powers import DecryptingPower, SigningPower
|
||||
from nucypher.crypto.umbral_adapter import PublicKey
|
||||
from nucypher.network.middleware import RestMiddleware
|
||||
|
@ -132,7 +132,7 @@ class AliceInterface(CharacterPublicInterface):
|
|||
policy_encrypting_key = self.implementer.get_policy_encrypting_key_from_label(label)
|
||||
|
||||
# TODO #846: May raise UnknownOpenSSLError and InvalidTag.
|
||||
message_kit = UmbralMessageKit.from_bytes(message_kit)
|
||||
message_kit = PolicyMessageKit.from_bytes(message_kit)
|
||||
|
||||
enrico = Enrico.from_public_keys(
|
||||
verifying_key=message_kit.sender_verifying_key,
|
||||
|
@ -175,7 +175,7 @@ class BobInterface(CharacterPublicInterface):
|
|||
|
||||
policy_encrypting_key = PublicKey.from_bytes(policy_encrypting_key)
|
||||
alice_verifying_key = PublicKey.from_bytes(alice_verifying_key)
|
||||
message_kit = UmbralMessageKit.from_bytes(message_kit) # TODO #846: May raise UnknownOpenSSLError and InvalidTag.
|
||||
message_kit = PolicyMessageKit.from_bytes(message_kit) # TODO #846: May raise UnknownOpenSSLError and InvalidTag.
|
||||
|
||||
enrico = Enrico.from_public_keys(verifying_key=message_kit.sender_verifying_key,
|
||||
policy_encrypting_key=policy_encrypting_key,
|
||||
|
|
|
@ -138,7 +138,7 @@ class Decrypt(BaseSchema):
|
|||
label = character_fields.Label(
|
||||
required=True, load_only=True,
|
||||
click=options.option_label(required=True))
|
||||
message_kit = character_fields.UmbralMessageKit(
|
||||
message_kit = character_fields.PolicyMessageKit(
|
||||
load_only=True,
|
||||
click=options.option_message_kit(required=True))
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ class Retrieve(BaseSchema):
|
|||
type=click.STRING,
|
||||
required=False)
|
||||
)
|
||||
message_kit = character_fields.UmbralMessageKit(
|
||||
message_kit = character_fields.PolicyMessageKit(
|
||||
required=True,
|
||||
load_only=True,
|
||||
click=options.option_message_kit(required=False)
|
||||
|
|
|
@ -65,5 +65,5 @@ class EncryptMessage(BaseSchema):
|
|||
return {"plaintext": data}
|
||||
|
||||
# output
|
||||
message_kit = fields.UmbralMessageKit(dump_only=True)
|
||||
message_kit = fields.PolicyMessageKit(dump_only=True)
|
||||
signature = fields.UmbralSignature(dump_only=True)
|
||||
|
|
|
@ -22,12 +22,12 @@ from marshmallow import fields
|
|||
from nucypher.characters.control.specifications.exceptions import InvalidNativeDataTypes
|
||||
from nucypher.control.specifications.exceptions import InvalidInputData
|
||||
from nucypher.control.specifications.fields.base import BaseField
|
||||
from nucypher.crypto.kits import UmbralMessageKit as UmbralMessageKitClass
|
||||
from nucypher.crypto.kits import PolicyMessageKit as PolicyMessageKitClass
|
||||
|
||||
|
||||
class UmbralMessageKit(BaseField, fields.Field):
|
||||
class PolicyMessageKit(BaseField, fields.Field):
|
||||
|
||||
def _serialize(self, value: UmbralMessageKitClass, attr, obj, **kwargs):
|
||||
def _serialize(self, value: PolicyMessageKitClass, attr, obj, **kwargs):
|
||||
return b64encode(value.to_bytes()).decode()
|
||||
|
||||
def _deserialize(self, value, attr, data, **kwargs):
|
||||
|
@ -40,6 +40,6 @@ class UmbralMessageKit(BaseField, fields.Field):
|
|||
|
||||
def _validate(self, value):
|
||||
try:
|
||||
UmbralMessageKitClass.from_bytes(value)
|
||||
PolicyMessageKitClass.from_bytes(value)
|
||||
except InvalidNativeDataTypes as e:
|
||||
raise InvalidInputData(f"Could not parse {self.name}: {e}")
|
||||
|
|
|
@ -76,7 +76,7 @@ from nucypher.config.storages import ForgetfulNodeStorage, NodeStorage
|
|||
from nucypher.control.controllers import WebController
|
||||
from nucypher.control.emitters import StdoutEmitter
|
||||
from nucypher.crypto.keypairs import HostingKeypair
|
||||
from nucypher.crypto.kits import UmbralMessageKit
|
||||
from nucypher.crypto.kits import PolicyMessageKit
|
||||
from nucypher.crypto.powers import (
|
||||
DecryptingPower,
|
||||
DelegatingPower,
|
||||
|
@ -419,7 +419,7 @@ class Alice(Character, BlockchainPolicyAuthor):
|
|||
return receipt, failed
|
||||
|
||||
def decrypt_message_kit(self,
|
||||
message_kit: UmbralMessageKit,
|
||||
message_kit: PolicyMessageKit,
|
||||
data_source: Character,
|
||||
label: bytes
|
||||
) -> List[bytes]:
|
||||
|
@ -697,7 +697,7 @@ class Bob(Character):
|
|||
|
||||
def _filter_work_orders_and_capsules(self,
|
||||
work_orders: Dict[ChecksumAddress, 'WorkOrder'],
|
||||
message_kits: Sequence['UmbralMessageKit'],
|
||||
message_kits: Sequence['PolicyMessageKit'],
|
||||
threshold: int,
|
||||
) -> Tuple[List['WorkOrder'], Set['Capsule']]:
|
||||
remaining_work_orders = []
|
||||
|
@ -712,7 +712,7 @@ class Bob(Character):
|
|||
work_order: 'WorkOrder',
|
||||
# TODO (#2028): it's kind of awkward to pass this mapping here,
|
||||
# there should be a better way to handle this.
|
||||
message_kits_map: Dict[Capsule, UmbralMessageKit],
|
||||
message_kits_map: Dict[Capsule, PolicyMessageKit],
|
||||
retain_cfrags: bool = False
|
||||
) -> Tuple[bool, Union[List['Ursula'], List['CapsuleFrag']]]:
|
||||
|
||||
|
@ -769,7 +769,7 @@ class Bob(Character):
|
|||
return True, verified_cfrags
|
||||
|
||||
def _assemble_work_orders(self,
|
||||
*message_kits: List[UmbralMessageKit],
|
||||
*message_kits: List[PolicyMessageKit],
|
||||
enrico: 'Enrico',
|
||||
policy_encrypting_key: PublicKey,
|
||||
use_attached_cfrags: bool,
|
||||
|
@ -828,7 +828,7 @@ class Bob(Character):
|
|||
|
||||
def _get_cleartexts(self,
|
||||
*message_kits,
|
||||
message_kits_map: Dict[Capsule, UmbralMessageKit],
|
||||
message_kits_map: Dict[Capsule, PolicyMessageKit],
|
||||
new_work_orders: Sequence['WorkOrder'],
|
||||
threshold: int,
|
||||
retain_cfrags: bool
|
||||
|
@ -911,7 +911,7 @@ class Bob(Character):
|
|||
def retrieve(self,
|
||||
|
||||
# Policy
|
||||
*message_kits: UmbralMessageKit,
|
||||
*message_kits: PolicyMessageKit,
|
||||
label: bytes,
|
||||
encrypted_treasure_map: Optional['EncryptedTreasureMap'] = None,
|
||||
policy_encrypting_key: Optional[PublicKey] = None,
|
||||
|
@ -1829,7 +1829,7 @@ class Enrico(Character):
|
|||
if is_me:
|
||||
self.log.info(self.banner.format(policy_encrypting_key))
|
||||
|
||||
def encrypt_message(self, plaintext: bytes) -> Tuple[UmbralMessageKit, Signature]:
|
||||
def encrypt_message(self, plaintext: bytes) -> Tuple[PolicyMessageKit, Signature]:
|
||||
# TODO: #2107 Rename to "encrypt"
|
||||
message_kit, signature = encrypt_and_sign(self.policy_pubkey,
|
||||
plaintext=plaintext,
|
||||
|
|
|
@ -178,9 +178,6 @@ class PolicyMessageKit(MessageKit):
|
|||
"Need eiter `enrico` or `policy_encrypting_key` to be given.")
|
||||
|
||||
|
||||
UmbralMessageKit = PolicyMessageKit # Temporarily, until serialization w/ Enrico's
|
||||
|
||||
|
||||
class RevocationKit:
|
||||
|
||||
def __init__(self, treasure_map, signer: 'SignatureStamp'):
|
||||
|
|
|
@ -28,7 +28,7 @@ from eth_keys import KeyAPI as EthKeyAPI
|
|||
from eth_utils.address import to_checksum_address
|
||||
|
||||
import nucypher.crypto.umbral_adapter as umbral
|
||||
from nucypher.crypto.kits import UmbralMessageKit
|
||||
from nucypher.crypto.kits import PolicyMessageKit
|
||||
from nucypher.crypto.signing import SignatureStamp
|
||||
from nucypher.crypto.umbral_adapter import Signature, PublicKey
|
||||
|
||||
|
@ -132,7 +132,7 @@ def encrypt_and_sign(recipient_pubkey_enc: PublicKey,
|
|||
plaintext: bytes,
|
||||
signer: 'SignatureStamp',
|
||||
sign_plaintext: bool = True
|
||||
) -> Tuple[UmbralMessageKit, Signature]:
|
||||
) -> Tuple[PolicyMessageKit, Signature]:
|
||||
if signer is not constants.DO_NOT_SIGN:
|
||||
# The caller didn't expressly tell us not to sign; we'll sign.
|
||||
if sign_plaintext:
|
||||
|
@ -145,13 +145,13 @@ def encrypt_and_sign(recipient_pubkey_enc: PublicKey,
|
|||
sig_header = constants.SIGNATURE_IS_ON_CIPHERTEXT
|
||||
capsule, ciphertext = umbral.encrypt(recipient_pubkey_enc, sig_header + plaintext)
|
||||
signature = signer(ciphertext)
|
||||
message_kit = UmbralMessageKit(ciphertext=ciphertext, capsule=capsule,
|
||||
message_kit = PolicyMessageKit(ciphertext=ciphertext, capsule=capsule,
|
||||
sender_verifying_key=signer.as_umbral_pubkey(),
|
||||
signature=signature)
|
||||
else:
|
||||
# Don't sign.
|
||||
signature = sig_header = constants.NOT_SIGNED
|
||||
capsule, ciphertext = umbral.encrypt(recipient_pubkey_enc, sig_header + plaintext)
|
||||
message_kit = UmbralMessageKit(ciphertext=ciphertext, capsule=capsule)
|
||||
message_kit = PolicyMessageKit(ciphertext=ciphertext, capsule=capsule)
|
||||
|
||||
return message_kit, signature
|
||||
|
|
|
@ -56,7 +56,7 @@ from nucypher.blockchain.eth.networks import NetworksInventory
|
|||
from nucypher.blockchain.eth.registry import BaseContractRegistry
|
||||
from nucypher.config.constants import SeednodeMetadata
|
||||
from nucypher.config.storages import ForgetfulNodeStorage
|
||||
from nucypher.crypto.kits import UmbralMessageKit
|
||||
from nucypher.crypto.kits import PolicyMessageKit
|
||||
from nucypher.crypto.powers import DecryptingPower, NoSigningPower, SigningPower
|
||||
from nucypher.crypto.splitters import signature_splitter
|
||||
from nucypher.crypto.signing import SignatureStamp
|
||||
|
@ -739,7 +739,7 @@ class Learner:
|
|||
|
||||
def verify_from(self,
|
||||
stranger: 'Teacher',
|
||||
message_kit: Union[UmbralMessageKit, bytes],
|
||||
message_kit: Union[PolicyMessageKit, bytes],
|
||||
signature: Signature):
|
||||
#
|
||||
# Optional Sanity Check
|
||||
|
|
|
@ -30,7 +30,7 @@ from eth_typing.evm import ChecksumAddress
|
|||
from nucypher.blockchain.eth.constants import ETH_ADDRESS_BYTE_LENGTH
|
||||
from nucypher.characters.base import Character
|
||||
from nucypher.crypto.constants import EIP712_MESSAGE_SIGNATURE_SIZE
|
||||
from nucypher.crypto.kits import UmbralMessageKit
|
||||
from nucypher.crypto.kits import PolicyMessageKit
|
||||
from nucypher.crypto.powers import DecryptingPower, SigningPower
|
||||
from nucypher.crypto.signing import SignatureStamp
|
||||
from nucypher.crypto.splitters import signature_splitter, kfrag_splitter
|
||||
|
@ -54,7 +54,7 @@ class TreasureMap:
|
|||
|
||||
ursula_and_kfrag_payload_splitter = BytestringSplitter(
|
||||
(to_checksum_address, ETH_ADDRESS_BYTE_LENGTH),
|
||||
(UmbralMessageKit, VariableLengthBytestring),
|
||||
(PolicyMessageKit, VariableLengthBytestring),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
@ -203,7 +203,7 @@ class EncryptedTreasureMap:
|
|||
_splitter = BytestringSplitter(
|
||||
signature_splitter, # public signature
|
||||
hrac_splitter, # HRAC
|
||||
(UmbralMessageKit, VariableLengthBytestring), # encrypted TreasureMap
|
||||
(PolicyMessageKit, VariableLengthBytestring), # encrypted TreasureMap
|
||||
(bytes, EIP712_MESSAGE_SIGNATURE_SIZE)) # blockchain signature
|
||||
|
||||
_EMPTY_BLOCKCHAIN_SIGNATURE = b'\x00' * EIP712_MESSAGE_SIGNATURE_SIZE
|
||||
|
@ -215,7 +215,7 @@ class EncryptedTreasureMap:
|
|||
def _sign(blockchain_signer: Callable[[bytes], bytes],
|
||||
public_signature: Signature,
|
||||
hrac: HRAC,
|
||||
encrypted_tmap: UmbralMessageKit,
|
||||
encrypted_tmap: PolicyMessageKit,
|
||||
) -> bytes:
|
||||
# This method exists mainly to link this scheme to the corresponding test
|
||||
payload = bytes(public_signature) + bytes(hrac) + encrypted_tmap.to_bytes()
|
||||
|
@ -251,7 +251,7 @@ class EncryptedTreasureMap:
|
|||
def __init__(self,
|
||||
hrac: HRAC,
|
||||
public_signature: Signature,
|
||||
encrypted_tmap: UmbralMessageKit,
|
||||
encrypted_tmap: PolicyMessageKit,
|
||||
blockchain_signature: Optional[bytes] = None,
|
||||
):
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import pytest
|
|||
from click.testing import CliRunner
|
||||
|
||||
import nucypher
|
||||
from nucypher.crypto.kits import UmbralMessageKit
|
||||
from nucypher.crypto.kits import PolicyMessageKit
|
||||
from nucypher.crypto.powers import DecryptingPower
|
||||
from nucypher.policy.maps import TreasureMap, EncryptedTreasureMap
|
||||
|
||||
|
@ -220,7 +220,7 @@ def test_enrico_web_character_control_encrypt_message(enrico_web_controller_test
|
|||
assert 'signature' in response_data['result']
|
||||
|
||||
# Check that it serializes correctly.
|
||||
message_kit = UmbralMessageKit.from_bytes(b64decode(response_data['result']['message_kit']))
|
||||
message_kit = PolicyMessageKit.from_bytes(b64decode(response_data['result']['message_kit']))
|
||||
|
||||
# Send bad data to assert error return
|
||||
response = enrico_web_controller_test_client.post('/encrypt_message', data=json.dumps({'bad': 'input'}))
|
||||
|
@ -296,7 +296,7 @@ def test_web_character_control_lifecycle(alice_web_controller_test_client,
|
|||
assert 'signature' in enrico_response_data['result']
|
||||
|
||||
kit_bytes = b64decode(enrico_response_data['result']['message_kit'].encode())
|
||||
bob_message_kit = UmbralMessageKit.from_bytes(kit_bytes)
|
||||
bob_message_kit = PolicyMessageKit.from_bytes(kit_bytes)
|
||||
|
||||
# Retrieve data via Bob control
|
||||
encoded_message_kit = b64encode(bob_message_kit.to_bytes()).decode()
|
||||
|
|
|
@ -33,7 +33,7 @@ from nucypher.cli.main import nucypher_cli
|
|||
from nucypher.config.characters import AliceConfiguration, BobConfiguration
|
||||
from nucypher.config.constants import NUCYPHER_ENVVAR_KEYSTORE_PASSWORD, TEMPORARY_DOMAIN, \
|
||||
NUCYPHER_ENVVAR_ALICE_ETH_PASSWORD, NUCYPHER_ENVVAR_BOB_ETH_PASSWORD
|
||||
from nucypher.crypto.kits import UmbralMessageKit
|
||||
from nucypher.crypto.kits import PolicyMessageKit
|
||||
from nucypher.policy.maps import EncryptedTreasureMap
|
||||
from nucypher.utilities.logging import GlobalLoggerSettings
|
||||
from tests.constants import INSECURE_DEVELOPMENT_PASSWORD, TEST_PROVIDER_URI
|
||||
|
@ -61,7 +61,7 @@ class MockSideChannel:
|
|||
def save_message_kit(self, message_kit: str) -> None:
|
||||
self.__message_kits.append(message_kit)
|
||||
|
||||
def fetch_message_kit(self) -> UmbralMessageKit:
|
||||
def fetch_message_kit(self) -> PolicyMessageKit:
|
||||
if self.__message_kits:
|
||||
message_kit = self.__message_kits.pop()
|
||||
return message_kit
|
||||
|
|
|
@ -30,7 +30,7 @@ from nucypher.cli.literature import SUCCESSFUL_DESTRUCTION, COLLECT_NUCYPHER_PAS
|
|||
from nucypher.cli.main import nucypher_cli
|
||||
from nucypher.config.characters import BobConfiguration
|
||||
from nucypher.config.constants import TEMPORARY_DOMAIN
|
||||
from nucypher.crypto.kits import UmbralMessageKit
|
||||
from nucypher.crypto.kits import PolicyMessageKit
|
||||
from nucypher.crypto.powers import SigningPower
|
||||
from nucypher.utilities.logging import GlobalLoggerSettings, Logger
|
||||
from nucypher.policy.identity import Card
|
||||
|
@ -151,7 +151,7 @@ def test_bob_retrieves_twice_via_cli(click_runner,
|
|||
|
||||
message_kit_bytes = bytes(three_message_kits[0])
|
||||
message_kit_b64_bytes = b64encode(message_kit_bytes)
|
||||
UmbralMessageKit.from_bytes(message_kit_bytes)
|
||||
PolicyMessageKit.from_bytes(message_kit_bytes)
|
||||
|
||||
retrieve_args = ('bob', 'retrieve',
|
||||
'--mock-networking',
|
||||
|
|
|
@ -25,7 +25,7 @@ import pytest
|
|||
from click.testing import CliRunner
|
||||
|
||||
import nucypher
|
||||
from nucypher.crypto.kits import UmbralMessageKit
|
||||
from nucypher.crypto.kits import PolicyMessageKit
|
||||
from nucypher.crypto.powers import DecryptingPower
|
||||
from nucypher.policy.maps import EncryptedTreasureMap
|
||||
|
||||
|
@ -216,7 +216,7 @@ def test_enrico_web_character_control_encrypt_message(enrico_web_controller_test
|
|||
assert 'signature' in response_data['result']
|
||||
|
||||
# Check that it serializes correctly.
|
||||
UmbralMessageKit.from_bytes(b64decode(response_data['result']['message_kit']))
|
||||
PolicyMessageKit.from_bytes(b64decode(response_data['result']['message_kit']))
|
||||
|
||||
# Send bad data to assert error return
|
||||
response = enrico_web_controller_test_client.post('/encrypt_message', data=json.dumps({'bad': 'input'}))
|
||||
|
@ -292,7 +292,7 @@ def test_web_character_control_lifecycle(alice_web_controller_test_client,
|
|||
assert 'signature' in enrico_response_data['result']
|
||||
|
||||
kit_bytes = b64decode(enrico_response_data['result']['message_kit'].encode())
|
||||
bob_message_kit = UmbralMessageKit.from_bytes(kit_bytes)
|
||||
bob_message_kit = PolicyMessageKit.from_bytes(kit_bytes)
|
||||
|
||||
# Retrieve data via Bob control
|
||||
encoded_message_kit = b64encode(bob_message_kit.to_bytes()).decode()
|
||||
|
|
|
@ -102,7 +102,7 @@ def test_messagekit_validation(capsule_side_channel):
|
|||
|
||||
class MessageKitsOnly(BaseSchema):
|
||||
|
||||
mkit = fields.UmbralMessageKit()
|
||||
mkit = fields.PolicyMessageKit()
|
||||
|
||||
# this will raise a base64 error
|
||||
with pytest.raises(SpecificationError) as e:
|
||||
|
|
|
@ -21,13 +21,13 @@ import maya
|
|||
import pytest
|
||||
from nucypher.crypto.umbral_adapter import SecretKey, Signer
|
||||
|
||||
from nucypher.crypto.kits import UmbralMessageKit as UmbralMessageKitClass
|
||||
from nucypher.crypto.kits import PolicyMessageKit as PolicyMessageKitClass
|
||||
|
||||
from nucypher.characters.control.specifications.fields import (
|
||||
DateTime,
|
||||
FileField,
|
||||
Key,
|
||||
UmbralMessageKit,
|
||||
PolicyMessageKit,
|
||||
UmbralSignature,
|
||||
EncryptedTreasureMap
|
||||
)
|
||||
|
@ -121,10 +121,10 @@ def test_umbral_message_kit(enacted_federated_policy, federated_alice):
|
|||
plaintext_bytes = bytes(message, encoding='utf-8')
|
||||
message_kit, signature = enrico.encrypt_message(plaintext=plaintext_bytes)
|
||||
message_kit_bytes = message_kit.to_bytes()
|
||||
umbral_message_kit = UmbralMessageKitClass.from_bytes(message_kit_bytes)
|
||||
umbral_message_kit = PolicyMessageKitClass.from_bytes(message_kit_bytes)
|
||||
|
||||
# Test
|
||||
field = UmbralMessageKit()
|
||||
field = PolicyMessageKit()
|
||||
serialized = field._serialize(value=umbral_message_kit, attr=None, obj=None)
|
||||
assert serialized == b64encode(umbral_message_kit.to_bytes()).decode()
|
||||
|
||||
|
@ -134,7 +134,7 @@ def test_umbral_message_kit(enacted_federated_policy, federated_alice):
|
|||
field._validate(value=umbral_message_kit.to_bytes())
|
||||
|
||||
with pytest.raises(InvalidInputData):
|
||||
field._validate(value=b"UmbralMessageKit")
|
||||
field._validate(value=b"PolicyMessageKit")
|
||||
|
||||
|
||||
def test_umbral_signature():
|
||||
|
|
|
@ -16,7 +16,7 @@ along with nucypher. If not, see <https://www.gnu.org/licenses/>.
|
|||
"""
|
||||
|
||||
from nucypher.characters.lawful import Enrico
|
||||
from nucypher.crypto.kits import UmbralMessageKit
|
||||
from nucypher.crypto.kits import PolicyMessageKit
|
||||
|
||||
|
||||
def test_message_kit_serialization_via_enrico(federated_alice):
|
||||
|
@ -37,7 +37,7 @@ def test_message_kit_serialization_via_enrico(federated_alice):
|
|||
message_kit_bytes = message_kit.to_bytes()
|
||||
|
||||
# Deserialize
|
||||
the_same_message_kit = UmbralMessageKit.from_bytes(message_kit_bytes)
|
||||
the_same_message_kit = PolicyMessageKit.from_bytes(message_kit_bytes)
|
||||
|
||||
# Confirm
|
||||
assert message_kit_bytes == the_same_message_kit.to_bytes()
|
||||
|
|
Loading…
Reference in New Issue