diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-04-08 02:48:56 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-04-08 02:48:56 +0800 |
commit | 758205b187e079080193c2fed2a21caff2377329 (patch) | |
tree | f8c82d47703aac292ab549c8fe3bfaf046075c1a /core | |
parent | f5978639279bac0bcd6270ebb4589099bae570ed (diff) | |
parent | 2591883a18113f1b60e6057313ff552c92d7f261 (diff) | |
download | dexon-758205b187e079080193c2fed2a21caff2377329.tar.gz dexon-758205b187e079080193c2fed2a21caff2377329.tar.zst dexon-758205b187e079080193c2fed2a21caff2377329.zip |
Merge pull request #648 from Gustav-Simonsson/forward_ecrecover_err_and_remove_dup_checks
Forward and log EC recover err and remove dup pubkey len check
Diffstat (limited to 'core')
-rw-r--r-- | core/types/transaction.go | 9 | ||||
-rw-r--r-- | core/vm/address.go | 7 |
2 files changed, 13 insertions, 3 deletions
diff --git a/core/types/transaction.go b/core/types/transaction.go index 6f438ad9d..6646bdf29 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -9,6 +9,8 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto/secp256k1" + "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/logger/glog" "github.com/ethereum/go-ethereum/rlp" ) @@ -129,7 +131,12 @@ func (tx *Transaction) PublicKey() []byte { //pubkey := crypto.Ecrecover(append(hash[:], sig...)) //pubkey, _ := secp256k1.RecoverPubkey(hash[:], sig) - pubkey := crypto.FromECDSAPub(crypto.SigToPub(hash[:], sig)) + p, err := crypto.SigToPub(hash[:], sig) + if err != nil { + glog.V(logger.Error).Infof("Could not get pubkey from signature: ", err) + return nil + } + pubkey := crypto.FromECDSAPub(p) return pubkey } diff --git a/core/vm/address.go b/core/vm/address.go index df801863f..742017dd2 100644 --- a/core/vm/address.go +++ b/core/vm/address.go @@ -5,6 +5,8 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/logger/glog" "github.com/ethereum/go-ethereum/params" ) @@ -80,9 +82,10 @@ func ecrecoverFunc(in []byte) []byte { // v needs to be moved to the end rsv := append(in[64:128], byte(v.Uint64())) - pubKey := crypto.Ecrecover(in[:32], rsv) + pubKey, err := crypto.Ecrecover(in[:32], rsv) // make sure the public key is a valid one - if pubKey == nil || len(pubKey) != 65 { + if err != nil { + glog.V(logger.Error).Infof("EC RECOVER FAIL: ", err) return nil } |