Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

Commit 3bf7514

Browse files
committed
fix: Pass VC Test Suite where JWS is passed as input data
closes #947 Signed-off-by: Dima <[email protected]>
1 parent 92ac19f commit 3bf7514

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

pkg/doc/verifiable/test-suite/verifiable_suite_test.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func main() {
6565
}
6666

6767
if *jwtPresentation {
68-
encodeVPToJWS(vcBytes, *jwtAud, privateKey)
68+
encodeVPToJWS(vcBytes, *jwtAud, privateKey, publicKey)
6969
} else {
7070
encodeVCToJWS(vcBytes, privateKey)
7171
}
@@ -90,8 +90,11 @@ func encodeVCToJWS(vcBytes []byte, privateKey interface{}) {
9090
fmt.Println(jws)
9191
}
9292

93-
func encodeVPToJWS(vpBytes []byte, audience string, privateKey interface{}) {
94-
vp, err := verifiable.NewPresentation(vpBytes, verifiable.WithPresSkippedEmbeddedProofCheck())
93+
func encodeVPToJWS(vpBytes []byte, audience string, privateKey, publicKey interface{}) {
94+
vp, err := verifiable.NewPresentation(vpBytes,
95+
verifiable.WithPresSkippedEmbeddedProofCheck(),
96+
// the public key is used to decode verifiable credentials passed as JWS to the presentation
97+
verifiable.WithPresPublicKeyFetcher(verifiable.SingleKey(publicKey)))
9598
if err != nil {
9699
abort("failed to decode presentation: %v", err)
97100
}
@@ -128,9 +131,7 @@ func encodeVCToJWTUnsecured(vcBytes []byte) {
128131
func decodeVCJWTToJSON(vcBytes []byte, publicKey interface{}) {
129132
// Asked to decode JWT
130133
credential, _, err := verifiable.NewCredential(vcBytes,
131-
verifiable.WithPublicKeyFetcher(func(issuerID, keyID string) (interface{}, error) {
132-
return publicKey, nil
133-
}))
134+
verifiable.WithPublicKeyFetcher(verifiable.SingleKey(publicKey)))
134135
if err != nil {
135136
abort("failed to decode credential: %v", err)
136137
}

scripts/run_vc_test_suite.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ export PATH=$PATH:`pwd`
3131

3232
# get the suite
3333
rm -rf ${SUITE_DIR}
34-
git clone --depth=1 -q https://github.com/w3c/vc-test-suite suite
34+
# todo clone from https://github.com/w3c/vc-test-suite as soon as https://github.com/w3c/vc-test-suite/pull/102 is merged.
35+
git clone --depth=1 -q https://github.com/kdimak/vc-test-suite -b vc-jwt-with-known-json-web-key suite
3536

3637
# build the suite
3738
cd ${SUITE_DIR}

0 commit comments

Comments
 (0)