nucypher.config

Submodules

class BaseConfiguration(config_root: Optional[pathlib.Path] = None, filepath: Optional[pathlib.Path] = None, *args, **kwargs)

Bases: abc.ABC

Abstract base class for saving a JSON serializable version of the subclass’s attributes to the disk exported by static_payload, generating an optionally unique filename, and restoring a subclass instance from the written JSON file by passing the deserialized values to the subclass’s constructor.

Implementation:

NAME and def static_payload are required for subclasses, for example:

class MyItem(BaseConfiguration):
    _NAME = 'my-item'

AND

def static_payload(self) -> dict:
    payload = dict(**super().static_payload(), key=value)
    return payload

OR

def static_payload(self) -> dict:
    subclass_payload = {'key': 'value'}
    payload = {**super().static_payload(), **subclass_payload}
    return payload

Filepath Generation

Default behavior avoids overwriting an existing configuration file:

  • The name of the JSON file to write/read from is determined by NAME. When calling to_configuration_file.

  • If the default path (i.e. my-item.json) already exists and, optionally, override is set to False, then a modifer is appended to the name (i.e. my-item-<MODIFIER>.json).

  • If modifier is None and override is False, FileExistsError will be raised.

If the subclass implementation has a global unique identifier, an additional method override to to_configuration_file will automate the renaming process.

def to_configuration_file(*args, **kwargs) -> str:
    filepath = super().to_configuration_file(modifier=<MODIFIER>, *args, **kwargs)
    return filepath
NAME = NotImplemented
INDENTATION = 2
DEFAULT_CONFIG_ROOT = PosixPath('/home/docs/.local/share/nucypher')
VERSION = NotImplemented
exception ConfigurationError

Bases: RuntimeError

exception InvalidConfiguration

Bases: nucypher.config.base.BaseConfiguration.ConfigurationError

exception NoConfigurationRoot

Bases: nucypher.config.base.BaseConfiguration.InvalidConfiguration

exception OldVersion

Bases: nucypher.config.base.BaseConfiguration.InvalidConfiguration

abstract static_payload()dict

Return a dictionary of JSON serializable configuration key/value pairs matching the input specification of this classes __init__.

Recommended subclass implementations:

` payload = dict(**super().static_payload(), key=value) return payload `

OR

` subclass_payload = {'key': 'value'} payload = {**super().static_payload(), **subclass_payload} return payload `

classmethod generate_filename(modifier: str = None)str

Generates the configuration filename with an optional modification string.

Parameters

modifier – String to modify default filename with.

Returns

The generated filepath string.

classmethod default_filepath(config_root: Optional[pathlib.Path] = None)pathlib.Path

Generates the default configuration filepath for the class.

Returns

The generated filepath string

generate_filepath(filepath: Optional[pathlib.Path] = None, modifier: str = None, override: bool = False)pathlib.Path

Generates a filepath for saving to writing to a configuration file.

Default behavior avoids overwriting an existing configuration file:

  • The filepath exists and a filename modifier is not provided, then FileExistsError will be raised.

  • The modified filepath exists, then FileExistsError will be raised.

To allow re-generation of an existing filepath, set override to True.

Parameters
  • filepath – A custom filepath to use for configuration.

  • modifier – A unique string to modify the filename if the file already exists.

  • override – Allow generation of an existing filepath.

Returns

The generated filepath.

classmethod peek(filepath: pathlib.Path, field: str) → Optional[str]
to_configuration_file(filepath: Optional[pathlib.Path] = None, modifier: str = None, override: bool = False)pathlib.Path
classmethod from_configuration_file(filepath: Optional[pathlib.Path] = None, **overrides)nucypher.config.base.BaseConfiguration
serialize(serializer=<function dumps>)str

Returns the JSON serialized output of static_payload

classmethod deserialize(payload: str, deserializer=<function loads>, payload_label: Optional[str] = None)dict

Returns the JSON deserialized content of payload

