laniakea.msgstream package¶
Submodules¶
laniakea.msgstream.event_msg module¶
- class laniakea.msgstream.event_msg.EventEmitter(module)¶
Bases:
objectEmit events on the Laniakea Message Stream if the system is configured to do so. Otherwise do nothing.
- submit_event(subject, data)¶
Submit an event to a Lighthouse instance for publication.
- submit_event_for_mod(mod, subject, data)¶
Submit and event for a different module than what the :EventEmitter was created for.
- submit_event_for_tag(tag, data)¶
Submit and event and set a custom tag.
- laniakea.msgstream.event_msg.create_event_listen_socket(zmq_context, subscribed_tags=None)¶
Create a ZeroMQ socket that is listening to events published on a Lighthouse event publisher socket.
- Return type:
Socket
- laniakea.msgstream.event_msg.create_event_message(sender, tag, data, key)¶
Create and sign a new event message to send to a Laniakea Lighthouse instance for publication.
- laniakea.msgstream.event_msg.create_message_tag(module, subject)¶
Create a message type tag for internal Laniakea modules.
- laniakea.msgstream.event_msg.create_submit_socket(zmq_context)¶
Create a ZeroMQ socket that is connected to a Lighthouse instance in order to submit messages to it.
- laniakea.msgstream.event_msg.event_message_is_valid_and_signed(event)¶
Check if an event message is valid and has signatures attached.
- laniakea.msgstream.event_msg.submit_event_message(socket, sender, tag, data, key)¶
Create a new event message, sign it and send it via the specified socket.
- laniakea.msgstream.event_msg.verify_event_message(sender, event, key, assume_valid=False)¶
Verify the validity of this event, via its required fields as well as cryptographical signature.
laniakea.msgstream.signedjson module¶
- exception laniakea.msgstream.signedjson.SignatureVerifyException¶
Bases:
ExceptionA signature could not be verified
- laniakea.msgstream.signedjson.sign_json(json_object, signature_name, signing_key)¶
Sign the JSON object. Stores the signature in json_object[‘signatures’].
- Args:
json_object (dict): The JSON object to sign. signature_name (str): The name of the signing entity. signing_key (syutil.crypto.SigningKey): The key to sign the JSON with.
- Returns:
The modified, signed JSON object.
- laniakea.msgstream.signedjson.signature_ids(json_object, signature_name, supported_algorithms=None)¶
Does the JSON object have a signature for the given name? Args:
json_object (dict): The JSON object to check. signature_name (str): The name of the signing entity to check for supported_algorithms (list of str): List of supported signature
algorithms
- Returns:
list of key identifier strings.
- laniakea.msgstream.signedjson.verify_signed_json(json_object, signature_name, verify_key)¶
Check a signature on a signed JSON object.
- Args:
json_object (dict): The signed JSON object to check. signature_name (str): The name of the signature to check. verify_key (syutil.crypto.VerifyKey): The key to verify the signature.
- Raises:
InvalidSignature: If the signature isn’t valid
laniakea.msgstream.signing module¶
- laniakea.msgstream.signing.decode_signing_key_base64(algorithm, key_base64, version=0)¶
Decode a base64 encoded signing key Args:
algorithm (str): The algorithm the key is for (currently ‘ed25519’). version (str): Identifies this key out of the keys for this entity. key_base64 (str): Base64 encoded bytes of the key.
- Returns:
A SigningKey object.
- laniakea.msgstream.signing.decode_verify_key_bytes(key_id, key_bytes)¶
Decode a raw verify key Args:
key_id (str): Identifies this key out of the keys for this entity. key_bytes (str): Raw bytes of the key.
- Returns:
A VerifyKey object.
- laniakea.msgstream.signing.encode_signing_key_base64(key)¶
Encode a signing key as base64 Args:
key (SigningKey): A signing key to encode.
- Returns:
base64 encoded string.
- laniakea.msgstream.signing.encode_verify_key_base64(key)¶
Encode a verify key as base64 Args:
key (VerifyKey): A signing key to encode.
- Returns:
base64 encoded string.
- laniakea.msgstream.signing.generate_signing_key(version=0)¶
Generate a new signing key Args:
version (str): Identifies this key out the keys for this entity.
- Returns:
A SigningKey object.
- laniakea.msgstream.signing.get_verify_key(signing_key)¶
Get a verify key from a signing key
- laniakea.msgstream.signing.is_signing_algorithm_supported(key_id)¶
Is the signing algorithm for this key_id supported
- laniakea.msgstream.signing.keyfile_read_signing_key(fname)¶
Read signing key and signer ID from a Laniakea keyfile and return them as tuple. The resulting key can be used to sign new messages.
- laniakea.msgstream.signing.keyfile_read_verify_key(fname)¶
Read verify key and signer ID from a Laniakea keyfile and return them as tuple. The resulting key can be used to verify messages.
- laniakea.msgstream.signing.read_old_signing_keys(stream)¶
Reads a list of old keys from a stream Args:
stream : A stream to iterate for keys.
- Returns:
list of VerifyKey objects.
- laniakea.msgstream.signing.read_signing_keys(stream)¶
Reads a list of keys from a stream Args:
stream : A stream to iterate for keys.
- Returns:
list of SigningKey objects.
- laniakea.msgstream.signing.write_signing_keys(stream, keys)¶
Writes a list of keys to a stream. Args:
stream: Stream to write keys to. keys: List of SigningKey objects.
Module contents¶
- class laniakea.msgstream.EventEmitter(module)¶
Bases:
objectEmit events on the Laniakea Message Stream if the system is configured to do so. Otherwise do nothing.
- submit_event(subject, data)¶
Submit an event to a Lighthouse instance for publication.
- submit_event_for_mod(mod, subject, data)¶
Submit and event for a different module than what the :EventEmitter was created for.
- submit_event_for_tag(tag, data)¶
Submit and event and set a custom tag.
- exception laniakea.msgstream.SignatureVerifyException¶
Bases:
ExceptionA signature could not be verified
- laniakea.msgstream.create_event_listen_socket(zmq_context, subscribed_tags=None)¶
Create a ZeroMQ socket that is listening to events published on a Lighthouse event publisher socket.
- Return type:
Socket
- laniakea.msgstream.create_event_message(sender, tag, data, key)¶
Create and sign a new event message to send to a Laniakea Lighthouse instance for publication.
- laniakea.msgstream.create_message_tag(module, subject)¶
Create a message type tag for internal Laniakea modules.
- laniakea.msgstream.create_submit_socket(zmq_context)¶
Create a ZeroMQ socket that is connected to a Lighthouse instance in order to submit messages to it.
- laniakea.msgstream.event_message_is_valid_and_signed(event)¶
Check if an event message is valid and has signatures attached.
- laniakea.msgstream.keyfile_read_signing_key(fname)¶
Read signing key and signer ID from a Laniakea keyfile and return them as tuple. The resulting key can be used to sign new messages.
- laniakea.msgstream.keyfile_read_verify_key(fname)¶
Read verify key and signer ID from a Laniakea keyfile and return them as tuple. The resulting key can be used to verify messages.
- laniakea.msgstream.submit_event_message(socket, sender, tag, data, key)¶
Create a new event message, sign it and send it via the specified socket.
- laniakea.msgstream.verify_event_message(sender, event, key, assume_valid=False)¶
Verify the validity of this event, via its required fields as well as cryptographical signature.