Skip to content

Commit f05b0a2

Browse files
authored
Merge pull request #159 from SAY-5/fix/ecdh-broadcast-nil-pubkey-158
fix(mpc): return error instead of panic when publicKey is nil in BroadcastPublicKey
2 parents cafc7e4 + b28c6d9 commit f05b0a2

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

pkg/mpc/key_exchange_session.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ func (s *ecdhSession) Close() error {
152152
}
153153

154154
func (e *ecdhSession) BroadcastPublicKey() error {
155+
// Peer restart mid-handshake can schedule this broadcast goroutine
156+
// before the local publicKey is populated; crypto/ecdh.(*PublicKey).Bytes
157+
// then panics with nil pointer dereference. Return an error so the
158+
// caller's retrigger logic takes over instead of the goroutine dying.
159+
if e == nil || e.publicKey == nil {
160+
return fmt.Errorf("ecdh session %s has no public key to broadcast yet", e.nodeID)
161+
}
155162
publicKeyBytes := e.publicKey.Bytes()
156163
msg := types.ECDHMessage{
157164
From: e.nodeID,

0 commit comments

Comments
 (0)