update(filepath: Optional[pathlib.Path] = None, **updates)None
class CharacterConfiguration(emitter=None, config_root: Optional[pathlib.Path] = None, filepath: Optional[pathlib.Path] = None, dev_mode: bool = False, federated_only: bool = False, checksum_address: str = None, crypto_power: nucypher.crypto.powers.CryptoPower = None, keystore: nucypher.crypto.keystore.Keystore = None, keystore_path: Optional[pathlib.Path] = None, learn_on_same_thread: bool = False, abort_on_learning_error: bool = False, start_learning_now: bool = True, controller_port: int = None, domain: str = 'mainnet', interface_signature: umbral.signing.Signature = None, network_middleware: nucypher.network.middleware.RestMiddleware = None, lonely: bool = False, known_nodes: set = None, node_storage: nucypher.config.storages.NodeStorage = None, reload_metadata: bool = True, save_metadata: bool = True, poa: bool = None, light: bool = False, provider_uri: str = None, gas_strategy: Union[Callable, str] = 'fast', max_gas_price: Optional[int] = None, signer_uri: str = None, registry: nucypher.blockchain.eth.registry.BaseContractRegistry = None, registry_filepath: Optional[pathlib.Path] = None, worker_data: dict = None)

Bases: nucypher.config.base.BaseConfiguration

‘Sideways Engagement’ of Character classes; a reflection of input parameters.

VERSION = 3
CHARACTER_CLASS = NotImplemented
DEFAULT_CONTROLLER_PORT = NotImplemented
MNEMONIC_KEYSTORE = False
DEFAULT_DOMAIN = 'mainnet'
DEFAULT_NETWORK_MIDDLEWARE

alias of nucypher.network.middleware.RestMiddleware

TEMP_CONFIGURATION_DIR_PREFIX = 'tmp-nucypher'
SIGNER_ENVVAR = None
known_node_class

alias of nucypher.characters.lawful.Ursula

DEFAULT_GAS_STRATEGY = 'fast'
property keystore
attach_keystore(keystore: nucypher.crypto.keystore.Keystore)None
classmethod checksum_address_from_filepath(filepath: pathlib.Path)str
update(**kwargs)None

A facility for updating existing attributes on existing configuration instances.

Warning: This method allows mutation and may result in an inconsistent configuration.

classmethod generate(password: str, key_material: Optional[bytes] = None, *args, **kwargs)

Shortcut: Hook-up a new initial installation and configuration.

cleanup()None
property dev_mode
forget_nodes()None
destroy()None

Parse a node configuration and remove all associated files from the filesystem

generate_parameters(**overrides)dict

Warning: This method allows mutation and may result in an inconsistent configuration.

produce(**overrides) → NotImplemented

Initialize a new character instance and return it.

classmethod assemble(filepath: Optional[pathlib.Path] = None, **overrides)dict

Warning: This method allows mutation and may result in an inconsistent configuration.

classmethod from_configuration_file(filepath: Optional[pathlib.Path] = None, **overrides)nucypher.config.base.CharacterConfiguration

Initialize a CharacterConfiguration from a JSON file.

validate()bool
static_payload()dict

Exported static configuration values for initializing Ursula

property dynamic_payload

Exported dynamic configuration values for initializing Ursula. These values are used to init a character instance but are not saved to the JSON configuration.

generate_filepath(filepath: Optional[pathlib.Path] = None, modifier: str = None, override: bool = False)pathlib.Path

Generates a filepath for saving to writing to a configuration file.

Default behavior avoids overwriting an existing configuration file:

  • The filepath exists and a filename modifier is not provided, then FileExistsError will be raised.

  • The modified filepath exists, then FileExistsError will be raised.

To allow re-generation of an existing filepath, set override to True.

Parameters
  • filepath – A custom filepath to use for configuration.

  • modifier – A unique string to modify the filename if the file already exists.

  • override – Allow generation of an existing filepath.

Returns

The generated filepath.

property runtime_filepaths
classmethod generate_runtime_filepaths(config_root: pathlib.Path)dict

Dynamically generate paths based on configuration root directory

derive_node_power_ups() → List[nucypher.crypto.powers.CryptoPowerUp]
initialize(password: str, key_material: Optional[bytes] = None)str

Initialize a new configuration and write installation files to disk.

