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

Commit e8202b5

Browse files
committed
Add additional test for ED25519 serialization
1 parent fd0b35a commit e8202b5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

jwk_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"strings"
3030
"testing"
3131

32+
"github.com/stretchr/testify/assert"
3233
"golang.org/x/crypto/ed25519"
3334

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

564+
func TestEd25519Serialization(t *testing.T) {
565+
jwk := JSONWebKey{
566+
Key: ed25519PrivateKey,
567+
}
568+
serialized, _ := json.Marshal(jwk)
569+
570+
var jwk2 JSONWebKey
571+
json.Unmarshal(serialized, &jwk2)
572+
573+
assert.True(t, bytes.Equal(
574+
[]byte(jwk.Key.(ed25519.PrivateKey).Public().(ed25519.PublicKey)),
575+
[]byte(jwk2.Key.(ed25519.PrivateKey).Public().(ed25519.PublicKey))))
576+
}
577+
563578
func TestThumbprint(t *testing.T) {
564579
for i, key := range cookbookJWKs {
565580
var jwk2 JSONWebKey

0 commit comments

Comments
 (0)