docs: def proof_req_attr_referents(proof_req: dict) -> dict:
      """
      Given a proof request with all requested attributes having cred def id restrictions,
      return its attribute referents by cred def id and attribute.
  
      The returned structure can be useful in populating the extra WQL query parameter
      in the credential search API.
  
      :param proof_req: proof request with all requested attribute specifications having cred def id restriction; e.g.,
  
      ::
  
          {
              'name": 'proof_req',
              'version': '0.0',
              'requested_attributes': {
                  '18_greenLevel_uuid': {
                      'restrictions': [
                          {
                              'cred_def_id': 'WgWxqztrNooG92RXvxSTWv:3:CL:18:tag'
                          }
                      ],
                      'name': 'greenLevel',
                      'non_revoked': {
                          'to': 1532367957,
                          'from': 1532367957
                      }
                  },
                  '18_legalName_uuid': {
                      'restrictions': [
                          {
                              'cred_def_id': 'WgWxqztrNooG92RXvxSTWv:3:CL:18:tag'
                          }
                      ],
                      'name': 'legalName',
                      'non_revoked': {
                          'to': 1532367957,
                          'from': 1532367957
                      }
                  },
                  '15_id_uuid': {  # this specification will not show up in response: no cred def id restriction :-(
                      'name': 'id',
                      'non_revoked': {
                          'to': 1532367957,
                          'from': 1532367957
                      }
                  }
              }
              'requested_predicates': {
              }
          }
  
      :return: nested dict mapping cred def id to name to proof request referent; e.g.,
  
      ::
  
          {
              'WgWxqztrNooG92RXvxSTWv:3:CL:18:tag': {
                  'legalName': '18_legalName_uuid'
                  'greenLevel': '18_greenLevel_uuid'
              }
          }
  
      """
  
      rv = {}
      for uuid, spec in proof_req['requested_attributes'].items():
          cd_id = None
          for restriction in spec.get('restrictions', []):
              cd_id = restriction.get('cred_def_id', None)
              if cd_id:
                  break
          if not cd_id:
              continue
          if cd_id not in rv:  # cd_id of None is not OK
              rv[cd_id] = {}
          rv[cd_id][spec['name']] = uuid
  
      return rv