Skip to content

Commit

Permalink
Merge pull request ethereum#267 from nguyenbatam/make_clean_func_reco…
Browse files Browse the repository at this point in the history
…ver_validator

make clean func recover validator
  • Loading branch information
ngtuna authored Nov 10, 2018
2 parents 2145bbb + 9478c63 commit 69114cf
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions consensus/posv/posv.go
Original file line number Diff line number Diff line change
Expand Up @@ -960,14 +960,13 @@ func (c *Posv) RecoverValidator(header *types.Header) (common.Address, error) {
if address, known := c.validatorSignatures.Get(hash); known {
return address.(common.Address), nil
}
// Retrieve the signature from the header extra-data
if len(header.Validator) < extraSeal {
// Retrieve the signature from the header.Validator
// len equals 65 bytes
if len(header.Validator) != extraSeal {
return common.Address{}, consensus.ErrMissingValidatorSignature
}
signature := header.Validator[len(header.Validator)-extraSeal:]

// Recover the public key and the Ethereum address
pubkey, err := crypto.Ecrecover(sigHash(header).Bytes(), signature)
pubkey, err := crypto.Ecrecover(sigHash(header).Bytes(), header.Validator)
if err != nil {
return common.Address{}, err
}
Expand Down

0 comments on commit 69114cf

Please sign in to comment.