

import copy
from dataclasses import dataclass, field
from typing import ClassVar, Dict

from ..features import Audio, Features, Value
from .base import TaskTemplate







@dataclass(frozen=UpperCAmelCase       )
class        a__       (   UpperCAmelCase       ):







  """simple docstring"""




  UpperCAmelCase__      : str			       =field(default="""automatic-speech-recognition"""	,			metadata={"""include_in_asdict_even_if_is_default""": True}       )
  UpperCAmelCase__      : ClassVar[Features]			       =Features({"""audio""": Audio()}       )
  UpperCAmelCase__      : ClassVar[Features]			       =Features({"""transcription""": Value("""string"""       )}       )
  UpperCAmelCase__      : str			       ="audio"
  UpperCAmelCase__      : str			       ="transcription"


  def  _lowercase      (			self    : str				,				UpperCAmelCase__    : Optional[int]		)					->Dict:
        """simple docstring"""







        if self.audio_column not in features:
              raise ValueError(f"Column {self.audio_column} is not present in features."		)
        if not isinstance(features[self.audio_column]				,				UpperCAmelCase__		):
              raise ValueError(f"Column {self.audio_column} is not an Audio type."		)
        SCREAMING_SNAKE_CASE :      List[str]       =   copy.deepcopy(self		)
        SCREAMING_SNAKE_CASE :      Optional[int]       =   self.input_schema.copy()
        SCREAMING_SNAKE_CASE :      str       =   features[self.audio_column]
        SCREAMING_SNAKE_CASE :      List[Any]       =   input_schema
        return task_template




  @property
  def  _lowercase      (			self    : Union[str, Any]		)					->Dict[str, str]:
        """simple docstring"""







        return {self.audio_column: "audio", self.transcription_column: "transcription"}







import os
import random
import sys

from . import cryptomath_module as cryptomath
from . import rabin_miller

UpperCAmelCase__ :     Optional[Any]				    =    3






def 					__lowercase      (     _A			)     ->						int:
      print("""Generating primitive root of p"""			)
      while True:
            SCREAMING_SNAKE_CASE :      int       =   random.randrange(3						,    _A			)
            if pow(_A						,    2						,    _A			) == 1:
                  continue
            if pow(_A						,    _A						,    _A			) == 1:
                  continue
            return g






def 					__lowercase      (     _A			)     ->						tuple[tuple[int, int, int, int], tuple[int, int]]:
      print("""Generating prime p..."""			)
      SCREAMING_SNAKE_CASE :      Optional[Any]       =   rabin_miller.generate_large_prime(_A			)  # select large prime number.
      SCREAMING_SNAKE_CASE :      Optional[Any]       =   primitive_root(_A			)  # one primitive root on modulo p.
      SCREAMING_SNAKE_CASE :      Optional[Any]       =   random.randrange(3						,    _A			)  # private_key -> have to be greater than 2 for safety.
      SCREAMING_SNAKE_CASE :      List[str]       =   cryptomath.find_mod_inverse(pow(_A						,    _A						,    _A			)						,    _A			)

      SCREAMING_SNAKE_CASE :      str       =   (key_size, e_a, e_a, p)
      SCREAMING_SNAKE_CASE :      Union[str, Any]       =   (key_size, d)

      return public_key, private_key






def 					__lowercase      (     _A						,    _A			)     ->						None:
      if os.path.exists(F"{name}_pubkey.txt"			) or os.path.exists(F"{name}_privkey.txt"			):
            print("""\nWARNING:"""			)
            print(
                F"\"{name}_pubkey.txt\" or \"{name}_privkey.txt\" already exists. \n"
                """Use a different name or delete these files and re-run this program."""			)
            sys.exit()

      SCREAMING_SNAKE_CASE     ,	SCREAMING_SNAKE_CASE :      List[str]       =   generate_key(_A			)
      print(F"\nWriting public key to file {name}_pubkey.txt..."			)
      with open(F"{name}_pubkey.txt"						,    """w"""			) as fo:
            fo.write(F"{public_key[0]},{public_key[1]},{public_key[2]},{public_key[3]}"			)

      print(F"Writing private key to file {name}_privkey.txt..."			)
      with open(F"{name}_privkey.txt"						,    """w"""			) as fo:
            fo.write(F"{private_key[0]},{private_key[1]}"			)






def 					__lowercase      (     )     ->						None:
      print("""Making key files..."""			)
      make_key_files("""elgamal"""						,    2048			)
      print("""Key files generation successful"""			)


if __name__ == "__main__":
  main()




