mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 12:46:44 +00:00
Add CRYPTO logger, remove duplicated pubkey len check
This commit is contained in:
parent
607fc788e3
commit
6e91142dc2
2 changed files with 10 additions and 3 deletions
|
|
@ -82,7 +82,7 @@ func ecrecoverFunc(in []byte) []byte {
|
|||
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 {
|
||||
if pubKey == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,11 +21,16 @@ import (
|
|||
"github.com/ethereum/go-ethereum/crypto/ecies"
|
||||
"github.com/ethereum/go-ethereum/crypto/secp256k1"
|
||||
"github.com/ethereum/go-ethereum/crypto/sha3"
|
||||
"github.com/ethereum/go-ethereum/logger"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"golang.org/x/crypto/pbkdf2"
|
||||
"golang.org/x/crypto/ripemd160"
|
||||
)
|
||||
|
||||
var (
|
||||
cryptologger = logger.NewLogger("CRYPTO")
|
||||
)
|
||||
|
||||
func init() {
|
||||
// specify the params for the s256 curve
|
||||
ecies.AddParamsForCurve(S256(), ecies.ECIES_AES128_SHA256)
|
||||
|
|
@ -69,8 +74,10 @@ func Ripemd160(data []byte) []byte {
|
|||
}
|
||||
|
||||
func Ecrecover(hash, sig []byte) []byte {
|
||||
r, _ := secp256k1.RecoverPubkey(hash, sig)
|
||||
|
||||
r, err := secp256k1.RecoverPubkey(hash, sig)
|
||||
if err != nil {
|
||||
cryptologger.Errorf("EC RECOVER FAIL: ", err)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue