[DONE] How can we improve our VC & VP validation API? #571
Replies: 5 comments 16 replies
-
Did we rule out making application specific validation an application level concern? e.g. : |
Beta Was this translation helpful? Give feedback.
-
From the Alternative 1-3 I vastly prefer Alternative 1. Fully agree with the Pros and Cons although I think we need to make sure we have a default configuration for minimal technical verification (signature valid, not expired) that can be overridden and extended. |
Beta Was this translation helpful? Give feedback.
-
I agree Approach 1 is more user-friendly and informative than the current approach. However, I would still prefer to return errors for individual validation functions. "Why" something failed validation is often just as important as the failure, particularly when considering user interfaces where feedback is expected. Without validation errors, developers would need to check cases individually to find out what went wrong (e.g. "was the signature expired?", "was the challenge wrong?", etc.) effectively duplicating a large part of the validation we do internally. I too think we need to have "sensible defaults" in addition to fine-grained validation checks, since we want to ensure as many developers validate credentials properly and completely to avoid perceived security flaws. That may mean something similar to Alternative 3 or the approach taken with Q1: Are the validation functions on the Q2: How does this affect validating pub struct ResolvedPresentation<T = Object, U = Object> {
pub presentation: Presentation<T, U>,
pub holder: ResolvedIotaDocument,
pub credentials: Vec<ResolvedCredential<U>>,
} with similar associated functions? |
Beta Was this translation helpful? Give feedback.
-
Thank you for all your input so far, Let us briefly summarize where we are at the moment before I ask some follow up questions.
Now for the follow up questions: In the case of the former in the context of Alternative 3, I think we would need a method of the form In the case of the latter I am thinking of doing something along the following lines: resolve_credential(credential: Credential, options: &FilterOptions<Credential>) -> Result<ResolvedCredential, Something> and resolve_presentation(presentation: Presentation, options: &FilterOptions<Presentation>) -> Result<ResolvedPresentation, Something> where For those that want to validate everything on their own we provide methods requiring a feature flag What do you think of these ideas? |
Beta Was this translation helpful? Give feedback.
-
Here is a new list of possible ways forward (taking into account the comments made in this discussion so far).
|
Beta Was this translation helpful? Give feedback.
-
Introduction
Validation is use case dependent by definition (see Verification and validation and/or Software verification and validation). In the context of verifiable credentials (VCs) an example would be a customer presenting a drivers licence as a VC. Then a car rental service and a concert hall would quite possibly validate this credential in different ways. The former is interested in the fact that the VC's subject can legally drive for the entire duration of the rental, while the latter may only be interested in knowing that the subject is old enough to attend a concert.
Our current VC validation process does not do much to accommodate for application dependent requirements during validation. It merely produces a
CredentialValidation
that has averified
field that informs us whether the issuer's signature was verified and that all the VC's subjects have active DID documents. Issue #312 requests errors to be thrown during validation, but what is to be considered an error is highly use case dependent. The question we want to answer is therefore: How can we make credential validation flexible enough to accommodate for different modes of failure?Some ideas
Let us explore some possible approaches.
Approach 1: Composition of validation units
We expose several single concern validator functions (validation units) such as: valid_issuer_signature, expires_after, issuance_date_after, trusted_issuer etc. and then each application can use these (and possibly their own functions) to compose their own validator. In order to avoid the need for every single function to resolve DID documents we would need to separate the resolution process and validation process. Hence we would have something like:
and the
Resolver
would have a corresponding method:async fn resolve_credential(&self) -> Result<ResolvedCredential>
then the validation units would look something like this:
Then each application bakes their own validator by composing these functions as they wish, and if they need any validation units that we haven't thought of they can easily create their own within their own application .
Pros:
Cons:
Alternative 2: Validation with a simple "allowed deficiencies" config.
We introduce an enum
and change the signature of
CredentialValidator
'svalidate_credential
method to bethen if signature verification fails or any deficiency (such as the current timestamp is later than the credential's expiry date) that is not in
allowed_deficiencies
leads to a failure. Since this is not a very expressive API (it is for instance not possible to state that an expiry is allowed exactly when it happened less than two weeks ago) we need to change the returnedCredentialValidation
to accommodate for application dependent post validation checks. This could look something like this:and in the case where
encountered_allowed_deficiencies
is not empty additional checks may be needed for this struct at the application level.Pros:
validate_credential
.CredentialValidation
type can only be constructed by callingvalidate_credential
. This does still not necessarily prove that validation was successful however.Cons:
CredentialValidation
struct adds more complexity.Alternative 3: Validation with an advanced config
We introduce a
CredentialValidationOptions
structure with builder methods:with_earliest_expiration_date
,allow_deactivated_subject_documents_for
,with_latest_issuance_date
,with_trusted_issuers
and so on. Then this is passed as an additional argument tovalidate_credential
(in place ofallowed_deficiencies
in Alternative 2).Pros:
CredentialValidation
means that the corresponding credential satisfies the needs of the application.CredentialValidation
in the happy case ofvalidate_credential
is simpler than in alternative 2: Now the error reports any validation failure instead.Cons:
validate_presentation
should be altered to accommodate forCredentialValidationOptions
.CredentialValidationOptions
adds more complexity to this library.Any thoughts on the proposed ideas or any other suggestions would be greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions