def _CID_validate_raw_digest(raw_digest: Union[(str, BytesLike)], hashfun: Multihash) -> bytes:
    if isinstance(raw_digest, str):
        raw_digest = bytes.fromhex(raw_digest)
    else:
        validate(raw_digest, BytesLike)
        if (not isinstance(raw_digest, bytes)):
            raw_digest = bytes(raw_digest)
    (_, max_digest_size) = hashfun.implementation
    _validate_raw_digest_size(hashfun.name, raw_digest, max_digest_size)
    return raw_digest
def _CID_validate_raw_digest(raw_digest: Union[(str, BytesLike)], hashfun: Multihash) -> bytes:
    if isinstance(raw_digest, str):
        raw_digest = bytes.fromhex(raw_digest)
    else:
        validate(raw_digest, BytesLike)
        if (not isinstance(raw_digest, bytes)):
            raw_digest = bytes(raw_digest)
    (_, max_digest_size) = hashfun.implementation
    _validate_raw_digest_size(hashfun.name, raw_digest, max_digest_size)
    return raw_digest