Skip to content

Commit bd93c59

Browse files
committed
crypto: replace noarg fmt.Errorf with errors.New (ethereum#27333)
1 parent ed03a99 commit bd93c59

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

crypto/signature_cgo.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ package crypto
2222
import (
2323
"crypto/ecdsa"
2424
"crypto/elliptic"
25+
"errors"
2526
"fmt"
2627

2728
"github.com/XinFinOrg/XDPoSChain/common/math"
@@ -72,7 +73,7 @@ func VerifySignature(pubkey, digestHash, signature []byte) bool {
7273
func DecompressPubkey(pubkey []byte) (*ecdsa.PublicKey, error) {
7374
x, y := secp256k1.DecompressPubkey(pubkey)
7475
if x == nil {
75-
return nil, fmt.Errorf("invalid public key")
76+
return nil, errors.New("invalid public key")
7677
}
7778
return &ecdsa.PublicKey{X: x, Y: y, Curve: S256()}, nil
7879
}

crypto/signature_nocgo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ func Sign(hash []byte, prv *ecdsa.PrivateKey) ([]byte, error) {
7474
return nil, fmt.Errorf("hash is required to be exactly 32 bytes (%d)", len(hash))
7575
}
7676
if prv.Curve != btcec.S256() {
77-
return nil, fmt.Errorf("private key curve is not secp256k1")
77+
return nil, errors.New("private key curve is not secp256k1")
7878
}
7979
// ecdsa.PrivateKey -> btcec.PrivateKey
8080
var priv btcec.PrivateKey
8181
if overflow := priv.Key.SetByteSlice(prv.D.Bytes()); overflow || priv.Key.IsZero() {
82-
return nil, fmt.Errorf("invalid private key")
82+
return nil, errors.New("invalid private key")
8383
}
8484
defer priv.Zero()
8585
sig, err := btc_ecdsa.SignCompact(&priv, hash, false) // ref uncompressed pubkey

0 commit comments

Comments
 (0)