

import math






def        SCREAMING_SNAKE_CASE__	(  lowerCamelCase__      )  ->					bool:
	__lowerCamelCase    :    List[str] 	=			math.loga(math.sqrt(4 * positive_integer + 1      ) / 2 + 1 / 2      )

	return exponent == int(lowerCamelCase__      )






def        SCREAMING_SNAKE_CASE__	(  lowerCamelCase__ = 1 / 1_2_3_4_5      )  ->					int:
	__lowerCamelCase    :    Union[str, Any] 	=			0
	__lowerCamelCase    :    Optional[int] 	=			0

	__lowerCamelCase    :    Any 	=			3
	while True:
		__lowerCamelCase    :    Union[str, Any] 	=			(integer**2 - 1) / 4
		# if candidate is an integer, then there is a partition for k
		if partition_candidate == int(lowerCamelCase__      ):
			__lowerCamelCase    :    List[str] 	=			int(lowerCamelCase__      )
			total_partitions += 1
			if check_partition_perfect(lowerCamelCase__      ):
				perfect_partitions += 1
		if perfect_partitions > 0:
			if perfect_partitions / total_partitions < max_proportion:
				return int(lowerCamelCase__      )
		integer += 1


if __name__ == "__main__":
					print(F"""{solution() = }""")







import os
import random
import sys

from . import cryptomath_module as cryptomath
from . import rabin_miller

a		=3






def        SCREAMING_SNAKE_CASE__	(  lowerCamelCase__      )  ->					int:
	print('Generating primitive root of p'      )
	while True:
		__lowerCamelCase    :    Tuple 	=			random.randrange(3     ,			lowerCamelCase__      )
		if pow(lowerCamelCase__     ,			2     ,			lowerCamelCase__      ) == 1:
			continue
		if pow(lowerCamelCase__     ,			lowerCamelCase__     ,			lowerCamelCase__      ) == 1:
			continue
		return g






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

	__lowerCamelCase    :    int 	=			(key_size, e_a, e_a, p)
	__lowerCamelCase    :    str 	=			(key_size, d)

	return public_key, private_key






def        SCREAMING_SNAKE_CASE__	(  lowerCamelCase__     ,			lowerCamelCase__      )  ->					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    :    List[Any] 	=			generate_key(lowerCamelCase__      )
	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__	(  )  ->					None:
	print('Making key files...'      )
	make_key_files('elgamal'     ,			2_0_4_8      )
	print('Key files generation successful'      )


if __name__ == "__main__":
					main()




