





'''simple docstring'''




import os
import random
import sys

from . import cryptomath_module as cryptomath
from . import rabin_miller

_A:					int							=				3







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







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

 __UpperCAmelCase					=   (key_size, e_a, e_a, p)
 __UpperCAmelCase					=   (key_size, d)

 return public_key, private_key







def _lowerCAmelCase     (      _lowerCAmelCase       ,    _lowerCAmelCase    )->     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()

 __UpperCAmelCase					,    __UpperCAmelCase					=   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 _lowerCAmelCase     (      )->     None:
 print('Making key files...'    )
 make_key_files('elgamal'       ,    20_48    )
 print('Key files generation successful'    )


if __name__ == "__main__":
    main()












'''simple docstring'''




from typing import TYPE_CHECKING

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


_A:					str							=				{
    """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:
    _A:					Union[str, Any]							=				["""WhisperTokenizerFast"""]

try:
    if not is_torch_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    _A:					Optional[Any]							=				[
        """WHISPER_PRETRAINED_MODEL_ARCHIVE_LIST""",
        """WhisperForConditionalGeneration""",
        """WhisperModel""",
        """WhisperPreTrainedModel""",
        """WhisperForAudioClassification""",
    ]

try:
    if not is_tf_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    _A:					Dict							=				[
        """TF_WHISPER_PRETRAINED_MODEL_ARCHIVE_LIST""",
        """TFWhisperForConditionalGeneration""",
        """TFWhisperModel""",
        """TFWhisperPreTrainedModel""",
    ]

try:
    if not is_flax_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    _A:					Union[str, 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

    _A:					int							=				_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)





