Ejemplo n.º 1
0
 def post(self, request, *args, **kwargs):
     """  
 Generates a proof from a proof request and set of filters.
 """
     proofRequestWithFilters = request.body.decode('utf-8')
     proofRequestProcesser = ProofRequestProcesser(proofRequestWithFilters)
     proofResponse = proofRequestProcesser.ConstructProof()
     return JsonResponse(proofResponse)
Ejemplo n.º 2
0
    def get(self, request, *args, **kwargs):
        """
        Verifies a verifiable claim given a verifiable claim id
        """
        __logger = logging.getLogger(__name__)
        verifiableClaimId = self.kwargs.get("id")
        if verifiableClaimId is not None:
            verifiableClaim = VerifiableClaim.objects.get(id=verifiableClaimId)

            claimType = verifiableClaim.claimType

            issuerService = claimType.issuerServiceId

            proofRequestBuilder = ProofRequestBuilder(
                claimType.schemaName, claimType.schemaVersion
            )

            proofRequestBuilder.matchCredential(
                verifiableClaim.claimJSON,
                claimType.schemaName,
                claimType.schemaVersion,
                issuerService.DID,
            )

            legal_entity_id = None
            try:
                legal_entity_id = json.loads(verifiableClaim.claimJSON)["values"][
                    "legal_entity_id"
                ]["raw"]
                __logger.debug("Claim for legal_entity_id: %s" %
                               legal_entity_id)
            except Error as e:
                # no-op
                self.__logger.debug("Claim for NO legal_entity_id")

            proofRequest = proofRequestBuilder.asDict()
            proofRequestWithFilters = {
                "filters": {"legal_entity_id": legal_entity_id},
                "proof_request": proofRequest,
            }

            proofRequestProcesser = ProofRequestProcesser(
                json.dumps(proofRequestWithFilters)
            )
            proofResponse = proofRequestProcesser.ConstructProof()

            return JsonResponse({"success": True, "proof": proofResponse})

        return JsonResponse({"success": False})
Ejemplo n.º 3
0
  def get(self, request, *args, **kwargs):
    """
    Verifies a verifiable claim given a verifiable claim id
    """
    verifiableClaimId = self.kwargs.get('id')
    if verifiableClaimId is not None:
      verifiableClaim = VerifiableClaim.objects.get(id=verifiableClaimId)
      claimType = verifiableClaim.claimType

      proofRequestBuilder = ProofRequestBuilder(
        claimType.schemaName,
        claimType.schemaVersion
      )

      proofRequestBuilder.matchCredential(
        verifiableClaim.claimJSON,
        claimType.schemaName,
        claimType.schemaVersion
      )

      proofRequest = proofRequestBuilder.asDict()

      # Looks like credential data is stored as a stringified json in the claim object
      claimJSON = json.loads(verifiableClaim.claimJSON)
      legal_entity_id = ''
      if claimJSON['values'] and claimJSON['values']['legal_entity_id']:
        # values are stored as arrays of length 2 ex "'country': ['US', '5187646771']". element 0 is the plaintext value
        legal_entity_id = claimJSON['values']['legal_entity_id'][0]

      proofRequestWithFilters = {
        'filters': {},
        'proof_request': proofRequest
      }
      if (legal_entity_id):
        proofRequestWithFilters['filters'] = {
            'legal_entity_id': legal_entity_id
        }

      proofRequestProcesser = ProofRequestProcesser(json.dumps(proofRequestWithFilters))
      proofResponse = proofRequestProcesser.ConstructProof()

      return JsonResponse({'success': True, 'proof': proofResponse})

    return JsonResponse({'success': False})
Ejemplo n.º 4
0
    def get(self, request, *args, **kwargs):
        """
    Verifies a verifiable claim given a verifiable claim id
    """
        __logger = logging.getLogger(__name__)
        verifiableClaimId = self.kwargs.get('id')
        if verifiableClaimId is not None:
            verifiableClaim = VerifiableClaim.objects.get(id=verifiableClaimId)
            claimType = verifiableClaim.claimType

            proofRequestBuilder = ProofRequestBuilder(claimType.schemaName,
                                                      claimType.schemaVersion)

            proofRequestBuilder.matchCredential(verifiableClaim.claimJSON,
                                                claimType.schemaName,
                                                claimType.schemaVersion)

            legal_entity_id = None
            try:
                legal_entity_id = json.loads(
                    verifiableClaim.claimJSON)['values']['legal_entity_id'][0]
                __logger.debug('Claim for legal_entity_id: %s' %
                               legal_entity_id)
            except Error as e:
                # no-op
                self.__logger.debug('Claim for NO legal_entity_id')

            proofRequest = proofRequestBuilder.asDict()
            proofRequestWithFilters = {
                'filters': {
                    'legal_entity_id': legal_entity_id
                },
                'proof_request': proofRequest
            }

            proofRequestProcesser = ProofRequestProcesser(
                json.dumps(proofRequestWithFilters))
            proofResponse = proofRequestProcesser.ConstructProof()

            return JsonResponse({'success': True, 'proof': proofResponse})

        return JsonResponse({'success': False})
Ejemplo n.º 5
0
    def post(self, request, *args, **kwargs):
        """
        Generates a proof from a proof request and set of filters.

        Example request payload:

        ```json
        {
          "filters": {
            "legal_entity_id": "c914cd7d-1f44-44b2-a0d3-c0bea12067fa"
          },
          "proof_request": {
            "name": "proof_request_name",
            "version": "1.0.0",
            "nonce": "1986273812765872",
            "requested_attrs": {
              "attr_1": {
                "name": "attr_1",
                "restrictions": [
                  {
                    "schema_key": {
                      "did": "issuer_did",
                      "name": "schema_name",
                      "version": "schema_version"
                    }
                  }
                ]
              }
            },
            "requested_predicates": {}
          }
        }
        ```

        returns: indy sdk proof json
        """
        __logger = logging.getLogger(__name__)
        proofRequestWithFilters = request.body.decode("utf-8")
        proofRequestProcesser = ProofRequestProcesser(proofRequestWithFilters)
        proofResponse = proofRequestProcesser.ConstructProof()
        return JsonResponse(proofResponse)