Skip to main content

Using Different Proof Formats

danger

TODO: Make tradeoffs less subjective and more practical

Introduction

In this tutorial, we will demonstrate how to use Veramo to generate different proof formats, such as JWT (JSON Web Tokens) and Linked Data (LD) proofs. One of the key benefits of using Veramo is its flexibility, which allows you to switch between different proof formats with ease.

Proof Formats Overview

JWT (JSON Web Tokens)

Advantages

  • Compact Representation: JWTs are compact, making them efficient to transmit over the network.
  • Wide Adoption: JWTs are widely supported across different platforms and programming languages.
  • Self-Contained: JWTs are self-contained, meaning they carry all the information needed to verify the credential within the token itself.

Disadvantages

  • Less Human-Readable: JWTs are less human-readable compared to LD proofs.
  • Limited Extensibility: JWTs have a more rigid structure, which can limit extensibility.

LD (Linked Data) Proofs

Advantages

  • Interoperability: LD proofs are based on linked data standards, making them highly interoperable.
  • Human-Readable: LD proofs are more human-readable, as they use JSON-LD format.
  • Extensibility: LD proofs are highly extensible, allowing for more complex data structures and relationships.

Disadvantages

  • Larger Size: LD proofs tend to be larger in size compared to JWTs, which can affect transmission efficiency.
  • Complexity: LD proofs can be more complex to implement and manage, especially with maintaining linked data contexts.

Steps

Prerequisites

Before you begin, follow the prerequisites for installation and configuration instructions.

1. Generating a JWT Proof

veramo credential create

Select the following options to generate a JWT proof:

? Credential proofFormat jwt
? Issuer DID did:web:identity.foundation:demos:sample_dids:company
? Subject DID did:ethr:0x0232c23a85049404480dac15519bfc74d36b2f6afad1dff7400fb2d09b6423c7fc
? Credential Type VerifiableCredential,EmployeeCredential
? Claim Type employeeOf
? Claim Value Sample Company

Expected output:

{
"credentialSubject": {
"employeeOf": "Sample Company",
"id": "did:ethr:0x0232c23a85049404480dac15519bfc74d36b2f6afad1dff7400fb2d09b6423c7fc"
},
"issuer": { "id": "did:web:identity.foundation:demos:sample_dids:company" },
"type": ["VerifiableCredential", "EmployeeCredential"],
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://veramo.io/contexts/profile/v1"
],
"issuanceDate": "2024-06-21T22:32:02.000Z",
"proof": {
"type": "JwtProof2020",
"jwt": "eyJhbGciOiJFUzI1NksiLCJ0eXAiOiJKV1QifQ.eyJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSIsImh0dHBzOi8vdmVyYW1vLmlvL2NvbnRleHRzL3Byb2ZpbGUvdjEiXSwidHlwZSI6WyJWZXJpZmlhYmxlQ3JlZGVudGlhbCIsIkVtcGxveWVlQ3JlZGVudGlhbCJdLCJjcmVkZW50aWFsU3ViamVjdCI6eyJlbXBsb3llZU9mIjoiU2FtcGxlIENvbXBhbnkifX0sInN1YiI6ImRpZDpldGhyOjB4MDIzMmMyM2E4NTA0OTQwNDQ4MGRhYzE1NTE5YmZjNzRkMzZiMmY2YWZhZDFkZmY3NDAwZmIyZDA5YjY0MjNjN2ZjIiwibmJmIjoxNzE5MDA5MTIyLCJpc3MiOiJkaWQ6d2ViOmlkZW50aXR5LmZvdW
5kYXRpb246ZGVtb3M6c2FtcGxlX2RpZHM6c2FtcGxlX29yZyJ9.lhDIDDbe-Uf3UcyStnxYgoZjKybWI4OswjeIGuXeBNs6HG8RU4ysGXPU_IoJYr_StpRciCF0VjywHxTVxbnZBw"
}
}

2. Generating an LD Proof

veramo credential create

Select the following options to generate an LD proof:

? Credential proofFormat lds
? Issuer DID did:web:identity.foundation:demos:sample_dids:company
? Subject DID did:ethr:0x0232c23a85049404480dac15519bfc74d36b2f6afad1dff7400fb2d09b6423c7fc
? Credential Type VerifiableCredential,EmployeeCredential
? Claim Type employeeOf
? Claim Value Sample Company

Expected output:

{
"credentialSubject": {
"employeeOf": "Sample Company",
"id": "did:ethr:0x0232c23a85049404480dac15519bfc74d36b2f6afad1dff7400fb2d09b6423c7fc"
},
"issuer": { "id": "did:web:identity.foundation:demos:sample_dids:company" },
"type": ["VerifiableCredential", "EmployeeCredential"],
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://veramo.io/contexts/profile/v1"
],
"issuanceDate": "2024-06-21T22:32:02.000Z",
"proof": {
"type": "Ed25519Signature2018",
"created": "2024-06-21T22:25:26Z",
"verificationMethod": "did:web:identity.foundation:demos:sample_dids:company#dc0a72e06d626576d2ec2b6c00029795ea2d3f89ac7087389e7c4da38f65768e",
"proofPurpose": "assertionMethod",
"jws": "eyJhbGciOiJFZERTQSIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..3cahb3pmoc9JlqFeFdMH8G2MhzFfY3V20DMh6D-fyCcZWo7P07IheeE9WuQRB48hgtEJ38rPudhz25rYWecEAA"
}
}

Switching Between Proof Formats with Veramo

One of the key benefits of using Veramo is its flexibility to switch between different proof formats with minimal changes to your code. This allows you to adapt to different requirements and standards as needed.

Maintaining Linked Data Contexts

When working with LD proofs, it is crucial to maintain linked data contexts to ensure interoperability and extensibility. Linked data contexts provide the necessary context for interpreting the data, ensuring that the credentials can be understood and verified by different systems.

Example of adding a linked data context:

{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://veramo.io/contexts/profile/v1",
"https://example.com/contexts/custom/v1"
]
}

By maintaining linked data contexts, you ensure that your credentials are interoperable and can be extended to include additional information as needed.

Conclusion

In this tutorial, we demonstrated how to generate different proof formats using Veramo, discussed the advantages and disadvantages of each proof format, and highlighted the importance of maintaining linked data contexts. Veramo's flexibility allows you to switch between proof formats easily, ensuring that your decentralized identity solutions can adapt to different requirements and standards with minimal effort.