mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-10 18:16:39 +00:00
signer/core: avoid mutating the input (#34908)
This commit is contained in:
parent
592209c0ee
commit
1f3989dc70
1 changed files with 3 additions and 1 deletions
|
|
@ -17,6 +17,7 @@
|
||||||
package core
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
@ -309,7 +310,8 @@ func (api *SignerAPI) EcRecover(ctx context.Context, data hexutil.Bytes, sig hex
|
||||||
if sig[64] != 27 && sig[64] != 28 {
|
if sig[64] != 27 && sig[64] != 28 {
|
||||||
return common.Address{}, errors.New("invalid Ethereum signature (V is not 27 or 28)")
|
return common.Address{}, errors.New("invalid Ethereum signature (V is not 27 or 28)")
|
||||||
}
|
}
|
||||||
sig[64] -= 27 // Transform yellow paper V from 27/28 to 0/1
|
sig = bytes.Clone(sig) // Avoid mutating the input
|
||||||
|
sig[64] -= 27 // Transform yellow paper V from 27/28 to 0/1
|
||||||
hash := accounts.TextHash(data)
|
hash := accounts.TextHash(data)
|
||||||
rpk, err := crypto.SigToPub(hash, sig)
|
rpk, err := crypto.SigToPub(hash, sig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue