


import os
import random
import sys

from . import cryptomath_module as cryptomath
from . import rabin_miller

UpperCAmelCase_				:			List[str]   =	3







def 	SCREAMING_SNAKE_CASE_						(      __A			:      int    )     ->		int:

       """simple docstring"""

       print('Generating primitive root of p'    )
       while True:
              a_ :		List[Any]							=  random.randrange(3  ,   lowerCamelCase__    )
              if pow(lowerCamelCase__  ,   2  ,   lowerCamelCase__    ) == 1:
                     continue
              if pow(lowerCamelCase__  ,   lowerCamelCase__  ,   lowerCamelCase__    ) == 1:
                     continue
              return g







def 	SCREAMING_SNAKE_CASE_						(      __A			:      int    )     ->		tuple[tuple[int, int, int, int], tuple[int, int]]:

       """simple docstring"""

       print('Generating prime p...'    )
       a_ :		List[str]							=  rabin_miller.generate_large_prime(lowerCamelCase__    )  # select large prime number.
       a_ :		str							=  primitive_root(lowerCamelCase__    )  # one primitive root on modulo p.
       a_ :		List[str]							=  random.randrange(3  ,   lowerCamelCase__    )  # private_key -> have to be greater than 2 for safety.
       a_ :		Tuple							=  cryptomath.find_mod_inverse(pow(lowerCamelCase__  ,   lowerCamelCase__  ,   lowerCamelCase__    )  ,   lowerCamelCase__    )

       a_ :		str							=  (key_size, e_a, e_a, p)
       a_ :		Dict							=  (key_size, d)

       return public_key, private_key







def 	SCREAMING_SNAKE_CASE_						(      __A			:      str  ,   __A			:      int    )     ->		None:

       """simple docstring"""

       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()

       a_ :		Optional[int]							=  generate_key(lowerCamelCase__    )
       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 	SCREAMING_SNAKE_CASE_						(      )     ->		None:

       """simple docstring"""

       print('Making key files...'    )
       make_key_files('elgamal'  ,   20_48    )
       print('Key files generation successful'    )


if __name__ == "__main__":
  main()






from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


UpperCAmelCase_				:			Union[str, Any]   =	{
    'configuration_whisper': ['WHISPER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'WhisperConfig', 'WhisperOnnxConfig'],
    'feature_extraction_whisper': ['WhisperFeatureExtractor'],
    'processing_whisper': ['WhisperProcessor'],
    'tokenization_whisper': ['WhisperTokenizer'],
}

try:
   if not is_tokenizers_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   UpperCAmelCase_				:			Optional[Any]   =	['WhisperTokenizerFast']

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   UpperCAmelCase_				:			int   =	[
       'WHISPER_PRETRAINED_MODEL_ARCHIVE_LIST',
       'WhisperForConditionalGeneration',
       'WhisperModel',
       'WhisperPreTrainedModel',
       'WhisperForAudioClassification',
   ]

try:
   if not is_tf_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   UpperCAmelCase_				:			int   =	[
       'TF_WHISPER_PRETRAINED_MODEL_ARCHIVE_LIST',
       'TFWhisperForConditionalGeneration',
       'TFWhisperModel',
       'TFWhisperPreTrainedModel',
   ]

try:
   if not is_flax_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   UpperCAmelCase_				:			Any   =	[
       'FlaxWhisperForConditionalGeneration',
       'FlaxWhisperModel',
       'FlaxWhisperPreTrainedModel',
       'FlaxWhisperForAudioClassification',
   ]


if TYPE_CHECKING:
   from .configuration_whisper import WHISPER_PRETRAINED_CONFIG_ARCHIVE_MAP, WhisperConfig, WhisperOnnxConfig
   from .feature_extraction_whisper import WhisperFeatureExtractor
   from .processing_whisper import WhisperProcessor
   from .tokenization_whisper import WhisperTokenizer

   try:
      if not is_tokenizers_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .tokenization_whisper_fast import WhisperTokenizerFast

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_whisper import (
          WHISPER_PRETRAINED_MODEL_ARCHIVE_LIST,
          WhisperForAudioClassification,
          WhisperForConditionalGeneration,
          WhisperModel,
          WhisperPreTrainedModel,
      )

   try:
      if not is_tf_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_tf_whisper import (
          TF_WHISPER_PRETRAINED_MODEL_ARCHIVE_LIST,
          TFWhisperForConditionalGeneration,
          TFWhisperModel,
          TFWhisperPreTrainedModel,
      )

   try:
      if not is_flax_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_flax_whisper import (
          FlaxWhisperForAudioClassification,
          FlaxWhisperForConditionalGeneration,
          FlaxWhisperModel,
          FlaxWhisperPreTrainedModel,
      )

else:
   import sys

   UpperCAmelCase_				:			int   =	_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)


