mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
crypto: fix small nit in fallback signature ops and add test
This commit is contained in:
parent
9b64913bba
commit
f5eb375e8a
2 changed files with 12 additions and 2 deletions
|
|
@ -30,8 +30,8 @@ func Ecrecover(hash, sig []byte) ([]byte, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
bytes := (*btcec.PublicKey)(pub).SerializeUncompressed()
|
||||
return bytes, err
|
||||
bytes := (*btcec.PublicKey)(pub).SerializeUncompressed(),
|
||||
return bytes, nil
|
||||
}
|
||||
|
||||
func SigToPub(hash, sig []byte) (*ecdsa.PublicKey, error) {
|
||||
|
|
|
|||
|
|
@ -34,3 +34,13 @@ func TestRecoverSanity(t *testing.T) {
|
|||
t.Errorf("pubkey mismatch: want: %x have: %x", pubkey1, pubkey2)
|
||||
}
|
||||
}
|
||||
|
||||
// https://github.com/btcsuite/btcd/issues/709
|
||||
func TestRecoverSanity2(t *testing.T) {
|
||||
msg, _ := hex.DecodeString("00c547e4f7b0f325ad1e56f57e26c745b09a3e503d86e00e5255ff7f715d3d1c")
|
||||
sig, _ := hex.DecodeString("00b1693892219d736caba55bdb67216e485557ea6b6af75f37096c9aa6a5a75f00b940b1d03b21e36b0e47e79769f095fe2ab855bd91e3a38756b7d75a9c454901")
|
||||
_, err := Ecrecover(msg, sig)
|
||||
if err == nil {
|
||||
t.Fatalf("recover should've returned an error")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue