Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
fix: addresses bug with blank nodes that was breaking nesting
Browse files Browse the repository at this point in the history
the blank nodes were only being transformed in the node identifier portion of the nQuad. This caused
issues in how the nQuads would be converted back from RDF to JSON which in-advertently broke the
ability for a proof to be derived from a nested structure. This fix makes it so that all blank node
identifiers are transformed properly rather than just the node identifiers (first part of the nQuad).

re #91
  • Loading branch information
kdenhartog committed Dec 14, 2020
1 parent 2673a0a commit 016364d
Show file tree
Hide file tree
Showing 18 changed files with 868 additions and 652 deletions.
40 changes: 39 additions & 1 deletion __tests__/BbsBlsSignatureProof2020.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import {
testSignedVcDocument,
testRevealVcDocument,
testPartialVcProof,
testRevealAllDocument
testRevealAllDocument,
testProofNestedVcDocument,
testPartialProofNestedVcDocument
} from "./__fixtures__";

import jsigs from "jsonld-signatures";
Expand Down Expand Up @@ -131,6 +133,42 @@ describe("BbsBlsSignatureProof2020", () => {
expect(result.verified).toBeTruthy();
});

it("should verify a fully revealed derived proof that uses nesting from a vc", async () => {
const suite = new BbsBlsSignatureProof2020();

const { proofs, document } = await getProofs({
document: testProofNestedVcDocument,
proofType: BbsBlsSignatureProof2020.proofType,
documentLoader: customLoader
});

const result = await suite.verifyProof({
document,
proof: proofs[0],
documentLoader: customLoader,
purpose: new jsigs.purposes.AssertionProofPurpose()
});
expect(result.verified).toBeTruthy();
});

it("should verify a partially revealed derived proof that uses nesting from a vc", async () => {
const suite = new BbsBlsSignatureProof2020();

const { proofs, document } = await getProofs({
document: testPartialProofNestedVcDocument,
proofType: BbsBlsSignatureProof2020.proofType,
documentLoader: customLoader
});

const result = await suite.verifyProof({
document,
proof: proofs[0],
documentLoader: customLoader,
purpose: new jsigs.purposes.AssertionProofPurpose()
});
expect(result.verified).toBeTruthy();
});

it("should verify partial derived proof from vc", async () => {
const suite = new BbsBlsSignatureProof2020();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"name": "http://schema.org/name",
"description": "http://schema.org/description",
"identifier": "http://schema.org/identifier",
"image": {"@id": "http://schema.org/image", "@type": "@id"},
"image": { "@id": "http://schema.org/image", "@type": "@id" },

"PermanentResidentCard": {
"@id": "https://w3id.org/citizenship#PermanentResidentCard",
Expand All @@ -20,7 +20,7 @@
"description": "http://schema.org/description",
"name": "http://schema.org/name",
"identifier": "http://schema.org/identifier",
"image": {"@id": "http://schema.org/image", "@type": "@id"}
"image": { "@id": "http://schema.org/image", "@type": "@id" }
}
},

Expand All @@ -38,17 +38,20 @@
"xsd": "http://www.w3.org/2001/XMLSchema#",

"birthCountry": "ctzn:birthCountry",
"birthDate": {"@id": "schema:birthDate", "@type": "xsd:dateTime"},
"birthDate": { "@id": "schema:birthDate", "@type": "xsd:dateTime" },
"commuterClassification": "ctzn:commuterClassification",
"familyName": "schema:familyName",
"gender": "schema:gender",
"givenName": "schema:givenName",
"lprCategory": "ctzn:lprCategory",
"lprNumber": "ctzn:lprNumber",
"residentSince": {"@id": "ctzn:residentSince", "@type": "xsd:dateTime"}
"residentSince": {
"@id": "ctzn:residentSince",
"@type": "xsd:dateTime"
}
}
},

"Person": "http://schema.org/Person"
}
}
}
111 changes: 111 additions & 0 deletions __tests__/__fixtures__/contexts/credential_vocab.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{
"@context": {
"@version": 1.1,
"@protected": true,
"id": "@id",
"type": "@type",
"VerifiableCredential": {
"@id": "https://www.w3.org/2018/credentials#VerifiableCredential",
"@context": {
"@version": 1.1,
"@protected": true,
"id": "@id",
"type": "@type",
"credentialSchema": {
"@id": "https://www.w3.org/2018/credentials#credentialSchema",
"@type": "@id",
"@context": {
"@version": 1.1,
"@protected": true,
"id": "@id",
"type": "@type",
"JsonSchemaValidator2018": "https://www.w3.org/2018/credentials#JsonSchemaValidator2018"
}
},
"credentialStatus": {
"@id": "https://www.w3.org/2018/credentials#credentialStatus",
"@type": "@id"
},
"credentialSubject": {
"@id": "https://www.w3.org/2018/credentials#credentialSubject",
"@type": "@id"
},
"evidence": {
"@id": "https://www.w3.org/2018/credentials#evidence",
"@type": "@id"
},
"expirationDate": {
"@id": "https://www.w3.org/2018/credentials#expirationDate",
"@type": "http://www.w3.org/2001/XMLSchema#dateTime"
},
"holder": {
"@id": "https://www.w3.org/2018/credentials#holder",
"@type": "@id"
},
"issued": {
"@id": "https://www.w3.org/2018/credentials#issued",
"@type": "http://www.w3.org/2001/XMLSchema#dateTime"
},
"issuer": {
"@id": "https://www.w3.org/2018/credentials#issuer",
"@type": "@id"
},
"issuanceDate": {
"@id": "https://www.w3.org/2018/credentials#issuanceDate",
"@type": "http://www.w3.org/2001/XMLSchema#dateTime"
},
"proof": {
"@id": "https://w3id.org/security#proof",
"@type": "@id",
"@container": "@graph"
},
"refreshService": {
"@id": "https://www.w3.org/2018/credentials#refreshService",
"@type": "@id",
"@context": {
"@version": 1.1,
"@protected": true,
"id": "@id",
"type": "@type",
"ManualRefreshService2018": "https://www.w3.org/2018/credentials#ManualRefreshService2018"
}
},
"termsOfUse": {
"@id": "https://www.w3.org/2018/credentials#termsOfUse",
"@type": "@id"
},
"validFrom": {
"@id": "https://www.w3.org/2018/credentials#validFrom",
"@type": "http://www.w3.org/2001/XMLSchema#dateTime"
},
"validUntil": {
"@id": "https://www.w3.org/2018/credentials#validUntil",
"@type": "http://www.w3.org/2001/XMLSchema#dateTime"
}
}
},
"VerifiablePresentation": {
"@id": "https://www.w3.org/2018/credentials#VerifiablePresentation",
"@context": {
"@version": 1.1,
"@protected": true,
"id": "@id",
"type": "@type",
"holder": {
"@id": "https://www.w3.org/2018/credentials#holder",
"@type": "@id"
},
"proof": {
"@id": "https://w3id.org/security#proof",
"@type": "@id",
"@container": "@graph"
},
"verifiableCredential": {
"@id": "https://www.w3.org/2018/credentials#verifiableCredential",
"@type": "@id",
"@container": "@graph"
}
}
}
}
}
Loading

0 comments on commit 016364d

Please sign in to comment.