Пример #1
0
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))
Пример #2
0
def testToFromDictWithStrValuesSets():
    dictionary = OrderedDict((
        ('44', {'aaa', 'bbb'}),
        ('4', {111, 2222}),
        ('1', {}),
        ('3', 3),
    ))
    assert dictionary == fromDictWithStrValues(toDictWithStrValues(dictionary))
Пример #3
0
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))
Пример #4
0
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))
Пример #5
0
    async def sendProofAsync(self, link: Link, claimPrfReq: ClaimProofRequest):
        nonce = getNonceForProof(link.invitationNonce)

        revealedAttrNames = claimPrfReq.verifiableAttributes
        proofInput = ProofInput(revealedAttrs=revealedAttrNames)
        proof, revealedAttrs = await self.prover.presentProof(proofInput, nonce)

        op = {
            NAME: claimPrfReq.name,
            VERSION: claimPrfReq.version,
            NONCE: link.invitationNonce,
            TYPE: CLAIM_PROOF,
            PROOF_FIELD: proof.toStrDict(),
            PROOF_INPUT_FIELD: proofInput.toStrDict(),
            REVEALED_ATTRS_FIELD: toDictWithStrValues(revealedAttrs)
        }

        self.signAndSend(msg=op, linkName=link.name)
Пример #6
0
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))
    async def sendProofAsync(self, link: Link, proofRequest: ProofRequest):
        # TODO _F_ this nonce should be from the Proof Request, not from an
        # invitation
        nonce = getNonceForProof(link.invitationNonce)

        revealedAttrNames = proofRequest.verifiableAttributes
        proofInput = ProofInput(revealedAttrs=revealedAttrNames)
        # TODO rename presentProof to buildProof or generateProof
        proof, revealedAttrs = await self.prover.presentProof(proofInput, nonce)
        revealedAttrs.update(proofRequest.selfAttestedAttrs)
        op = OrderedDict([
            (TYPE, PROOF),
            (NAME, proofRequest.name),
            (VERSION, proofRequest.version),
            (NONCE, link.invitationNonce),
            (PROOF_FIELD, proof.toStrDict()),
            (PROOF_INPUT_FIELD, proofInput.toStrDict()),  # TODO _F_ why do we need to send this? isn't the same data passed as keys in 'proof'?
            (REVEALED_ATTRS_FIELD, toDictWithStrValues(revealedAttrs))])

        self.signAndSend(msg=op, linkName=link.name)
Пример #8
0
    async def sendProofAsync(self, link: Link, proofRequest: ProofRequest):
        # TODO _F_ this nonce should be from the Proof Request, not from an
        # invitation
        nonce = getNonceForProof(link.invitationNonce)

        revealedAttrNames = proofRequest.verifiableAttributes
        proofInput = ProofInput(revealedAttrs=revealedAttrNames)
        # TODO rename presentProof to buildProof or generateProof
        proof, revealedAttrs = await self.prover.presentProof(proofInput, nonce)
        revealedAttrs.update(proofRequest.selfAttestedAttrs)
        op = OrderedDict([
            (TYPE, PROOF),
            (NAME, proofRequest.name),
            (VERSION, proofRequest.version),
            (NONCE, link.invitationNonce),
            (PROOF_FIELD, proof.toStrDict()),
            (PROOF_INPUT_FIELD, proofInput.toStrDict()),  # TODO _F_ why do we need to send this? isn't the same data passed as keys in 'proof'?
            (REVEALED_ATTRS_FIELD, toDictWithStrValues(revealedAttrs))])

        self.signAndSendToLink(msg=op, linkName=link.name)
Пример #9
0
 def toStrDict(self):
     return toDictWithStrValues(self.__dict__)
Пример #10
0
 def toStrDict(self):
     return toDictWithStrValues(self._asdict())
Пример #11
0
async def testRevealedAttrsFromToDict(prover1, nonce, claimsProver1Gvt):
    proofInput = ProofInput(['name'], [PredicateGE('age', 18)])
    _, revealedAttrs = await prover1.presentProof(proofInput, nonce)
    assert revealedAttrs == fromDictWithStrValues(
        toDictWithStrValues(revealedAttrs))
Пример #12
0
def testToFromDictWithStrValuesInteKeys():
    dictionary = OrderedDict(((11, '43'), (12, 3)))
    assert dictionary == fromDictWithStrValues(toDictWithStrValues(dictionary))
Пример #13
0
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))