Ejemplo n.º 1
0
async def testRevealedAndPredicateDifferentIssuers(prover1, allClaims,
                                                   schemaGvtId, schemaXyzId,
                                                   attrRepo, schemaGvt):
    proofRequest = ProofRequest(
        "proof1",
        "1.0",
        1,
        verifiableAttributes={'attr_uuid': AttributeInfo(name='status')},
        predicates={'predicate_uuid': PredicateGE('age', 18)})

    claimsGvt = await prover1.wallet.getClaimSignature(schemaGvtId)
    claimsXyz = await prover1.wallet.getClaimSignature(schemaXyzId)
    proofClaims = {
        schemaGvt.seqId: ProofClaims(claimsGvt, [], [PredicateGE('age', 18)]),
        schemaGvt.seqId: ProofClaims(claimsXyz, ['status'], [])
    }

    attr = attrRepo.getAttributes(schemaXyzId.schemaKey,
                                  prover1.proverId)['status']
    requestedProof = RequestedProof(
        revealed_attrs={
            'attr_uuid': [schemaGvt.seqId, attr,
                          str(encodeAttr(attr))]
        },
        predicates={'predicate_uuid': schemaGvt.seqId})

    assert proofClaims, requestedProof == await prover1._findClaims(
        proofRequest)
Ejemplo n.º 2
0
async def testMultipledPredicates(prover1, allClaims, schemaGvtId, schemaXyzId,
                                  schemaGvt):
    proofRequest = ProofRequest("proof1",
                                "1.0",
                                1,
                                predicates={
                                    'predicate_uuid1': PredicateGE('age', 18),
                                    'predicate_uuid2':
                                    PredicateGE('period', 8)
                                })

    claimsGvt = await prover1.wallet.getClaimSignature(schemaGvtId)
    claimsXyz = await prover1.wallet.getClaimSignature(schemaXyzId)
    proofClaims = {
        schemaGvt.seqId: ProofClaims(claimsGvt, [], [PredicateGE('age', 18)]),
        schemaGvt.seqId: ProofClaims(claimsXyz, [], [PredicateGE('period', 8)])
    }

    requestedProof = RequestedProof(predicates={
        'predicate_uuid1': schemaGvt.seqId,
        'predicate_uuid2': schemaGvt.seqId
    })

    assert proofClaims, requestedProof == await prover1._findClaims(
        proofRequest)
async def testMultipleGePredicateNegative(prover1, verifier, claimsProver1):
    proofRequest = ProofRequest("proof1", "1.0", verifier.generateNonce(),
                                verifiableAttributes={'attr_uuid': AttributeInfo(name='name')},
                                predicates={'predicate_uuid1': PredicateGE('age', 18),
                                            'predicate_uuid2': PredicateGE('period', 9)})
    with pytest.raises(ValueError):
        await presentProofAndVerify(verifier, proofRequest, prover1)
async def testGePredicateNegativeForOne(prover1, prover2, verifier, allClaims):
    proofInput = ProofInput(['name'],
                            [PredicateGE('age', 18),
                             PredicateGE('period', 9)])
    assert await presentProofAndVerify(verifier, proofInput, prover2)
    with pytest.raises(ValueError):
        await presentProofAndVerify(verifier, proofInput, prover1)
async def testGePredicate(prover1, prover2, verifier, allClaims):
    proofRequest = ProofRequest("proof1", "1.0", verifier.generateNonce(),
                                verifiableAttributes={'attr_uuid1': AttributeInfo(name='name')},
                                predicates={'predicate_uuid1': PredicateGE('age', 18),
                                            'predicate_uuid2': PredicateGE('period', 3)})
    assert await presentProofAndVerify(verifier, proofRequest, prover1)
    assert await presentProofAndVerify(verifier, proofRequest, prover2)
async def testMultipleGePredicateMultipleRevealed(prover1, verifier,
                                                  claimsProver1):
    proofRequest = ProofRequest("proof1", "1.0", verifier.generateNonce(),
                                verifiableAttributes={'attr_uuid1': AttributeInfo(name='name'),
                                               'attr_uuid2': AttributeInfo(name='status')},
                                predicates={'predicate_uuid1': PredicateGE('age', 18),
                                            'predicate_uuid2': PredicateGE('period', 5)})
    await presentProofAndVerify(verifier, proofRequest, prover1)
