Skip to content

Commit

Permalink
chore: improve ECDH public key converting
Browse files Browse the repository at this point in the history
  • Loading branch information
zensh committed Sep 29, 2024
1 parent 1ee1caf commit c89833e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions key/ecdh/ecdh.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package ecdh

import (
goecdh "crypto/ecdh"
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
"fmt"
Expand Down Expand Up @@ -119,8 +120,8 @@ func keyToPublic(pk key.Key) (*goecdh.PublicKey, error) {
copy(compressed[1:], x)
ix, iy = elliptic.UnmarshalCompressed(ecdsaCurve, compressed)
}

return curve.NewPublicKey(elliptic.Marshal(ecdsaCurve, ix, iy))
k := ecdsa.PublicKey{Curve: ecdsaCurve, X: ix, Y: iy}
return k.ECDH()
}

// KeyFromPublic returns a public Key with given ecdh.PublicKey.
Expand Down

0 comments on commit c89833e

Please sign in to comment.