import hashlib


def _validate_hash_powork(difficulty: int, powork: bytes) -> bool:
    """Check whether the proof of work fulfills the difficulty demands.

    The difficulty is given as number of leading 0.
    E.g. a diffulty of 4 means that powork has to be smaller than 0001....

    :difficulty: int:
        Difficulty level of the PoW, see above explanation
    :powork: bytes:
        The seed + nonce to validate
     :return: bool:
        True if the given PoW is valid, False otherwise
    """
    powork_bits_amount = len(powork) * 8
    target = 2 ** (powork_bits_amount - difficulty)

    first = hashlib.sha256(powork).digest()
    second = hashlib.sha256(first).digest()

    if int.from_bytes(second, byteorder='big') < target:
        return True
    else:
        return False