def add_policy_arrangement(self, expiration, id, kfrag=None, alice_pubkey_sig=None, alice_signature=None, session=None) -> PolicyArrangement: """ Creates a PolicyArrangement to the Keystore. :return: The newly added PolicyArrangement object """ session = session or self._session_on_init_thread alice_key_instance = session.query(Key).filter_by( key_data=bytes(alice_pubkey_sig)).first() if not alice_key_instance: alice_key_instance = Key.from_umbral_key(alice_pubkey_sig, is_signing=True) new_policy_arrangement = PolicyArrangement( expiration, id, kfrag, alice_pubkey_sig=alice_key_instance, alice_signature=None, # bob_pubkey_sig.id ) session.add(new_policy_arrangement) session.commit() return new_policy_arrangement
def add_key(self, key, is_signing=True, session=None) -> Key: """ :param key: Keypair object to store in the keystore. :return: The newly added key object. """ session = session or self._session_on_init_thread fingerprint = fingerprint_from_key(key) key_data = bytes(key) new_key = Key(fingerprint, key_data, is_signing) session.add(new_key) session.commit() return new_key