diff --git a/beacon-chain/core/helpers/BUILD.bazel b/beacon-chain/core/helpers/BUILD.bazel index 8f9ca1439..4b17ef3ef 100644 --- a/beacon-chain/core/helpers/BUILD.bazel +++ b/beacon-chain/core/helpers/BUILD.bazel @@ -68,7 +68,6 @@ go_test( "//config/params:go_default_library", "//consensus-types/primitives:go_default_library", "//container/slice:go_default_library", - "//crypto/bls:go_default_library", "//crypto/hash:go_default_library", "//encoding/bytesutil:go_default_library", "//proto/prysm/v1alpha1:go_default_library", diff --git a/beacon-chain/core/helpers/attestation.go b/beacon-chain/core/helpers/attestation.go index 75b826ef3..b55a8799b 100644 --- a/beacon-chain/core/helpers/attestation.go +++ b/beacon-chain/core/helpers/attestation.go @@ -8,7 +8,6 @@ import ( "github.com/prysmaticlabs/prysm/v4/config/params" "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives" - "github.com/prysmaticlabs/prysm/v4/crypto/bls" "github.com/prysmaticlabs/prysm/v4/crypto/hash" ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1" prysmTime "github.com/prysmaticlabs/prysm/v4/time" @@ -66,25 +65,6 @@ func IsAggregator(committeeCount uint64, slotSig []byte) (bool, error) { return binary.LittleEndian.Uint64(b[:8])%modulo == 0, nil } -// AggregateSignature returns the aggregated signature of the input attestations. -// -// Spec pseudocode definition: -// -// def get_aggregate_signature(attestations: Sequence[Attestation]) -> BLSSignature: -// signatures = [attestation.signature for attestation in attestations] -// return bls.Aggregate(signatures) -func AggregateSignature(attestations []*ethpb.Attestation) (bls.Signature, error) { - sigs := make([]bls.Signature, len(attestations)) - var err error - for i := 0; i < len(sigs); i++ { - sigs[i], err = bls.SignatureFromBytes(attestations[i].Signature) - if err != nil { - return nil, err - } - } - return bls.AggregateSignatures(sigs), nil -} - // IsAggregated returns true if the attestation is an aggregated attestation, // false otherwise. func IsAggregated(attestation *ethpb.Attestation) bool { diff --git a/beacon-chain/core/helpers/attestation_test.go b/beacon-chain/core/helpers/attestation_test.go index 3e0c69373..38173f0f8 100644 --- a/beacon-chain/core/helpers/attestation_test.go +++ b/beacon-chain/core/helpers/attestation_test.go @@ -10,8 +10,6 @@ import ( state_native "github.com/prysmaticlabs/prysm/v4/beacon-chain/state/state-native" "github.com/prysmaticlabs/prysm/v4/config/params" "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives" - "github.com/prysmaticlabs/prysm/v4/crypto/bls" - "github.com/prysmaticlabs/prysm/v4/encoding/bytesutil" ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v4/testing/assert" "github.com/prysmaticlabs/prysm/v4/testing/require" @@ -45,44 +43,6 @@ func TestAttestation_IsAggregator(t *testing.T) { }) } -func TestAttestation_AggregateSignature(t *testing.T) { - t.Run("verified", func(t *testing.T) { - pubkeys := make([]bls.PublicKey, 0, 100) - atts := make([]*ethpb.Attestation, 0, 100) - msg := bytesutil.ToBytes32([]byte("hello")) - for i := 0; i < 100; i++ { - priv, err := bls.RandKey() - require.NoError(t, err) - pub := priv.PublicKey() - sig := priv.Sign(msg[:]) - pubkeys = append(pubkeys, pub) - att := ðpb.Attestation{Signature: sig.Marshal()} - atts = append(atts, att) - } - aggSig, err := helpers.AggregateSignature(atts) - require.NoError(t, err) - assert.Equal(t, true, aggSig.FastAggregateVerify(pubkeys, msg), "Signature did not verify") - }) - - t.Run("not verified", func(t *testing.T) { - pubkeys := make([]bls.PublicKey, 0, 100) - atts := make([]*ethpb.Attestation, 0, 100) - msg := []byte("hello") - for i := 0; i < 100; i++ { - priv, err := bls.RandKey() - require.NoError(t, err) - pub := priv.PublicKey() - sig := priv.Sign(msg) - pubkeys = append(pubkeys, pub) - att := ðpb.Attestation{Signature: sig.Marshal()} - atts = append(atts, att) - } - aggSig, err := helpers.AggregateSignature(atts[0 : len(atts)-2]) - require.NoError(t, err) - assert.Equal(t, false, aggSig.FastAggregateVerify(pubkeys, bytesutil.ToBytes32(msg)), "Signature not suppose to verify") - }) -} - func TestAttestation_ComputeSubnetForAttestation(t *testing.T) { // Create 10 committees committeeCount := uint64(10)