





import os
import random
import sys

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





def        lowerCamelCase__   (  )  ->					None:
				print("""Making key files..."""			)
				make_key_files("""rsa"""     , 10_24			)
				print("""Key files generation successful."""			)





def        lowerCamelCase__   (  _UpperCAmelCase			)  ->					tuple[tuple[int, int], tuple[int, int]]:
				print("""Generating prime p..."""			)
				lowerCamelCase			=rabinMiller.generate_large_prime(_UpperCAmelCase			)
				print("""Generating prime q..."""			)
				lowerCamelCase			=rabinMiller.generate_large_prime(_UpperCAmelCase			)
				lowerCamelCase			=p * q

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

				print("""Calculating d that is mod inverse of e..."""			)
				lowerCamelCase			=cryptoMath.find_mod_inverse(_UpperCAmelCase     , (p - 1) * (q - 1)			)

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





def        lowerCamelCase__   (  _UpperCAmelCase     , _UpperCAmelCase			)  ->					None:
				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()

				lowerCamelCase	,					lowerCamelCase			=generate_key(_UpperCAmelCase			)
				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()












# this script reports modified .py files under the desired list of top-level sub-dirs passed as a list of arguments, e.g.:
#   python ./utils/get_modified_files.py utils src tests examples
#
# it uses git to find the forking point and which files were modified - i.e. files not under git won't be considered
# since the output of this script is fed into Makefile commands it doesn't print a newline after the results

import re
import subprocess
import sys


UpperCAmelCase__  :     Union[str, Any]   			=subprocess.check_output('''git merge-base main HEAD'''.split()).decode('''utf-8''')
UpperCAmelCase__  :     List[str]   			=(
    subprocess.check_output(F"git diff --diff-filter=d --name-only {fork_point_sha}".split()).decode('''utf-8''').split()
)

UpperCAmelCase__  :     Tuple   			='''|'''.join(sys.argv[1:])
UpperCAmelCase__  :     List[str]   			=re.compile(rF"^({joined_dirs}).*?\.py$")

UpperCAmelCase__  :     Any   			=[x for x in modified_files if regex.match(x)]
print(''' '''.join(relevant_modified_files), end='''''')





