mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
Merge 711c4fcd28 into 38827dd9ca
This commit is contained in:
commit
b2a28f7de7
1 changed files with 4 additions and 1 deletions
|
|
@ -292,9 +292,12 @@ func (s *PrivateAccountAPI) SendTransaction(ctx context.Context, args SendTxArgs
|
||||||
// safely used to calculate a signature from. The hash is calulcated with:
|
// safely used to calculate a signature from. The hash is calulcated with:
|
||||||
// keccak256("\x19Ethereum Signed Message:\n"${message length}${message}).
|
// keccak256("\x19Ethereum Signed Message:\n"${message length}${message}).
|
||||||
func signHash(message string) []byte {
|
func signHash(message string) []byte {
|
||||||
data := common.FromHex(message)
|
|
||||||
// Give context to the signed message. This prevents an adversery to sign a tx.
|
// Give context to the signed message. This prevents an adversery to sign a tx.
|
||||||
// It has no cryptographic purpose.
|
// It has no cryptographic purpose.
|
||||||
|
data := common.FromHex(message)
|
||||||
|
if len(data) == 0 {
|
||||||
|
data = []byte(message)
|
||||||
|
}
|
||||||
msg := fmt.Sprintf("\x19Ethereum Signed Message:\n%d%s", len(data), data)
|
msg := fmt.Sprintf("\x19Ethereum Signed Message:\n%d%s", len(data), data)
|
||||||
// Always hash, this prevents choosen plaintext attacks that can extract key information
|
// Always hash, this prevents choosen plaintext attacks that can extract key information
|
||||||
return crypto.Keccak256([]byte(msg))
|
return crypto.Keccak256([]byte(msg))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue