Skip to content

Commit

Permalink
fix: Pass VC Test Suite where JWS is passed as input data
Browse files Browse the repository at this point in the history
closes hyperledger-archives#947

Signed-off-by: Dima <[email protected]>
  • Loading branch information
kdimak committed Dec 17, 2019
1 parent 92ac19f commit 3bf7514
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
13 changes: 7 additions & 6 deletions pkg/doc/verifiable/test-suite/verifiable_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func main() {
}

if *jwtPresentation {
encodeVPToJWS(vcBytes, *jwtAud, privateKey)
encodeVPToJWS(vcBytes, *jwtAud, privateKey, publicKey)
} else {
encodeVCToJWS(vcBytes, privateKey)
}
Expand All @@ -90,8 +90,11 @@ func encodeVCToJWS(vcBytes []byte, privateKey interface{}) {
fmt.Println(jws)
}

func encodeVPToJWS(vpBytes []byte, audience string, privateKey interface{}) {
vp, err := verifiable.NewPresentation(vpBytes, verifiable.WithPresSkippedEmbeddedProofCheck())
func encodeVPToJWS(vpBytes []byte, audience string, privateKey, publicKey interface{}) {
vp, err := verifiable.NewPresentation(vpBytes,
verifiable.WithPresSkippedEmbeddedProofCheck(),
// the public key is used to decode verifiable credentials passed as JWS to the presentation
verifiable.WithPresPublicKeyFetcher(verifiable.SingleKey(publicKey)))
if err != nil {
abort("failed to decode presentation: %v", err)
}
Expand Down Expand Up @@ -128,9 +131,7 @@ func encodeVCToJWTUnsecured(vcBytes []byte) {
func decodeVCJWTToJSON(vcBytes []byte, publicKey interface{}) {
// Asked to decode JWT
credential, _, err := verifiable.NewCredential(vcBytes,
verifiable.WithPublicKeyFetcher(func(issuerID, keyID string) (interface{}, error) {
return publicKey, nil
}))
verifiable.WithPublicKeyFetcher(verifiable.SingleKey(publicKey)))
if err != nil {
abort("failed to decode credential: %v", err)
}
Expand Down
3 changes: 2 additions & 1 deletion scripts/run_vc_test_suite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export PATH=$PATH:`pwd`

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

# build the suite
cd ${SUITE_DIR}
Expand Down

0 comments on commit 3bf7514

Please sign in to comment.