From 820ddee8381807712e304455213553a96d26f980 Mon Sep 17 00:00:00 2001 From: jMyles Date: Thu, 9 Aug 2018 17:30:28 -0400 Subject: [PATCH] Small fixes to restore federated demo. --- examples/finnegans-wake-federated.py | 4 +-- ..._ursula_with_rest_and_dht_but_no_mining.py | 2 -- nucypher/characters.py | 26 ++++++++----------- nucypher/data_sources.py | 2 +- 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/examples/finnegans-wake-federated.py b/examples/finnegans-wake-federated.py index d39be9d38..4df884bde 100644 --- a/examples/finnegans-wake-federated.py +++ b/examples/finnegans-wake-federated.py @@ -25,8 +25,8 @@ formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(messag ch.setFormatter(formatter) root.addHandler(ch) -teacher_dht_port = 3552 -teacher_rest_port = 3652 +teacher_dht_port = sys.argv[2] +teacher_rest_port = int(teacher_dht_port) + 100 with open("examples-runtime-cruft/node-metadata-{}".format(teacher_rest_port), "r") as f: f.seek(0) teacher_bytes = binascii.unhexlify(f.read()) diff --git a/examples/run_ursula_with_rest_and_dht_but_no_mining.py b/examples/run_ursula_with_rest_and_dht_but_no_mining.py index ab6c33559..d5fc60dad 100644 --- a/examples/run_ursula_with_rest_and_dht_but_no_mining.py +++ b/examples/run_ursula_with_rest_and_dht_but_no_mining.py @@ -14,8 +14,6 @@ from nucypher.characters import Ursula DB_NAME = "examples-runtime-cruft/db" -STARTING_PORT = 3501 - import logging, binascii import sys diff --git a/nucypher/characters.py b/nucypher/characters.py index ed9dc3cb2..1a6a511dd 100644 --- a/nucypher/characters.py +++ b/nucypher/characters.py @@ -1,5 +1,6 @@ import asyncio import random +import time from collections import OrderedDict from collections import deque from contextlib import suppress @@ -10,15 +11,16 @@ from typing import Union, List import kademlia import maya -import time +from bytestring_splitter import BytestringSplitter, VariableLengthBytestring +from constant_sorrow import constants, default_constant_splitter from eth_keys import KeyAPI as EthKeyAPI +from eth_utils import to_checksum_address, to_canonical_address from kademlia.network import Server from kademlia.utils import digest from twisted.internet import task, threads +from umbral.keys import UmbralPublicKey +from umbral.signing import Signature -from bytestring_splitter import BytestringSplitter, VariableLengthBytestring -from constant_sorrow import constants, default_constant_splitter -from eth_utils import to_checksum_address, to_canonical_address from nucypher.blockchain.eth.actors import PolicyAuthor, Miner from nucypher.blockchain.eth.agents import MinerAgent from nucypher.config.configs import CharacterConfiguration @@ -32,8 +34,6 @@ from nucypher.network.middleware import RestMiddleware from nucypher.network.nodes import VerifiableNode from nucypher.network.protocols import InterfaceInfo from nucypher.network.server import NucypherDHTServer, NucypherSeedOnlyDHTServer, ProxyRESTServer -from umbral.keys import UmbralPublicKey -from umbral.signing import Signature class Character: @@ -977,16 +977,12 @@ class Bob(Character): cfrags = self.get_reencrypted_cfrags(work_order) message_kit.capsule.attach_cfrag(cfrags[0]) - verified, delivered_cleartext = self.verify_from(data_source, - message_kit, - decrypt=True, - delegator_signing_key=alice_verifying_key) + delivered_cleartext = self.verify_from(data_source, + message_kit, + decrypt=True, + delegator_signing_key=alice_verifying_key) - if verified: - cleartexts.append(delivered_cleartext) - else: - raise RuntimeError( - "Not verified - replace this with real message.") # TODO: Actually raise an error in verify_from instead of here 358 + cleartexts.append(delivered_cleartext) return cleartexts diff --git a/nucypher/data_sources.py b/nucypher/data_sources.py index f7bc76adc..f6b8d372b 100644 --- a/nucypher/data_sources.py +++ b/nucypher/data_sources.py @@ -28,6 +28,6 @@ class DataSource: def from_public_keys(cls, policy_public_key, datasource_public_key, label): umbral_public_key = UmbralPublicKey.from_bytes(datasource_public_key) return cls(policy_public_key, - signing_keypair=SigningKeypair(umbral_public_key), + signing_keypair=SigningKeypair(public_key=umbral_public_key), label=label, )