diff --git a/nucypher/characters/lawful.py b/nucypher/characters/lawful.py index 86b534da1..be694342d 100644 --- a/nucypher/characters/lawful.py +++ b/nucypher/characters/lawful.py @@ -832,14 +832,12 @@ class Bob(Character): delegating_pk=keys['delegating'], receiving_pk=keys['receiving']) except VerificationError: - # TODO: WARNING - This block is untested. - from nucypher.policy.disputes import IndisputableEvidence - evidence = IndisputableEvidence(task=pre_task, work_order=work_order) + # TODO: Implement slashing conditions here. # I got a lot of problems with you people ... the_airing_of_grievances.append(work_order.ursula) else: - verified_cfrags.append(verified_cfrag) # FIXME: this is unused - pre_task.cfrag = verified_cfrag # FIXME: massive yikes, needs to be done properly + verified_cfrags.append(verified_cfrag) # FIXME: this is unused/unimplemented + pre_task.cfrag = verified_cfrag # FIXME: massive yikes, needs to be done properly if the_airing_of_grievances: return False, the_airing_of_grievances @@ -847,15 +845,15 @@ class Bob(Character): return True, verified_cfrags def _assemble_work_orders(self, - *message_kits, - enrico, - policy_encrypting_key, - use_attached_cfrags, - publisher_verifying_key, - alice_verifying_key, - treasure_map, - label, - use_precedent_work_orders + *message_kits: List[UmbralMessageKit], + enrico: 'Enrico', + policy_encrypting_key: PublicKey, + use_attached_cfrags: bool, + alice_verifying_key: PublicKey, + publisher_verifying_key: Optional[PublicKey], + treasure_map: Optional[TreasureMap], + label: bytes, + use_precedent_work_orders: bool ): # Part I: Assembling the WorkOrders. @@ -1003,20 +1001,18 @@ class Bob(Character): # Policy *message_kits: UmbralMessageKit, label: bytes, - - # Alice(s) - alice_verifying_key: Union[PublicKey, bytes], - publisher_verifying_key: Optional[Union[PublicKey, bytes]] = None, + policy_encrypting_key: PublicKey = None, + treasure_map: Union['TreasureMap', bytes] = None, # Source Authentication enrico: "Enrico" = None, - policy_encrypting_key: PublicKey = None, + alice_verifying_key: Union[PublicKey, bytes], + publisher_verifying_key: Optional[Union[PublicKey, bytes]] = None, # Retrieval Behaviour retain_cfrags: bool = False, use_attached_cfrags: bool = False, use_precedent_work_orders: bool = False, - treasure_map: Union['TreasureMap', bytes] = None ) -> List[bytes]: diff --git a/nucypher/policy/policies.py b/nucypher/policy/policies.py index a10e18075..22b35b6a1 100644 --- a/nucypher/policy/policies.py +++ b/nucypher/policy/policies.py @@ -30,6 +30,7 @@ from nucypher.blockchain.eth.constants import POLICY_ID_LENGTH from nucypher.crypto.constants import HRAC_LENGTH from nucypher.crypto.kits import RevocationKit from nucypher.crypto.powers import TransactingPower +from nucypher.crypto.splitters import key_splitter from nucypher.crypto.utils import keccak_digest from nucypher.crypto.umbral_adapter import PublicKey, KeyFrag, Signature from nucypher.crypto.utils import construct_policy_id @@ -43,8 +44,10 @@ class Arrangement: A contract between Alice and a single Ursula. """ - splitter = BytestringSplitter((PublicKey, PublicKey.serialized_size()), # alice_verifying_key - (bytes, VariableLengthBytestring)) # expiration + splitter = BytestringSplitter( + key_splitter, # alice_verifying_key + (bytes, VariableLengthBytestring) # expiration + ) def __init__(self, alice_verifying_key: PublicKey, expiration: maya.MayaDT): self.expiration = expiration @@ -115,7 +118,7 @@ class TreasureMapPublisher: # OK, let's check: if any Ursulas claimed we didn't pay, # we need to re-evaluate our situation here. - claims_of_freeloading = sum(response.status_code == 402 for response in responses.values()) + claims_of_freeloading = any(response.status_code == 402 for response in responses.values()) if claims_of_freeloading: raise Policy.Unpaid