Skip to content

Instantly share code, notes, and snippets.

@bblfish
Last active February 1, 2023 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bblfish/908145116b14486af9dd3460ce14b2c1 to your computer and use it in GitHub Desktop.
Save bblfish/908145116b14486af9dd3460ce14b2c1 to your computer and use it in GitHub Desktop.
Example1 Verifiable Credential
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/v1"
],
"id": "http://example.edu/credentials/1872",
"type": ["VerifiableCredential", "AlumniCredential"],
"issuer": "https://example.edu/issuers/565049",
"issuanceDate": "2010-01-01T19:23:24Z",
"credentialSubject": {
"id": "did:example:ebfeb1f712ebc6f1c276e12ec21",
"alumniOf": {
"id": "did:example:c276e12ec21ebfeb1f712ebc6f1",
"name": [{
"value": "Example University",
"lang": "en"
}, {
"value": "Exemple d'Université",
"lang": "fr"
}]
}
},
"proof": {
"type": "RsaSignature2018",
"created": "2017-06-18T21:19:10Z",
"proofPurpose": "assertionMethod",
"verificationMethod": "https://example.edu/issuers/565049#key-1",
"jws": "eyJhbGciOiJSUzI1NiIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..TCYt5XsITJX1CxPCT8yAV-TVkIEq_PbChOMqsLfRoPsnsgw5WEuts01mq-pQy7UJiN5mgRxD-WUcX16dUEMGlv50aqzpqh4Qktb3rk-BuQy72IFLOqV0G_zS245-kronKb78cPN25DGlcTwLtjPAYuNzVBAh4vGHSrQyHUdBBPM"
}
}
@prefix dc: <http://purl.org/dc/terms/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix schema: <http://schema.org/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
<http://example.edu/credentials/1872> a <https://www.w3.org/2018/credentials#VerifiableCredential>,
<https://example.org/examples#AlumniCredential>;
<https://w3id.org/security#proof> {
[
a <https://w3id.org/security#RsaSignature2018>;
dc:created "2017-06-18T21:19:10Z"^^xsd:dateTime;
<sec:jws> "eyJhbGciOiJSUzI1NiIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..TCYt5XsITJX1CxPCT8yAV-TVkIEq_PbChOMqsLfRoPsnsgw5WEuts01mq-pQy7UJiN5mgRxD-WUcX16dUEMGlv50aqzpqh4Qktb3rk-BuQy72IFLOqV0G_zS245-kronKb78cPN25DGlcTwLtjPAYuNzVBAh4vGHSrQyHUdBBPM";
<sec:proofPurpose> <https://w3id.org/security#assertionMethod>;
<sec:verificationMethod> <https://example.edu/issuers/565049#key-1>
] .
};
<https://www.w3.org/2018/credentials#credentialSubject> <did:example:ebfeb1f712ebc6f1c276e12ec21>;
<https://www.w3.org/2018/credentials#issuanceDate> "2010-01-01T19:23:24Z"^^xsd:dateTime;
<https://www.w3.org/2018/credentials#issuer> <https://example.edu/issuers/565049> .
<did:example:c276e12ec21ebfeb1f712ebc6f1> schema:name [], [] .
<did:example:ebfeb1f712ebc6f1c276e12ec21> schema:alumniOf <did:example:c276e12ec21ebfeb1f712ebc6f1> .
<did:example:c276e12ec21ebfeb1f712ebc6f1> <http://schema.org/name> _:b2 .
<did:example:c276e12ec21ebfeb1f712ebc6f1> <http://schema.org/name> _:b3 .
<did:example:ebfeb1f712ebc6f1c276e12ec21> <http://schema.org/alumniOf> <did:example:c276e12ec21ebfeb1f712ebc6f1> .
<http://example.edu/credentials/1872> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://example.org/examples#AlumniCredential> .
<http://example.edu/credentials/1872> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://www.w3.org/2018/credentials#VerifiableCredential> .
<http://example.edu/credentials/1872> <https://w3id.org/security#proof> _:b0 .
<http://example.edu/credentials/1872> <https://www.w3.org/2018/credentials#credentialSubject> <did:example:ebfeb1f712ebc6f1c276e12ec21> .
<http://example.edu/credentials/1872> <https://www.w3.org/2018/credentials#issuanceDate> "2010-01-01T19:23:24Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
<http://example.edu/credentials/1872> <https://www.w3.org/2018/credentials#issuer> <https://example.edu/issuers/565049> .
_:b1 <http://purl.org/dc/terms/created> "2017-06-18T21:19:10Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> _:b0 .
_:b1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://w3id.org/security#RsaSignature2018> _:b0 .
_:b1 <sec:jws> "eyJhbGciOiJSUzI1NiIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..TCYt5XsITJX1CxPCT8yAV-TVkIEq_PbChOMqsLfRoPsnsgw5WEuts01mq-pQy7UJiN5mgRxD-WUcX16dUEMGlv50aqzpqh4Qktb3rk-BuQy72IFLOqV0G_zS245-kronKb78cPN25DGlcTwLtjPAYuNzVBAh4vGHSrQyHUdBBPM" _:b0 .
_:b1 <sec:proofPurpose> <https://w3id.org/security#assertionMethod> _:b0 .
_:b1 <sec:verificationMethod> <https://example.edu/issuers/565049#key-1> _:b0 .
@bblfish
Copy link
Author

bblfish commented Feb 1, 2023

The first snippet is taken from the Verifiable Credentials Data Modal spec
https://www.w3.org/TR/vc-data-model/#example-a-simple-example-of-a-verifiable-credential

Greg Kellog's RDF distiller
http://rdf.greggkellogg.net/distiller?command=serialize&format=jsonld&output_format=n3
translates that to n3 resulting in the second snippet.

That is consistent with the result given by first going through https://json-ld.org/playground/ and first
converting to NQuads (third snipped in [1]) and then using distiller to convert nquads to n3.

In both cases there is a problem because we end up with the uninformative 2 triples

  <did:example:c276e12ec21ebfeb1f712ebc6f1> schema:name [], [] .

For a fix see https://gist.github.com/bblfish/ab1b450c725674a4386cfc391b7e307b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment