Exemplo n.º 1
0
    def sendProofReq(self, link: Link, proofReqSchemaKey):
        if self._proofRequestsSchema and (proofReqSchemaKey
                                          in self._proofRequestsSchema):
            proofRequest = self._proofRequestsSchema[proofReqSchemaKey]

            proofRequest = ProofRequest(
                proofRequest[NAME], proofRequest[VERSION],
                getNonceForProof(link.invitationNonce),
                proofRequest[ATTRIBUTES], proofRequest[VERIFIABLE_ATTRIBUTES]
                if VERIFIABLE_ATTRIBUTES in proofRequest else [],
                proofRequest[PREDICATES] if PREDICATES in proofRequest else [])

            op = {
                TYPE: PROOF_REQUEST,
                PROOF_REQUEST_FIELD: proofRequest.to_str_dict()
            }

            self.signAndSendToLink(msg=op, linkName=link.name)
        else:
            return ERR_NO_PROOF_REQUEST_SCHEMA_FOUND
Exemplo n.º 2
0
    async def sendProofAsync(self, link: Link, proofRequest: ProofRequest):
        # TODO _F_ this nonce should be from the Proof Request, not from an
        # invitation
        proofInput = ProofInput(
            nonce=proofRequest.nonce,
            revealedAttrs=proofRequest.verifiableAttributes,
            predicates=proofRequest.predicates)
        # TODO rename presentProof to buildProof or generateProof

        proof = await self.prover.presentProof(proofInput)
        proof.requestedProof.self_attested_attrs.update(
            proofRequest.selfAttestedAttrs)

        op = {
            TYPE: PROOF,
            NONCE: link.invitationNonce,
            PROOF_FIELD: proof.to_str_dict(),
            PROOF_REQUEST_FIELD: proofRequest.to_str_dict()
        }

        self.signAndSendToLink(msg=op, linkName=link.name)