コード例 #1
0
    async def verifyClaimProof(self, msg: Any):
        body, (frm, ha) = msg
        link = self.verifyAndGetLink(msg)
        if not link:
            raise NotImplementedError

        claimName = body[NAME]
        nonce = getNonceForProof(body[NONCE])
        proof = FullProof.fromStrDict(body[PROOF_FIELD])
        proofInput = ProofInput.fromStrDict(body[PROOF_INPUT_FIELD])
        revealedAttrs = fromDictWithStrValues(body[REVEALED_ATTRS_FIELD])

        result = await self.verifier.verify(proofInput, proof, revealedAttrs,
                                            nonce)

        status = 'verified' if result else 'failed verification'
        resp = {
            TYPE:
            CLAIM_PROOF_STATUS,
            DATA:
            '    Your claim {} {} was received and {}\n'.format(
                body[NAME], body[VERSION], status),
        }
        self.signAndSend(resp,
                         link.localIdentifier,
                         frm,
                         origReqId=body.get(f.REQ_ID.nm))

        if result:
            await self._postClaimVerif(claimName, link, frm)
コード例 #2
0
    async def verifyProof(self, msg: Any):
        body, (frm, _) = msg
        link = self.verifyAndGetLink(msg)
        if not link:
            raise NotImplementedError

        proofName = body[NAME]
        nonce = getNonceForProof(body[NONCE])
        proof = FullProof.fromStrDict(body[PROOF_FIELD])
        proofInput = ProofInput.fromStrDict(body[PROOF_INPUT_FIELD])
        revealedAttrs = fromDictWithStrValues(body[REVEALED_ATTRS_FIELD])
        result = await self.verifier.verify(proofInput, proof, revealedAttrs,
                                            nonce)

        self.logger.info('Proof "{}" accepted with nonce {}'.format(
            proofName, nonce))
        self.logger.info('Verifying proof "{}" from {}'.format(
            proofName, link.name))
        status = 'verified' if result else 'failed verification'
        resp = {
            TYPE:
            PROOF_STATUS,
            DATA:
            '    Your Proof {} {} was received and {}\n'.format(
                body[NAME], body[VERSION], status),
        }
        self.signAndSend(resp,
                         link.localIdentifier,
                         frm,
                         origReqId=body.get(f.REQ_ID.nm))

        if result:
            for attribute in proofInput.revealedAttrs:
                # Log attributes that were verified
                self.logger.info('verified {}: {}'.format(
                    attribute, revealedAttrs[attribute]))
            self.logger.info(
                'Verified that proof "{}" contains attributes '
                'from claim(s) issued by: {}'.format(
                    proofName,
                    ", ".join(sorted([sk.issuerId
                                      for sk in proof.schemaKeys]))))
            await self._postProofVerif(proofName, link, frm)
        else:
            self.logger.info(
                'Verification failed for proof {} from {} '.format(
                    proofName, link.name))
コード例 #3
0
ファイル: agent_verifier.py プロジェクト: dhh1128/indy-client
    async def verifyProof(self, msg: Any):
        body, (frm, _) = msg
        link = self.verifyAndGetLink(msg)
        if not link:
            raise NotImplementedError

        proofName = body[NAME]
        nonce = getNonceForProof(body[NONCE])
        proof = FullProof.fromStrDict(body[PROOF_FIELD])
        proofInput = ProofInput.fromStrDict(body[PROOF_INPUT_FIELD])
        revealedAttrs = fromDictWithStrValues(body[REVEALED_ATTRS_FIELD])
        result = await self.verifier.verify(proofInput, proof,
                                            revealedAttrs, nonce)

        self.logger.info('Proof "{}" accepted with nonce {}'
                              .format(proofName, nonce))
        self.logger.info('Verifying proof "{}" from {}'
                              .format(proofName, link.name))
        status = 'verified' if result else 'failed verification'
        resp = {
            TYPE: PROOF_STATUS,
            DATA: '    Your Proof {} {} was received and {}\n'.
                format(body[NAME], body[VERSION], status),
        }
        self.signAndSend(resp, link.localIdentifier, frm,
                         origReqId=body.get(f.REQ_ID.nm))

        if result:
            for attribute in proofInput.revealedAttrs:
                # Log attributes that were verified
                self.logger.info('verified {}: {}'.
                                 format(attribute, revealedAttrs[attribute]))
            self.logger.info('Verified that proof "{}" contains attributes '
                             'from claim(s) issued by: {}'.format(
                proofName, ", ".join(
                    sorted([sk.issuerId for sk in proof.schemaKeys]))))
            await self._postProofVerif(proofName, link, frm)
        else:
            self.logger.info('Verification failed for proof {} from {} '
                              .format(proofName, link.name))
コード例 #4
0
def testProofInputFromToDict():
    proofInput = ProofInput(['name', 'age'],
                            [PredicateGE('age', 18),
                             PredicateGE('age', 25)])
    assert proofInput == ProofInput.fromStrDict(proofInput.toStrDict())