@@ -65,7 +65,7 @@ func main() {
65
65
}
66
66
67
67
if * jwtPresentation {
68
- encodeVPToJWS (vcBytes , * jwtAud , privateKey )
68
+ encodeVPToJWS (vcBytes , * jwtAud , privateKey , publicKey )
69
69
} else {
70
70
encodeVCToJWS (vcBytes , privateKey )
71
71
}
@@ -90,8 +90,11 @@ func encodeVCToJWS(vcBytes []byte, privateKey interface{}) {
90
90
fmt .Println (jws )
91
91
}
92
92
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 )))
95
98
if err != nil {
96
99
abort ("failed to decode presentation: %v" , err )
97
100
}
@@ -128,9 +131,7 @@ func encodeVCToJWTUnsecured(vcBytes []byte) {
128
131
func decodeVCJWTToJSON (vcBytes []byte , publicKey interface {}) {
129
132
// Asked to decode JWT
130
133
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 )))
134
135
if err != nil {
135
136
abort ("failed to decode credential: %v" , err )
136
137
}
0 commit comments