Skip to content

Commit 6ed4db6

Browse files
committed
fix: fix unmarshalPubkey
1 parent ef70d9d commit 6ed4db6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

crypto/crypto.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import (
3939
"golang.org/x/crypto/sha3"
4040
)
4141

42-
//SignatureLength indicates the byte length required to carry a signature with recovery id.
42+
// SignatureLength indicates the byte length required to carry a signature with recovery id.
4343
const SignatureLength = 64 + 1 // 64 bytes ECDSA signature + 1 byte recovery id
4444

4545
// RecoveryIDOffset points to the byte offset within the signature that contains the recovery id.
@@ -204,6 +204,9 @@ func UnmarshalPubkey(pub []byte) (*ecdsa.PublicKey, error) {
204204
if x == nil {
205205
return nil, errInvalidPubkey
206206
}
207+
if !S256().IsOnCurve(x, y) {
208+
return nil, errInvalidPubkey
209+
}
207210
return &ecdsa.PublicKey{Curve: S256(), X: x, Y: y}, nil
208211
}
209212

0 commit comments

Comments
 (0)