






"""simple docstring"""





import os
import random
import sys

from . import cryptomath_module as cryptomath
from . import rabin_miller

UpperCamelCase_	:				List[Any]										= 3



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



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

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

      return public_key, private_key



def     __lowercase					(    a :				str       ,		a :				int )					->					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()

      __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'''       ,		2_048 )
      print('''Key files generation successful''' )


if __name__ == "__main__":
      main()










"""simple docstring"""





from typing import TYPE_CHECKING

from ...utils import _LazyModule


UpperCamelCase_	:				Union[str, Any]										= {"""tokenization_wav2vec2_phoneme""": ["""Wav2Vec2PhonemeCTCTokenizer"""]}


if TYPE_CHECKING:
    from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer
else:
    import sys

    UpperCamelCase_	:				List[Any]										= _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)


