From 50850cf8a23a88428b0d49be82b48d731131c2e0 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Mon, 21 Aug 2017 14:15:09 -0400 Subject: [PATCH] verify sigs on both votes; note about indices --- types/evidence.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/types/evidence.go b/types/evidence.go index 5e2be9b5..a9fdc42f 100644 --- a/types/evidence.go +++ b/types/evidence.go @@ -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 }