Esempio n. 1
0
        public async Task TestAnoncredsWorksForClaimRevokedBeforeProofCreated()
        {
            //9. Issuer revoke claim
            var revocRegUpdateJson = await AnonCreds.IssuerRevokeClaimAsync(
                _issuerWallet,
                issuerDid,
                1,
                1);

            //10. Prover gets Claims for Proof Request
            var claimsJson = await AnonCreds.ProverGetClaimsForProofReqAsync(_issuerWallet, _proofReqJson);

            var claims         = JObject.Parse(claimsJson);
            var claimsForAttr1 = claims["attrs"]["attr1_referent"];
            var claim          = claimsForAttr1[0];
            var claimUuid      = claim.Value <string>("referent");

            //11. Prover create Proof
            var requestedClaimsJson = string.Format(_requestedClaimsJsonTemplate, claimUuid);

            var schemasJson    = string.Format("{{\"{0}\":{1}}}", claimUuid, schema);
            var claimDefsJson  = string.Format("{{\"{0}\":{1}}}", claimUuid, _claimDefJson);
            var revocRegsJsons = string.Format("{{\"{0}\":{1}}}", claimUuid, revocRegUpdateJson);

            var ex = await Assert.ThrowsExceptionAsync <ClaimRevokedException>(() =>
                                                                               AnonCreds.ProverCreateProofAsync(
                                                                                   _issuerWallet,
                                                                                   _proofReqJson,
                                                                                   requestedClaimsJson,
                                                                                   schemasJson,
                                                                                   masterSecretName,
                                                                                   claimDefsJson,
                                                                                   revocRegsJsons)
                                                                               );
        }
Esempio n. 2
0
        public async Task TestAnoncredsWorksForClaimRevokedAfterProofCreated()
        {
            //9. Prover gets Claims for Proof Request
            var claimsJson = await AnonCreds.ProverGetClaimsForProofReqAsync(_issuerWallet, _proofReqJson);

            var claims         = JObject.Parse(claimsJson);
            var claimsForAttr1 = claims["attrs"]["attr1_referent"];
            var claim          = claimsForAttr1[0];
            var claimUuid      = claim.Value <string>("referent");

            //10. Prover create Proof
            var requestedClaimsJson = string.Format(_requestedClaimsJsonTemplate, claimUuid);

            var schemasJson    = string.Format("{{\"{0}\":{1}}}", claimUuid, schema);
            var claimDefsJson  = string.Format("{{\"{0}\":{1}}}", claimUuid, _claimDefJson);
            var revocRegsJsons = string.Format("{{\"{0}\":{1}}}", claimUuid, _claimResult.RevocRegUpdateJson);

            var proofJson = await AnonCreds.ProverCreateProofAsync(
                _issuerWallet,
                _proofReqJson,
                requestedClaimsJson,
                schemasJson,
                masterSecretName,
                claimDefsJson,
                revocRegsJsons);

            //11. Issuer revoke prover claim
            var revocRegUpdateJson = await AnonCreds.IssuerRevokeClaimAsync(
                _issuerWallet,
                issuerDid,
                1,
                1);

            //12. Verifier verify proof
            var updatedRevocRegsJsons = string.Format("{{\"{0}\":{1}}}", claimUuid, revocRegUpdateJson);

            var valid = await AnonCreds.VerifierVerifyProofAsync(
                _proofReqJson,
                proofJson,
                schemasJson,
                claimDefsJson,
                updatedRevocRegsJsons);

            Assert.IsFalse(valid);
        }