From 156c4102bc943cc6720f62301c58b823bd50fc80 Mon Sep 17 00:00:00 2001 From: irrun Date: Thu, 30 Jan 2025 21:17:30 +0800 Subject: [PATCH] fix: unmarshal pubkey when not on curve (#68) * fix: unmarshal pubkey when not on curve * fix: unmarshal pubkey when not on curve --- crypto/crypto.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crypto/crypto.go b/crypto/crypto.go index bd9b12756b..5cf5472fa6 100644 --- a/crypto/crypto.go +++ b/crypto/crypto.go @@ -203,6 +203,9 @@ func UnmarshalPubkey(pub []byte) (*ecdsa.PublicKey, error) { if x == nil { return nil, errInvalidPubkey } + if !S256().IsOnCurve(x, y) { + return nil, errInvalidPubkey + } return &ecdsa.PublicKey{Curve: S256(), X: x, Y: y}, nil }