Skip to content

fix(mpc): return error instead of panic when publicKey is nil in BroadcastPublicKey#159

Open
SAY-5 wants to merge 1 commit intofystack:masterfrom
SAY-5:fix/ecdh-broadcast-nil-pubkey-158
Open

fix(mpc): return error instead of panic when publicKey is nil in BroadcastPublicKey#159
SAY-5 wants to merge 1 commit intofystack:masterfrom
SAY-5:fix/ecdh-broadcast-nil-pubkey-158

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented Apr 23, 2026

Fixes #158.

Problem

registerReadyPairs schedules triggerECDHExchangeBroadcastPublicKey from a goroutine. If the peer restarts between scheduling and reading the local publicKey, e.publicKey is nil and crypto/ecdh.(*PublicKey).Bytes panics:

panic: runtime error: invalid memory address or nil pointer dereference
crypto/ecdh.(*PublicKey).Bytes
mpc.(*ecdhSession).BroadcastPublicKey key_exchange_session.go:155
mpc.(*registry).triggerECDHExchange registry.go:164

It self-heals via container restart + ECDH retrigger but each hit adds ~10-15s before the node rejoins quorum during rolling restarts, and the stderr panics pollute log shipping.

Fix

Nil-check the receiver and e.publicKey at the top of BroadcastPublicKey. Return a descriptive error so the caller's retrigger path handles it cleanly instead of a panic propagating to stderr.

Test

go build ./... and go test ./pkg/mpc/... pass locally.

…dcastPublicKey

registerReadyPairs spawns a goroutine that calls triggerECDHExchange ->
BroadcastPublicKey. If the peer restarts between scheduling and the
goroutine reading the local publicKey, e.publicKey is nil and
crypto/ecdh.(*PublicKey).Bytes panics with 'invalid memory address or
nil pointer dereference', killing the goroutine and forcing a
container restart+rejoin cycle of ~10-15s per occurrence.

Nil-check the receiver and e.publicKey at the top of BroadcastPublicKey
and return a descriptive error so the caller's ECDH retrigger logic
takes over instead of a panic propagating to stderr.

Refs fystack/mpcium issue 158.

Signed-off-by: SAY-5 <say.apm35@gmail.com>
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v0.3.5 nil-pointer panic in ecdhSession.BroadcastPublicKey on rolling restart

1 participant