write_keystore(password: str, key_material: Optional[bytes] = None, interactive: bool = True)nucypher.crypto.keystore.Keystore
classmethod load_node_storage(storage_payload: dict, federated_only: bool)
class UrsulaConfiguration(rest_host: str = None, worker_address: str = None, dev_mode: bool = False, db_filepath: Optional[pathlib.Path] = None, keystore_path: Optional[pathlib.Path] = None, rest_port: int = None, certificate: cryptography.x509.base.Certificate = None, availability_check: bool = None, *args, **kwargs)

Bases: nucypher.config.base.CharacterConfiguration

class Ursula(rest_host: str, rest_port: int, domain: str, is_me: bool = True, certificate: cryptography.x509.base.Certificate = None, certificate_filepath: Optional[pathlib.Path] = None, db_filepath: Optional[pathlib.Path] = None, interface_signature=None, timestamp=None, availability_check: bool = False, checksum_address: NewType.<locals>.new_type = None, worker_address: NewType.<locals>.new_type = None, client_password: str = None, decentralized_identity_evidence=NOT_SIGNED, provider_uri: str = None, abort_on_learning_error: bool = False, federated_only: bool = False, crypto_power=None, known_nodes: Iterable[nucypher.network.nodes.Teacher] = None, **character_kwargs)

Bases: nucypher.network.nodes.Teacher, nucypher.characters.base.Character, nucypher.blockchain.eth.actors.Worker

exception NotEnoughUrsulas

Bases: nucypher.network.nodes.Learner.NotEnoughTeachers, nucypher.blockchain.eth.agents.StakingEscrowAgent.NotEnoughStakers

All Characters depend on knowing about enough Ursulas to perform their role. This exception is raised when a piece of logic can’t proceed without more Ursulas.

exception NotFound

Bases: Exception

banner = '\n\n\n ,ggg, gg \ndP""Y8a 88 ,dPYb, \nYb, `88 88 IP\'`Yb \n `" 88 88 I8 8I \n 88 88 I8 8\' \n 88 88 ,gggggg, ,g, gg gg I8 dP ,gggg,gg \n 88 88 dP""""8I ,8\'8, I8 8I I8dP dP" "Y8I \n 88 88 ,8\' 8I ,8\' Yb I8, ,8I I8P i8\' ,8I \n Y8b,____,d88,,dP Y8,,8\'_ 8) ,d8b, ,d8b,,d8b,_ ,d8, ,d8b,\n "Y888888P"Y88P `Y8P\' "YY8P8P8P\'"Y88P"`Y88P\'"Y88P"Y8888P"`Y8\n\n\nthe Untrusted Re-Encryption Proxy.\n{}\n'
property datastore
classmethod from_metadata_bytes(metadata_bytes)
classmethod from_rest_url(network_middleware: nucypher.network.middleware.RestMiddleware, host: str, port: int, certificate_filepath, *args, **kwargs)
classmethod from_seed_and_stake_info(seed_uri: str, federated_only: bool = False, minimum_stake: int = 0, registry: nucypher.blockchain.eth.registry.BaseContractRegistry = None, network_middleware: nucypher.network.middleware.RestMiddleware = None, *args, **kwargs)nucypher.characters.lawful.Ursula
classmethod from_seednode_metadata(seednode_metadata, *args, **kwargs)

Essentially another deserialization method, but this one doesn’t reconstruct a complete node from bytes; instead it’s just enough to connect to and verify a node.

NOTE: This is a federated only method.

classmethod from_storage(node_storage: nucypher.config.storages.NodeStorage, checksum_adress: str, federated_only: bool = False)nucypher.characters.lawful.Ursula
classmethod from_teacher_uri(federated_only: bool, teacher_uri: str, min_stake: int, network_middleware: nucypher.network.middleware.RestMiddleware = None, registry: nucypher.blockchain.eth.registry.BaseContractRegistry = None, retry_attempts: int = 2, retry_interval: int = 2)nucypher.characters.lawful.Ursula
get_deployer()
interface_info_with_metadata()
metadata()nucypher.core.NodeMetadata
property rest_app
rest_information()
property rest_interface
property rest_url
run(emitter: nucypher.control.emitters.StdoutEmitter = None, discovery: bool = True, availability: bool = False, worker: bool = True, pruning: bool = True, interactive: bool = False, hendrix: bool = True, start_reactor: bool = True, prometheus_config: PrometheusMetricsConfig = None, preflight: bool = True, block_until_ready: bool = True, eager: bool = False)None

