mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 20:56:42 +00:00
Merge 66bfcb864a into 3040296beb
This commit is contained in:
commit
b24991275c
2 changed files with 8 additions and 9 deletions
|
|
@ -80,9 +80,9 @@ 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)
|
||||
// make sure the public key is a valid one
|
||||
if pubKey == nil || len(pubKey) != 65 {
|
||||
pubKey, err := crypto.Ecrecover(in[:32], rsv)
|
||||
if err != nil {
|
||||
vmlogger.Errorf("EC RECOVER FAIL: ", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,10 +68,8 @@ func Ripemd160(data []byte) []byte {
|
|||
return ripemd.Sum(nil)
|
||||
}
|
||||
|
||||
func Ecrecover(hash, sig []byte) []byte {
|
||||
r, _ := secp256k1.RecoverPubkey(hash, sig)
|
||||
|
||||
return r
|
||||
func Ecrecover(hash, sig []byte) ([]byte, error) {
|
||||
return secp256k1.RecoverPubkey(hash, sig)
|
||||
}
|
||||
|
||||
// New methods using proper ecdsa keys from the stdlib
|
||||
|
|
@ -146,8 +144,9 @@ func GenerateKey() (*ecdsa.PrivateKey, error) {
|
|||
}
|
||||
|
||||
func SigToPub(hash, sig []byte) *ecdsa.PublicKey {
|
||||
s := Ecrecover(hash, sig)
|
||||
if s == nil || len(s) != 65 {
|
||||
s, err := Ecrecover(hash, sig)
|
||||
// TODO: add logging of error
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue