diff --git a/shared/bls/blst/public_key.go b/shared/bls/blst/public_key.go index 18f164b97..2dfaae6f0 100644 --- a/shared/bls/blst/public_key.go +++ b/shared/bls/blst/public_key.go @@ -57,6 +57,9 @@ func AggregatePublicKeys(pubs [][]byte) (common.PublicKey, error) { if featureconfig.Get().SkipBLSVerify { return &PublicKey{}, nil } + if pubs == nil || len(pubs) == 0 { + return nil, errors.New("nil or empty public keys") + } agg := new(blstAggregatePublicKey) mulP1 := make([]*blstPublicKey, 0, len(pubs)) for _, pubkey := range pubs { diff --git a/shared/bls/blst/public_key_test.go b/shared/bls/blst/public_key_test.go index bfae3025f..e086e5b0f 100644 --- a/shared/bls/blst/public_key_test.go +++ b/shared/bls/blst/public_key_test.go @@ -76,3 +76,9 @@ func TestPublicKey_Copy(t *testing.T) { require.DeepEqual(t, pubkeyA.Marshal(), pubkeyBytes, "Pubkey was mutated after copy") } + +func TestPublicKeysEmpty(t *testing.T) { + pubs := [][]byte{} + _, err := blst.AggregatePublicKeys(pubs) + require.ErrorContains(t, "nil or empty public keys", err) +}