Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
Add additional test for ED25519 serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
csstaub committed Apr 10, 2019
1 parent fd0b35a commit e8202b5
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions jwk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"strings"
"testing"

"github.com/stretchr/testify/assert"
"golang.org/x/crypto/ed25519"

"gopkg.in/square/go-jose.v2/json"
Expand Down Expand Up @@ -560,6 +561,20 @@ func TestWebKeyVectorsValid(t *testing.T) {
}
}

func TestEd25519Serialization(t *testing.T) {
jwk := JSONWebKey{
Key: ed25519PrivateKey,
}
serialized, _ := json.Marshal(jwk)

var jwk2 JSONWebKey
json.Unmarshal(serialized, &jwk2)

assert.True(t, bytes.Equal(
[]byte(jwk.Key.(ed25519.PrivateKey).Public().(ed25519.PublicKey)),
[]byte(jwk2.Key.(ed25519.PrivateKey).Public().(ed25519.PublicKey))))
}

func TestThumbprint(t *testing.T) {
for i, key := range cookbookJWKs {
var jwk2 JSONWebKey
Expand Down

0 comments on commit e8202b5

Please sign in to comment.