Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core/parsigex: add support for DutySyncMessage #1241

Merged
merged 2 commits into from
Oct 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions core/parsigex/parsigex.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,13 @@ func NewEth2Verifier(eth2Cl eth2wrap.Client, pubSharesByKey map[core.PubKey]map[
}

return signing.VerifyAggregateAndProof(ctx, eth2Cl, pubshare, &aggAndProof.SignedAggregateAndProof)
case core.DutySyncMessage:
msg, ok := data.SignedData.(core.SignedSyncMessage)
if !ok {
return errors.New("invalid sync committee message")
}

return signing.VerifySyncCommitteeMessage(ctx, eth2Cl, pubshare, &msg.SyncCommitteeMessage)
default:
return errors.New("unknown duty type")
}
Expand Down
12 changes: 12 additions & 0 deletions core/parsigex/parsigex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,4 +261,16 @@ func TestParSigExVerifier(t *testing.T) {

require.NoError(t, verifyFunc(ctx, core.NewAggregatorDuty(slot), pubkey, data))
})

t.Run("verify sync committee message", func(t *testing.T) {
msg := testutil.RandomSyncCommitteeMessage()
msg.Slot = slot

sigData, err := signing.GetDataRoot(ctx, bmock, signing.DomainSyncCommittee, epoch, msg.BeaconBlockRoot)
require.NoError(t, err)
msg.Signature = sign(sigData[:])

data := core.NewPartialSignedSyncMessage(msg, shareIdx)
require.NoError(t, verifyFunc(ctx, core.NewSyncMessageDuty(slot), pubkey, data))
})
}
2 changes: 2 additions & 0 deletions core/signeddata.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ var (
_ SignedData = SignedRandao{}
_ SignedData = SignedBeaconCommitteeSubscription{}
_ SignedData = SignedAggregateAndProof{}
_ SignedData = SignedSyncMessage{}
_ SignedData = SignedSyncContribution{}
)

// SigFromETH2 returns a new signature from eth2 phase0 BLSSignature.
Expand Down