From f11cf2cce705f9bb0b993d723c8d6d0c7022a55f Mon Sep 17 00:00:00 2001 From: Daniel Liu <139250065@qq.com> Date: Sat, 28 Feb 2026 21:00:35 +0800 Subject: [PATCH] fix(crypto): fix ECIES invalid-curve handling #33669 (#2043) Co-authored-by: fengjian <445077+fengjian@users.noreply.github.com> --- crypto/ecies/ecies.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crypto/ecies/ecies.go b/crypto/ecies/ecies.go index 593f1bd622..8def7bed90 100644 --- a/crypto/ecies/ecies.go +++ b/crypto/ecies/ecies.go @@ -124,6 +124,9 @@ func (prv *PrivateKey) GenerateShared(pub *PublicKey, skLen, macLen int) (sk []b if prv.PublicKey.Curve != pub.Curve { return nil, ErrInvalidCurve } + if pub.X == nil || pub.Y == nil || !pub.Curve.IsOnCurve(pub.X, pub.Y) { + return nil, ErrInvalidPublicKey + } if skLen+macLen > MaxSharedKeyLength(pub) { return nil, ErrSharedKeyTooBig }