def bitstring_to_bytes(s: str) -> bytes:
    """ Converts a bitstring to a byte object.

    This function is necessary as certain libraries (specifically the base64 library) accepts byte objects, not strings
    which are often expressed in UTF-8 or ASCII formats.

    Parameters
    ----------
    s: str
        Bitstring to be converted to bytes object.

    Returns
    -------
    bytes
        Corresponding bitstring in bytes format.
    """
    return int(s, 2).to_bytes((len(s)+7) // 8, byteorder='big')