From 450c1c64bc07f9f35510c895e061b7dcf6fb65cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Fri, 14 Dec 2018 17:46:38 +0100 Subject: [PATCH] Shame on you, Ursula. --- nucypher/characters/lawful.py | 12 ++++-------- nucypher/policy/models.py | 3 ++- .../mining_adjudicator/test_mining_adjudicator.py | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/nucypher/characters/lawful.py b/nucypher/characters/lawful.py index 49613eeb5..69146f6ca 100644 --- a/nucypher/characters/lawful.py +++ b/nucypher/characters/lawful.py @@ -66,8 +66,6 @@ from nucypher.network.nodes import Teacher from nucypher.network.protocols import InterfaceInfo, parse_node_uri from nucypher.network.server import ProxyRESTServer, TLSHostingPower, make_rest_app from nucypher.utilities.decorators import validate_checksum_address -# TODO: Fix circular import issue -#from nucypher.policy.models import UnquestionableEvidence class Alice(Character, PolicyAuthor): @@ -552,10 +550,9 @@ class Bob(Character): except UmbralCorrectnessError: evidence = self.collect_evidence(capsule=capsule, cfrag=cfrag, - ) + ursula=work_order.ursula) # TODO: Here's the evidence of Ursula misbehavior. Now what? #500 raise self.IncorrectCFragReceived(evidence) - else: raise Ursula.NotEnoughUrsulas("Unable to snag m cfrags.") @@ -567,10 +564,9 @@ class Bob(Character): cleartexts.append(delivered_cleartext) return cleartexts - def collect_evidence(self, capsule, cfrag): - pass - # TODO: Fix circular import problem - # return UnquestionableEvidence(capsule, cfrag) + def collect_evidence(self, capsule, cfrag, ursula): + from nucypher.policy.models import UnquestionableEvidence + return UnquestionableEvidence(capsule, cfrag, ursula) def make_wsgi_app(drone_bob, start_learning=True): bob_control = Flask('bob-control') diff --git a/nucypher/policy/models.py b/nucypher/policy/models.py index f4dd80081..ad0b4f008 100644 --- a/nucypher/policy/models.py +++ b/nucypher/policy/models.py @@ -681,9 +681,10 @@ class Revocation: class UnquestionableEvidence: - def __init__(self, capsule: Capsule, cfrag: CapsuleFrag) -> None: + def __init__(self, capsule: Capsule, cfrag: CapsuleFrag, ursula) -> None: self.capsule = capsule self.cfrag = cfrag + self.ursula = ursula def get_proof_challenge_scalar(self) -> CurveBN: umbral_params = default_params() diff --git a/tests/blockchain/eth/contracts/main/mining_adjudicator/test_mining_adjudicator.py b/tests/blockchain/eth/contracts/main/mining_adjudicator/test_mining_adjudicator.py index 357b6b4fc..339aa02f6 100644 --- a/tests/blockchain/eth/contracts/main/mining_adjudicator/test_mining_adjudicator.py +++ b/tests/blockchain/eth/contracts/main/mining_adjudicator/test_mining_adjudicator.py @@ -125,7 +125,7 @@ def test_evaluate_cfrag(testerchain, escrow, adjudicator_contract): cfrag_bytes = cfrag.to_bytes() # Bob prepares supporting Evidence - evidence = UnquestionableEvidence(capsule, cfrag) + evidence = UnquestionableEvidence(capsule, cfrag, ursula=None) some_data = evidence.precompute_values() assert len(some_data) == 20 * 32