w3c / vc-json-schema

A mechanism to use JSON Schemas with Verifiable Credentials
https://w3c.github.io/vc-json-schema
Other
27 stars 8 forks source link

Question regarding JsonSchemaCredential #235

Open mjfelis opened 2 months ago

mjfelis commented 2 months ago

I think it could be interesting to have a third option for using Json Schema in credentials.

The third option would be, in the JsonSchemaCredential, instead of providing the full Json Schema (property "jsonSchema"), provide a "jsonSchemaReference" that would include the id of the Json Schema and a "digestSRI" property. That would be handy to verify several issuers are conforming to the same json schema without having to manually compare the content of the jsonSchema property.


{
  "@context": [
      "https://www.w3.org/ns/credentials/v2",
      "https://www.w3.org/ns/credentials/examples/v2"
  ],
  "id": "https://example.com/credentials/3734",
  "type": ["VerifiableCredential", "JsonSchemaCredential"],
  "issuer": "https://example.com/issuers/14",
  "issuanceDate": "2010-01-01T19:23:24Z",
  "credentialSchema": {
    "id": "https://www.w3.org/2022/credentials/v2/json-schema-credential-schema.json",
    "type": "JsonSchema",
    "digestSRI": "sha384-S57yQDg1MTzF56Oi9DbSQ14u7jBy0RDdx0YbeV7shwhCS88G8SCXeFq82PafhCrW"
  },
  "credentialSubject": {
    "id": "https://example.com/schemas/favorite-color-schema.json",
    "type": "JsonSchema",
    "jsonSchemaReference": {
       "id": "https://example.com/schemas/email-credential-schema.json",
       "digestSRI": "sha384-ABCSGyugst67rs67rdbugsy0RDdx0YbeV7shwhCS88G8SCXeFq82PafhCrW"
    }    
  }
}
decentralgabe commented 2 months ago

thanks @mjfelis for the issue.

Today we can...

  1. Reference a JSON Schema in a VC with the JsonSchema or JsonSchemaCredential types
  2. The id reference to a JsonSchema could be a schema or reference to a JSON Schema (using $ref).
  3. The id reference to a JsonSchemaCredential could be a VC that contains a reference to another JSON Schema (using $ref) without re-defining the JSON Schema.

I am happy to expand on any/all of those depending on the functionality you're looking for, in addition to improving spec language/examples to illustrate these possibilities.

I think you are looking for (3) -- amending your example it could work with something like...

{
  "@context": [
    "https://www.w3.org/ns/credentials/v2",
    "https://www.w3.org/ns/credentials/examples/v2"
  ],
  "id": "https://example.com/credentials/3734",
  "type": [
    "VerifiableCredential",
    "JsonSchemaCredential"
  ],
  "issuer": "https://example.com/issuers/14",
  "issuanceDate": "2010-01-01T19:23:24Z",
  "credentialSchema": {
    "id": "https://www.w3.org/2022/credentials/v2/json-schema-credential-schema.json",
    "type": "JsonSchema",
    "digestSRI": "sha384-S57yQDg1MTzF56Oi9DbSQ14u7jBy0RDdx0YbeV7shwhCS88G8SCXeFq82PafhCrW"
  },
  "credentialSubject": {
    "id": "https://example.com/schemas/favorite-color-schema.json",
    "type": "JsonSchema",
    "jsonSchema": {
      "$ref": "https://example.com/schemas/email-credential-schema.json"
    },
    "digestSRI": "sha384-ABCSGyugst67rs67rdbugsy0RDdx0YbeV7shwhCS88G8SCXeFq82PafhCrW"
  }
}

If that is what you're looking for we would need to update guidance on how to provide digestSRI for JsonSchemaCredentials with external references.

mjfelis commented 2 months ago

Hi @decentralgabe,

Yes, that's exactly what we need. That would be an optimal solution for referencing json schemas stored in a Trust Registry.

decentralgabe commented 2 months ago

great - I'll assign myself to add spec text around this.

separately -- does your organization or an organization you're working with belong to the W3C or have an interest in joining? we are looking for more editors and implementers for this spec.