async def testGePredicateNegativeForBoth(prover1, prover2, verifier, allClaims):
    proofRequest = ProofRequest("proof1", "1.0", verifier.generateNonce(),
                                verifiableAttributes={'attr_uuid1': AttributeInfo(name='name')},
                                predicates={'predicate_uuid1': PredicateGE('age', 38),
                                            'predicate_uuid2': PredicateGE('period', 30)})
    with pytest.raises(ValueError):
        await presentProofAndVerify(verifier, proofRequest, prover1)
    with pytest.raises(ValueError):
        await presentProofAndVerify(verifier, proofRequest, prover2)
Ejemplo n.º 8
0
async def testRevealedEmpty(prover1, allClaims, schemaGvtId):
    proofInput = ProofInput([], [PredicateGE('age', 18)])
    claimsGvt = await prover1.wallet.getClaims(schemaGvtId)
    proofClaims = {
        schemaGvtId.schemaKey: ProofClaims(claimsGvt, [],
                                           [PredicateGE('age', 18)])
    }
    revealedAttrs = {}
    assert (proofClaims,
            revealedAttrs) == await prover1._findClaims(proofInput)
Ejemplo n.º 9
0
async def testPredicateNotFound(prover1, allClaims):
    proofRequest = ProofRequest("proof1",
                                "1.0",
                                1,
                                predicates={
                                    'predicate_uuid1': PredicateGE('age', 18),
                                    'predicate_uuid2': PredicateGE('aaaa', 8)
                                })
    with pytest.raises(ValueError):
        await prover1._findClaims(proofRequest)
async def testOnePredicateOnly(prover1, allClaims, schemaGvtId, schemaGvt):
    proofRequest = ProofRequest("proof1", "1.0", 1, predicates={'uuid': PredicateGE('age', 18)})

    claimsGvt = await prover1.wallet.getClaimSignature(schemaGvtId)
    proofClaims = {schemaGvt.seqId:
                       ProofClaims(claimsGvt, [], [PredicateGE('age', 18)])}

    requestedProof = RequestedProof(predicates={'uuid': schemaGvt.seqId})

    assert proofClaims, requestedProof == await prover1._findClaims(proofRequest)
async def testMultipleGePredicate(prover1, verifier, claimsProver1Gvt):
    proofRequest = ProofRequest(
        "proof1",
        "1.0",
        verifier.generateNonce(),
        verifiableAttributes={'attr_uuid': AttributeInfo(name='name')},
        predicates={
            'predicate_uuid1': PredicateGE('age', 18),
            'predicate_uuid2': PredicateGE('height', 170)
        })
    assert await presentProofAndVerify(verifier, proofRequest, prover1)
Ejemplo n.º 12
0
async def testSingleIssuerMultipleCredDefsSingleProver(primes1, primes2):
    # 1. Init entities
    publicRepo = PublicRepoInMemory()
    attrRepo = AttributeRepoInMemory()
    issuer = Issuer(IssuerWalletInMemory('issuer1', publicRepo), attrRepo)

    # 2. Create a Schema
    schema1 = await issuer.genSchema('GVT', '1.0', GVT.attribNames())
    schemaId1 = ID(schema1.getKey())
    schema2 = await issuer.genSchema('XYZCorp', '1.0', XYZCorp.attribNames())
    schemaId2 = ID(schema2.getKey())

    # 3. Create keys for the Schema
    await issuer.genKeys(schemaId1, **primes1)
    await issuer.genKeys(schemaId2, **primes2)

    # 4. Issue accumulator
    await issuer.issueAccumulator(schemaId=schemaId1, iA='110', L=5)
    await issuer.issueAccumulator(schemaId=schemaId2, iA=9999999, L=5)

    # 4. set attributes for user1
    userId = '111'
    attrs1 = GVT.attribs(name='Alex', age=28, height=175, sex='male')
    attrs2 = XYZCorp.attribs(status='FULL', period=8)
    attrRepo.addAttributes(schema1.getKey(), userId, attrs1)
    attrRepo.addAttributes(schema2.getKey(), userId, attrs2)

    # 5. request Claims
    prover = Prover(ProverWalletInMemory(userId, publicRepo))
    claimsReqs = await prover.createClaimRequests([schemaId1, schemaId2])
    claims = await issuer.issueClaims(claimsReqs)
    await prover.processClaims(claims)

    # 6. proof Claims
    verifier = Verifier(WalletInMemory('verifier1', publicRepo))

    proofRequest = ProofRequest("proof1",
                                "1.0",
                                verifier.generateNonce(),
                                verifiableAttributes={
                                    'attr_uuid1':
                                    AttributeInfo('name', schema1.seqId)
                                },
                                predicates={
                                    'predicate_uuid1': PredicateGE('age', 18),
                                    'predicate_uuid2':
                                    PredicateGE('period', 5)
                                })

    proof = await prover.presentProof(proofRequest)

    assert proof.requestedProof.revealed_attrs['attr_uuid1'][1] == 'Alex'
    assert await verifier.verify(proofRequest, proof)
