


'''simple docstring'''
import os
import random
import sys

from . import cryptomath_module as cryptomath
from . import rabin_miller

__snake_case				 =	3


def      a (     __a  )    ->      Dict:



					'''simple docstring'''






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


def      a (     __a  )    ->      List[str]:



					'''simple docstring'''






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

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

					return public_key, private_key


def      a (     __a					,   __a  )    ->      Dict:



					'''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__  :Optional[Any]				   =					generate_key(_UpperCamelCase  )
					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      a (     )    ->      List[Any]:



					'''simple docstring'''






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


if __name__ == "__main__":
		main()







'''simple docstring'''
from typing import TYPE_CHECKING

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


UpperCamelCase__			=      {
    'configuration_funnel': ['FUNNEL_PRETRAINED_CONFIG_ARCHIVE_MAP', 'FunnelConfig'],
    'convert_funnel_original_tf_checkpoint_to_pytorch': [],
    'tokenization_funnel': ['FunnelTokenizer'],
}

try:
 if not is_tokenizers_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 UpperCamelCase__			=      ['FunnelTokenizerFast']

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 UpperCamelCase__			=      [
     'FUNNEL_PRETRAINED_MODEL_ARCHIVE_LIST',
     'FunnelBaseModel',
     'FunnelForMaskedLM',
     'FunnelForMultipleChoice',
     'FunnelForPreTraining',
     'FunnelForQuestionAnswering',
     'FunnelForSequenceClassification',
     'FunnelForTokenClassification',
     'FunnelModel',
     'FunnelPreTrainedModel',
     'load_tf_weights_in_funnel',
 ]

try:
 if not is_tf_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 UpperCamelCase__			=      [
     'TF_FUNNEL_PRETRAINED_MODEL_ARCHIVE_LIST',
     'TFFunnelBaseModel',
     'TFFunnelForMaskedLM',
     'TFFunnelForMultipleChoice',
     'TFFunnelForPreTraining',
     'TFFunnelForQuestionAnswering',
     'TFFunnelForSequenceClassification',
     'TFFunnelForTokenClassification',
     'TFFunnelModel',
     'TFFunnelPreTrainedModel',
 ]


if TYPE_CHECKING:
 from .configuration_funnel import FUNNEL_PRETRAINED_CONFIG_ARCHIVE_MAP, FunnelConfig
 from .tokenization_funnel import FunnelTokenizer

 try:
  if not is_tokenizers_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .tokenization_funnel_fast import FunnelTokenizerFast

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_funnel import (
      FUNNEL_PRETRAINED_MODEL_ARCHIVE_LIST,
      FunnelBaseModel,
      FunnelForMaskedLM,
      FunnelForMultipleChoice,
      FunnelForPreTraining,
      FunnelForQuestionAnswering,
      FunnelForSequenceClassification,
      FunnelForTokenClassification,
      FunnelModel,
      FunnelPreTrainedModel,
      load_tf_weights_in_funnel,
  )

 try:
  if not is_tf_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_tf_funnel import (
      TF_FUNNEL_PRETRAINED_MODEL_ARCHIVE_LIST,
      TFFunnelBaseModel,
      TFFunnelForMaskedLM,
      TFFunnelForMultipleChoice,
      TFFunnelForPreTraining,
      TFFunnelForQuestionAnswering,
      TFFunnelForSequenceClassification,
      TFFunnelForTokenClassification,
      TFFunnelModel,
      TFFunnelPreTrainedModel,
  )

else:
 import sys

 UpperCamelCase__			=      _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)




