コード例 #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
ファイル: test_util.py プロジェクト: sunilake/indy-anoncreds
def testToFromDictWithStrValuesDictInList():
    dictionary = OrderedDict((('2', [
        OrderedDict((('33', OrderedDict((('45', 45), ('11', 11)))),
                     ('23', OrderedDict((('47', 47), ('34', 34)))))),
        OrderedDict((('63', OrderedDict((('65', 45), ('61', 11)))),
                     ('63', OrderedDict((('67', 47), ('64', 34))))))
    ]), ('3', 3)))
    assert dictionary == fromDictWithStrValues(toDictWithStrValues(dictionary))
コード例 #3
0
ファイル: test_util.py プロジェクト: sunilake/indy-anoncreds
def testToFromDictWithStrValuesSets():
    dictionary = OrderedDict((
        ('44', {'aaa', 'bbb'}),
        ('4', {111, 2222}),
        ('1', {}),
        ('3', 3),
    ))
    assert dictionary == fromDictWithStrValues(toDictWithStrValues(dictionary))
コード例 #4
0
    def fromStrDict(cls, d):
        d = fromDictWithStrValues(d)
        aggregatedProof = AggregatedProof.fromStrDict(d['aggregatedProof'])
        requestedProof = RequestedProof.fromStrDict(d['requestedProof'])
        proofs = {k: ProofInfo.fromStrDict(v) for k, v in d['proofs'].items()}

        return FullProof(aggregatedProof=aggregatedProof,
                         proofs=proofs,
                         requestedProof=requestedProof)
コード例 #5
0
ファイル: test_util.py プロジェクト: sunilake/indy-anoncreds
def testToFromDictWithStrValuesSubDicts():
    cmod.PairingGroup(PAIRING_GROUP)
    dictionary = OrderedDict(
        (('4', {'aaa',
                'bbb'}), ('2',
                          OrderedDict(
                              (('33', OrderedDict((('45', 45), ('11', 11)))),
                               ('23', OrderedDict(
                                   (('47', 47), ('34', 34))))))), ('3', 3)))
    assert dictionary == fromDictWithStrValues(toDictWithStrValues(dictionary))
コード例 #6
0
ファイル: test_util.py プロジェクト: sunilake/indy-anoncreds
def testToFromDictWithStrValuesLists():
    group = cmod.PairingGroup(PAIRING_GROUP)
    dictionary = OrderedDict(
        (('47', []),
         ('7',
          [cmod.integer(111) % 11,
           cmod.integer(222),
           cmod.integer(333) % 45]), ('6', [
               group.init(cmod.ZR, 555),
               group.random(cmod.G1),
               group.random(cmod.G1)
           ])))
    assert dictionary == fromDictWithStrValues(toDictWithStrValues(dictionary))
コード例 #7
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))
コード例 #8
0
ファイル: test_util.py プロジェクト: sunilake/indy-anoncreds
def testToFromDictWithStrValuesMixed():
    group = cmod.PairingGroup(PAIRING_GROUP)
    dictionary = OrderedDict(
        (('4', {'aaa',
                'bbb'}), ('2',
                          OrderedDict(
                              (('33', OrderedDict((('45', 45), ('11', 11)))),
                               ('23', OrderedDict(
                                   (('47', 47), ('34', 34))))))), ('1', {}),
         ('3', 3), ('5', cmod.integer(111) % 11),
         ('7',
          [cmod.integer(111) % 11,
           cmod.integer(222),
           cmod.integer(333) % 45]), ('6', [
               group.init(cmod.ZR, 555),
               group.random(cmod.G1),
               group.random(cmod.G1)
           ]), ('10', group.random(cmod.G1))))
    assert dictionary == fromDictWithStrValues(toDictWithStrValues(dictionary))
コード例 #9
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))
コード例 #10
0
ファイル: test_util.py プロジェクト: sunilake/indy-anoncreds
def testToFromDictWithStrValues():
    group = cmod.PairingGroup(PAIRING_GROUP)
    dictionary = OrderedDict(
        (('43', '43'), ('3', 3), ('5', cmod.integer(111) % 11),
         ('10', group.random(cmod.G1))))
    assert dictionary == fromDictWithStrValues(toDictWithStrValues(dictionary))
コード例 #11
0
 def fromStrDict(cls, d):
     d = fromDictWithStrValues(d)
     proof = Proof.fromStrDict(d['proof'])
     result = cls(**d)
     return result._replace(proof=proof)
コード例 #12
0
 def fromStrDict(cls, d):
     d = fromDictWithStrValues(d)
     predicate = PredicateGE(**d['predicate'])
     result = cls(**d)
     return result._replace(predicate=predicate)
コード例 #13
0
 def fromStrDict(cls, d):
     d = fromDictWithStrValues(d)
     witness = Witness(**d['witness'])
     result = cls(**d)
     return result._replace(witness=witness)
コード例 #14
0
 def fromStrDict(cls, d):
     d = fromDictWithStrValues(d)
     return cls(**d)
コード例 #15
0
ファイル: types.py プロジェクト: surabhiagrawal89/anoncreds
 def fromStrDict(cls, d):
     d = fromDictWithStrValues(d)
     predicates = [Predicate.fromStrDict(v) for v in d['predicates']]
     result = cls(**d)
     return result._replace(predicates=predicates)
コード例 #16
0
async def testRevealedAttrsFromToDict(prover1, nonce, claimsProver1Gvt):
    proofInput = ProofInput(['name'], [PredicateGE('age', 18)])
    _, revealedAttrs = await prover1.presentProof(proofInput, nonce)
    assert revealedAttrs == fromDictWithStrValues(
        toDictWithStrValues(revealedAttrs))
コード例 #17
0
ファイル: test_util.py プロジェクト: sunilake/indy-anoncreds
def testToFromDictWithStrValuesInteKeys():
    dictionary = OrderedDict(((11, '43'), (12, 3)))
    assert dictionary == fromDictWithStrValues(toDictWithStrValues(dictionary))