publickeyJwk - Json Web Key in go lang


(Talwinder Kaur) #1

Does anyone worked on implementing the json web key public key encoding in golang.

What is most appropriate go lang library to decode the JWK using ecds algortithm


(Lutz Horn) #2

I’ve played around with jwt-go some time ago. Using a public/private key pair, the code looks like in the gist below.

Note that I’ve embedded the jwt.StandardClaims in my own struct sbcsClaims. This of course is optional.


(Talwinder Kaur) #3

I have figured out and using “github.com/lestrrat-go/jwx/jwk

func getPublicKeyJwk(jsonBuf []byte) (interface{}, error) {
pubKeyJwk, err := jwk.Parse(jsonBuf)
if err != nil {
return nil, err
}
key := pubKeyJwk.Keys[0]
pubKey, err := key.Materialize()
if err != nil {
return nil, err
}
return pubKey, nil
}