

'''simple docstring'''

def 				UpperCamelCase(					UpperCAmelCase_     ):
 return 10 - x * x




def 				UpperCamelCase(					UpperCAmelCase_  ,	UpperCAmelCase_     ):




 if equation(UpperCAmelCase_     ) * equation(UpperCAmelCase_     ) >= 0:
  raise ValueError('Wrong space!'     )

 UpperCAmelCase	:     Any						 =			a
 while (b - a) >= 0.01:
  # Find middle point
  UpperCAmelCase	:     Dict						 =			(a + b) / 2
  # Check if middle point is root
  if equation(UpperCAmelCase_     ) == 0.0:
   break
  # Decide the side to repeat the steps
  if equation(UpperCAmelCase_     ) * equation(UpperCAmelCase_     ) < 0:
   UpperCAmelCase	:     str						 =			c
  else:
   UpperCAmelCase	:     Optional[int]						 =			c
 return c


if __name__ == "__main__":
 import doctest

 doctest.testmod()

 print(bisection(-2, 5))
 print(bisection(0, 6))







'''simple docstring'''

import os
import random
import sys

from . import cryptomath_module as cryptomath
from . import rabin_miller

lowercase__         =      3




def 				UpperCamelCase(					UpperCAmelCase_     ):
 print('Generating primitive root of p'     )
 while True:
  UpperCAmelCase	:     Union[str, Any]						 =			random.randrange(3  ,	UpperCAmelCase_     )
  if pow(UpperCAmelCase_  ,	2  ,	UpperCAmelCase_     ) == 1:
   continue
  if pow(UpperCAmelCase_  ,	UpperCAmelCase_  ,	UpperCAmelCase_     ) == 1:
   continue
  return g




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

 UpperCAmelCase	:     Tuple						 =			(key_size, e_a, e_a, p)
 UpperCAmelCase	:     Optional[int]						 =			(key_size, d)

 return public_key, private_key




def 				UpperCamelCase(					UpperCAmelCase_  ,	UpperCAmelCase_     ):
 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()

 UpperCAmelCase ,			UpperCAmelCase	:     Dict						 =			generate_key(UpperCAmelCase_     )
 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 				UpperCamelCase(					):
 print('Making key files...'     )
 make_key_files('elgamal'  ,	20_48     )
 print('Key files generation successful'     )


if __name__ == "__main__":
 main()




