import random


def calculate_Private_Key(bit_length: int, p: int):
    """
    Provided a byte length, find a random exponent (integer value)
    of that bit size -1  to use as a private key for Diffie-Hellman
    (Code from cocalc examples provided by Kevin)
    """
    upper_limit = (p - 2)
    lower_limit = ((p - 2) // 2)

    private_key = int(random.randint(lower_limit, upper_limit))
    return private_key