mirror of https://github.com/nucypher/nucypher.git
Allow ephemeral node and node storage default in Finnegans Wake demo.
parent
1663eb78d6
commit
06d689f45b
|
@ -1,15 +1,15 @@
|
|||
import datetime
|
||||
import os
|
||||
import shutil
|
||||
|
||||
import datetime
|
||||
import maya
|
||||
import shutil
|
||||
from twisted.logger import globalLogPublisher
|
||||
from umbral.keys import UmbralPublicKey
|
||||
|
||||
from nucypher.characters.lawful import Alice, Bob, Ursula
|
||||
from nucypher.data_sources import DataSource as Enrico
|
||||
from nucypher.network.middleware import RestMiddleware
|
||||
from nucypher.utilities.logging import simpleObserver
|
||||
from umbral.keys import UmbralPublicKey
|
||||
from nucypher.utilities.logging import SimpleObserver
|
||||
|
||||
######################
|
||||
# Boring setup stuff #
|
||||
|
@ -19,18 +19,7 @@ from umbral.keys import UmbralPublicKey
|
|||
BOOK_PATH = os.path.join('.', 'finnegans-wake.txt')
|
||||
|
||||
# Twisted Logger
|
||||
globalLogPublisher.addObserver(simpleObserver)
|
||||
|
||||
# Temporary file storage
|
||||
TEMP_FILES_DIR = "{}/examples-runtime-cruft".format(os.path.dirname(os.path.abspath(__file__)))
|
||||
TEMP_DEMO_DIR = "{}/finnegans-wake-demo".format(TEMP_FILES_DIR)
|
||||
TEMP_CERTIFICATE_DIR = "{}/certs".format(TEMP_DEMO_DIR)
|
||||
|
||||
# Remove previous demo files and create new ones
|
||||
shutil.rmtree(TEMP_FILES_DIR, ignore_errors=True)
|
||||
os.mkdir(TEMP_FILES_DIR)
|
||||
os.mkdir(TEMP_DEMO_DIR)
|
||||
os.mkdir(TEMP_CERTIFICATE_DIR)
|
||||
globalLogPublisher.addObserver(SimpleObserver())
|
||||
|
||||
|
||||
#######################################
|
||||
|
@ -38,13 +27,12 @@ os.mkdir(TEMP_CERTIFICATE_DIR)
|
|||
# (will fail with bad connection) #####
|
||||
#######################################
|
||||
|
||||
TESTNET_LOAD_BALANCER = "eu-federated-balancer-40be4480ec380cd7.elb.eu-central-1.amazonaws.com"
|
||||
SEEDNODE_URI = "https://localhost:11501"
|
||||
|
||||
##############################################
|
||||
# Ursula, the Untrusted Re-Encryption Proxy #
|
||||
##############################################
|
||||
ursula = Ursula.from_seed_and_stake_info(host=TESTNET_LOAD_BALANCER,
|
||||
certificates_directory=TEMP_CERTIFICATE_DIR,
|
||||
ursula = Ursula.from_seed_and_stake_info(seed_uri=SEEDNODE_URI,
|
||||
federated_only=True,
|
||||
minimum_stake=0)
|
||||
|
||||
|
@ -60,8 +48,7 @@ label = b"secret/files/and/stuff"
|
|||
ALICE = Alice(network_middleware=RestMiddleware(),
|
||||
known_nodes=[ursula],
|
||||
learn_on_same_thread=True,
|
||||
federated_only=True,
|
||||
known_certificates_dir=TEMP_CERTIFICATE_DIR)
|
||||
federated_only=True)
|
||||
|
||||
# Alice can get the public key even before creating the policy.
|
||||
# From this moment on, any Data Source that knows the public key
|
||||
|
@ -69,13 +56,11 @@ ALICE = Alice(network_middleware=RestMiddleware(),
|
|||
# any Bob that Alice grants access.
|
||||
policy_pubkey = ALICE.get_policy_pubkey_from_label(label)
|
||||
|
||||
BOB = Bob(
|
||||
known_nodes=[ursula],
|
||||
network_middleware=RestMiddleware(),
|
||||
federated_only=True,
|
||||
start_learning_now=True,
|
||||
learn_on_same_thread=True,
|
||||
known_certificates_dir=TEMP_CERTIFICATE_DIR)
|
||||
BOB = Bob(known_nodes=[ursula],
|
||||
network_middleware=RestMiddleware(),
|
||||
federated_only=True,
|
||||
start_learning_now=True,
|
||||
learn_on_same_thread=True)
|
||||
|
||||
ALICE.start_learning_loop(now=True)
|
||||
|
||||
|
@ -127,9 +112,9 @@ for counter, plaintext in enumerate(finnegans_wake):
|
|||
# single passage from James Joyce's Finnegan's Wake.
|
||||
# The matter of whether encryption makes the passage more or less readable
|
||||
# is left to the reader to determine.
|
||||
single_passage_ciphertext, _signature = enciro.encrypt_message(plaintext)
|
||||
data_source_public_key = bytes(enciro.stamp)
|
||||
del enciro
|
||||
single_passage_ciphertext, _signature = enrico.encrypt_message(plaintext)
|
||||
data_source_public_key = bytes(enrico.stamp)
|
||||
del enrico
|
||||
|
||||
###############
|
||||
# Back to Bob #
|
||||
|
|
Loading…
Reference in New Issue