- Data Consistency: Ensures all credentials of the same type have identical field structures
- Validation: Defines data types and constraints for each field
- Interoperability: Allows different systems to understand and process your credentials
- Privacy: Enables selective disclosure of specific fields within a credential
SD-JWT and Iden3 use schemas differently. For SD-JWT VC credentials, the default format, the schema defines the claim names and types, and the schema ID becomes the credential type (
vct) unless your issuer sets its own. Which claims are selectively disclosable is set by the issuer’s disclosureFrame. The JSON-LD context and $metadata described below apply to Iden3 credentials.Schema components
A Schema Type encodes the structure of a particular Verifiable Credential (VC) by defining the type, the fields that must be included inside the VC, and a description for these fields. Schemas let different services interpret the same credential consistently. A verifier that knows the schema can read the credential’s claims without contacting the issuer. A schema type is made of two separate documents:1. JSON-LD context
The JSON-LD Context contains a description of the type and its fields, providing semantic meaning to your credential data by linking it to standardized vocabularies and ontologies.Understanding JSON-LD context
JSON-LD context defines the vocabulary and data types used in your credentials. It maps local field names to globally unique identifiers (URIs) that have well-defined meanings. Here’s an example of a JSON-LD Context for aMembershipPointsCredential:
Key JSON-LD context elements
- @version: Specifies the JSON-LD version (typically 1.1)
- @protected: Ensures that terms cannot be overridden
- @id: Maps to globally unique identifiers
- @type: Specifies the data type using XML Schema types
- vocab: Custom vocabulary namespace for your specific fields
- xsd: XML Schema Definition namespace for standard data types
2. JSON Schema
The JSON Schema contains the validation rules for the Issuer Node, defining the structure and constraints for the credential data. Here’s an example of a JSON Schema for theMembershipPointsCredential:
Key JSON Schema elements
- $metadata: Contains URIs linking to both the JSON-LD context and JSON schema
- required: Lists all mandatory fields for the credential
- properties: Defines the structure and validation rules for each field
- credentialSubject: Contains the actual credential data fields
- format: Specifies validation formats (uri, date-time, etc.)
Benefits of this two-document approach
- Separation of Concerns: JSON-LD handles semantics, JSON Schema handles validation
- Interoperability: Different systems can understand credentials using standard vocabularies
- Validation: Issuer nodes can validate credential structure before issuance
- Flexibility: Allows for complex validation rules while maintaining semantic clarity