Skip to content

Commit

Permalink
fixup! verificationhelper: fix JSON serialization of keys
Browse files Browse the repository at this point in the history
Signed-off-by: Sumner Evans <[email protected]>
  • Loading branch information
sumnerevans committed Nov 22, 2024
1 parent d3df25e commit 6ff8be6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions crypto/verificationhelper/ecdhkeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (e *ECDHPrivateKey) UnmarshalJSON(data []byte) (err error) {
if err != nil {
return
}
e.PrivateKey, err = ecdh.P256().NewPrivateKey(raw)
e.PrivateKey, err = ecdh.X25519().NewPrivateKey(raw)
return err
}

Expand All @@ -39,7 +39,7 @@ func (e *ECDHPublicKey) UnmarshalJSON(data []byte) (err error) {
if err != nil {
return
}
e.PublicKey, err = ecdh.P256().NewPublicKey(raw)
e.PublicKey, err = ecdh.X25519().NewPublicKey(raw)
return
}

Expand Down
6 changes: 3 additions & 3 deletions crypto/verificationhelper/ecdhkeys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

func TestECDHPrivateKey(t *testing.T) {
pk, err := ecdh.P256().GenerateKey(rand.Reader)
pk, err := ecdh.X25519().GenerateKey(rand.Reader)
require.NoError(t, err)
private := verificationhelper.ECDHPrivateKey{pk}
marshalled, err := json.Marshal(private)
Expand All @@ -29,7 +29,7 @@ func TestECDHPrivateKey(t *testing.T) {
}

func TestECDHPublicKey(t *testing.T) {
private, err := ecdh.P256().GenerateKey(rand.Reader)
private, err := ecdh.X25519().GenerateKey(rand.Reader)
require.NoError(t, err)

public := private.PublicKey()
Expand All @@ -38,7 +38,7 @@ func TestECDHPublicKey(t *testing.T) {
marshalled, err := json.Marshal(pub)
require.NoError(t, err)

assert.Len(t, marshalled, 90)
assert.Len(t, marshalled, 46)

var unmarshalled verificationhelper.ECDHPublicKey
err = json.Unmarshal(marshalled, &unmarshalled)
Expand Down

0 comments on commit 6ff8be6

Please sign in to comment.