Ejemplo n.º 13
0
async def testRevealedAndPredicateSameIssuer(prover1, allClaims, schemaGvtId,
                                             attrRepo):
    proofInput = ProofInput(['name'], [PredicateGE('age', 18)])
    claimsGvt = await prover1.wallet.getClaims(schemaGvtId)
    proofClaims = {
        schemaGvtId.schemaKey:
        ProofClaims(claimsGvt, ['name'], [PredicateGE('age', 18)])
    }
    revealedAttrs = {
        'name':
        attrRepo.getAttributes(schemaGvtId.schemaKey, prover1.proverId)['name']
    }
    assert (proofClaims,
            revealedAttrs) == await prover1._findClaims(proofInput)
Ejemplo n.º 14
0
async def testMultiplIssuersSingleProver(primes1, primes2):
    # 1. Init entities
    publicRepo = PublicRepoInMemory()
    attrRepo = AttributeRepoInMemory()
    issuer1 = Issuer(IssuerWalletInMemory('issuer1', publicRepo), attrRepo)
    issuer2 = Issuer(IssuerWalletInMemory('issuer2', publicRepo), attrRepo)

    # 2. Create a Schema
    schema1 = await issuer1.genSchema('GVT', '1.0', GVT.attribNames())
    schemaId1 = ID(schema1.getKey())
    schema2 = await issuer2.genSchema('XYZCorp', '1.0', XYZCorp.attribNames())
    schemaId2 = ID(schema2.getKey())

    # 3. Create keys for the Schema
    await issuer1.genKeys(schemaId1, **primes1)
    await issuer2.genKeys(schemaId2, **primes2)

    # 4. Issue accumulator
    await issuer1.issueAccumulator(schemaId=schemaId1, iA='110', L=5)
    await issuer2.issueAccumulator(schemaId=schemaId2, iA=9999999, L=5)

    # 4. set attributes for user1
    userId = '111'
    attrs1 = GVT.attribs(name='Alex', age=28, height=175, sex='male')
    attrs2 = XYZCorp.attribs(status='FULL', period=8)
    attrRepo.addAttributes(schema1.getKey(), userId, attrs1)
    attrRepo.addAttributes(schema2.getKey(), userId, attrs2)

    # 5. request Claims
    prover = Prover(ProverWalletInMemory(userId, publicRepo))
    claimsReq1 = await prover.createClaimRequest(schemaId1)
    claimsReq2 = await prover.createClaimRequest(schemaId2)
    claims1 = await issuer1.issueClaim(schemaId1, claimsReq1)
    claims2 = await issuer2.issueClaim(schemaId2, claimsReq2)
    await prover.processClaim(schemaId1, claims1)
    await prover.processClaim(schemaId2, claims2)

    # 6. proof Claims
    proofInput = ProofInput(['name', 'status'],
                            [PredicateGE('age', 18),
                             PredicateGE('period', 5)])

    verifier = Verifier(WalletInMemory('verifier1', publicRepo))
    nonce = verifier.generateNonce()
    proof, revealedAttrs = await prover.presentProof(proofInput, nonce)

    assert revealedAttrs['name'] == 'Alex'
    assert revealedAttrs['status'] == 'FULL'
    assert await verifier.verify(proofInput, proof, revealedAttrs, nonce)
