def _populate_cred_def_ids(proof_req: dict, creds: list):
    """
    Populate cred_def_id for each attribute in proof request if not defined
    """
    cdef_map = {}
    default_cred_def_id = None
    for cred in creds:
        if 'cred_info' in cred:
            cred = cred['cred_info']
        cdef_map[cred['schema_id']] = cred['cred_def_id']
        if len(creds) == 1:
            default_cred_def_id = cred['cred_def_id']
    for attr in proof_req['requested_attributes'].values():
        attr_cdef_id = None
        attr_schema_id = None
        for rest in attr['restrictions']:
            attr_cdef_id = rest.get('cred_def_id', attr_cdef_id)
            attr_schema_id = rest.get('schema_id', attr_schema_id)
        if not attr_cdef_id:
            if attr_schema_id and attr_schema_id in cdef_map:
                attr['restrictions'].append({'cred_def_id': cdef_map[
                    attr_schema_id]})
            elif default_cred_def_id:
                attr['restrictions'].append({'cred_def_id':
                    default_cred_def_id})
        if 'non_revoked' not in attr:
            attr['non_revoked'] = {}
