



"""simple docstring"""

import os
import random
import sys

from . import cryptomath_module as cryptomath
from . import rabin_miller

a_			   =					3







def 							SCREAMING_SNAKE_CASE__      (		SCREAMING_SNAKE_CASE__ :  int			):



					"""simple docstring"""





					print("""Generating primitive root of p"""			)
					while True:
										snake_case_					:		Union[str, Any] 					=					random.randrange(3				,    SCREAMING_SNAKE_CASE__			)
										if pow(SCREAMING_SNAKE_CASE__				,    2				,    SCREAMING_SNAKE_CASE__			) == 1:
															continue
										if pow(SCREAMING_SNAKE_CASE__				,    SCREAMING_SNAKE_CASE__				,    SCREAMING_SNAKE_CASE__			) == 1:
															continue
										return g







def 							SCREAMING_SNAKE_CASE__      (		SCREAMING_SNAKE_CASE__ :  int			):



					"""simple docstring"""





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

					snake_case_					:		List[Any] 					=					(key_size, e_a, e_a, p)
					snake_case_					:		Any 					=					(key_size, d)

					return public_key, private_key







def 							SCREAMING_SNAKE_CASE__      (		SCREAMING_SNAKE_CASE__ :  str				,    SCREAMING_SNAKE_CASE__ :  int			):



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

					snake_case_					:		Optional[int] 					=					generate_key(SCREAMING_SNAKE_CASE__			)
					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 							SCREAMING_SNAKE_CASE__      (		):



					"""simple docstring"""





					print("""Making key files..."""			)
					make_key_files("""elgamal"""				,    2_0_4_8			)
					print("""Key files generation successful"""			)


if __name__ == "__main__":
				main()









"""simple docstring"""

import copy
from dataclasses import dataclass, field
from typing import ClassVar, Dict

from ..features import Audio, Features, Value
from .base import TaskTemplate







@dataclass(frozen=_UpperCAmelCase)
class    __lowercase     (					_UpperCAmelCase):







						"""simple docstring"""







						_A		:							str							       =		field(default="""automatic-speech-recognition"""					,    metadata={"""include_in_asdict_even_if_is_default""": True})
						_A		:							ClassVar[Features]							       =		Features({"""audio""": Audio()})
						_A		:							ClassVar[Features]							       =		Features({"""transcription""": Value("""string""")})
						_A		:							str							       =		"audio"
						_A		:							str							       =		"transcription"







						def 						__UpperCamelCase							(self   ,		lowercase__       ):
											if self.audio_column not in features:
																raise ValueError(f'Column {self.audio_column} is not present in features.'       )
											if not isinstance(features[self.audio_column]   ,		lowercase__       ):
																raise ValueError(f'Column {self.audio_column} is not an Audio type.'       )
											snake_case_					:		Optional[int] 					=					copy.deepcopy(self       )
											snake_case_					:		Tuple 					=					self.input_schema.copy()
											snake_case_					:		List[str] 					=					features[self.audio_column]
											snake_case_					:		Any 					=					input_schema
											return task_template







						@property
						def 						__UpperCamelCase							(self       ):
											return {self.audio_column: "audio", self.transcription_column: "transcription"}