Schedule and start select ursula services, then optionally start the reactor.

classmethod seednode_for_network(network: str)nucypher.characters.lawful.Ursula

Returns a default seednode ursula for a given network.

status_info(omit_known_nodes: bool = False)nucypher.characters.lawful.LocalUrsulaStatus
stop(halt_reactor: bool = False)None

Stop services for partially or fully initialized characters. # CAUTION #

verify_kfrag_authorization(hrac: nucypher.core.HRAC, author_verifying_key: umbral.keys.PublicKey, publisher_verifying_key: umbral.keys.PublicKey, authorized_kfrag: nucypher.core.AuthorizedKeyFrag) → umbral.key_frag.VerifiedKeyFrag
CHARACTER_CLASS

alias of nucypher.characters.lawful.Ursula

NAME = 'ursula'
DEFAULT_REST_PORT = 9151
DEFAULT_DEVELOPMENT_REST_HOST = '127.0.0.1'
DEFAULT_DEVELOPMENT_REST_PORT = 10151
DEFAULT_DB_NAME = 'ursula.db'
DEFAULT_AVAILABILITY_CHECKS = False
LOCAL_SIGNERS_ALLOWED = True
SIGNER_ENVVAR = 'NUCYPHER_WORKER_ETH_PASSWORD'
MNEMONIC_KEYSTORE = True
classmethod checksum_address_from_filepath(filepath: pathlib.Path)str

Extracts worker address by “peeking” inside the ursula configuration file.

generate_runtime_filepaths(config_root: pathlib.Path)dict

Dynamically generate paths based on configuration root directory

generate_filepath(modifier: str = None, *args, **kwargs)pathlib.Path

Generates a filepath for saving to writing to a configuration file.

Default behavior avoids overwriting an existing configuration file:

  • The filepath exists and a filename modifier is not provided, then FileExistsError will be raised.

  • The modified filepath exists, then FileExistsError will be raised.

To allow re-generation of an existing filepath, set override to True.

Parameters
  • filepath – A custom filepath to use for configuration.

  • modifier – A unique string to modify the filename if the file already exists.

  • override – Allow generation of an existing filepath.

Returns

The generated filepath.

static_payload()dict

Exported static configuration values for initializing Ursula

property dynamic_payload

Exported dynamic configuration values for initializing Ursula. These values are used to init a character instance but are not saved to the JSON configuration.

produce(**overrides)

Produce a new Ursula from configuration

destroy()None

Parse a node configuration and remove all associated files from the filesystem

classmethod deserialize(payload: str, deserializer=<function loads>, payload_label: Optional[str] = None)dict

Returns the JSON deserialized content of payload

classmethod assemble(filepath: Optional[pathlib.Path] = None, **overrides)dict

Warning: This method allows mutation and may result in an inconsistent configuration.

class AliceConfiguration(threshold: int = None, shares: int = None, rate: int = None, payment_periods: int = None, store_policies: bool = True, store_cards: bool = True, *args, **kwargs)

Bases: nucypher.config.base.CharacterConfiguration

class Alice(is_me: bool = True, federated_only: bool = False, provider_uri: str = None, signer=None, checksum_address: str = None, threshold: Optional[int] = None, shares: Optional[int] = None, rate: int = None, payment_periods: int = None, store_policy_credentials: bool = None, store_character_cards: bool = None, timeout: int = 10, network_middleware: nucypher.network.middleware.RestMiddleware = None, controller: bool = True, *args, **kwargs)

Bases: nucypher.characters.base.Character, nucypher.blockchain.eth.actors.BlockchainPolicyAuthor

add_active_policy(active_policy)

Adds a Policy object that is active on the NuCypher network to Alice’s active_policies dictionary by the policy ID.

banner = '\n\n / \\ | (_) ___ ___\n / _ \\ | | |/ __/ _ \\\n / ___ \\| | | (_| __/\n /_/ \\_|_|_|\\___\\___|\n\n the Authority.\n'
create_policy(bob: nucypher.characters.lawful.Bob, label: bytes, **policy_params)

