From e5d15fddb9c486dfe382bc95dc38d2fd247813bf Mon Sep 17 00:00:00 2001 From: zhiqiangxu <652732310@qq.com> Date: Wed, 10 Jul 2024 20:43:15 +0800 Subject: [PATCH] btcec/ecdsa: remove error return value for SignCompact (#2211) --- btcec/ecdsa/bench_test.go | 2 +- btcec/ecdsa/signature.go | 4 ++-- btcec/ecdsa/signature_test.go | 6 +----- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/btcec/ecdsa/bench_test.go b/btcec/ecdsa/bench_test.go index 3e27994cd4..57864af9fd 100644 --- a/btcec/ecdsa/bench_test.go +++ b/btcec/ecdsa/bench_test.go @@ -170,7 +170,7 @@ func BenchmarkSignCompact(b *testing.B) { b.ReportAllocs() b.ResetTimer() for i := 0; i < b.N; i++ { - _, _ = SignCompact(privKey, msgHash, true) + _ = SignCompact(privKey, msgHash, true) } } diff --git a/btcec/ecdsa/signature.go b/btcec/ecdsa/signature.go index 11c6267caf..a2574f8794 100644 --- a/btcec/ecdsa/signature.go +++ b/btcec/ecdsa/signature.go @@ -233,9 +233,9 @@ func ParseDERSignature(sigStr []byte) (*Signature, error) { // <(byte of 27+public key solution)+4 if compressed >< padded bytes for signature R> // where the R and S parameters are padde up to the bitlengh of the curve. func SignCompact(key *btcec.PrivateKey, hash []byte, - isCompressedKey bool) ([]byte, error) { + isCompressedKey bool) []byte { - return secp_ecdsa.SignCompact(key, hash, isCompressedKey), nil + return secp_ecdsa.SignCompact(key, hash, isCompressedKey) } // RecoverCompact verifies the compact signature "signature" of "hash" for the diff --git a/btcec/ecdsa/signature_test.go b/btcec/ecdsa/signature_test.go index f36e15db89..7a457b1e66 100644 --- a/btcec/ecdsa/signature_test.go +++ b/btcec/ecdsa/signature_test.go @@ -479,11 +479,7 @@ func testSignCompact(t *testing.T, tag string, curve *btcec.KoblitzCurve, priv, _ := btcec.NewPrivateKey() hashed := []byte("testing") - sig, err := SignCompact(priv, hashed, isCompressed) - if err != nil { - t.Errorf("%s: error signing: %s", tag, err) - return - } + sig := SignCompact(priv, hashed, isCompressed) pk, wasCompressed, err := RecoverCompact(sig, hashed) if err != nil {