from __future__ import annotations from typing import TYPE_CHECKING if TYPE_CHECKING: from core.essentials.observers.ConnectionObserver import ConnectionObserver from core.observers.TicketObserver import TicketObserver # from core.services.prepare_tickets.get_public_key_by_config import ( get_public_key_from_LOCAL_files_only, ) from core.services.failed_verification.is_the_key_to_blame import is_the_key_to_blame from core.services.failed_verification.prep_with_previously_saved_blind_sigs import ( prep_with_previously_saved_blind_sigs, ) def evaluate_if_its_the_key( failed_validations: list, ticket_observer: TicketObserver, connection_observer: ConnectionObserver, ) -> dict: if ( failed_validations == [] or failed_validations == None or failed_validations == False ): return {"valid": False, "message": "no_failed_verifications"} # which key was originally being used: local_results = get_public_key_from_LOCAL_files_only(connection_observer) if "public_key" not in local_results: return local_results old_public_key = local_results["public_key"] did_it_help = is_the_key_to_blame( old_public_key, failed_validations, ticket_observer, connection_observer ) return did_it_help # This is technically a debug function if the orignal flow has an error in validation of blind sigs. # Then this exists so they can come back and try again with those blind sigs, that they have saved.: def prepare_tickets_with_saved_blind_sigs( ticket_observer: TicketObserver, connection_observer: ConnectionObserver ) -> dict: results = prep_with_previously_saved_blind_sigs( ticket_observer, connection_observer ) return results