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

Additional RDF validation of linked data proofs #241

Merged
merged 3 commits into from
Aug 10, 2021
Merged

Conversation

clehner
Copy link
Contributor

@clehner clehner commented Jul 29, 2021

This addresses #235 by adding checking of proof properties as RDF terms in addition to their handling as JSON. This is implemented for every proof type that uses JSON-LD to RDF conversion for signing. The processing is done on the proof object's RDF dataset just before creating the linked data proof verification hash.

Negative test cases are added, using JsonWebSignature2020, to demonstrate the validation.

The example VCs/VPs using RsaSignature2018 do not pass this validation, due to a bug in the Credentials v1 base context which resulted in proof objects of that type not using the expected IRIs: w3c/vc-data-model#778. Rather than working around this context bug (as in w3c/vc-data-model#778 (comment)), the example VCs/VPs are replaced with ones using JsonWebSignature2020, since RsaSignature2018 is deprecated.

The validation is done even for the proof types in the core Credentials v1 context, where their terms cannot be redefined due to using @protected. It may be possible to relax this validation for certain proof types when certain context files are in effect. However, even with use of @protected, additional RDF statements may exist in the proof not using the expected compact terms, even as in fully expanded proof objects, which JSON-only parsing would not detect; the validation added here ensures that the RDF statements must match one-to-one with the JSON properties of the proof object. If we want to support proof objects in expanded form (full IRIs as property names), and/or aliased property names other than the commonly-defined terms, this validation would need to be relaxed, but could be repurposed for its RDF parsing which could be used instead of serde deserialization of the Proof struct.

RDF validation is not added for proof types that do not use JSON-LD/RDF (i.e. EthereumEip712Signature2021).

@clehner clehner force-pushed the feat/rdf-check branch 7 times, most recently from 35fdb5f to f81a914 Compare August 5, 2021 14:48
@clehner clehner marked this pull request as ready for review August 5, 2021 15:50
@clehner clehner requested a review from sbihel August 5, 2021 15:56
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.

I think it looks good, although I find it a bit hard to follow, to keep the big picture in mind. Not sure what could be done to simplify it though 😬

src/ldp.rs Show resolved Hide resolved
src/rdf.rs Outdated Show resolved Hide resolved
src/rdf.rs Show resolved Hide resolved
src/rdf.rs Outdated Show resolved Hide resolved
src/rdf.rs Show resolved Hide resolved
src/rdf.rs Show resolved Hide resolved
@clehner clehner marked this pull request as draft August 6, 2021 17:32
@clehner clehner marked this pull request as ready for review August 6, 2021 17:55
@clehner clehner requested a review from sbihel August 6, 2021 18:28
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