forked from tangled.org/core
this repo has no description
1// adapted from https://tangled.sh/icyphox.sh/atproto-oauth 2 3package main 4 5import ( 6 "crypto/ecdsa" 7 "crypto/elliptic" 8 "crypto/rand" 9 "encoding/json" 10 "fmt" 11 "time" 12 13 "github.com/lestrrat-go/jwx/v2/jwk" 14) 15 16func main() { 17 privKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) 18 if err != nil { 19 panic(err) 20 } 21 22 key, err := jwk.FromRaw(privKey) 23 if err != nil { 24 panic(err) 25 } 26 27 kid := fmt.Sprintf("%d", time.Now().Unix()) 28 29 if err := key.Set(jwk.KeyIDKey, kid); err != nil { 30 panic(err) 31 } 32 33 b, err := json.Marshal(key) 34 if err != nil { 35 panic(err) 36 } 37 38 fmt.Println(string(b)) 39}