btcec/ecdsa: remove error return value for SignCompact (#2211)

This commit is contained in:
zhiqiangxu 2024-07-10 20:43:15 +08:00 committed by GitHub
parent d881c686e6
commit e5d15fddb9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 8 deletions

View File

@ -170,7 +170,7 @@ func BenchmarkSignCompact(b *testing.B) {
b.ReportAllocs() b.ReportAllocs()
b.ResetTimer() b.ResetTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
_, _ = SignCompact(privKey, msgHash, true) _ = SignCompact(privKey, msgHash, true)
} }
} }

View File

@ -233,9 +233,9 @@ func ParseDERSignature(sigStr []byte) (*Signature, error) {
// <(byte of 27+public key solution)+4 if compressed >< padded bytes for signature R><padded bytes for signature S> // <(byte of 27+public key solution)+4 if compressed >< padded bytes for signature R><padded bytes for signature S>
// where the R and S parameters are padde up to the bitlengh of the curve. // where the R and S parameters are padde up to the bitlengh of the curve.
func SignCompact(key *btcec.PrivateKey, hash []byte, 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 // RecoverCompact verifies the compact signature "signature" of "hash" for the

View File

@ -479,11 +479,7 @@ func testSignCompact(t *testing.T, tag string, curve *btcec.KoblitzCurve,
priv, _ := btcec.NewPrivateKey() priv, _ := btcec.NewPrivateKey()
hashed := []byte("testing") hashed := []byte("testing")
sig, err := SignCompact(priv, hashed, isCompressed) sig := SignCompact(priv, hashed, isCompressed)
if err != nil {
t.Errorf("%s: error signing: %s", tag, err)
return
}
pk, wasCompressed, err := RecoverCompact(sig, hashed) pk, wasCompressed, err := RecoverCompact(sig, hashed)
if err != nil { if err != nil {