From 3f306f63d48f011a527e301e3bf9aec2d6efb7e1 Mon Sep 17 00:00:00 2001 From: Gustav Simonsson Date: Sun, 5 Apr 2015 19:31:18 +0200 Subject: Forward and log EC recover err and remove dup pubkey len check --- core/types/transaction.go | 8 +++++++- core/vm/address.go | 6 ++++-- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'core') diff --git a/core/types/transaction.go b/core/types/transaction.go index 6f438ad9d..2f23a7960 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -9,6 +9,7 @@ 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/glog" "github.com/ethereum/go-ethereum/rlp" ) @@ -129,7 +130,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(0).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..c6db1d5ff 100644 --- a/core/vm/address.go +++ b/core/vm/address.go @@ -5,6 +5,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/logger/glog" "github.com/ethereum/go-ethereum/params" ) @@ -80,9 +81,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(0).Infof("EC RECOVER FAIL: ", err) return nil } -- cgit v1.2.3