






'''simple docstring'''





import os
import random
import sys

from . import cryptomath_module as cryptoMath  # noqa: N812
from . import rabin_miller as rabinMiller  # noqa: N812







def      snake_case		(							):
				print('Making key files...'   )
				make_key_files('rsa',						10_24   )
				print('Key files generation successful.'   )







def      snake_case		(							UpperCAmelCase	:       Union[str, Any]   ):
				print('Generating prime p...'   )
				A	 =      rabinMiller.generate_large_prime(__lowerCAmelCase   )
				print('Generating prime q...'   )
				A	 =      rabinMiller.generate_large_prime(__lowerCAmelCase   )
				A	 =      p * q

				print('Generating e that is relatively prime to (p - 1) * (q - 1)...'   )
				while True:
								A	 =      random.randrange(2 ** (key_size - 1),						2 ** (key_size)   )
								if cryptoMath.gcd(__lowerCAmelCase,						(p - 1) * (q - 1)   ) == 1:
												break

				print('Calculating d that is mod inverse of e...'   )
				A	 =      cryptoMath.find_mod_inverse(__lowerCAmelCase,						(p - 1) * (q - 1)   )

				A	 =      (n, e)
				A	 =      (n, d)
				return (public_key, private_key)







def      snake_case		(							UpperCAmelCase	:       List[Any],						UpperCAmelCase	:       Union[str, Any]   ):
				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()

				A	 =      generate_key(__lowerCAmelCase   )
				print(f'\nWriting public key to file {name}_pubkey.txt...'   )
				with open(f'{name}_pubkey.txt',						'w'   ) as out_file:
								out_file.write(f'{key_size},{public_key[0]},{public_key[1]}'   )

				print(f'Writing private key to file {name}_privkey.txt...'   )
				with open(f'{name}_privkey.txt',						'w'   ) as out_file:
								out_file.write(f'{key_size},{private_key[0]},{private_key[1]}'   )


if __name__ == "__main__":
					main()













import os


# All paths are set with the intent you should run this script from the root of the repo with the command
# python utils/check_doctest_list.py
lowerCAmelCase_           = '.'


if __name__ == "__main__":
					lowerCAmelCase_           = os.path.join(REPO_PATH, 'utils/documentation_tests.txt')
					lowerCAmelCase_           = []
					lowerCAmelCase_           = []
					with open(doctest_file_path) as fp:
										for line in fp:
															lowerCAmelCase_           = line.strip()
															lowerCAmelCase_           = os.path.join(REPO_PATH, line)
															if not (os.path.isfile(path) or os.path.isdir(path)):
																				non_existent_paths.append(line)
															all_paths.append(path)
					if len(non_existent_paths) > 0:
										lowerCAmelCase_           = '\n'.join(non_existent_paths)
										raise ValueError(f'''`utils/documentation_tests.txt` contains non-existent paths:\n{non_existent_paths}''')
					if all_paths != sorted(all_paths):
										raise ValueError('Files in `utils/documentation_tests.txt` are not in alphabetical order.')





