


'''simple docstring'''
import os
import random
import sys

from . import cryptomath_module as cryptomath
from . import rabin_miller

UpperCamelCase__    					=      3





def 					a__       (					lowerCAmelCase__						)    ->	int:
    print('''Generating primitive root of p'''						)
    while True:
        UpperCAmelCase__			:		List[str]													=				random.randrange(3  ,					lowerCAmelCase__						)
        if pow(lowerCAmelCase__  ,					2  ,					lowerCAmelCase__						) == 1:
            continue
        if pow(lowerCAmelCase__  ,					lowerCAmelCase__  ,					lowerCAmelCase__						) == 1:
            continue
        return g





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

    UpperCAmelCase__			:		Union[str, Any]													=				(key_size, e_a, e_a, p)
    UpperCAmelCase__			:		Tuple													=				(key_size, d)

    return public_key, private_key





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

    UpperCAmelCase__						,						UpperCAmelCase__			:		Tuple													=				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 					a__       (					)    ->	None:
    print('''Making key files...'''						)
    make_key_files('''elgamal'''  ,					20_48						)
    print('''Key files generation successful'''						)


if __name__ == "__main__":
  main()




'''simple docstring'''
import pprint

import requests

UpperCamelCase__    					=      '''https://zenquotes.io/api'''





def 					a__       (					)    ->	list:
    return requests.get(API_ENDPOINT_URL + '''/today'''						).json()





def 					a__       (					)    ->	list:
    return requests.get(API_ENDPOINT_URL + '''/random'''						).json()


if __name__ == "__main__":
  UpperCamelCase__    					=      random_quotes()
  pprint.pprint(response)
