コード例 #1
0
def testGetSchema(submittedSchemaDefGvt, publicRepo, looper):
    key = submittedSchemaDefGvt.getKey()
    schema = looper.run(publicRepo.getSchema(ID(schemaKey=key)))
    assert schema == submittedSchemaDefGvt
コード例 #2
0
 async def chkClaims():
     claim = await aliceAgent.prover.wallet.getClaimSignature(ID(schemaKey))
     assert claim.primaryClaim
コード例 #3
0
    def executeGstFlow(name, userCLI, userMap, be, connectedToTest, do, fMap,
                       aMap, jobCertificateClaimMap, newKeyringOut, reqClaimOut,
                       reqClaimOut1, syncLinkOutWithEndpoint,
                       syncedInviteAcceptedOutWithoutClaims, tMap,
                       transcriptClaimMap):

        async def getPublicKey(wallet, schemaId):
            return await wallet.getPublicKey(schemaId)

        async def getClaim(schemaId):
            return await userCLI.agent.prover.wallet.getClaims(schemaId)

        # Start User cli

        be(userCLI)
        setPromptAndKeyring(do, name, newKeyringOut, userMap)
        do('connect test', within=3, expect=connectedToTest)
        # Accept faber
        do('load sample/faber-invitation.sovrin')
        syncInvite(be, do, userCLI, syncLinkOutWithEndpoint, fMap)
        do('show link faber')
        acceptInvitation(be, do, userCLI, fMap,
                         syncedInviteAcceptedOutWithoutClaims)
        # Request claim
        do('show claim Transcript')
        aliceRequestedTranscriptClaim(be, do, userCLI, transcriptClaimMap,
                                      reqClaimOut,
                                      None,  # Passing None since its not used
                                      None)  # Passing None since its not used

        faberSchemaId = ID(SchemaKey('Transcript', '1.2', fMap['remote']))
        faberIssuerPublicKey = userCLI.looper.run(
            getPublicKey(faberAgent.issuer.wallet, faberSchemaId))
        userFaberIssuerPublicKey = userCLI.looper.run(
            getPublicKey(userCLI.agent.prover.wallet, faberSchemaId))
        assert faberIssuerPublicKey == userFaberIssuerPublicKey

        do('show claim Transcript')
        assert userCLI.looper.run(getClaim(faberSchemaId))

        # Accept acme
        do('load sample/acme-job-application.sovrin')
        syncInvite(be, do, userCLI, syncLinkOutWithEndpoint, aMap)
        acceptInvitation(be, do, userCLI, aMap,
                         syncedInviteAcceptedOutWithoutClaims)
        # Send claim
        do('show claim request Job-Application')
        do('set first_name to Alice')
        do('set last_name to Garcia')
        do('set phone_number to 123-45-6789')
        do('show claim request Job-Application')
        # Passing some args as None since they are not used in the method
        jobApplicationProofSent(be, do, userCLI, aMap, None, None, None)
        do('show claim Job-Certificate')
        # Request new available claims Job-Certificate
        jobCertClaimRequested(be, do, userCLI, None,
                              jobCertificateClaimMap, reqClaimOut1, None)

        acmeSchemaId = ID(SchemaKey('Job-Certificate', '0.2', aMap['remote']))
        acmeIssuerPublicKey = userCLI.looper.run(getPublicKey(
            acmeAgent.issuer.wallet, acmeSchemaId))
        userAcmeIssuerPublicKey = userCLI.looper.run(getPublicKey(
            userCLI.agent.prover.wallet, acmeSchemaId))
        assert acmeIssuerPublicKey == userAcmeIssuerPublicKey

        do('show claim Job-Certificate')
        assert userCLI.looper.run(getClaim(acmeSchemaId))

        # Accept thrift
        do('load sample/thrift-loan-application.sovrin')
        acceptInvitation(be, do, userCLI, tMap,
                         syncedInviteAcceptedOutWithoutClaims)
        # Send proofs
        bankBasicProofSent(be, do, userCLI, tMap, None)

        thriftAcmeIssuerPublicKey = userCLI.looper.run(getPublicKey(
            thriftAgent.issuer.wallet, acmeSchemaId))
        assert acmeIssuerPublicKey == thriftAcmeIssuerPublicKey
        passed = False
        try:
            bankKYCProofSent(be, do, userCLI, tMap, None)
            passed = True
        except:
            thriftFaberIssuerPublicKey = userCLI.looper.run(getPublicKey(
                thriftAgent.issuer.wallet, faberSchemaId))
            assert faberIssuerPublicKey == thriftFaberIssuerPublicKey
        assert passed
