




import os
import random
import sys

from . import cryptomath_module as cryptomath
from . import rabin_miller

snake_case_ : Optional[Any]    		=       3


def    A						(__A   :    int       )   ->      int:







     """simple docstring"""


     print('''Generating primitive root of p'''       )
     while True:
          UpperCAmelCase_          =							random.randrange(3   ,				__A       )
          if pow(__A   ,				2   ,				__A       ) == 1:
               continue
          if pow(__A   ,				__A   ,				__A       ) == 1:
               continue
          return g


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







     """simple docstring"""


     print('''Generating prime p...'''       )
     UpperCAmelCase_          =							rabin_miller.generate_large_prime(__A       )  # select large prime number.
     UpperCAmelCase_          =							primitive_root(__A       )  # one primitive root on modulo p.
     UpperCAmelCase_          =							random.randrange(3   ,				__A       )  # private_key -> have to be greater than 2 for safety.
     UpperCAmelCase_          =							cryptomath.find_mod_inverse(pow(__A   ,				__A   ,				__A       )   ,				__A       )

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

     return public_key, private_key


def    A						(__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()

     UpperCAmelCase_     ,       UpperCAmelCase_          =							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    A						()   ->      None:







     """simple docstring"""


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


if __name__ == "__main__":
    main()












from typing import TYPE_CHECKING

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


snake_case_ : int    		=       {
    "configuration_deberta": ["DEBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP", "DebertaConfig", "DebertaOnnxConfig"],
    "tokenization_deberta": ["DebertaTokenizer"],
}

try:
    if not is_tokenizers_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    snake_case_ : int    		=       ["DebertaTokenizerFast"]

try:
    if not is_torch_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    snake_case_ : List[str]    		=       [
        "DEBERTA_PRETRAINED_MODEL_ARCHIVE_LIST",
        "DebertaForMaskedLM",
        "DebertaForQuestionAnswering",
        "DebertaForSequenceClassification",
        "DebertaForTokenClassification",
        "DebertaModel",
        "DebertaPreTrainedModel",
    ]

try:
    if not is_tf_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    snake_case_ : Any    		=       [
        "TF_DEBERTA_PRETRAINED_MODEL_ARCHIVE_LIST",
        "TFDebertaForMaskedLM",
        "TFDebertaForQuestionAnswering",
        "TFDebertaForSequenceClassification",
        "TFDebertaForTokenClassification",
        "TFDebertaModel",
        "TFDebertaPreTrainedModel",
    ]


if TYPE_CHECKING:
    from .configuration_deberta import DEBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP, DebertaConfig, DebertaOnnxConfig
    from .tokenization_deberta import DebertaTokenizer

    try:
        if not is_tokenizers_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .tokenization_deberta_fast import DebertaTokenizerFast

    try:
        if not is_torch_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_deberta import (
            DEBERTA_PRETRAINED_MODEL_ARCHIVE_LIST,
            DebertaForMaskedLM,
            DebertaForQuestionAnswering,
            DebertaForSequenceClassification,
            DebertaForTokenClassification,
            DebertaModel,
            DebertaPreTrainedModel,
        )

    try:
        if not is_tf_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_tf_deberta import (
            TF_DEBERTA_PRETRAINED_MODEL_ARCHIVE_LIST,
            TFDebertaForMaskedLM,
            TFDebertaForQuestionAnswering,
            TFDebertaForSequenceClassification,
            TFDebertaForTokenClassification,
            TFDebertaModel,
            TFDebertaPreTrainedModel,
        )


else:
    import sys

    snake_case_ : Dict    		=       _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)






