'''simple docstring'''





import os
import random
import sys

from . import cryptomath_module as cryptomath
from . import rabin_miller

UpperCAmelCase_			    =							3




def       lowerCAmelCase_     (		lowercase:							str		)    ->				List[Any]:







 '''simple docstring'''
 print('''Generating primitive root of p'''		)
 while True:
  _UpperCamelCase:     Tuple							= random.randrange(3  ,					lowerCAmelCase_		)
  if pow(lowerCAmelCase_  ,					2  ,					lowerCAmelCase_		) == 1:
   continue
  if pow(lowerCAmelCase_  ,					lowerCAmelCase_  ,					lowerCAmelCase_		) == 1:
   continue
  return g




def       lowerCAmelCase_     (		lowercase:							int		)    ->				int:







 '''simple docstring'''
 print('''Generating prime p...'''		)
 _UpperCamelCase:     str							= rabin_miller.generate_large_prime(lowerCAmelCase_		)  # select large prime number.
 _UpperCamelCase:     int							= primitive_root(lowerCAmelCase_		)  # one primitive root on modulo p.
 _UpperCamelCase:     Tuple							= random.randrange(3  ,					lowerCAmelCase_		)  # private_key -> have to be greater than 2 for safety.
 _UpperCamelCase:     Any							= cryptomath.find_mod_inverse(pow(lowerCAmelCase_  ,					lowerCAmelCase_  ,					lowerCAmelCase_		)  ,					lowerCAmelCase_		)

 _UpperCamelCase:     Optional[Any]							= (key_size, e_a, e_a, p)
 _UpperCamelCase:     Optional[int]							= (key_size, d)

 return public_key, private_key




def       lowerCAmelCase_     (		lowercase:							int  ,					lowercase:							Optional[int]		)    ->				Tuple:







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

 _UpperCamelCase:     Tuple							= 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_     (		)    ->				Optional[int]:







 '''simple docstring'''
 print('''Making key files...'''		)
 make_key_files('''elgamal'''  ,					2_048		)
 print('''Key files generation successful'''		)


if __name__ == "__main__":
  main()
import warnings

from ..trainer import Trainer
from ..utils import logging


UpperCAmelCase_			    =							logging.get_logger(__name__)




class  __magic_name__  (		__a    ):





   """simple docstring"""




   def __init__(	self					:  List[Any]		,  _lowercase					:  int=None		,  **_lowercase					:  Optional[Any]							):



    """simple docstring"""



    warnings.warn(
        '''`SageMakerTrainer` is deprecated and will be removed in v5 of Transformers. You can use `Trainer` '''
        '''instead.'''		,  _lowercase		,  )
    super().__init__(args=_lowercase		,  **_lowercase							)