

from __future__ import annotations

from numpy import array, cos, cross, floataa, radians, sin
from numpy.typing import NDArray






def        SCREAMING_SNAKE_CASE__	(  lowerCamelCase__     ,			lowerCamelCase__     ,			lowerCamelCase__ = False      )  ->					list[float]:
	if radian_mode:
		return [magnitude * cos(lowerCamelCase__      ), magnitude * sin(lowerCamelCase__      )]
	return [magnitude * cos(radians(lowerCamelCase__      )      ), magnitude * sin(radians(lowerCamelCase__      )      )]






def        SCREAMING_SNAKE_CASE__	(  lowerCamelCase__     ,			lowerCamelCase__     ,			lowerCamelCase__ = 1_0**-1      )  ->					bool:
	__lowerCamelCase    :    NDArray[floataa] 	=			cross(lowerCamelCase__     ,			lowerCamelCase__      )
	__lowerCamelCase    :    float 	=			sum(lowerCamelCase__      )
	return abs(lowerCamelCase__      ) < eps


if __name__ == "__main__":
					# Test to check if it works
					a		=array(
					    [
					        polar_force(718.4, 180 - 30),
					        polar_force(879.54, 45),
					        polar_force(100, -90),
					    ]
					)

					a		=array([[0, 0], [0, 0], [0, 0]])

					assert in_static_equilibrium(forces, location)

					# Problem 1 in image_data/2D_problems.jpg
					a		=array(
					    [
					        polar_force(30 * 9.81, 15),
					        polar_force(215, 180 - 45),
					        polar_force(264, 90 - 30),
					    ]
					)

					a		=array([[0, 0], [0, 0], [0, 0]])

					assert in_static_equilibrium(forces, location)

					# Problem in image_data/2D_problems_1.jpg
					a		=array([[0, -2000], [0, -1200], [0, 15600], [0, -12400]])

					a		=array([[0, 0], [6, 0], [10, 0], [12, 0]])

					assert in_static_equilibrium(forces, location)

					import doctest

					doctest.testmod()







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




