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

Require credentialSubject to be non-empty #409

Merged
merged 3 commits into from Mar 29, 2022
Merged

Conversation

clehner
Copy link
Contributor

@clehner clehner commented Mar 21, 2022

As seen in decentralized-identity/JWS-Test-Suite#46, VC Data Model appears to require that credentialSubject contains at least one property. Similarly, there must be at least one credential subject. This PR adds checks for these two cases (no empty-object or empty-array credentialSubject values), and updates two examples to use non-empty credentialSubject values. Signed test vectors using empty credentialSubject with RDF-based signatures are updated to use a blank node id as the credential subject id, since this does not require reissuing those credential. One test vector VC (did-pkh/tests/vc-poly-epsig.jsonld) had to be reissued, since it was using an empty credential subject but not an RDF-based signature.

@clehner clehner marked this pull request as ready for review March 22, 2022 17:13
@clehner clehner requested a review from sbihel March 24, 2022 19:47
Copy link
Member

@sbihel sbihel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just remove the Option?

@clehner
Copy link
Contributor Author

clehner commented Mar 28, 2022

Why not just remove the Option?

Which?

Credential::credential_subject is using OneOrMany, no Option:

ssi/src/vc.rs

Line 51 in d3c0253

pub credential_subject: OneOrMany<CredentialSubject>,

CredentialSubject::id is an Option; this is allowed (id is optional):

ssi/src/vc.rs

Line 111 in d3c0253

pub id: Option<URI>,

CredentialSubject::property_set is an Option; this could be changed I think - using skip_serializing_if = "Map::is_empty"; this occurs in other structs as well.

ssi/src/vc.rs

Line 114 in d3c0253

pub property_set: Option<Map<String, Value>>,

If we want to distinguish CredentialSubject into the id and id-less cases, it could maybe be changed into an untagged enum where one variant has a non-optional id and the other variant is just the property_set map.

@sbihel
Copy link
Member

sbihel commented Mar 29, 2022

I think I might have been looking at the issuer instead of subject, sorry.

@clehner
Copy link
Contributor Author

clehner commented Mar 29, 2022

OK, no problem.

The issuer property is optional on the Credential struct only because in a JWT "vc" claim it might be omitted in favor of a JWT "iss" claim.
We could consider making the types more specific by splitting the Credential type into "credential", "verifiable credential", and JWT "vc" claim object.

@clehner clehner merged commit ab332d1 into main Mar 29, 2022
@clehner clehner deleted the feat/non-empty-subj branch March 29, 2022 13:25
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.

None yet

2 participants