Ejemplo n.º 15
0
async def testSingleIssuerSingleProver(primes1):
    # 1. Init entities
    publicRepo = PublicRepoInMemory()
    attrRepo = AttributeRepoInMemory()
    issuer = Issuer(IssuerWalletInMemory('issuer1', publicRepo), attrRepo)

    # 2. Create a Schema
    schema = await issuer.genSchema('GVT', '1.0', GVT.attribNames())
    schemaId = ID(schema.getKey())

    # 3. Create keys for the Schema
    await issuer.genKeys(schemaId, **primes1)

    # 4. Issue accumulator
    await issuer.issueAccumulator(schemaId=schemaId, iA='110', L=5)

    # 4. set attributes for user1
    userId = '111'
    attrs = GVT.attribs(name='Alex', age=28, height=175, sex='male')
    attrRepo.addAttributes(schema.getKey(), userId, attrs)

    # 5. request Claims
    prover = Prover(ProverWalletInMemory(userId, publicRepo))
    claimsReq = await prover.createClaimRequest(schemaId)
    claims = await issuer.issueClaim(schemaId, claimsReq)
    await prover.processClaim(schemaId, claims)

    # 6. proof Claims
    proofInput = ProofInput(['name'], [PredicateGE('age', 18)])

    verifier = Verifier(WalletInMemory('verifier1', publicRepo))
    nonce = verifier.generateNonce()
    proof, revealedAttrs = await prover.presentProof(proofInput, nonce)
    assert revealedAttrs['name'] == 'Alex'
    assert await verifier.verify(proofInput, proof, revealedAttrs, nonce)
Ejemplo n.º 16
0
    async def doTestAnonCredsPrimaryOnly():
        # 1. Create a Schema
        schema = await issuer.genSchema('GVT', '1.0', GVT.attribNames())
        schemaId = ID(schemaKey=schema.getKey(), schemaId=schema.seqId)

        # 2. Create keys for the Schema
        await issuer.genKeys(schemaId, **primes1)

        # 3. Issue accumulator
        #TODO: Not implemented yet
        #await issuer.issueAccumulator(schemaId=schemaId, iA='110', L=5)

        # 4. set attributes for user1
        attrs = GVT.attribs(name='Alex', age=28, height=175, sex='male')
        proverId = str(prover.proverId)
        attrRepo.addAttributes(schema.getKey(), proverId, attrs)

        # 5. request Claims
        claimsReq = await prover.createClaimRequest(schemaId, proverId, False)
        claims = await issuer.issueClaim(schemaId, claimsReq)
        await prover.processClaim(schemaId, claims)

        # 6. proof Claims
        proofInput = ProofInput(
            ['name'],
            [PredicateGE('age', 18)])

        nonce = verifier.generateNonce()
        proof, revealedAttrs = await prover.presentProof(proofInput, nonce)
        assert await verifier.verify(proofInput, proof, revealedAttrs, nonce)
Ejemplo n.º 17
0
async def test_ge_proof_from_to_dict():
    n = cmod.integer(12345)

    predicate = PredicateGE(attrName='age', value=18)
    geProof = PrimaryPredicateGEProof(alpha=cmod.integer(1), mj=cmod.integer(12), r={'1': cmod.integer(13)},
                                      u={'1': cmod.integer(42)}, T={'1': cmod.integer(21) % n}, predicate=predicate)

    proof_serialized = {
        'alpha': '1',
        'mj': '12',
        't': {'1': '21'},
        'r': {'1': '13'},
        'u': {'1': '42'},
        'predicate': {
            'p_type': 'GE',
            'attr_name': 'age',
            'value': 18,
            'schema_seq_no': None,
            'issuer_did': None
        }
    }

    assert geProof.to_str_dict() == proof_serialized
    assert geProof == PrimaryPredicateGEProof.from_str_dict(
        proof_serialized, n)
    assert geProof == PrimaryPredicateGEProof.from_str_dict(
        geProof.to_str_dict(), n)
