nucypher.datastore

Submodules

exception NotFound

Bases: Exception

Exception class for Datastore calls for objects that don’t exist.

class Datastore(sqlalchemy_engine=None)

Bases: object

A storage class of persistent cryptographic entities for use by Ursula.

kfrag_splitter = <bytestring_splitter.BytestringSplitter object>
add_key(key: umbral.keys.UmbralPublicKey, is_signing: bool = True, session=None)nucypher.datastore.db.models.Key
Parameters

key – Keypair object to store in the keystore.

Returns

The newly added key object.

get_key(fingerprint: bytes, session=None) → umbral.keys.UmbralPublicKey

Returns a key from the Datastore.

Parameters

fingerprint – Fingerprint, in bytes, of key to return

Returns

Keypair of the returned key.

del_key(fingerprint: bytes, session=None)

Deletes a key from the Datastore.

Parameters

fingerprint – Fingerprint of key to delete

add_policy_arrangement(expiration: maya.core.MayaDT, arrangement_id: bytes, kfrag: umbral.kfrags.KFrag = None, alice_verifying_key: umbral.keys.UmbralPublicKey = None, alice_signature: umbral.signing.Signature = None, session=None)nucypher.datastore.db.models.PolicyArrangement

Creates a PolicyArrangement to the Keystore.

Returns

The newly added PolicyArrangement object

get_policy_arrangement(arrangement_id: bytes, session=None)nucypher.datastore.db.models.PolicyArrangement

Retrieves a PolicyArrangement by its HRAC.

Returns

The PolicyArrangement object

get_all_policy_arrangements(session=None) → List[nucypher.datastore.db.models.PolicyArrangement]

Returns all the PolicyArrangements

Returns

The list of PolicyArrangement objects

attach_kfrag_to_saved_arrangement(alice, id_as_hex, kfrag, session=None)
del_policy_arrangement(arrangement_id: bytes, session=None)int

Deletes a PolicyArrangement from the Keystore.

del_expired_policy_arrangements(session=None, now=None)int

Deletes all expired PolicyArrangements from the Keystore.

save_workorder(bob_verifying_key: umbral.keys.UmbralPublicKey, bob_signature: umbral.signing.Signature, arrangement_id: bytes, session=None)nucypher.datastore.db.models.Workorder

Adds a Workorder to the keystore.

get_workorders(arrangement_id: bytes = None, bob_verifying_key: bytes = None, session=None) → List[nucypher.datastore.db.models.Workorder]

Returns a list of Workorders by HRAC.

del_workorders(arrangement_id: bytes, session=None)int

Deletes a Workorder from the Keystore.

class Keypair(private_key=None, public_key=None, generate_keys_if_needed=True)

Bases: object

A parent Keypair class for all types of Keypairs.

serialize_pubkey(as_b64=False)bytes

Serializes the pubkey for storage/transport in either urlsafe base64 or as a bytestring.

Parameters

as_b64 – Return the pubkey as urlsafe base64 byte string

Returns

The serialized pubkey in bytes

fingerprint()

Hashes the key using keccak-256 and returns the hexdigest in bytes.

Returns

Hexdigest fingerprint of key (keccak-256) in bytes

class DecryptingKeypair(*args, **kwargs)

Bases: nucypher.datastore.keypairs.Keypair

A keypair for Umbral

decrypt(message_kit: nucypher.crypto.kits.MessageKit)bytes

Decrypt data encrypted with Umbral.

Returns

bytes

class SigningKeypair(*args, **kwargs)

Bases: nucypher.datastore.keypairs.Keypair

A SigningKeypair that uses ECDSA.

sign(message: bytes)bytes

Signs a hashed message and returns a signature.

Parameters

message – The message to sign

Returns

Signature in bytes

get_signature_stamp()
class HostingKeypair(host: str, checksum_address: str = None, private_key: Union[umbral.keys.UmbralPrivateKey, umbral.keys.UmbralPublicKey] = None, curve=None, certificate=None, certificate_filepath: str = None, generate_certificate=True)

Bases: nucypher.datastore.keypairs.Keypair

A keypair for TLS’ing.

get_deployer(rest_app, port)
class ThreadedSession(sqlalchemy_engine)

Bases: object