コード例 #4
0
def schemaXyzId(schemaXyz):
    return ID(schemaXyz.getKey())
コード例 #5
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)
    (claim1_signature,
     claim1_attributes) = await issuer1.issueClaim(schemaId1, claimsReq1)
    (claim2_signature,
     claim2_attributes) = await issuer2.issueClaim(schemaId2, claimsReq2)
    await prover.processClaim(schemaId1, claim1_attributes, claim1_signature)
    await prover.processClaim(schemaId2, claim2_attributes, claim2_signature)

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

    proofRequest = ProofRequest("proof1",
                                "1.0",
                                verifier.generateNonce(),
                                verifiableAttributes={
                                    'attr_uuid1':
                                    AttributeInfo('name', schema1.seqId),
                                    'attr_uuid2':
                                    AttributeInfo('status', schema2.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 proof.requestedProof.revealed_attrs['attr_uuid2'][1] == 'FULL'

    assert await verifier.verify(proofRequest, proof)
コード例 #6
0
 async def chkClaims():
     claim = await aliceAgent.prover.wallet.getClaims(ID(claimDefKey))
     assert claim.primaryClaim
コード例 #7
0
def schemaGvtId(schemaGvt):
    return ID(schemaGvt.getKey())
コード例 #8
0
ファイル: test_schema.py プロジェクト: zukobronja/indy-node
def test_get_schema_non_existent(submitted_schema, public_repo, looper):
    key = submitted_schema.getKey()
    key = key._replace(name=key.name + randomString(5))
    with pytest.raises(SchemaNotFoundError):
        looper.run(public_repo.getSchema(ID(schemaKey=key)))
コード例 #9
0
 async def getAllClaimsAttributes(self) -> ClaimsPair:
     res = ClaimsPair()
     for schemaKey in self._claims.keys():
         res[schemaKey] = await self.getClaimAttributes(ID(schemaKey))
     return res
コード例 #10
0
ファイル: test_schema.py プロジェクト: zukobronja/indy-node
def test_get_schema_by_seqno(submitted_schema, public_repo, looper):
    schema = looper.run(
        public_repo.getSchema(ID(schemaId=submitted_schema.seqId)))
    assert schema == submitted_schema
コード例 #11
0
ファイル: test_schema.py プロジェクト: zukobronja/indy-node
def test_get_schema_by_invalid_seqno(submitted_schema, public_repo, looper):
    with pytest.raises(SchemaNotFoundError):
        looper.run(
            public_repo.getSchema(
                ID(schemaId=(submitted_schema.seqId + randint(100, 1000)))))
コード例 #12
0
ファイル: test_schema.py プロジェクト: zukobronja/indy-node
def test_get_schema(submitted_schema, public_repo, looper):
    key = submitted_schema.getKey()
    schema = looper.run(public_repo.getSchema(ID(schemaKey=key)))
    assert schema == submitted_schema
コード例 #13
0
ファイル: test_public_repo.py プロジェクト: steptan/indy-node
def submittedSchemaDefGvtID2(submittedSchemaDefGvt2):
    return ID(schemaKey=submittedSchemaDefGvt2.getKey(),
              schemaId=submittedSchemaDefGvt2.seqId)
コード例 #14
0
ファイル: test_public_repo.py プロジェクト: steptan/indy-node
def testGetSchemaNonExistent(submittedSchemaDefGvt, publicRepo, looper):
    key = submittedSchemaDefGvt.getKey()
    key = key._replace(name=key.name + randomString(5))
    with pytest.raises(SchemaNotFoundError):
        looper.run(publicRepo.getSchema(ID(schemaKey=key)))
コード例 #15
0
def testGetSchemaBySeqNo(submittedSchemaDefGvt, publicRepo, looper):
    schema = looper.run(
        publicRepo.getSchema(ID(schemaId=submittedSchemaDefGvt.seqId)))
    assert schema == submittedSchemaDefGvt
コード例 #16
0
 async def getAllClaimsSignatures(self):
     res = dict()
     for schemaKey in self._c1s.keys():
         res[schemaKey] = await self.getClaimSignature(ID(schemaKey))
     return res
コード例 #17
0
def testGetSchemaByInvalidSeqNo(submittedSchemaDefGvt, publicRepo, looper):
    with pytest.raises(SchemaNotFoundError):
        looper.run(
            publicRepo.getSchema(
                ID(schemaId=(submittedSchemaDefGvt.seqId +
                             randint(100, 1000)))))
コード例 #18
0
def submitted_schema_ID(submitted_schema):
    return ID(schemaKey=submitted_schema.getKey(),
              schemaId=submitted_schema.seqId)