Browse Source

verify sigs on both votes; note about indices

pull/592/head
Ethan Buchman 7 years ago
parent
commit
50850cf8a2
1 changed files with 5 additions and 1 deletions
  1. +5
    -1
      types/evidence.go

+ 5
- 1
types/evidence.go 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) 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) { 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) 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 { 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) 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) { if !dve.PubKey.Verify(SignBytes(chainID, dve.VoteA), dve.VoteA.Signature) {
return ErrVoteInvalidSignature return ErrVoteInvalidSignature
} }
if !dve.PubKey.Verify(SignBytes(chainID, dve.VoteB), dve.VoteB.Signature) {
return ErrVoteInvalidSignature
}
return nil return nil
} }

Loading…
Cancel
Save