verify sigs on both votes; note about indices

This commit is contained in:
Ethan Buchman 2017-08-21 14:15:09 -04:00
parent 35587658cd
commit 50850cf8a2
1 changed files with 5 additions and 1 deletions

View File

@ -44,10 +44,11 @@ func (dve *DuplicateVoteEvidence) Verify() error {
return fmt.Errorf("DuplicateVoteEvidence Error: H/R/S does not match. Got %v and %v", dve.VoteA, dve.VoteB)
}
// Address and Index must be the same
// Address must be the same
if !bytes.Equal(dve.VoteA.ValidatorAddress, dve.VoteB.ValidatorAddress) {
return fmt.Errorf("DuplicateVoteEvidence Error: Validator addresses do not match. Got %X and %X", dve.VoteA.ValidatorAddress, dve.VoteB.ValidatorAddress)
}
// XXX: Should we enforce index is the same ?
if dve.VoteA.ValidatorIndex != dve.VoteB.ValidatorIndex {
return fmt.Errorf("DuplicateVoteEvidence Error: Validator indices do not match. Got %d and %d", dve.VoteA.ValidatorIndex, dve.VoteB.ValidatorIndex)
}
@ -61,6 +62,9 @@ func (dve *DuplicateVoteEvidence) Verify() error {
if !dve.PubKey.Verify(SignBytes(chainID, dve.VoteA), dve.VoteA.Signature) {
return ErrVoteInvalidSignature
}
if !dve.PubKey.Verify(SignBytes(chainID, dve.VoteB), dve.VoteB.Signature) {
return ErrVoteInvalidSignature
}
return nil
}