sm2: fix bug

This commit is contained in:
Sun Yimin 2023-12-15 13:14:02 +08:00 committed by GitHub
parent 167f0e0b11
commit 58d30f6655
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -377,6 +377,7 @@ func NewPublicKey(key []byte) (*ecdsa.PublicKey, error) {
return nil, err
}
k := new(ecdsa.PublicKey)
k.Curve = c.curve
k.X, k.Y, err = c.pointToAffine(p)
if err != nil {
return nil, err

View File

@ -19,7 +19,7 @@ func TestEqual(t *testing.T) {
t.Errorf("private.Public() is not Equal to public: %q", public)
}
if !private.Equal(private) {
t.Errorf("private key is not equal to itself: %q", private)
t.Errorf("private key is not equal to itself")
}
enc, err := MarshalPKCS8PrivateKey(private)