async def create_proof_request(conn):
    # 1. Init entities
    public_repo = PublicRepoInMemory()
    attr_repo = AttributeRepoInMemory()
    issuer = Issuer(IssuerWalletInMemory('issuer1', public_repo), attr_repo)

    # 2. Create a Schema
    schema = await issuer.genSchema('GVT', '1.0', GVT.attribNames())
    schema_id = ID(schema.getKey())

    # 3. Create keys for the Schema
    global global_dict
    await issuer.wallet.submitPublicKeys(schema_id, global_dict['public_key'])

    # 4. set attributes for user1
    prover_id = 'BzfFCYk'
    attributes = GVT.attribs(name='Alex', age=28, height=175, sex='male')
    attr_repo.addAttributes(schema.getKey(), prover_id, attributes)

    verifier = Verifier(WalletInMemory('verifier1', public_repo))

    proof_request = ProofRequest(
        name='Test_proof', version='1.0',
        nonce=verifier.generateNonce(),
        verifiableAttributes={
            'attr_uuid': AttributeInfo('name', schema.seqId)},
        predicates={'predicate_uuid': PredicateGE('age', 18)})

    global_dict['verifier'] = verifier
    global_dict['proof_request'] = proof_request

    conn.send(json.dumps(proof_request.to_str_dict()).encode())
Ejemplo n.º 19
0
async def testClaimProofFromToDictPrimaryOnly(prover1, nonce, claimsProver1Gvt):
    proofInput = ProofInput(['name'], [PredicateGE('age', 18)])
    proof, _ = await prover1.presentProof(proofInput, nonce)

    proofs = [Proof(primaryProof=proof.proofs[0].primaryProof)]
    proof = proof._replace(proofs=proofs)
    assert proof == FullProof.fromStrDict(proof.toStrDict())
Ejemplo n.º 20
0
async def testMultipledPredicates(prover1, allClaims, schemaGvtId,
                                  schemaXyzId):
    proofInput = ProofInput([],
                            [PredicateGE('age', 18),
                             PredicateGE('period', 8)])
    claimsGvt = await prover1.wallet.getClaims(schemaGvtId)
    claimsXyz = await prover1.wallet.getClaims(schemaXyzId)
    proofClaims = {
        schemaGvtId.schemaKey:
        ProofClaims(claimsGvt, [], [PredicateGE('age', 18)]),
        schemaXyzId.schemaKey:
        ProofClaims(claimsXyz, [], [PredicateGE('period', 8)])
    }
    revealedAttrs = {}
    assert (proofClaims,
            revealedAttrs) == await prover1._findClaims(proofInput)
Ejemplo n.º 21
0
async def test_primary_proof_from_to_dict():
    n = cmod.integer(12345)

    eqProof = PrimaryEqualProof(e=cmod.integer(1),
                                v=cmod.integer(11),
                                m={'name': cmod.integer(12)},
                                m1=cmod.integer(12),
                                m2=cmod.integer(32),
                                Aprime=cmod.integer(32) % n,
                                revealedAttrs={'name': cmod.integer(35)})

    predicate = PredicateGE(attrName='age', value=18)
    geProof = PrimaryPredicateGEProof(alpha=cmod.integer(1),
                                      mj=cmod.integer(12),
                                      r={'1': cmod.integer(13)},
                                      u={'1': cmod.integer(42)},
                                      T={'1': cmod.integer(21) % n},
                                      predicate=predicate)
    primaryProof = PrimaryProof(eqProof=eqProof, geProofs=[geProof])

    proof_serialized = {
        'eq_proof': {
            'a_prime': '32',
            'e': '1',
            'm': {
                'name': '12'
            },
            'm1': '12',
            'm2': '32',
            'v': '11',
            'revealed_attrs': {
                'name': '35'
            }
        },
        'ge_proofs': [{
            'alpha': '1',
            'mj': '12',
            't': {
                '1': '21'
            },
            'r': {
                '1': '13'
            },
            'u': {
                '1': '42'
            },
            'predicate': {
                'p_type': 'GE',
                'attr_name': 'age',
                'value': 18,
                'schema_seq_no': None,
                'issuer_did': None
            }
        }]
    }

    assert primaryProof.to_str_dict() == proof_serialized
    assert primaryProof == PrimaryProof.from_str_dict(proof_serialized, n)
    assert primaryProof == PrimaryProof.from_str_dict(
        primaryProof.to_str_dict(), n)
