def extractDidParts(did):
    """
    Parses and returns a tuple containing the prefix method and key string contained in the supplied did string.
    If the supplied string does not fit the pattern pre:method:keystr a ValueError is raised.

    :param did: W3C DID string

    :return: (pre, method, key string) a tuple containing the did parts.
    """
    try:  # correct did format  pre:method:keystr
        pre, meth, keystr = did.split(":")
    except ValueError as ex:
        raise ValueError("Malformed DID value")

    if not pre or not meth or not keystr:  # check for empty values
        raise ValueError("Malformed DID value")

    return pre, meth, keystr