Create a Policy so that Bob has access to all resources under label. Generates KFrags and attaches them.

decrypt_message_kit(label: bytes, message_kit: nucypher.core.MessageKit) → List[bytes]

Decrypt this Alice’s own encrypted data.

I/O signatures match Bob’s retrieve interface.

generate_kfrags(bob: nucypher.characters.lawful.Bob, label: bytes, threshold: int = None, shares: int = None) → List

Generates re-encryption key frags (“KFrags”) and returns them.

These KFrags can be used by Ursula to re-encrypt a Capsule for Bob so that he can activate the Capsule.

Parameters
  • bob – Bob instance which will be able to decrypt messages re-encrypted with these kfrags.

  • m – Minimum number of kfrags needed to activate a Capsule.

  • n – Total number of kfrags to generate

generate_policy_parameters(threshold: int = None, shares: int = None, payment_periods: int = None, expiration: maya.core.MayaDT = None, *args, **kwargs)dict

Construct policy creation from parameters or overrides.

get_card() → Card
get_policy_encrypting_key_from_label(label: bytes) → umbral.keys.PublicKey
grant(bob: nucypher.characters.lawful.Bob, label: bytes, handpicked_ursulas: set = None, timeout: int = None, **policy_params)
make_web_controller(crash_on_error: bool = False)
revoke(policy: Policy, onchain: bool = True, offchain: bool = True) → Tuple[web3.types.TxReceipt, Dict[NewType.<locals>.new_type, Tuple[Revocation, Exception]]]
CHARACTER_CLASS

alias of nucypher.characters.lawful.Alice

NAME = 'alice'
DEFAULT_CONTROLLER_PORT = 8151
DEFAULT_THRESHOLD = 2
DEFAULT_SHARES = 3
DEFAULT_STORE_POLICIES = True
DEFAULT_STORE_CARDS = True
SIGNER_ENVVAR = 'NUCYPHER_ALICE_ETH_PASSWORD'
static_payload()dict

Exported static configuration values for initializing Ursula

class BobConfiguration(store_policies: bool = True, store_cards: bool = True, *args, **kwargs)

Bases: nucypher.config.base.CharacterConfiguration

class Bob(is_me: bool = True, controller: bool = True, verify_node_bonding: bool = False, provider_uri: str = None, *args, **kwargs)

Bases: nucypher.characters.base.Character

exception IncorrectCFragsReceived(evidence: List)

Bases: Exception

Raised when Bob detects incorrect CFrags returned by some Ursulas

banner = '\n\noooooooooo oooo \n 888 888 ooooooo 888ooooo \n 888oooo88 888 888 888 888\n 888 888 888 888 888 888\no888ooo888 88ooo88 o888ooo88 \n\nthe BUIDLer.\n'
get_card() → Card
make_web_controller(crash_on_error: bool = False)
retrieve(message_kits: Sequence[Union[nucypher.core.MessageKit, nucypher.policy.kits.PolicyMessageKit]], alice_verifying_key: umbral.keys.PublicKey, encrypted_treasure_map: nucypher.core.EncryptedTreasureMap, publisher_verifying_key: Optional[umbral.keys.PublicKey] = None) → List[nucypher.policy.kits.PolicyMessageKit]

Attempts to retrieve reencrypted capsule fragments corresponding to given message kits from Ursulas.

Accepts both “clean” message kits (obtained from a side channel) and “loaded” ones (with earlier retrieved capsule frags attached, along with the addresses of Ursulas they were obtained from).

Returns a list of loaded message kits corresponding to the input list, with the kits containing the capsule fragments obtained during the retrieval. These kits can be used as an external cache to preserve the cfrags between several retrieval attempts.

retrieve_and_decrypt(*args, **kwds) → List[bytes]

Attempts to retrieve reencrypted capsule fragments from Ursulas and decrypt the ciphertexts in the given message kits.

See retrieve() for the parameter list.

CHARACTER_CLASS

alias of nucypher.characters.lawful.Bob