Ejemplo n.º 22
0
async def test_requested_proof_from_to_dict(prover1, nonce, claimsProver1Gvt):
    proofRequest = ProofRequest(
        "proof1",
        "1.0",
        1,
        verifiableAttributes={'attr_uuid': AttributeInfo(name='name')},
        predicates={'predicate_uuid': PredicateGE('age', 18)})

    proof = await prover1.presentProof(proofRequest)

    requested_proof_serialized = {
        'revealed_attrs': {
            'attr_uuid':
            ['1', 'Alex', '1139481716457488690172217916278103335']
        },
        'predicates': {
            'predicate_uuid': '1'
        },
        'self_attested_attrs': {},
        'unrevealed_attrs': {}
    }

    assert proof.requestedProof.to_str_dict() == requested_proof_serialized
    assert proof.requestedProof == RequestedProof.from_str_dict(
        requested_proof_serialized)
    assert proof.requestedProof == RequestedProof.from_str_dict(
        proof.requestedProof.to_str_dict())
Ejemplo n.º 23
0
def test_proof_request_from_to_dict():
    proofRequest = ProofRequest(
        "proof1",
        "1.0",
        1,
        verifiableAttributes={'attr_uuid': AttributeInfo(name='name')},
        predicates={'predicate_uuid': PredicateGE('age', 18)})

    proof_input_serialized = {
        'name': 'proof1',
        'version': '1.0',
        'nonce': '1',
        'requested_attrs': {
            'attr_uuid': {
                'name': 'name',
                'schema_seq_no': None,
                'issuer_did': None
            }
        },
        'requested_predicates': {
            'predicate_uuid': {
                'p_type': 'GE',
                'value': 18,
                'attr_name': 'age',
                'schema_seq_no': None,
                'issuer_did': None
            }
        }
    }
    assert proofRequest.to_str_dict() == proof_input_serialized
    assert proofRequest == ProofRequest.from_str_dict(proof_input_serialized)
    assert proofRequest == ProofRequest.from_str_dict(
        proofRequest.to_str_dict())
async def testGePredicateForEqual(prover1, verifier, claimsProver1Gvt):
    proofRequest = ProofRequest(
        "proof1",
        "1.0",
        verifier.generateNonce(),
        verifiableAttributes={'attr_uuid': AttributeInfo(name='name')},
        predicates={'predicate_uuid': PredicateGE('age', 28)})
    assert await presentProofAndVerify(verifier, proofRequest, prover1)
Ejemplo n.º 25
0
async def testRevealedAndPredicateDifferentIssuers(prover1, allClaims,
                                                   schemaGvtId, schemaXyzId,
                                                   attrRepo):
    proofInput = ProofInput(['status'], [PredicateGE('age', 18)])
    claimsGvt = await prover1.wallet.getClaims(schemaGvtId)
    claimsXyz = await prover1.wallet.getClaims(schemaXyzId)
    proofClaims = {
        schemaGvtId.schemaKey: ProofClaims(claimsGvt, [],
                                           [PredicateGE('age', 18)]),
        schemaXyzId.schemaKey: ProofClaims(claimsXyz, ['status'], [])
    }
    revealedAttrs = {
        'status':
        attrRepo.getAttributes(schemaXyzId.schemaKey,
                               prover1.proverId)['status']
    }
    assert (proofClaims,
            revealedAttrs) == await prover1._findClaims(proofInput)
Ejemplo n.º 26
0
async def testClaimProofFromToDict(prover1, nonce, claimsProver1Gvt):
    proofRequest = ProofRequest("proof1", "1.0", 1,
                                verifiableAttributes={
                                    'attr_uuid': AttributeInfo(name='name')},
                                predicates={'predicate_uuid': PredicateGE('age', 18)})

    proof = await prover1.presentProof(proofRequest)

    assert proof == FullProof.fromStrDict(proof.toStrDict())
