-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Verify aggregator signature in sync #5208
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0e44d98
Add validateAggregatorSignature
terencechain 8dbfe9b
Merge branch 'v0.11' of github.com:prysmaticlabs/prysm into verify-ag…
terencechain 0a89603
Use it
terencechain 2b78a00
Tests
terencechain dd6150b
Fixed signing root test
terencechain 9257469
Gaz
terencechain 3e78338
Gaz
terencechain cda5005
Merge refs/heads/v0.11 into verify-aggregator-sig
prylabs-bulldozer[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,7 +70,7 @@ func (r *Service) validateAggregateAndProof(ctx context.Context, pid peer.ID, ms | |
return false | ||
} | ||
|
||
if !r.validateAggregatedAtt(ctx, m.Message) { | ||
if !r.validateAggregatedAtt(ctx, m) { | ||
return false | ||
} | ||
|
||
|
@@ -85,11 +85,11 @@ func (r *Service) validateAggregateAndProof(ctx context.Context, pid peer.ID, ms | |
return true | ||
} | ||
|
||
func (r *Service) validateAggregatedAtt(ctx context.Context, a *ethpb.AggregateAttestationAndProof) bool { | ||
func (r *Service) validateAggregatedAtt(ctx context.Context, signed *ethpb.SignedAggregateAttestationAndProof) bool { | ||
ctx, span := trace.StartSpan(ctx, "sync.validateAggregatedAtt") | ||
defer span.End() | ||
|
||
attSlot := a.Aggregate.Data.Slot | ||
attSlot := signed.Message.Aggregate.Data.Slot | ||
if err := validateAggregateAttTime(attSlot, uint64(r.chain.GenesisTime().Unix())); err != nil { | ||
traceutil.AnnotateError(span, err) | ||
return false | ||
|
@@ -111,19 +111,25 @@ func (r *Service) validateAggregatedAtt(ctx context.Context, a *ethpb.AggregateA | |
} | ||
|
||
// Verify validator index is within the aggregate's committee. | ||
if err := validateIndexInCommittee(ctx, s, a.Aggregate, a.AggregatorIndex); err != nil { | ||
if err := validateIndexInCommittee(ctx, s, signed.Message.Aggregate, signed.Message.AggregatorIndex); err != nil { | ||
traceutil.AnnotateError(span, errors.Wrapf(err, "Could not validate index in committee")) | ||
return false | ||
} | ||
|
||
// Verify selection proof reflects to the right validator and signature is valid. | ||
if err := validateSelection(ctx, s, a.Aggregate.Data, a.AggregatorIndex, a.SelectionProof); err != nil { | ||
traceutil.AnnotateError(span, errors.Wrapf(err, "Could not validate selection for validator %d", a.AggregatorIndex)) | ||
if err := validateSelection(ctx, s, signed.Message.Aggregate.Data, signed.Message.AggregatorIndex, signed.Message.SelectionProof); err != nil { | ||
traceutil.AnnotateError(span, errors.Wrapf(err, "Could not validate selection for validator %d", signed.Message.AggregatorIndex)) | ||
return false | ||
} | ||
|
||
// Verify the aggregator's signature is valid. | ||
if err := validateAggregatorSignature(s, signed); err != nil { | ||
traceutil.AnnotateError(span, errors.Wrapf(err, "Could not verify aggregator signature %d", signed.Message.AggregatorIndex)) | ||
return false | ||
} | ||
|
||
// Verify aggregated attestation has a valid signature. | ||
if err := blocks.VerifyAttestation(ctx, s, a.Aggregate); err != nil { | ||
if err := blocks.VerifyAttestation(ctx, s, signed.Message.Aggregate); err != nil { | ||
traceutil.AnnotateError(span, err) | ||
return false | ||
} | ||
|
@@ -245,3 +251,20 @@ func validateSelection(ctx context.Context, s *stateTrie.BeaconState, data *ethp | |
|
||
return nil | ||
} | ||
|
||
// This verifies aggregator signature over the signed aggregate and proof object. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the meat of the implementation |
||
func validateAggregatorSignature(s *stateTrie.BeaconState, a *ethpb.SignedAggregateAttestationAndProof) error { | ||
aggregator, err := s.ValidatorAtIndex(a.Message.AggregatorIndex) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
currentEpoch := helpers.SlotToEpoch(a.Message.Aggregate.Data.Slot) | ||
domain, err := helpers.Domain(s.Fork(), currentEpoch, params.BeaconConfig().DomainAggregateAndProof, s.GenesisValidatorRoot()) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return helpers.VerifySigningRoot(a.Message, aggregator.PublicKey, a.Signature, domain) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved this to /core/helpers/signing_root.go
Not sure why it was here to begin with....