def get_nostr_ann_pow_amount(nostr_pubk: bytes, nonce: Optional[int]) -> int:
    """Return the amount of leading zero bits for a nostr announcement PoW."""
    if not nonce:
        return 0
    hash_function = hashlib.sha256
    hash_len_bits = 256
    hash_preimage = b'electrum-' + nostr_pubk

    digest = hash_function(hash_preimage + nonce.to_bytes(32, 'big')).digest()
    digest = int.from_bytes(digest, 'big')
    return hash_len_bits - digest.bit_length()
Return the amount of leading zero bits for a nostr announcement PoW.
electrum/util.py