Ejemplo n.º 27
0
async def testMultipleAll(prover1, allClaims, schemaGvtId, schemaXyzId,
                          attrRepo, schemaGvt):
    proofRequest = ProofRequest("proof1",
                                "1.0",
                                1,
                                verifiableAttributes={
                                    'attr_uuid1': AttributeInfo(name='status'),
                                    'attr_uuid2': AttributeInfo(name='name')
                                },
                                predicates={
                                    'predicate_uuid1': PredicateGE('age', 18),
                                    'predicate_uuid2':
                                    PredicateGE('period', 8)
                                })

    claimsGvt = await prover1.wallet.getClaimSignature(schemaGvtId)
    claimsXyz = await prover1.wallet.getClaimSignature(schemaXyzId)
    proofClaims = {
        schemaGvt.seqId:
        ProofClaims(claimsGvt, ['name'], [PredicateGE('age', 18)]),
        schemaGvt.seqId:
        ProofClaims(claimsXyz, ['status'], [PredicateGE('period', 8)])
    }

    attr1 = attrRepo.getAttributes(schemaXyzId.schemaKey,
                                   prover1.proverId)['status']
    attr2 = attrRepo.getAttributes(schemaGvtId.schemaKey,
                                   prover1.proverId)['name']

    requestedProof = RequestedProof(revealed_attrs={
        'attr_uuid1': [schemaGvt.seqId, attr1,
                       str(encodeAttr(attr1))],
        'attr_uuid2': [schemaGvt.seqId, attr2,
                       str(encodeAttr(attr2))]
    },
                                    predicates={
                                        'predicate_uuid1': schemaGvt.seqId,
                                        'predicate_uuid2': schemaGvt.seqId
                                    })

    assert proofClaims, requestedProof == await prover1._findClaims(
        proofRequest)
Ejemplo n.º 28
0
async def testPrimaryClaimPredicatesOnly(prover1, verifier, claimsProver1Gvt,
                                         nonce, schemaGvtId):
    predicates = [PredicateGE('age', 18)]
    proofInput = ProofInput(predicates=predicates)
    claims, revealedAttrs = await prover1._findClaims(proofInput)
    claims = {schemaKey: ProofClaims(
        Claims(primaryClaim=proofClaim.claims.primaryClaim),
        predicates=predicates)
              for schemaKey, proofClaim in claims.items()}
    proof = await prover1._prepareProof(claims, nonce)
    assert await verifier.verify(proofInput, proof, revealedAttrs, nonce)
Ejemplo n.º 29
0
async def testMultipleAll(prover1, allClaims, schemaGvtId, schemaXyzId,
                          attrRepo):
    proofInput = ProofInput(['status', 'name'],
                            [PredicateGE('age', 18),
                             PredicateGE('period', 8)])
    claimsGvt = await prover1.wallet.getClaims(schemaGvtId)
    claimsXyz = await prover1.wallet.getClaims(schemaXyzId)
    proofClaims = {
        schemaGvtId.schemaKey:
        ProofClaims(claimsGvt, ['name'], [PredicateGE('age', 18)]),
        schemaXyzId.schemaKey:
        ProofClaims(claimsXyz, ['status'], [PredicateGE('period', 8)])
    }
    revealedAttrs = {
        'name':
        attrRepo.getAttributes(schemaGvtId.schemaKey,
                               prover1.proverId)['name'],
        'status':
        attrRepo.getAttributes(schemaXyzId.schemaKey,
                               prover1.proverId)['status'],
    }
    assert (proofClaims,
            revealedAttrs) == await prover1._findClaims(proofInput)
Ejemplo n.º 30
0
 def from_str_dict(d):
     return ProofRequest(
         name=d['name'],
         version=d['version'],
         nonce=int(d['nonce']),
         attributes=d['attributes'] if 'attributes' in d else [],
         verifiableAttributes={
             k: AttributeInfo.from_str_dict(v)
             for k, v in d['verifiableAttributes'].items()
         },
         predicates={
             k: PredicateGE.from_str_dict(v)
             for k, v in d['requested_predicates'].items()
         })