NAME = 'bob'
DEFAULT_CONTROLLER_PORT = 7151
DEFAULT_STORE_POLICIES = True
DEFAULT_STORE_CARDS = True
SIGNER_ENVVAR = 'NUCYPHER_BOB_ETH_PASSWORD'
static_payload()dict

Exported static configuration values for initializing Ursula

class FelixConfiguration(db_filepath: Optional[pathlib.Path] = None, rest_host: str = None, rest_port: int = None, tls_curve: cryptography.hazmat.primitives.asymmetric.ec.EllipticCurve = None, certificate: cryptography.x509.base.Certificate = None, *args, **kwargs)

Bases: nucypher.config.base.CharacterConfiguration

class Felix(db_filepath: pathlib.Path, rest_host: str, rest_port: int, client_password: str = None, crash_on_error: bool = False, distribute_ether: bool = True, registry: nucypher.blockchain.eth.registry.BaseContractRegistry = None, *args, **kwargs)

Bases: nucypher.characters.base.Character, nucypher.blockchain.eth.actors.NucypherTokenActor

A NuCypher ERC20 faucet / Airdrop scheduler.

Felix is a web application that gives NuCypher testnet tokens to registered addresses with a scheduled reduction of disbursement amounts, and an HTTP endpoint for handling new address registration.

The main goal of Felix is to provide a source of testnet tokens for research and the development of production-ready nucypher dApps.

BATCH_SIZE = 10
DISBURSEMENT_INTERVAL = 8760
DISTRIBUTION_INTERVAL = 60
ETHER_AIRDROP_AMOUNT = 100000000000000000
LEARNING_TIMEOUT = 30
MAX_INDIVIDUAL_REGISTRATIONS = 3
MINIMUM_DISBURSEMENT = 1000000000000000000
MULTIPLIER = Decimal('0.9')
exception NoDatabase

Bases: RuntimeError

STAGING_DELAY = 10
airdrop_tokens()

Calculate airdrop eligibility via faucet registration and transfer tokens to selected recipients.

create_tables()None
make_web_app()
start(host: str, port: int, web_services: bool = True, distribution: bool = True, crash_on_error: bool = False)
start_distribution(now: bool = True)bool

Start token distribution

start_learning_loop(now=False)

Felix needs to not even be a Learner, but since it is at the moment, it certainly needs not to learn.

stop_distribution()bool

Start token distribution

CHARACTER_CLASS

alias of nucypher.characters.chaotic.Felix

NAME = 'felix'
DEFAULT_DB_NAME = 'felix.db'
DEFAULT_REST_PORT = 6151
DEFAULT_LEARNER_PORT = 9151
DEFAULT_REST_HOST = '127.0.0.1'
static_payload()dict

Exported static configuration values for initializing Ursula

class StakeHolderConfiguration(checksum_addresses: set = None, *args, **kwargs)

Bases: nucypher.config.base.CharacterConfiguration

NAME = 'stakeholder'
CHARACTER_CLASS

alias of nucypher.blockchain.eth.actors.StakeHolder

static_payload()dict

Values to read/write from stakeholder JSON configuration files

property dynamic_payload

Exported dynamic configuration values for initializing Ursula. These values are used to init a character instance but are not saved to the JSON configuration.

classmethod assemble(filepath: Optional[pathlib.Path] = None, **overrides)dict

Warning: This method allows mutation and may result in an inconsistent configuration.

classmethod generate_runtime_filepaths(config_root: pathlib.Path)dict

Dynamically generate paths based on configuration root directory

initialize(password: Optional[str] = None)pathlib.Path

Initialize a new configuration and write installation files to disk.

classmethod generate(*args, **kwargs)

Shortcut: Hook-up a new initial installation configuration.

to_configuration_file(override: bool = True, *args, **kwargs)pathlib.Path
SeednodeMetadata

alias of nucypher.config.constants.seednode

class NodeStorage(federated_only: bool, character_class=None, registry: nucypher.blockchain.eth.registry.BaseContractRegistry = None)

Bases: abc.ABC

TLS_CERTIFICATE_ENCODING = 'PEM'
TLS_CERTIFICATE_EXTENSION = '.pem'
exception NodeStorageError

Bases: Exception

exception UnknownNode

Bases: nucypher.config.storages.NodeStorage.NodeStorageError

