-
Notifications
You must be signed in to change notification settings - Fork 17
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
implement vc verification #182
Conversation
crates/credentials/src/vc.rs
Outdated
pub async fn verify_vcjwt(jwt: &str) -> Result<Arc<VerifiableCredential>, CredentialError> { | ||
let jwt_decoded = Jwt::verify::<VcJwtClaims>(jwt).await?; | ||
Ok(Arc::new(jwt_decoded.claims.vc)) | ||
fn validate_vc_data_model( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this should be an instance method on the impl VerifiableCredential
implementation, so maybe like
impl VerifiableCredential {
// ...
pub fn validate(&self) -> Result<(), CredentialDataModelValidationError> {
// ...
}
}
Which then brings into question, perhaps we should add *_vcjwt
to the sign()
, verify()
and decode()
functions. So that would be sign_vcjwt()
, verify_vcjwt()
and decode_vcjwt()
. Rust doesn't support function overloading FWIW.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well we've been down this path before
The thought was that the end user would get confused for
vc.validate()
vc.verify()
so the thought was to have a verifyOptions
object, which you can have to only do validatePayload vs check specific verification vs all:
decentralized-identity/web5-js#425
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay cool, I may make a follow up GitHub Issue for this matter -- specifically, for the endeavor of maximizing modularity here at the rust core layer I think it's fitting to offer every single one of these little verification/validation checks as its own function. my thought process is a barbell design, wherein verify()
does everything, but then we expose public facing methods for each individual one, so if developers want to create their own set of verification rules then they string the atomic ones together
this is really great work! I appreciate how you created follow-up ticket items. I've added a handful of comments probably worth addressing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🏆
This pr does a change on how we process and verify VCs from a VcJwt:
This looks at registered claims fields and does a few checks:
Here is the spec specific text:
for reference:
This "minimum" vc object is valid according to the spec
Notice how every field in the vc is missing like id and issuer, these are populated from the claims like jti, iss
We actually dont support "empty" and only support Default like empty string and 0, so we will need to fix this issuer tracked here #202