diff options
Diffstat (limited to 'core/vm/contracts.go')
-rw-r--r-- | core/vm/contracts.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/core/vm/contracts.go b/core/vm/contracts.go index 2793d2aa7..0479adfda 100644 --- a/core/vm/contracts.go +++ b/core/vm/contracts.go @@ -19,6 +19,7 @@ package vm import ( "crypto/sha256" "fmt" + "math/big" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" @@ -69,13 +70,13 @@ func (c *ecrecover) Run(in []byte) []byte { // "in" is (hash, v, r, s), each 32 bytes // but for ecrecover we want (r, s, v) - r := common.BytesToBig(in[64:96]) - s := common.BytesToBig(in[96:128]) + r := new(big.Int).SetBytes(in[64:96]) + s := new(big.Int).SetBytes(in[96:128]) v := in[63] - 27 // tighter sig s values in homestead only apply to tx sigs - if common.Bytes2Big(in[32:63]).BitLen() > 0 || !crypto.ValidateSignatureValues(v, r, s, false) { - log.Trace(fmt.Sprintf("ECRECOVER error: v, r or s value invalid")) + if !allZero(in[32:63]) || !crypto.ValidateSignatureValues(v, r, s, false) { + log.Trace("ECRECOVER error: v, r or s value invalid") return nil } // v needs to be at the end for libsecp256k1 |