abstract property source

Human readable source string

encode_node_bytes(node_bytes)
decode_node_bytes(encoded_node)bytes
abstract store_node_certificate(certificate: cryptography.x509.base.Certificate, port: int)pathlib.Path
abstract store_node_metadata(node, filepath: Optional[pathlib.Path] = None)pathlib.Path

Save a single node’s metadata and tls certificate

abstract generate_certificate_filepath(host: str, port: int)pathlib.Path
abstract payload()dict
abstract classmethod from_payload(data: dict, *args, **kwargs)nucypher.config.storages.NodeStorage

Instantiate a storage object from a dictionary

abstract initialize()

One-time initialization steps to establish a node storage backend

abstract all(federated_only: bool, certificates_only: bool = False)set

Return s set of all stored nodes

abstract get(checksum_address: str, federated_only: bool)

Retrieve a single stored node

abstract clear()bool

Remove all stored nodes

class ForgetfulNodeStorage(parent_dir: Optional[pathlib.Path] = None, *args, **kwargs)

Bases: nucypher.config.storages.NodeStorage

property source

Human readable source string

all(federated_only: bool, certificates_only: bool = False)set

Return s set of all stored nodes

get(federated_only: bool, host: str = None, stamp: nucypher.crypto.signing.SignatureStamp = None, certificate_only: bool = False)

Retrieve a single stored node

forget()bool
store_node_certificate(certificate: cryptography.x509.base.Certificate, port: int)pathlib.Path
store_node_metadata(node, filepath: Optional[pathlib.Path] = None)bytes

Save a single node’s metadata and tls certificate

generate_certificate_filepath(host: str, port: int)pathlib.Path
clear(metadata: bool = True, certificates: bool = True)None

Forget all stored nodes and certificates

payload()dict
classmethod from_payload(payload: dict, *args, **kwargs)nucypher.config.storages.ForgetfulNodeStorage

Alternate constructor to create a storage instance from JSON-like configuration

initialize()

One-time initialization steps to establish a node storage backend

class LocalFileBasedNodeStorage(config_root: Optional[pathlib.Path] = None, storage_root: Optional[pathlib.Path] = None, metadata_dir: Optional[pathlib.Path] = None, certificates_dir: Optional[pathlib.Path] = None, *args, **kwargs)

Bases: nucypher.config.storages.NodeStorage

exception NoNodeMetadataFileFound

Bases: FileNotFoundError, nucypher.config.storages.NodeStorage.UnknownNode

exception InvalidNodeMetadata

Bases: nucypher.config.storages.NodeStorage.NodeStorageError

Node metadata is corrupt or not possible to parse

property source

Human readable source string

encode_node_bytes(node_bytes)bytes
decode_node_bytes(encoded_node)bytes
generate_certificate_filepath(host: str, port: int)pathlib.Path
all(federated_only: bool, certificates_only: bool = False) → Set[Union[Any, cryptography.x509.base.Certificate]]

Return s set of all stored nodes

get(stamp: Union[nucypher.crypto.signing.SignatureStamp, str], federated_only: bool, certificate_only: bool = False)

Retrieve a single stored node

store_node_certificate(certificate: cryptography.x509.base.Certificate, port: int, force: bool = True)
store_node_metadata(node, filepath: Optional[pathlib.Path] = None)pathlib.Path

Save a single node’s metadata and tls certificate

clear(metadata: bool = True, certificates: bool = True)None

Forget all stored nodes and certificates

payload()dict
classmethod from_payload(payload: dict, *args, **kwargs)nucypher.config.storages.LocalFileBasedNodeStorage

Instantiate a storage object from a dictionary

initialize()

One-time initialization steps to establish a node storage backend

class TemporaryFileBasedNodeStorage(*args, **kwargs)

Bases: nucypher.config.storages.LocalFileBasedNodeStorage

initialize()

One-time initialization steps to establish a node storage backend

cast_paths_from(cls, payload)

A serialization helper. Iterates over constructor arguments of cls and cls parents. Finds arguments of type pathlib.Path or Optional[pathlib.Path]. Based on this, it casts corresponding values in payload from str to pathlib.Path or None.