verify evidence in block

This commit is contained in:
Ethan Buchman
2017-07-25 12:29:38 -04:00
parent 4661c98c17
commit 35587658cd
4 changed files with 33 additions and 5 deletions

View File

@@ -101,3 +101,14 @@ func (vote *Vote) String() string {
cmn.Fingerprint(vote.BlockID.Hash), vote.Signature,
CanonicalTime(vote.Timestamp))
}
func (vote *Vote) Verify(chainID string, pubKey crypto.PubKey) error {
if !bytes.Equal(pubKey.Address(), v.ValidatorAddress) {
return ErrVoteInvalidValidatorAddress
}
if !pubKey.VerifyBytes(SignBytes(chainID, vote), vote.Signature) {
return ErrVoteInvalidSignature
}
return nil
}