Skip to content

Commit

Permalink
Add failing example
Browse files Browse the repository at this point in the history
  • Loading branch information
lestrrat committed Nov 16, 2023
1 parent 24daab5 commit 1a4e1ed
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions examples/jwx_register_ec_and_key_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,23 @@ func convertShangMiSm2(key interface{}) (jwk.Key, error) {

func ExampleShangMiSm2() {
shangmi2pk, _ := sm2.GenerateKey(rand.Reader)

// Create a jwk.Key from ShangMi SM2 private key
shangmi2JWK, err := jwk.FromRaw(shangmi2pk)
if err != nil {
fmt.Println(err)
return
}

{
// Create a ShangMi SM2 private key back from the jwk.Key
var clone sm2.PrivateKey
if err := shangmi2JWK.Raw(&clone); err != nil {
fmt.Println(err)
return
}
}

payload := []byte("Lorem ipsum")
signed, err := jws.Sign(payload, jws.WithKey(jwa.ES256, shangmi2JWK))
if err != nil {
Expand Down

0 comments on commit 1a4e1ed

Please sign in to comment.