diff --git a/nucypher/characters/lawful.py b/nucypher/characters/lawful.py index 57eebcfed..1e4dd3a83 100644 --- a/nucypher/characters/lawful.py +++ b/nucypher/characters/lawful.py @@ -631,7 +631,8 @@ class Bob(Character): def get_reencrypted_cfrags(self, work_order, retain_cfrags=False): if work_order.completed: - raise TypeError("This WorkOrder is already complete; if you want Ursula to perform additional service, make a new WorkOrder.") + raise TypeError( + "This WorkOrder is already complete; if you want Ursula to perform additional service, make a new WorkOrder.") cfrags_and_signatures = self.network_middleware.reencrypt(work_order) cfrags = work_order.complete(cfrags_and_signatures) @@ -650,9 +651,9 @@ class Bob(Character): message_kit: UmbralMessageKit, alice_verifying_key: UmbralPublicKey, label: bytes, - retain_cfrags: bool=False, - use_attached_cfrags: bool=False, - use_precedent_work_orders: bool=False): + retain_cfrags: bool = False, + use_attached_cfrags: bool = False, + use_precedent_work_orders: bool = False): # Try our best to get an UmbralPublicKey from input alice_verifying_key = UmbralPublicKey.from_bytes(bytes(alice_verifying_key)) @@ -667,10 +668,10 @@ class Bob(Character): _unknown_ursulas, _known_ursulas, m = self.follow_treasure_map(map_id=map_id, block=True) capsule.set_correctness_keys( - delegating=data_source.policy_pubkey, + delegating=enrico.policy_pubkey, receiving=self.public_keys(DecryptingPower), verifying=alice_verifying_key) - incomplete_work_orders, complete_work_orders = self.work_orders_for_capsule(map_id, capsule) + new_work_orders, complete_work_orders = self.work_orders_for_capsule(map_id, capsule) self.log.info(f"Found {len(complete_work_orders)} for this Capsule ({capsule}).") @@ -680,7 +681,8 @@ class Bob(Character): cfrag_in_question = work_order.tasks[capsule].cfrag capsule.attach_cfrag(cfrag_in_question) else: - self.log.warn("Found existing complete WorkOrders, but use_precedent_work_orders is set to False. To use Bob in 'KMS mode', set retain_cfrags=False as well.") + self.log.warn( + "Found existing complete WorkOrders, but use_precedent_work_orders is set to False. To use Bob in 'KMS mode', set retain_cfrags=False as well.") cleartexts = [] diff --git a/nucypher/policy/collections.py b/nucypher/policy/collections.py index 24febec3f..f10e62c0a 100644 --- a/nucypher/policy/collections.py +++ b/nucypher/policy/collections.py @@ -20,6 +20,7 @@ from typing import List, Optional, Tuple import maya import msgpack from bytestring_splitter import BytestringSplitter, VariableLengthBytestring +from constant_sorrow.constants import UNKNOWN_KFRAG, NO_DECRYPTION_PERFORMED, NOT_SIGNED, CFRAG_NOT_RETAINED from constant_sorrow.constants import NO_DECRYPTION_PERFORMED from cryptography.hazmat.backends.openssl import backend from cryptography.hazmat.primitives import hashes @@ -269,9 +270,9 @@ class WorkOrder: self.completed = False def __repr__(self): - return "WorkOrder for hrac {hrac}: (capsules: {capsule_bytes}) for Ursula: {node}".format( + return "WorkOrder for hrac {hrac}: (capsules: {capsule_reprs}) for Ursula: {node}".format( hrac=self.arrangement_id.hex()[:6], - capsule_bytes=[binascii.hexlify(bytes(item.capsule))[:6] for item in self.tasks.values()], + capsule_reprs=[t.capsule for t in self.tasks.values()], node=binascii.hexlify(bytes(self.ursula.stamp))[:6]) def __eq__(self, other): diff --git a/tests/characters/test_bob_handles_frags.py b/tests/characters/test_bob_handles_frags.py index 95253dd09..45f419c19 100644 --- a/tests/characters/test_bob_handles_frags.py +++ b/tests/characters/test_bob_handles_frags.py @@ -321,6 +321,9 @@ def test_bob_gathers_and_combines(enacted_federated_policy, federated_bob, feder _id_of_yet_another_ursula, new_work_order = list(new_incomplete_work_orders.items())[0] cfrags = federated_bob.get_reencrypted_cfrags(new_work_order) + cfrag = cfrags[0] + assert cfrag not in the_message_kit.capsule._attached_cfrags + the_message_kit.capsule.attach_cfrag(cfrags[0]) # Now.