def testInteraction(gvtSecretKey):
    mcds = MemoryCredDefStore()

    miks = MemoryIssuerKeyStore()

    attrRepo = InMemoryAttrRepo()

    attrs = GVT.attribs(name='John Anthony White',
                        age=41,
                        sex='male')
    attrNames = tuple(attrs.keys())
    revealedAttrs = ["age", ]
    encodedAttrs = attrs.encoded()

    credName = "Profile"
    credVersion = "1.0"
    attrRepo.addAttributes(proverId, attrs)

    misks = MemoryIssuerSecretKeyStore()
    issuer = Issuer(issuerId, attrRepo, credDefStore=mcds, issuerSecretKeyStore=misks)
    credDefId = 1

    cd = CredentialDefinition(credDefId, attrNames, credName, credVersion)
    mcds.publish(cd)

    # Issuer Key set up
    issuerKeyId = 1
    issuerSecretKey = IssuerSecretKey(cd, sk=gvtSecretKey, uid=issuerKeyId)
    misks.put(issuerSecretKey)
    issuerKey = issuerSecretKey.PK

    miks.publish(issuerKey)

    # issuer.addNewCredDef(cd)
    prover = Prover(proverId, mcds, miks)
    verifier = Verifier(verifierId, mcds, miks)

    proofBuilder = prover.createProofBuilder(cduid=credDefId,
                                             ikuid=issuerKeyId,
                                             issuer=issuer,
                                             attrNames=attrNames,
                                             interactionId=interactionId,
                                             verifier=verifier,
                                             revealedAttrs=revealedAttrs)

    proof = proofBuilder.prepareProof(proofBuilder.credDefPks, proofBuilder.masterSecret,
                                      proofBuilder.credential,
                                      encodedAttrs,
                                      proofBuilder.revealedAttrs, proofBuilder.nonce)
    assert verifier.verify(issuer=issuer,
                           name=credName,
                           version=credVersion,
                           proof=proof,
                           nonce=proofBuilder.nonce,
                           attrs=encodedAttrs,
                           revealedAttrs=proofBuilder.revealedAttrs,
                           credDefId=credDefId,
                           issuerKeyId=issuerKeyId)
Ejemplo n.º 2
0
def testIssuerShouldBePassedAttributesList():
    attrRepo = InMemoryAttrRepo()
    attrRepo.addAttributes('prover1', GVT.attribs())

    issuer = Issuer(GVT.name, attrRepo)
    # This test should fail to add credential definition as
    # Credential definition requires attributes name list
    with pytest.raises(ValueError):
        CredentialDefinition(1, list())
Ejemplo n.º 3
0
def xyzCredDef(xyzCredDefId, xyzAttrNames):
    return CredentialDefinition(xyzCredDefId, xyzAttrNames)
Ejemplo n.º 4
0
def gvtCredDef(gvtCredDefId, gvtAttrNames):
    return CredentialDefinition(gvtCredDefId, gvtAttrNames)
Ejemplo n.º 5
0
def testIssuerShouldBePassedAttributesList():
    # This test should fail to add credential definition as
    # Credential definition requires attributes name list
    with pytest.raises(ValueError):
        CredentialDefinition(1, list())