Given a credentials structure and an optional list of credential identifiers
    (aka wallet cred-ids, referents; specify None to include all), return dict mapping each
    credential identifier to a box ids structure (i.e., a dict specifying its corresponding
    schema identifier, credential definition identifier, and revocation registry identifier,
    the latter being None if cred def does not support revocation).

    :param creds: creds structure returned by (HolderProver agent) get_creds()
    :param cred_ids: list of credential identifiers for which to find corresponding schema identifiers, None for all
    :return: dict mapping each credential identifier to its corresponding box ids (empty dict if
        no matching credential identifiers present)

def box_ids(creds: dict, cred_ids: list = None) -> dict:
    """
    Given a credentials structure and an optional list of credential identifiers
    (aka wallet cred-ids, referents; specify None to include all), return dict mapping each
    credential identifier to a box ids structure (i.e., a dict specifying its corresponding
    schema identifier, credential definition identifier, and revocation registry identifier,
    the latter being None if cred def does not support revocation).

    :param creds: creds structure returned by (HolderProver agent) get_creds()
    :param cred_ids: list of credential identifiers for which to find corresponding schema identifiers, None for all
    :return: dict mapping each credential identifier to its corresponding box ids (empty dict if
        no matching credential identifiers present)
    """

    rv = {}
    for inner_creds in {**creds.get('attrs', {}), **creds.get('predicates', {})}.values():
        for cred in inner_creds:  # cred is a dict in a list of dicts
            cred_info = cred['cred_info']
            cred_id = cred_info['referent']
            if (cred_id not in rv) and (not cred_ids or cred_id in cred_ids):
                rv[cred_id] = {
                    'schema_id': cred_info['schema_id'],
                    'cred_def_id': cred_info['cred_def_id'],
                    'rev_reg_id': cred_info['rev_reg_id']
                }

    return rv