-
Notifications
You must be signed in to change notification settings - Fork 55
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
update to latest vc-jwt spec; differentiate between id and key id #341
Conversation
// normalizePresentationClaims takes a set of Presentation Claims and turns them into map[string]any as | ||
// go-JSON representations. The claim format and signature algorithm type are noted as well. | ||
// This method is greedy, meaning it returns the set of claims it was able to normalize. | ||
func normalizePresentationClaims(claims []exchange.PresentationClaim) []exchange.NormalizedClaim { |
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.
removed some dead code along the way
Codecov Report
@@ Coverage Diff @@
## main #341 +/- ##
==========================================
- Coverage 57.51% 57.32% -0.19%
==========================================
Files 51 51
Lines 6201 6232 +31
==========================================
+ Hits 3566 3572 +6
- Misses 1967 1983 +16
- Partials 668 677 +9
|
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.
Lots of changes, I hope our test vectors are up to par. Good stuff!
@@ -18,7 +18,7 @@ import ( | |||
|
|||
func TestBuildPresentationSubmission(t *testing.T) { | |||
t.Run("Unsupported embed target", func(tt *testing.T) { | |||
_, err := BuildPresentationSubmission(crypto.JWTSigner{}, PresentationDefinition{}, nil, "badEmbedTarget") | |||
_, err := BuildPresentationSubmission(crypto.JWTSigner{}, "requester", PresentationDefinition{}, nil, "badEmbedTarget") |
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.
if "requester" and "submitter" are things we will use mostly in production may be good to make a const
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.
not used in production as these strings. I would imagine they're each the DIDs of the requester/submitter
return nil, errors.Wrap(err, "could not set nbf value") | ||
} | ||
// remove the issuance date from the credential | ||
cred.IssuanceDate = "" |
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 is to spec?
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.
yes, strange to me too - see the spec text below and examples https://w3c.github.io/vc-jwt/#jwt-decoding
In the example above, vc does not contain the id property because the JWT encoding uses the jti attribute to represent a unique identifier. The sub attribute encodes the information represented by the id property of credentialSubject
|
||
idVal := cred.ID | ||
if idVal != "" { | ||
if err := t.Set(jwt.JwtIDKey, idVal); err != nil { | ||
return nil, errors.Wrap(err, "could not set jti value") | ||
} | ||
// remove the id from the credential | ||
cred.ID = "" |
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.
here too
} | ||
|
||
subVal := cred.CredentialSubject.GetID() | ||
if subVal != "" { | ||
if err := t.Set(jwt.SubjectKey, subVal); err != nil { | ||
return nil, errors.Wrap(err, "setting subject value") | ||
} | ||
// remove the id from the credential subject | ||
delete(cred.CredentialSubject, "id") |
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.
here too
// JWTVVPParameters represents additional parameters needed when constructing a JWT VP as opposed to a VP | ||
type JWTVVPParameters struct { | ||
// Audience is a required intended audience of the JWT. | ||
Audience string `validate:"required"` |
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 is an awesome field btw
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.
yeah turns out for JWTs you must have an intended audience. cc: @amika-sq
// BuildPresentationSubmission builds a submission using... | ||
// https://github.com/TBD54566975/ssi-sdk/blob/d279ca2779361091a70b8aa3c685a388067409a9/credential/exchange/submission.go#L126 | ||
func BuildPresentationSubmission(presentationRequest []byte, signer crypto.JWTSigner, verifier crypto.JWTVerifier, vc credential.VerifiableCredential) ([]byte, error) { | ||
func BuildPresentationSubmission(presentationRequestJWT string, signer crypto.JWTSigner, vc credential.VerifiableCredential) ([]byte, error) { |
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.
much better
fixes #340