Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple subjects in a Verifiable Credential #33

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

provTheodoreNewell
Copy link

Implementing #32, this change adds support for an array of subjects in the credentialSubject field of a Verifiable Credential to improve conformance with the Verifiable Credential Data Model v1.1, Section 4.4.

Behavior is maintained for credentials with a single subject object.

Implementation

Because the credentialSubject field may be an object or an array, I've added support for a list of credential subjects that is populated with however many subjects are in the credential.

If there is a single subject, the new VerifiableCredential::getCredentialSubjects() will return an array of size 1. The subject in the array will match the subject returned by VerifiableCredential::getCredentialSubject().

If there are multiple subjects, the new VerifiableCredential::getCredentialSubjects() will return an array with all the subjects in the same order as the source JSON-LD. The first subject will be returned by VerifiableCredential::getCredentialSubject().

Note that conversion to a JWT is unsupported for a credential with multiple subjects, as indicated by the Verifiable Credential Data Model v1.1, Section 6.3.1, heading JWT Encoding.

I've added unit tests for verifying, signing, and verifiable presentations for credentials with multiple subjects.

@provTheodoreNewell
Copy link
Author

@peacekeeper or @azuzi, let me know if you need any more information about this PR, or if there is someone else who should be reviewing it when you get a chance.
Thank you!

@azuzi
Copy link
Member

azuzi commented Mar 15, 2023

@provTheodoreNewell
The credentialSubject can be Json Array or Json Object as per the spec. Therefore, supporting both type of object will be the suitable approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants