def verify_credential(request, *args, **kwargs): """ Constructs a proof request for a credential stored in the application database, constructs a proof for that proof request, and then verifies it. returns: ```json { "verified": <verification successful boolean>, "proof": <proof json>, "proof_request": <proof_request json>, } ``` """ logger.warn(">>> Verify Credential") credential_id = kwargs.get("id") if not credential_id: raise Http404 try: credential = CredentialModel.objects.get(id=credential_id) except CredentialModel.DoesNotExist as error: logger.warn(error) raise Http404 proof_request = ProofRequest(name="the-org-book", version="1.0.0") proof_request.build_from_credential(credential) proof_manager = ProofManager(proof_request.dict, {credential.wallet_id}) proof = proof_manager.construct_proof() async def verify(): return await indy_client().verify_proof( indy_holder_id(), VonxProofRequest(proof_request.dict), VonxConstructedProof(proof)) verified = run_coro(verify()) verified = verified.verified return JsonResponse({ "success": verified, "result": { "verified": verified, "proof": proof, "proof_request": proof_request.dict, }, })
def generate_credential_request(self): """Generates a credential request Returns: tuple -- credential_request, credential_request_metadata """ async def run(): cred_req = await indy_client().create_credential_request( indy_holder_id(), self.credential_offer, self.credential_def_id, ) return cred_req.data, cred_req.metadata return run_coro(run())
def status(request, *args, **kwargs): async def get_status(): return await indy_client().get_status() return JsonResponse(run_coro(get_status()))
def construct_proof(self): return run_coro(self.construct_proof_async())
def pre_init(): start_indy_manager() run_coro(perform_register_services())
def pre_init(proc=False): if proc: MANAGER.start_process() else: MANAGER.start() run_coro(register_services())